Re: How to tell if a network interface was renamed (and from what)

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 20 Nov 2023 20:56:05 UTC
On 20 Nov 2023, at 21:29, Mike Karels wrote:
> On 19 Nov 2023, at 15:35, Mina Galić wrote:
>> Hi Zhenlei,
>>
>>
>>> Since it is just for physical devices, may I propose to have the driver name in their groups ?
>>>
>>> So an if_ure interface ue0 will look like:
>>>
>>> ```
>>> ue0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
>>>
>>> options=60009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
>>>
>>> ether 00:e0:4c:xx:xx:xx
>>> media: Ethernet autoselect (1000baseT <full-duplex>)
>>>
>>> status: active
>>> +++ groups: ure
>>> nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
>>>
>>> ```
>>>
>>> That does not include the unit number. But could be useful to quickly get the driver name of physical devices.
>>>
>>
>> Given that currently on FreeBSD the easiest way to tell if something
>> is a physical device is by checking the *absence* of groups, this
>> would only really be acceptable if we add an "egress" group like
>> OpenBSD does, in addition to the driver name.
>>
>> If we can't do that, then I think Mike's solution with having the
>> driver (and unit) as a separate category would be preferable.
>
> I have a proof of concept that makes the presumed original name
> (driver name + unit number) available to ifconfig, which prints
> the string with everything else in the standard output format.
> I don't think that is the right solution,

I believe a similar solution has been proposed before, and it failed to cope with things like epair interfaces.

I’d look in the direction of just adding a field to struct ifnet with the original interface name (likely easily done in if_attach()), along with a new ioctl to retrieve that field.

Best regards,
Kristof