Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Nov 2023 11:10:20 +0800
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        =?utf-8?Q?Mina_Gali=C4=87?= <freebsd@igalic.co>
Cc:        Kyle Evans <kevans@FreeBSD.org>, freebsd-net@freebsd.org, "mike@karels.net" <mike@karels.net>
Subject:   Re: How to tell if a network interface was renamed (and from what)
Message-ID:  <1A3E6AF3-400B-4807-8C9F-EBA438B41703@FreeBSD.org>
In-Reply-To: <rvRLOlpJc9xIf67ZwmZ4Si6TN2VtmIuyuguoQgEk5NTOeqsqkAwB_9KvlMbW6y-npSjCC2lmLVXbD4oIqyKJdDboThcWiehF_hU0L9D6GZc=@igalic.co>
References:  <pdHC0ObBkAbx2HfFIhWYaB5-dmQDEUzNTWvVVJAuJV7FWdWWeSwybVFD-uyBUxPlqDRpAW7D1aAZsbrTxEj9kqsq7ESgO41srPmS-PcXGqw=@igalic.co> <E5F5F61E-3827-404A-A46F-BBCF45A29A82@FreeBSD.org> <9eef5488-e8da-4edd-bc00-baeb5aaf4a23@FreeBSD.org> <ptnVEMJ_x48tdYePN4iYRiEW2vWqwulbEOUJ4dQ1cKGkxNXZPPfdEVHdJKNHFfs2onxNipVZKPwDZZKlDv1peS1Xttim1VitMFsdUiTkAKE=@igalic.co> <032BADD4-0A49-42E2-BAAB-40D2F76C64B9@FreeBSD.org> <rvRLOlpJc9xIf67ZwmZ4Si6TN2VtmIuyuguoQgEk5NTOeqsqkAwB_9KvlMbW6y-npSjCC2lmLVXbD4oIqyKJdDboThcWiehF_hU0L9D6GZc=@igalic.co>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_A81168F8-59F9-4063-8D58-CE25C2427A96
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8



> On Nov 20, 2023, at 5:35 AM, Mina Gali=C4=87 <freebsd@igalic.co> =
wrote:
>=20
> Hi Zhenlei,
>=20
>=20
>> Since it is just for physical devices, may I propose to have the =
driver name in their groups ?
>>=20
>> So an if_ure interface ue0 will look like:
>>=20
>> ```
>> ue0: flags=3D1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> =
metric 0 mtu 1500
>>=20
>> =
options=3D60009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,RXCSUM_=
IPV6,TXCSUM_IPV6>
>>=20
>> ether 00:e0:4c:xx:xx:xx
>> media: Ethernet autoselect (1000baseT <full-duplex>)
>>=20
>> status: active
>> +++ groups: ure
>> nd6 options=3D23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
>>=20
>> ```
>>=20
>> That does not include the unit number. But could be useful to quickly =
get the driver name of physical devices.
>>=20
>=20
> Given that currently on FreeBSD the easiest way to tell if something
> is a physical device is by checking the *absence* of groups,

Emm, that sounds more a HACK to test physical devices.

> this
> would only really be acceptable if we add an "egress" group like
> OpenBSD does, in addition to the driver name.
>=20
> 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.

The interface group feature was imported from OpenBSD by 0dad3f0e1512 .

> Import interface groups from OpenBSD.  This allows to group interfaces =
in
> order to - for example - apply firewall rules to a whole group of
> interfaces.  This is required for importing pf from OpenBSD 3.9

Despite the purpose to get driver name, it seems not useful to have =
driver name in groups.

>=20
> Unrelatedly, I don't see anything in ure(4) mentioning that if_ure
> devices will be named "ue".

Currently usb ethernet have interface named `ue%u` regardless  the =
actual device drivers.
See =
https://cgit.freebsd.org/src/tree/sys/dev/usb/net/usb_ethernet.c#n202 =
<https://cgit.freebsd.org/src/tree/sys/dev/usb/net/usb_ethernet.c#n202>;
```
static void
ue_attach_post_task(struct usb_proc_msg *_task)
{
...
    if_initname(ifp, "ue", ue->ue_unit);
...
}
```

> Don't we usually  document such deviation from the norm?

I'm not familiar with usb protocols, I guess usb ethernet is sub device =
of usb controller.

```
smsc0 on uhub1
smsc0: <vendor 0x0424 product 0xec00, rev 2.00/2.00, addr 3> on usbus1
ue0: <USB Ethernet> on smsc0
```

Then `ue%u` for all usb ethernet make senses.

>=20
>=20
> Kind regards,
>=20
> Mina




--Apple-Mail=_A81168F8-59F9-4063-8D58-CE25C2427A96
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><br =
class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On Nov 20, 2023, at 5:35 AM, Mina Gali=C4=87 &lt;<a =
href=3D"mailto:freebsd@igalic.co" class=3D"">freebsd@igalic.co</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div =
class=3D"">Hi Zhenlei,<br class=3D""><br class=3D""><br =
class=3D""><blockquote type=3D"cite" class=3D"">Since it is just for =
physical devices, may I propose to have the driver name in their groups =
?<br class=3D""><br class=3D"">So an if_ure interface ue0 will look =
like:<br class=3D""><br class=3D"">```<br class=3D"">ue0: =
flags=3D1008843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP&gt; =
metric 0 mtu 1500<br class=3D""><br =
class=3D"">options=3D60009b&lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_=
HWCSUM,RXCSUM_IPV6,TXCSUM_IPV6&gt;<br class=3D""><br class=3D"">ether =
00:e0:4c:xx:xx:xx<br class=3D"">media: Ethernet autoselect (1000baseT =
&lt;full-duplex&gt;)<br class=3D""><br class=3D"">status: active<br =
class=3D"">+++ groups: ure<br class=3D"">nd6 =
options=3D23&lt;PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL&gt;<br =
class=3D""><br class=3D"">```<br class=3D""><br class=3D"">That does not =
include the unit number. But could be useful to quickly get the driver =
name of physical devices.<br class=3D""><br class=3D""></blockquote><br =
class=3D"">Given that currently on FreeBSD the easiest way to tell if =
something<br class=3D"">is a physical device is by checking the =
*absence* of groups,</div></div></blockquote><div><br =
class=3D""></div><div>Emm, that sounds more a HACK to test physical =
devices.</div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D""><div class=3D""> this<br class=3D"">would only really be =
acceptable if we add an "egress" group like<br class=3D"">OpenBSD does, =
in addition to the driver name.<br class=3D""><br class=3D"">If we can't =
do that, then I think Mike's solution with having the<br class=3D"">driver=
 (and unit) as a separate category would be preferable.<br =
class=3D""></div></div></blockquote><div><br class=3D""></div><div>The =
interface group feature was imported from OpenBSD by 0dad3f0e1512 =
.</div><div><br class=3D""></div><div>&gt; Import interface groups from =
OpenBSD. &nbsp;This allows to group interfaces in</div><div>&gt; order =
to - for example - apply firewall rules to a whole group =
of</div><div>&gt; interfaces. &nbsp;This is required for importing pf =
from OpenBSD 3.9</div><div><br class=3D""></div><div>Despite the purpose =
to get&nbsp;<span style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, =
0);" class=3D"">driver name, it&nbsp;</span>seems not useful to have =
driver name in groups.</div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D""><div class=3D""><br class=3D"">Unrelatedly, I =
don't see anything in ure(4) mentioning that if_ure<br class=3D"">devices =
will be named "ue".<br class=3D""></div></div></blockquote><div><br =
class=3D""></div><div>Currently usb ethernet have&nbsp;<span =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" =
class=3D"">interface named `</span>ue%u` regardless &nbsp;the actual =
device drivers.</div><div>See&nbsp;<a =
href=3D"https://cgit.freebsd.org/src/tree/sys/dev/usb/net/usb_ethernet.c#n=
202" =
class=3D"">https://cgit.freebsd.org/src/tree/sys/dev/usb/net/usb_ethernet.=
c#n202</a></div><div>```</div><div><div>static =
void</div><div>ue_attach_post_task(struct usb_proc_msg =
*_task)</div><div>{</div><div>...</div><div>&nbsp; &nbsp; =
if_initname(ifp, "ue", =
ue-&gt;ue_unit);</div><div>...</div><div>}</div></div><div>```</div><br =
class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div =
class=3D"">Don't we usually &nbsp;document such deviation from the =
norm?<br class=3D""></div></div></blockquote><div><br =
class=3D""></div><div>I'm not familiar with usb protocols, I guess =
usb&nbsp;<span style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" =
class=3D"">ethernet is sub device of usb =
controller.</span></div><div><span style=3D"caret-color: rgb(0, 0, 0); =
color: rgb(0, 0, 0);" class=3D""><br =
class=3D""></span></div><div>```</div><div><div>smsc0 on =
uhub1</div><div>smsc0: &lt;vendor 0x0424 product 0xec00, rev 2.00/2.00, =
addr 3&gt; on usbus1</div><div>ue0: &lt;USB Ethernet&gt; on =
smsc0</div></div><div>```</div><div><br class=3D""></div><div>Then =
`ue%u` for all usb ethernet make senses.</div><br class=3D""><blockquote =
type=3D"cite" class=3D""><div class=3D""><div class=3D""><br =
class=3D""><br class=3D"">Kind regards,<br class=3D""><br =
class=3D"">Mina<br class=3D""></div></div></blockquote></div><br =
class=3D""><div class=3D"">
<div><br class=3D""></div>

</div>
<br class=3D""></body></html>=

--Apple-Mail=_A81168F8-59F9-4063-8D58-CE25C2427A96--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1A3E6AF3-400B-4807-8C9F-EBA438B41703>