From owner-p4-projects@FreeBSD.ORG Wed May 2 19:40:49 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 065A816A406; Wed, 2 May 2007 19:40:49 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B837A16A400 for ; Wed, 2 May 2007 19:40:48 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id A895413C448 for ; Wed, 2 May 2007 19:40:48 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l42Jemhv087846 for ; Wed, 2 May 2007 19:40:48 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l42JemRA087843 for perforce@freebsd.org; Wed, 2 May 2007 19:40:48 GMT (envelope-from zec@FreeBSD.org) Date: Wed, 2 May 2007 19:40:48 GMT Message-Id: <200705021940.l42JemRA087843@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 119182 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 19:40:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=119182 Change 119182 by zec@zec_tpx32 on 2007/05/02 19:40:41 When a ng_eiface node is created, automatically assign it a name in the current netgraph namespace, just as we do for ng_iface nodes. The name defaults to ngethXX. When an arpcom ifnet is attached via ether_ifattach(), and ng_ether module is present, do not create / attach an ether node to this ifnet if a netgraph node with the same name already exists. This should prevent ether nodes to be attached to eiface nodes in the same vnet, which is pointless for all practical purposes. However, if a ng_eiface ifnet is reassigned to another vnet, a ng_ether node will be attached to such an ifnet there (in the other netgraph namespace), allowing for netgraph processing elements to be inserted in the data path in both the original and the target vnet. I.e. in such case one netgraph node of eiface type will be attached to the ifnet in the original vnet, and another node of type ether will be attached in the target vnet. Affected files ... .. //depot/projects/vimage/src/sys/netgraph/netgraph.h#2 edit .. //depot/projects/vimage/src/sys/netgraph/ng_base.c#7 edit .. //depot/projects/vimage/src/sys/netgraph/ng_eiface.c#3 edit .. //depot/projects/vimage/src/sys/netgraph/ng_ether.c#7 edit Differences ... ==== //depot/projects/vimage/src/sys/netgraph/netgraph.h#2 (text+ko) ==== @@ -1080,6 +1080,7 @@ struct ng_type *ng_findtype(const char *type); int ng_make_node_common(struct ng_type *typep, node_p *nodep); int ng_name_node(node_p node, const char *name); +node_p ng_name2noderef(node_p node, const char *name); int ng_newtype(struct ng_type *tp); ng_ID_t ng_node2ID(node_p node); item_p ng_package_data(struct mbuf *m, int flags); ==== //depot/projects/vimage/src/sys/netgraph/ng_base.c#7 (text+ko) ==== @@ -213,7 +213,6 @@ /* Imported, these used to be externally visible, some may go back. */ void ng_destroy_hook(hook_p hook); -node_p ng_name2noderef(node_p node, const char *name); int ng_path2noderef(node_p here, const char *path, node_p *dest, hook_p *lasthook); int ng_make_node(const char *type, node_p *nodepp); ==== //depot/projects/vimage/src/sys/netgraph/ng_eiface.c#3 (text+ko) ==== @@ -361,12 +361,10 @@ ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST); -#if 0 - /* Give this node name */ - bzero(ifname, sizeof(ifname)); - sprintf(ifname, "if%s", ifp->if_xname); - (void)ng_name_node(node, ifname); -#endif + /* Give this node the same name as the interface (if possible) */ + if (ng_name_node(node, ifp->if_xname) != 0) + log(LOG_WARNING, "%s: can't acquire netgraph name\n", + ifp->if_xname); /* Attach the interface */ ether_ifattach(ifp, eaddr); ==== //depot/projects/vimage/src/sys/netgraph/ng_ether.c#7 (text+ko) ==== @@ -286,6 +286,15 @@ priv_p priv; node_p node; + /* + * Do not create / attach an ether node to this ifnet if + * a netgraph node with the same name already exists. + * This should prevent ether nodes to be attached to + * eiface nodes in the same vnet, which is pointless. + */ + if (ng_name2noderef(node, ifp->if_xname) != NULL) + return; + /* Create node */ KASSERT(!IFP2NG(ifp), ("%s: node already exists?", __func__)); if (ng_make_node_common(&ng_ether_typestruct, &node) != 0) {