From nobody Sun Nov 19 02:33:10 2023 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SXvnl083Yz51404 for ; Sun, 19 Nov 2023 02:33:15 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SXvnk6hV7z3YBX for ; Sun, 19 Nov 2023 02:33:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700361194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bbL4XsEn0qHkkjfp7DyHPmI4C6AvuAV6deRc1t4+i+U=; b=GwPbnh7k9T03BjkBnHLXQAAdHHTKQg13rKRFwKjb64Goo1wTVMtTcq9sjJbOfH0m5Avjwl 0zewldTUF2p9sc/ynz+DGdzUeNssxn7IMvSDG5umcMtJcpoUf00F1jcu6QLiexORdHwOCG zIOSR9UDcBhhnIttuap2XjutgNSA61arhIcltyMULs3KRypeu0c228EmK44e3p0VeTjG3j n7IDOucCypvMQLE1amdPa7KY9cCsTWrLiaHVku5sWdz0trwJgGL3WkOmKtw9vXqdSMtsQp ByjQULZ7Dy+C/iPgDl10nXu5Ii+zMaD1K8mxhhTrVnOzoTCfVVwGhijIeXxIZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700361194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bbL4XsEn0qHkkjfp7DyHPmI4C6AvuAV6deRc1t4+i+U=; b=clN221rwMhZbRcri4gPOlETU+qAHsLEw/hWqgGOsQ1YuNap9w1Ldhd+9ZgDJ1fMoWIXzPa kKnhJmXIDL1nM2t1mo1Qg+qKhhZkbwQ9JUkNtgiHdgSdE35/afjteJKtZwqK3pjyxlRfzh adGaskllEzs2S1ujLB3Q6K/4Fzf673jjhgnMzMGPNxjCNH5EP4ALpcOgEF/IgtDkBTumun K4ioYgV38RqzMLp0AlCxsjMxI/zJAZ6GXAzrI8mS49KvcUBVnlYSLP2pR/+NcWm1CE/hwB tRYCivuN1kosJjIPy7DfbHvhE0hKv47tcoVpmrY51shkg9YPUVhhY1gt4zIOOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700361194; a=rsa-sha256; cv=none; b=Hc5szViCqTxUU2rCuB/TLEgwjQA90olhQWCh3CTYl5Z5015MNUniqc8JvCly0YOBo6Oy5n WdDrZq12pzQkhqYOpQ+nM+eiKMYRPIlam+/xPsYgR2btf5l2ARUv8bo1+04uoxSn4SrfOb ns7vRi5yBhMv5645YWTUaW0cnqhzq3eCXq8bfZEoPSnOfAmn7eNB0Jex/dvoHSlyz8vDg8 TkVD4Y4zcTZUYhCAbxE2ij/5owPRSJ9YAZIckwrBILEzhIrOiSAYwiOvLrADcHH8VcI6D3 ZvKzenIf2ncsBBTeCGnn5bp8AIhDMpxYSE9iyo476KDEbJ+NN1I2abj5PP8dqw== Received: from [10.9.4.95] (unknown [209.182.120.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: kevans/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4SXvnk4kMfz194c for ; Sun, 19 Nov 2023 02:33:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Message-ID: <9eef5488-e8da-4edd-bc00-baeb5aaf4a23@FreeBSD.org> Date: Sat, 18 Nov 2023 20:33:10 -0600 List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How to tell if a network interface was renamed (and from what) Content-Language: en-US To: freebsd-net@freebsd.org References: From: Kyle Evans In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/18/23 19:15, Zhenlei Huang wrote: > > >> On Nov 19, 2023, at 6:20 AM, Mina Galić > > wrote: >> >> Hi folks, >> >> Linux has an "easy" way of telling if an interface has been renamed. >> See cloud-init's is_renamed function: >> https://github.com/canonical/cloud-init/blob/5496745b394f9b7b9eaf57fd619330d484ce2da8/cloudinit/net/__init__.py#L338-L350 >> This code reads /sys/class/net//name_assign_type and if that is >> 3 or 4, it's been renamed. >> >> I can't even think of an sensible way of replicating that. >> I can only think of terrible / wrong way of finding it out: >> >> dmesg | grep "changing name to ''" >> >> a less terrible method would be to check for, say: >> >> sysctl dev..0.%driver >> >> if that fails, we probably have a renamed interface… but we don't know >> what it was renamed from, and this only works for *real* interfaces, >> not for cloned devices, or epairs. >> >> Now, ignoring my terrible hacky attempts at command line tooling, I >> would also happily accept a solution in C, which is fairly easily >> accessible from Python, and which we already use to figure out the >> uptime (or rather, the boottime): >> https://github.com/canonical/cloud-init/blob/5496745b394f9b7b9eaf57fd619330d484ce2da8/cloudinit/util.py#L2073-L2105 >> >> Looking forward to reading your ideas. > > FreeBSD currently does not preserve the old ( original ) name of > interfaces if it is renamed ( either physical or cloned ones ). > While there's an attempt https://reviews.freebsd.org/D28247 >  to get the device name (physical > ones) but it is not perfect and not completed. > > So may I ask why you need to know if a network interface was renamed ? > Just last week I found this quite a pain as well; once an interface has been renamed, if it's not a pseudo-interface with an obvious group there's no clear way, AFAICT, to determine which driver created it without perusing pciconf output or whatnot and hopefully being able to associate the NICs listed with the new names (easier when there's only one NIC, of course). Kind of a pain when you're working on a remote machine that you're not at all familiar with. Thanks, Kyle Evans