From owner-freebsd-bugs@FreeBSD.ORG Thu Feb 17 18:20:10 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3CB1106564A for ; Thu, 17 Feb 2011 18:20:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 849B98FC16 for ; Thu, 17 Feb 2011 18:20:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p1HIKAh2021207 for ; Thu, 17 Feb 2011 18:20:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p1HIKAqn021206; Thu, 17 Feb 2011 18:20:10 GMT (envelope-from gnats) Resent-Date: Thu, 17 Feb 2011 18:20:10 GMT Resent-Message-Id: <201102171820.p1HIKAqn021206@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nikolay Denev Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 602D5106564A for ; Thu, 17 Feb 2011 18:15:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 330478FC1A for ; Thu, 17 Feb 2011 18:15:59 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1HIFxdq064868 for ; Thu, 17 Feb 2011 18:15:59 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p1HIFwWO064867; Thu, 17 Feb 2011 18:15:58 GMT (envelope-from nobody) Message-Id: <201102171815.p1HIFwWO064867@red.freebsd.org> Date: Thu, 17 Feb 2011 18:15:58 GMT From: Nikolay Denev To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/154850: ng_ether fails to name nodes when the associated interface contains dots or colons X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2011 18:20:10 -0000 >Number: 154850 >Category: kern >Synopsis: ng_ether fails to name nodes when the associated interface contains dots or colons >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Feb 17 18:20:10 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Nikolay Denev >Release: FreeBSD-8-STABLE >Organization: >Environment: >Description: As discussed here : http://lists.freebsd.org/pipermail/freebsd-net/2011-February/027986.html ng_ether(4) fails to name newly created nodes when their associated interface has netgraph reserved characters in the name (dots and colons). While colons are uncommon in interface names, dots are used for vlan interfaces. >How-To-Repeat: Assuming that the physical interface is em(4) : # ifconfig em0.13 create # kldload ng_ether # ngctl -l And the newly created ether node for the em0.13 vlan interface will be . >Fix: The attached patch still names the ether nodes with the same name as their associated interface, but replaces all occurences of dots or colons in the string so ng_name_node() would not fail. Patch attached with submission follows: --- 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); } } --- share/man/man4/ng_ether.4.orig 2011-02-16 15:16:11.775255282 +0200 +++ share/man/man4/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 , >Release-Note: >Audit-Trail: >Unformatted: