ng_ether and vlan interfaces
Julian Elischer
julian at freebsd.org
Wed Feb 16 17:09:39 UTC 2011
On 2/16/11 5:20 AM, Nikolay Denev wrote:
> On 15 Feb, 2011, at 21:08 , Nikolay Denev wrote:
>
>> On 15.02.2011, at 18:53, Arnaud Lacombe<lacombar at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> On Tue, Feb 15, 2011 at 11:30 AM, Julian Elischer<julian at freebsd.org> wrote:
>>>> changing it to '_' might be accceptable, '.' is much like '/' in th
>>>> filesystem.
>>>> it is a separator. You can't have it in the name.
>>>> a patch that converted . to _ would be a nice idea.
>>>> please ensure that the man page is updated as well.
>>>>
>>> Doesn't FreeBSD care about kernel/userland backward interface
>>> compatibility at all ? ie. will all my scripts assuming '.' as a
>>> separator need to also check the FreeBSD version to use whatever path
>>> separator ? How would you do that with bare ngctl script, which cannot
>>> be really that evolved ? How do you deal with node in the wild already
>>> using '_' in their name ?
>>>
>>> Thanks,
>>> - Arnaud
>> I'm actually thinking on doing the check and replacement of dots in
>> ng_ether, so it won't affect other netgraph consumers.
>>
>> Regards,
>> Nikolay
> Does this look reasonable? :
>
> [14:57]root at nas:/home/ndenev# ifconfig sge0.13 create
> [14:57]root at nas:/home/ndenev# ifconfig sge0.14 create
> [14:57]root at nas:/home/ndenev# ifconfig sge0.14 name sge0:14
> [14:58]root at nas:/home/ndenev# kldload ng_ether
> [14:58]root at nas:/home/ndenev# ngctl l
> There are 5 total nodes:
> Name: sge0_13 Type: ether ID: 00000003 Num hooks: 0
> Name: sge0_14 Type: ether ID: 00000004 Num hooks: 0
> Name: ipfw0 Type: ether ID: 00000002 Num hooks: 0
> Name: ngctl1685 Type: socket ID: 00000005 Num hooks: 0
> Name: sge0 Type: ether ID: 00000001 Num hooks: 0
>
> This is the patch to ng_ether which replaces both dots and colons with underscore.
> I'm unsure about changing them both to underscore, and a colon in interface name does
> not seem like something common. So I can rework it to replace only dots.
>
>
> Patch URL : http://ndenev.ath.cx/patches/ng_ether_namemangling.patch
>
> --- sys/netgraph/ng_ether.c.orig 2011-02-15 19:29:09.706568297 +0200
> +++ sys/netgraph/ng_ether.c 2011-02-16 15:11:03.138114973 +0200
> @@ -285,6 +285,8 @@
> {
> priv_p priv;
> node_p node;
> + int i;
> + char name[IFNAMSIZ];
>
> /*
> * Do not create / attach an ether node to this ifnet if
> @@ -319,10 +321,22 @@
> IFP2NG(ifp) = node;
> priv->hwassist = ifp->if_hwassist;
>
> - /* Try to give the node the same name as the interface */
> - if (ng_name_node(node, ifp->if_xname) != 0) {
> + /*
> + * Try to give the node the same name as the interface
> + * replacing netgraph reserved characters (dot and colon)
> + */
> + for (i = 0; i< IFNAMSIZ; i++) {
> + if (ifp->if_xname[i] == '.' || ifp->if_xname[i] == ':') {
> + name[i] = '_';
> + } else {
> + name[i] = ifp->if_xname[i];
> + }
> + if (ifp->if_xname[i] == '\0')
> + break;
> + }
> + if (ng_name_node(node, name) != 0) {
> log(LOG_WARNING, "%s: can't name node %s\n",
> - __func__, ifp->if_xname);
> + __func__, name);
> }
> }
>
looks good to me
> --- ng_ether.4.orig 2011-02-16 15:16:11.775255282 +0200
> +++ ng_ether.4 2011-02-16 15:18:53.114257799 +0200
> @@ -54,7 +54,8 @@
> module is loaded into the kernel, a node is automatically created
> for each Ethernet interface in the system.
> Each node will attempt to name itself with the same name
> -as the associated interface.
> +as the associated interface, substituting netgraph reserved
> +characters in the name with underscores.
> .Pp
> Three hooks are supported:
> .Va lower , upper ,
>
>
>
More information about the freebsd-net
mailing list