Date: Thu, 17 Feb 2011 20:30:16 +0200 From: Nikolay Denev <ndenev@gmail.com> To: freebsd-net@freebsd.org Subject: Re: ng_ether and vlan interfaces Message-ID: <C79DFCDA-99AE-4984-B741-0BA08F0E1A3D@gmail.com> In-Reply-To: <4D5C04DD.3020704@freebsd.org> References: <D275511D-0502-48ED-9186-EF4BF42B372E@gmail.com> <AANLkTi=bVv_M=2ShVos113Y6ROsJ3_M3Qp-wBP8=B=bH@mail.gmail.com> <4D5AAA28.50408@freebsd.org> <AANLkTim%2Bht=PjU3cg2e8AzReqFDW8pw_e-i1RYT3M2P4@mail.gmail.com> <5516808338355511684@unknownmsgid> <7DACE499-8AE3-427B-99EB-39618699625F@gmail.com> <4D5C04DD.3020704@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 16 Feb, 2011, at 19:09 , Julian Elischer wrote: > On 2/16/11 5:20 AM, Nikolay Denev wrote: >> On 15 Feb, 2011, at 21:08 , Nikolay Denev wrote: >>=20 >>> On 15.02.2011, at 18:53, Arnaud Lacombe<lacombar@gmail.com> wrote: >>>=20 >>>> Hi, >>>>=20 >>>> On Tue, Feb 15, 2011 at 11:30 AM, Julian = Elischer<julian@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. >>>>>=20 >>>> 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 ? >>>>=20 >>>> 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. >>>=20 >>> Regards, >>> Nikolay >> Does this look reasonable? : >>=20 >> [14:57]root@nas:/home/ndenev# ifconfig sge0.13 create >> [14:57]root@nas:/home/ndenev# ifconfig sge0.14 create >> [14:57]root@nas:/home/ndenev# ifconfig sge0.14 name sge0:14 >> [14:58]root@nas:/home/ndenev# kldload ng_ether >> [14:58]root@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 >>=20 >> 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. >>=20 >>=20 >> Patch URL : http://ndenev.ath.cx/patches/ng_ether_namemangling.patch >>=20 >> --- 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]; >>=20 >> /* >> * Do not create / attach an ether node to this ifnet if >> @@ -319,10 +321,22 @@ >> IFP2NG(ifp) =3D node; >> priv->hwassist =3D ifp->if_hwassist; >>=20 >> - /* Try to give the node the same name as the interface */ >> - if (ng_name_node(node, ifp->if_xname) !=3D 0) { >> + /* >> + * Try to give the node the same name as the interface >> + * replacing netgraph reserved characters (dot and colon) >> + */ >> + for (i =3D 0; i< IFNAMSIZ; i++) { >> + if (ifp->if_xname[i] =3D=3D '.' || ifp->if_xname[i] =3D=3D= ':') { >> + name[i] =3D '_'; >> + } else { >> + name[i] =3D ifp->if_xname[i]; >> + } >> + if (ifp->if_xname[i] =3D=3D '\0') >> + break; >> + } >> + if (ng_name_node(node, name) !=3D 0) { >> log(LOG_WARNING, "%s: can't name node %s\n", >> - __func__, ifp->if_xname); >> + __func__, name); >> } >> } >>=20 > looks good to me >=20 >> --- 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 , >>=20 >>=20 >>=20 >=20 Sumbitted as kern/154850=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C79DFCDA-99AE-4984-B741-0BA08F0E1A3D>