From owner-freebsd-net@FreeBSD.ORG Wed Feb 16 17:09:39 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FEA2106564A for ; Wed, 16 Feb 2011 17:09:39 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 2BB448FC16 for ; Wed, 16 Feb 2011 17:09:38 +0000 (UTC) Received: from julian-mac.elischer.org (home-nat.elischer.org [67.100.89.137]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p1GH9WLR000541 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 16 Feb 2011 09:09:37 -0800 (PST) (envelope-from julian@freebsd.org) Message-ID: <4D5C04DD.3020704@freebsd.org> Date: Wed, 16 Feb 2011 09:09:49 -0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Nikolay Denev References: <4D5AAA28.50408@freebsd.org> <5516808338355511684@unknownmsgid> <7DACE499-8AE3-427B-99EB-39618699625F@gmail.com> In-Reply-To: <7DACE499-8AE3-427B-99EB-39618699625F@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: ng_ether and vlan interfaces X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2011 17:09:39 -0000 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 wrote: >> >>> Hi, >>> >>> On Tue, Feb 15, 2011 at 11:30 AM, Julian Elischer 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@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 > > 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 , > > >