Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Nov 2023 12:54:49 +0300
From:      =?UTF-8?B?w5Z6a2FuIEtJUklL?= <ozkan.kirik@gmail.com>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        freebsd-net@freebsd.org
Subject:   Re: How to tell if a network interface was renamed (and from what)
Message-ID:  <CAAcX-AE4rFhO4RGVVFSZJcgQK=qCg-Aucx5QO-wbX1%2B3Ag38Nw@mail.gmail.com>
In-Reply-To: <9eef5488-e8da-4edd-bc00-baeb5aaf4a23@FreeBSD.org>
References:  <pdHC0ObBkAbx2HfFIhWYaB5-dmQDEUzNTWvVVJAuJV7FWdWWeSwybVFD-uyBUxPlqDRpAW7D1aAZsbrTxEj9kqsq7ESgO41srPmS-PcXGqw=@igalic.co> <E5F5F61E-3827-404A-A46F-BBCF45A29A82@FreeBSD.org> <9eef5488-e8da-4edd-bc00-baeb5aaf4a23@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
It would be better if FreeBSD could have "interface altname feature"
like Linux has.

Kyle Evans <kevans@freebsd.org>, 19 Kas 2023 Paz, 07:50 tarihinde =C5=9Funu=
 yazd=C4=B1:
>
> On 11/18/23 19:15, Zhenlei Huang wrote:
> >
> >
> >> On Nov 19, 2023, at 6:20 AM, Mina Gali=C4=87 <freebsd@igalic.co
> >> <mailto:freebsd@igalic.co>> 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/5496745b394f9b7b9eaf57fd6=
19330d484ce2da8/cloudinit/net/__init__.py#L338-L350 <https://github.com/can=
onical/cloud-init/blob/5496745b394f9b7b9eaf57fd619330d484ce2da8/cloudinit/n=
et/__init__.py#L338-L350>
> >> This code reads /sys/class/net/<netif>/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 '<new-netif>'"
> >>
> >> a less terrible method would be to check for, say:
> >>
> >> sysctl dev.<new-netif>.0.%driver
> >>
> >> if that fails, we probably have a renamed interface=E2=80=A6 but we do=
n'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/5496745b394f9b7b9eaf57fd6=
19330d484ce2da8/cloudinit/util.py#L2073-L2105 <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
> > <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
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAcX-AE4rFhO4RGVVFSZJcgQK=qCg-Aucx5QO-wbX1%2B3Ag38Nw>