PERFORCE change 119182 for review
Marko Zec
zec at FreeBSD.org
Wed May 2 19:40:49 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=119182
Change 119182 by zec at 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) {
More information about the p4-projects
mailing list