From owner-freebsd-net@FreeBSD.ORG Thu Feb 17 18:30:23 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 3455E106566C for ; Thu, 17 Feb 2011 18:30:23 +0000 (UTC) (envelope-from ndenev@gmail.com) Received: from mail-ew0-f54.google.com (mail-ew0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id B2E8F8FC17 for ; Thu, 17 Feb 2011 18:30:22 +0000 (UTC) Received: by ewy24 with SMTP id 24so1236571ewy.13 for ; Thu, 17 Feb 2011 10:30:21 -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:content-transfer-encoding:message-id:references:to :x-mailer; bh=huwveJvgrLXVmAuw2PSOA/NjVY6FxuPoP8FYOJJGW2E=; b=LSa2tnMvRf0V/rvE0MH/y0f8MJgspx/IyeKmj0qmGXcXooYHpo8nlPmmjlzutsGUjp R+4t9ecYs/yzv00jviovH5yHvJ0Ni6SxNWgVCdMqdch1w/WIVZMcMJ/WD+81vyNZaOEC JyGJ2Ew7BZaGO8HTW4yjrg6nEV8CLPBwaxSIo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=TiybNJRqoWp3FxdLfXoKnqZLGRJkBLEC75s2YUaw2oPD9can5ZwmLuna3Mmq3MR+Q/ GAF7izTozjkdNLH5/Bdbgw9HLX8Rwi1BqnSJqhPVpsWU+RLZ4C1KeGPP681Tw6GdDdq8 tXK5KToRAFmK4XFn1U8UPSMzqUsbGYUDTfls0= Received: by 10.213.17.200 with SMTP id t8mr12248eba.1.1297967420620; Thu, 17 Feb 2011 10:30:20 -0800 (PST) Received: from [10.0.0.49] (93-152-151-19.ddns.onlinedirect.bg [93.152.151.19]) by mx.google.com with ESMTPS id u1sm1097461eeh.16.2011.02.17.10.30.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Feb 2011 10:30:19 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Nikolay Denev In-Reply-To: <4D5C04DD.3020704@freebsd.org> Date: Thu, 17 Feb 2011 20:30:16 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4D5AAA28.50408@freebsd.org> <5516808338355511684@unknownmsgid> <7DACE499-8AE3-427B-99EB-39618699625F@gmail.com> <4D5C04DD.3020704@freebsd.org> To: freebsd-net@freebsd.org X-Mailer: Apple Mail (2.1082) 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: Thu, 17 Feb 2011 18:30:23 -0000 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 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 >>> 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=