From owner-freebsd-net@FreeBSD.ORG Wed Feb 16 13:20:29 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 5114B1065675; Wed, 16 Feb 2011 13:20:29 +0000 (UTC) (envelope-from ndenev@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id AC2318FC0A; Wed, 16 Feb 2011 13:20:28 +0000 (UTC) Received: by fxm16 with SMTP id 16so1355173fxm.13 for ; Wed, 16 Feb 2011 05:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=WZJEqXNGmfpgT8YXG1RonNBauCJ8BRRFaK4ejNZn3JU=; b=IeM7dJLiHVlfYqO6RBAmzdl7YZsZWZ2XxHUISKYBKaxHnLkQUZcXXx/yS6Nchns6z2 /8jnaAwT3mneYji7W2aPtrSEuspNRlhGvTlrhuKyaU9O+K4wruuHJ+bqfYhQpkgGhWwB 5TqdbuFi0Vzd54Ms3HHC8GM2VG+vLGbrkbYrQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=mY/tB3qJeGm440adoSSSeHXfp4/s7t+PSC46mfPqsaw3fl7PVjo8/ip+n3FI9IM7WZ l5BIOdjC3Ixp/SytLoMnnaykufV4bhse4zJx2kA51ZA/C+hugGw5UGdn5p1zUCMzjaCy chC3LKzp9lX+Pl1cUuNXGFzhGKjEJyarWtcZA= Received: by 10.223.101.202 with SMTP id d10mr718531fao.132.1297862427540; Wed, 16 Feb 2011 05:20:27 -0800 (PST) Received: from ndenevsa.sf.moneybookers.net (g1.moneybookers.com [217.18.249.148]) by mx.google.com with ESMTPS id j12sm15388fax.33.2011.02.16.05.20.24 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Feb 2011 05:20:24 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Nikolay Denev In-Reply-To: <5516808338355511684@unknownmsgid> Date: Wed, 16 Feb 2011 15:20:22 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <7DACE499-8AE3-427B-99EB-39618699625F@gmail.com> References: <4D5AAA28.50408@freebsd.org> <5516808338355511684@unknownmsgid> To: freebsd-net@freebsd.org X-Mailer: Apple Mail (2.1082) Cc: 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 13:20:29 -0000 On 15 Feb, 2011, at 21:08 , Nikolay Denev wrote: > On 15.02.2011, at 18:53, Arnaud Lacombe wrote: >=20 >> Hi, >>=20 >> 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. >>>=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 >=20 > 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? : [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]; =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); } } --- 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 ,