summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2008-08-17 23:27:27 +0000
committerbz <bz@FreeBSD.org>2008-08-17 23:27:27 +0000
commit1021d43b569bfc8d2c5544bde2f540fa432b011f (patch)
tree1496da534aec03cf2f9d2d0735d80e4c1e3b5715 /sys/netgraph
parent7fc341305a3e341fca7f202fc1219358f8d9dbbd (diff)
downloadFreeBSD-src-1021d43b569bfc8d2c5544bde2f540fa432b011f.zip
FreeBSD-src-1021d43b569bfc8d2c5544bde2f540fa432b011f.tar.gz
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@). This is the first in a series of commits over the course of the next few weeks. Mark all uses of global variables to be virtualized with a V_ prefix. Use macros to map them back to their global names for now, so this is a NOP change only. We hope to have caught at least 85-90% of what is needed so we do not invalidate a lot of outstanding patches again. Obtained from: //depot/projects/vimage-commit2/... Reviewed by: brooks, des, ed, mav, julian, jamie, kris, rwatson, zec, ... (various people I forgot, different versions) md5 (with a bit of help) Sponsored by: NLnet Foundation, The FreeBSD Foundation X-MFC after: never V_Commit_Message_Reviewed_By: more people than the patch
Diffstat (limited to 'sys/netgraph')
-rw-r--r--sys/netgraph/atm/ng_atm.c5
-rw-r--r--sys/netgraph/ng_base.c17
-rw-r--r--sys/netgraph/ng_bridge.c3
-rw-r--r--sys/netgraph/ng_eiface.c9
-rw-r--r--sys/netgraph/ng_ether.c3
-rw-r--r--sys/netgraph/ng_gif.c3
-rw-r--r--sys/netgraph/ng_iface.c9
-rw-r--r--sys/netgraph/ng_source.c3
8 files changed, 30 insertions, 22 deletions
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c
index b8a489e..1378eec 100644
--- a/sys/netgraph/atm/ng_atm.c
+++ b/sys/netgraph/atm/ng_atm.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sbuf.h>
#include <sys/ioccom.h>
#include <sys/sysctl.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -1401,7 +1402,7 @@ ng_atm_mod_event(module_t mod, int event, void *data)
ng_atm_event_p = ng_atm_event;
/* Create nodes for existing ATM interfaces */
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ATM)
ng_atm_attach(ifp);
}
@@ -1418,7 +1419,7 @@ ng_atm_mod_event(module_t mod, int event, void *data)
ng_atm_input_orphan_p = NULL;
ng_atm_event_p = NULL;
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ATM)
ng_atm_detach(ifp);
}
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 1213273..487fd25 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -61,6 +61,7 @@
#include <sys/syslog.h>
#include <sys/refcount.h>
#include <sys/proc.h>
+#include <sys/vimage.h>
#include <machine/cpu.h>
#include <net/netisr.h>
@@ -174,7 +175,7 @@ static struct mtx ng_idhash_mtx;
#define NG_IDHASH_FIND(ID, node) \
do { \
mtx_assert(&ng_idhash_mtx, MA_OWNED); \
- LIST_FOREACH(node, &ng_ID_hash[NG_IDHASH_FN(ID)], \
+ LIST_FOREACH(node, &V_ng_ID_hash[NG_IDHASH_FN(ID)], \
nd_idnodes) { \
if (NG_NODE_IS_VALID(node) \
&& (NG_NODE_ID(node) == ID)) { \
@@ -638,14 +639,14 @@ ng_make_node_common(struct ng_type *type, node_p *nodepp)
/* Link us into the name hash. */
mtx_lock(&ng_namehash_mtx);
- LIST_INSERT_HEAD(&ng_name_hash[0], node, nd_nodes);
+ LIST_INSERT_HEAD(&V_ng_name_hash[0], node, nd_nodes);
mtx_unlock(&ng_namehash_mtx);
/* get an ID and put us in the hash chain */
mtx_lock(&ng_idhash_mtx);
for (;;) { /* wrap protection, even if silly */
node_p node2 = NULL;
- node->nd_ID = nextID++; /* 137/second for 1 year before wrap */
+ node->nd_ID = V_nextID++; /* 137/second for 1 year before wrap */
/* Is there a problem with the new number? */
NG_IDHASH_FIND(node->nd_ID, node2); /* already taken? */
@@ -653,7 +654,7 @@ ng_make_node_common(struct ng_type *type, node_p *nodepp)
break;
}
}
- LIST_INSERT_HEAD(&ng_ID_hash[NG_IDHASH_FN(node->nd_ID)],
+ LIST_INSERT_HEAD(&V_ng_ID_hash[NG_IDHASH_FN(node->nd_ID)],
node, nd_idnodes);
mtx_unlock(&ng_idhash_mtx);
@@ -848,7 +849,7 @@ ng_name_node(node_p node, const char *name)
NG_NAMEHASH(name, hash);
mtx_lock(&ng_namehash_mtx);
LIST_REMOVE(node, nd_nodes);
- LIST_INSERT_HEAD(&ng_name_hash[hash], node, nd_nodes);
+ LIST_INSERT_HEAD(&V_ng_name_hash[hash], node, nd_nodes);
mtx_unlock(&ng_namehash_mtx);
return (0);
@@ -885,7 +886,7 @@ ng_name2noderef(node_p here, const char *name)
/* Find node by name */
NG_NAMEHASH(name, hash);
mtx_lock(&ng_namehash_mtx);
- LIST_FOREACH(node, &ng_name_hash[hash], nd_nodes) {
+ LIST_FOREACH(node, &V_ng_name_hash[hash], nd_nodes) {
if (NG_NODE_IS_VALID(node) &&
(strcmp(NG_NODE_NAME(node), name) == 0)) {
break;
@@ -2574,7 +2575,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
mtx_lock(&ng_namehash_mtx);
/* Count number of nodes */
for (i = 0; i < NG_NAME_HASH_SIZE; i++) {
- LIST_FOREACH(node, &ng_name_hash[i], nd_nodes) {
+ LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) {
if (NG_NODE_IS_VALID(node) &&
(unnamed || NG_NODE_HAS_NAME(node))) {
num++;
@@ -2596,7 +2597,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
nl->numnames = 0;
mtx_lock(&ng_namehash_mtx);
for (i = 0; i < NG_NAME_HASH_SIZE; i++) {
- LIST_FOREACH(node, &ng_name_hash[i], nd_nodes) {
+ LIST_FOREACH(node, &V_ng_name_hash[i], nd_nodes) {
struct nodeinfo *const np =
&nl->nodeinfo[nl->numnames];
diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c
index bc36172..5f9c835 100644
--- a/sys/netgraph/ng_bridge.c
+++ b/sys/netgraph/ng_bridge.c
@@ -67,6 +67,7 @@
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/ctype.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/ethernet.h>
@@ -631,7 +632,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
/* Run packet through ipfw processing, if enabled */
#if 0
- if (priv->conf.ipfw[linkNum] && fw_enable && ip_fw_chk_ptr != NULL) {
+ if (priv->conf.ipfw[linkNum] && V_fw_enable && ip_fw_chk_ptr != NULL) {
/* XXX not implemented yet */
}
#endif
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index a47aadd..ae47c75 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -38,6 +38,7 @@
#include <sys/sockio.h>
#include <sys/socket.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -351,7 +352,7 @@ ng_eiface_constructor(node_p node)
ifp->if_softc = priv;
/* Get an interface unit number */
- priv->unit = alloc_unr(ng_eiface_unit);
+ priv->unit = alloc_unr(V_ng_eiface_unit);
/* Link together node and private info */
NG_NODE_SET_PRIVATE(node, priv);
@@ -549,7 +550,7 @@ ng_eiface_rmnode(node_p node)
ether_ifdetach(ifp);
if_free(ifp);
- free_unr(ng_eiface_unit, priv->unit);
+ free_unr(V_ng_eiface_unit, priv->unit);
FREE(priv, M_NETGRAPH);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node);
@@ -578,10 +579,10 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
- ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
+ V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
break;
case MOD_UNLOAD:
- delete_unrhdr(ng_eiface_unit);
+ delete_unrhdr(V_ng_eiface_unit);
break;
default:
error = EOPNOTSUPP;
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
index 8c13c8f..115f3cf 100644
--- a/sys/netgraph/ng_ether.c
+++ b/sys/netgraph/ng_ether.c
@@ -54,6 +54,7 @@
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -752,7 +753,7 @@ ng_ether_mod_event(module_t mod, int event, void *data)
/* Create nodes for any already-existing Ethernet interfaces */
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ETHER
|| ifp->if_type == IFT_L2VLAN)
ng_ether_attach(ifp);
diff --git a/sys/netgraph/ng_gif.c b/sys/netgraph/ng_gif.c
index 5d948bd..139a50b 100644
--- a/sys/netgraph/ng_gif.c
+++ b/sys/netgraph/ng_gif.c
@@ -77,6 +77,7 @@
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/socket.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/route.h>
@@ -560,7 +561,7 @@ ng_gif_mod_event(module_t mod, int event, void *data)
/* Create nodes for any already-existing gif interfaces */
IFNET_RLOCK();
- TAILQ_FOREACH(ifp, &ifnet, if_link) {
+ TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_GIF)
ng_gif_attach(ifp);
}
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index fec2432..3753adb 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -69,6 +69,7 @@
#include <sys/socket.h>
#include <sys/syslog.h>
#include <sys/libkern.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -523,7 +524,7 @@ ng_iface_constructor(node_p node)
priv->ifp = ifp;
/* Get an interface unit number */
- priv->unit = alloc_unr(ng_iface_unit);
+ priv->unit = alloc_unr(V_ng_iface_unit);
/* Link together node and private info */
NG_NODE_SET_PRIVATE(node, priv);
@@ -771,7 +772,7 @@ ng_iface_shutdown(node_p node)
if_detach(priv->ifp);
if_free(priv->ifp);
priv->ifp = NULL;
- free_unr(ng_iface_unit, priv->unit);
+ free_unr(V_ng_iface_unit, priv->unit);
FREE(priv, M_NETGRAPH_IFACE);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node);
@@ -804,10 +805,10 @@ ng_iface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
- ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
+ V_ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
break;
case MOD_UNLOAD:
- delete_unrhdr(ng_iface_unit);
+ delete_unrhdr(V_ng_iface_unit);
break;
default:
error = EOPNOTSUPP;
diff --git a/sys/netgraph/ng_source.c b/sys/netgraph/ng_source.c
index dad819a..e27a199 100644
--- a/sys/netgraph/ng_source.c
+++ b/sys/netgraph/ng_source.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/syslog.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netgraph/ng_message.h>
@@ -615,7 +616,7 @@ ng_source_store_output_ifp(sc_p sc, char *ifname)
ifp = ifunit(ifname);
if (ifp == NULL) {
- printf("%s: can't find interface %d\n", __func__, if_index);
+ printf("%s: can't find interface %d\n", __func__, V_if_index);
return (EINVAL);
}
sc->output_ifp = ifp;
OpenPOWER on IntegriCloud