Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Feb 2011 15:20:22 +0200
From:      Nikolay Denev <ndenev@gmail.com>
To:        freebsd-net@freebsd.org
Subject:   Re: ng_ether and vlan interfaces
Message-ID:  <7DACE499-8AE3-427B-99EB-39618699625F@gmail.com>
In-Reply-To: <5516808338355511684@unknownmsgid>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On 15 Feb, 2011, at 21:08 , Nikolay Denev wrote:

> 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
>=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 ,




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7DACE499-8AE3-427B-99EB-39618699625F>