diff options
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/atm/ng_atm.c | 6 | ||||
-rw-r--r-- | sys/netgraph/netgraph.h | 35 | ||||
-rw-r--r-- | sys/netgraph/ng_base.c | 28 | ||||
-rw-r--r-- | sys/netgraph/ng_bridge.c | 4 | ||||
-rw-r--r-- | sys/netgraph/ng_ether.c | 5 | ||||
-rw-r--r-- | sys/netgraph/ng_gif.c | 4 | ||||
-rw-r--r-- | sys/netgraph/ng_sample.c | 8 | ||||
-rw-r--r-- | sys/netgraph/ng_source.c | 1 |
8 files changed, 54 insertions, 37 deletions
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c index f33f2c5..de57bee 100644 --- a/sys/netgraph/atm/ng_atm.c +++ b/sys/netgraph/atm/ng_atm.c @@ -1317,7 +1317,7 @@ ng_atm_shutdown(node_p node) { struct priv *priv = NG_NODE_PRIVATE(node); - if (node->nd_flags & NG_REALLY_DIE) { + if (node->nd_flags & NGF_REALLY_DIE) { /* * We are called from unloading the ATM driver. Really, * really need to shutdown this node. The ifp was @@ -1332,7 +1332,7 @@ ng_atm_shutdown(node_p node) #ifdef NGATM_DEBUG if (!allow_shutdown) - node->nd_flags &= ~NG_INVALID; + NG_NODE_REVIVE(node); /* we persist */ else { IFP2NG(priv->ifp) = NULL; NG_NODE_SET_PRIVATE(node, NULL); @@ -1343,7 +1343,7 @@ ng_atm_shutdown(node_p node) /* * We are persistant - reinitialize */ - node->nd_flags &= ~NG_INVALID; + NG_NODE_REVIVE(node); #endif return (0); } diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index 5af4c83..f0925c4 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -345,11 +345,16 @@ struct ng_node { }; /* Flags for a node */ -#define NG_INVALID 0x00000001 /* free when refs go to 0 */ -#define NG_WORKQ 0x00000002 /* node is on the work queue */ -#define NG_FORCE_WRITER 0x00000004 /* Never multithread this node */ -#define NG_CLOSING 0x00000008 /* ng_rmnode() at work */ -#define NG_REALLY_DIE 0x00000010 /* "persistant" node is unloading */ +#define NGF_INVALID 0x00000001 /* free when refs go to 0 */ +#define NG_INVALID NGF_INVALID /* compat for old code */ +#define NGF_WORKQ 0x00000002 /* node is on the work queue */ +#define NG_WORKQ NGF_WORKQ /* compat for old code */ +#define NGF_FORCE_WRITER 0x00000004 /* Never multithread this node */ +#define NG_FORCE_WRITER NGF_FORCE_WRITER /* compat for old code */ +#define NGF_CLOSING 0x00000008 /* ng_rmnode() at work */ +#define NG_CLOSING NGF_CLOSING /* compat for old code */ +#define NGF_REALLY_DIE 0x00000010 /* "persistent" node is unloading */ +#define NG_REALLY_DIE NGF_REALLY_DIE /* compat for old code */ #define NGF_TYPE1 0x10000000 /* reserved for type specific storage */ #define NGF_TYPE2 0x20000000 /* reserved for type specific storage */ #define NGF_TYPE3 0x40000000 /* reserved for type specific storage */ @@ -367,13 +372,15 @@ int ng_unref_node(node_p node); /* don't move this */ #define _NG_NODE_UNREF(node) ng_unref_node(node) #define _NG_NODE_SET_PRIVATE(node, val) do {(node)->nd_private = val;} while (0) #define _NG_NODE_PRIVATE(node) ((node)->nd_private) -#define _NG_NODE_IS_VALID(node) (!((node)->nd_flags & NG_INVALID)) -#define _NG_NODE_NOT_VALID(node) ((node)->nd_flags & NG_INVALID) +#define _NG_NODE_IS_VALID(node) (!((node)->nd_flags & NGF_INVALID)) +#define _NG_NODE_NOT_VALID(node) ((node)->nd_flags & NGF_INVALID) #define _NG_NODE_NUMHOOKS(node) ((node)->nd_numhooks + 0) /* rvalue */ #define _NG_NODE_FORCE_WRITER(node) \ - do{ node->nd_flags |= NG_FORCE_WRITER; }while (0) + do{ node->nd_flags |= NGF_FORCE_WRITER; }while (0) #define _NG_NODE_REALLY_DIE(node) \ - do{ node->nd_flags |= (NG_REALLY_DIE|NG_INVALID); }while (0) + do{ node->nd_flags |= (NGF_REALLY_DIE|NGF_INVALID); }while (0) +#define _NG_NODE_REVIVE(node) \ + do { node->nd_flags &= ~NGF_INVALID; } while (0) /* * The hook iterator. * This macro will call a function of type ng_fn_eachhook for each @@ -411,6 +418,7 @@ static __inline int _ng_node_numhooks(node_p node, char *file, int line); static __inline void _ng_node_force_writer(node_p node, char *file, int line); static __inline hook_p _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg, char *file, int line); +static __inline void _ng_node_revive(node_p node, char *file, int line); static void __inline _chknode(node_p node, char *file, int line) @@ -508,6 +516,13 @@ _ng_node_really_die(node_p node, char *file, int line) _NG_NODE_REALLY_DIE(node); } +static __inline void +_ng_node_revive(node_p node, char *file, int line) +{ + _chknode(node, file, line); + _NG_NODE_REVIVE(node); +} + static __inline hook_p _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg, char *file, int line) @@ -530,6 +545,7 @@ _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg, #define NG_NODE_FORCE_WRITER(node) _ng_node_force_writer(node, _NN_) #define NG_NODE_REALLY_DIE(node) _ng_node_really_die(node, _NN_) #define NG_NODE_NUMHOOKS(node) _ng_node_numhooks(node, _NN_) +#define NG_NODE_REVIVE(node) _ng_node_revive(node, _NN_) #define NG_NODE_FOREACH_HOOK(node, fn, arg, rethook) \ do { \ rethook = _ng_node_foreach_hook(node, fn, (void *)arg, _NN_); \ @@ -549,6 +565,7 @@ _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg, #define NG_NODE_FORCE_WRITER(node) _NG_NODE_FORCE_WRITER(node) #define NG_NODE_REALLY_DIE(node) _NG_NODE_REALLY_DIE(node) #define NG_NODE_NUMHOOKS(node) _NG_NODE_NUMHOOKS(node) +#define NG_NODE_REVIVE(node) _NG_NODE_REVIVE(node) #define NG_NODE_FOREACH_HOOK(node, fn, arg, rethook) \ _NG_NODE_FOREACH_HOOK(node, fn, arg, rethook) #endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index bf69181..74032a5 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -110,7 +110,7 @@ struct ng_type ng_deadtype = { struct ng_node ng_deadnode = { "dead", &ng_deadtype, - NG_INVALID, + NGF_INVALID, 1, /* refs */ 0, /* numhooks */ NULL, /* private */ @@ -675,7 +675,7 @@ ng_rmnode(node_p node, hook_p dummy1, void *dummy2, int dummy3) hook_p hook; /* Check if it's already shutting down */ - if ((node->nd_flags & NG_CLOSING) != 0) + if ((node->nd_flags & NGF_CLOSING) != 0) return; if (node == &ng_deadnode) { @@ -689,10 +689,10 @@ ng_rmnode(node_p node, hook_p dummy1, void *dummy2, int dummy3) /* * Mark it invalid so any newcomers know not to try use it * Also add our own mark so we can't recurse - * note that NG_INVALID does not do this as it's also set during + * note that NGF_INVALID does not do this as it's also set during * creation */ - node->nd_flags |= NG_INVALID|NG_CLOSING; + node->nd_flags |= NGF_INVALID|NGF_CLOSING; /* If node has its pre-shutdown method, then call it first*/ if (node->nd_type && node->nd_type->close) @@ -721,9 +721,9 @@ ng_rmnode(node_p node, hook_p dummy1, void *dummy2, int dummy3) * Presumably it is a persistant node. * If we REALLY want it to go away, * e.g. hardware going away, - * Our caller should set NG_REALLY_DIE in nd_flags. + * Our caller should set NGF_REALLY_DIE in nd_flags. */ - node->nd_flags &= ~(NG_INVALID|NG_CLOSING); + node->nd_flags &= ~(NGF_INVALID|NGF_CLOSING); NG_NODE_UNREF(node); /* Assume they still have theirs */ return; } @@ -1460,8 +1460,8 @@ ng_rmnode_self(node_p node) if (node == &ng_deadnode) return (0); - node->nd_flags |= NG_INVALID; - if (node->nd_flags & NG_CLOSING) + node->nd_flags |= NGF_INVALID; + if (node->nd_flags & NGF_CLOSING) return (0); error = ng_send_fn(node, NULL, &ng_rmnode, NULL, 0); @@ -2200,7 +2200,7 @@ ng_snd_item(item_p item, int queue) * Similarly the node may say one hook always produces writers. * These are over-rides. */ - if ((node->nd_flags & NG_FORCE_WRITER) + if ((node->nd_flags & NGF_FORCE_WRITER) || (hook && (hook->hk_flags & HK_FORCE_WRITER))) { rw = NGQRW_W; item->el_flags &= ~NGQF_READER; @@ -3288,7 +3288,7 @@ ngintr(void) mtx_unlock_spin(&ng_worklist_mtx); break; } - node->nd_flags &= ~NG_WORKQ; + node->nd_flags &= ~NGF_WORKQ; TAILQ_REMOVE(&ng_worklist, node, nd_work); mtx_unlock_spin(&ng_worklist_mtx); /* @@ -3325,8 +3325,8 @@ static void ng_worklist_remove(node_p node) { mtx_lock_spin(&ng_worklist_mtx); - if (node->nd_flags & NG_WORKQ) { - node->nd_flags &= ~NG_WORKQ; + if (node->nd_flags & NGF_WORKQ) { + node->nd_flags &= ~NGF_WORKQ; TAILQ_REMOVE(&ng_worklist, node, nd_work); mtx_unlock_spin(&ng_worklist_mtx); NG_NODE_UNREF(node); @@ -3344,12 +3344,12 @@ static void ng_setisr(node_p node) { mtx_lock_spin(&ng_worklist_mtx); - if ((node->nd_flags & NG_WORKQ) == 0) { + if ((node->nd_flags & NGF_WORKQ) == 0) { /* * If we are not already on the work queue, * then put us on. */ - node->nd_flags |= NG_WORKQ; + node->nd_flags |= NGF_WORKQ; TAILQ_INSERT_TAIL(&ng_worklist, node, nd_work); NG_NODE_REF(node); /* XXX fafe in mutex? */ } diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 2f20b3d..0dcb30f 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -760,7 +760,7 @@ ng_bridge_shutdown(node_p node) __func__, priv->numLinks, priv->numHosts)); FREE(priv->tab, M_NETGRAPH_BRIDGE); - /* NG_INVALID flag is now set so node will be freed at next timeout */ + /* NGF_INVALID flag is now set so node will be freed at next timeout */ return (0); } @@ -954,7 +954,7 @@ ng_bridge_remove_hosts(priv_p priv, int linkNum) * a detected loopback condition, and we remove any hosts from * the hashtable whom we haven't heard from in a long while. * - * If the node has the NG_INVALID flag set, our job is to kill it. + * If the node has the NGF_INVALID flag set, our job is to kill it. */ static void ng_bridge_timeout(void *arg) diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c index 8d9b765..c997278 100644 --- a/sys/netgraph/ng_ether.c +++ b/sys/netgraph/ng_ether.c @@ -565,7 +565,7 @@ ng_ether_shutdown(node_p node) { const priv_p priv = NG_NODE_PRIVATE(node); - if (node->nd_flags & NG_REALLY_DIE) { + if (node->nd_flags & NGF_REALLY_DIE) { /* * WE came here because the ethernet card is being unloaded, * so stop being persistant. @@ -582,7 +582,8 @@ ng_ether_shutdown(node_p node) priv->promisc = 0; } priv->autoSrcAddr = 1; /* reset auto-src-addr flag */ - node->nd_flags &= ~NG_INVALID; /* Signal ng_rmnode we are persisant */ + NG_NODE_REVIVE(node); /* Signal ng_rmnode we are persisant */ + return (0); } diff --git a/sys/netgraph/ng_gif.c b/sys/netgraph/ng_gif.c index 9ef3cc9..3ecd852 100644 --- a/sys/netgraph/ng_gif.c +++ b/sys/netgraph/ng_gif.c @@ -492,7 +492,7 @@ ng_gif_shutdown(node_p node) { const priv_p priv = NG_NODE_PRIVATE(node); - if (node->nd_flags & NG_REALLY_DIE) { + if (node->nd_flags & NGF_REALLY_DIE) { /* * WE came here because the gif interface is being destroyed, * so stop being persistant. @@ -504,7 +504,7 @@ ng_gif_shutdown(node_p node) NG_NODE_UNREF(node); /* free node itself */ return (0); } - node->nd_flags &= ~NG_INVALID; /* Signal ng_rmnode we are persisant */ + NG_NODE_REVIVE(node); /* Signal ng_rmnode we are persisant */ return (0); } diff --git a/sys/netgraph/ng_sample.c b/sys/netgraph/ng_sample.c index 48b58c7..b41cee2 100644 --- a/sys/netgraph/ng_sample.c +++ b/sys/netgraph/ng_sample.c @@ -408,8 +408,8 @@ devintr() * All our links and the name have already been removed. * If we are a persistant device, we might refuse to go away. * In the case of a persistant node we signal the framework that we - * are still in business by clearing the NG_INVALID bit. However - * If we find the NG_REALLY_DIE bit set, this means that + * are still in business by clearing the NGF_INVALID bit. However + * If we find the NGF_REALLY_DIE bit set, this means that * we REALLY need to die (e.g. hardware removed). * This would have been set using the NG_NODE_REALLY_DIE(node) * macro in some device dependent function (not shown here) before @@ -425,7 +425,7 @@ ng_xxx_shutdown(node_p node) NG_NODE_UNREF(privdata->node); FREE(privdata, M_NETGRAPH); #else - if (node->nd_flags & NG_REALLY_DIE) { + if (node->nd_flags & NGF_REALLY_DIE) { /* * WE came here because the widget card is being unloaded, * so stop being persistant. @@ -436,7 +436,7 @@ ng_xxx_shutdown(node_p node) FREE(privdata, M_NETGRAPH); return (0); } - node->nd_flags &= ~NG_INVALID; /* reset invalid flag */ + NG_NODE_REVIVE(node); /* tell ng_rmnode() we will persist */ #endif /* PERSISTANT_NODE */ return (0); } diff --git a/sys/netgraph/ng_source.c b/sys/netgraph/ng_source.c index 4192e10..72fee44 100644 --- a/sys/netgraph/ng_source.c +++ b/sys/netgraph/ng_source.c @@ -433,7 +433,6 @@ ng_source_rmnode(node_p node) sc = NG_NODE_PRIVATE(node); KASSERT(sc != NULL, ("%s: null node private", __func__)); - node->nd_flags |= NG_INVALID; ng_source_stop(sc); ng_source_clr_data(sc); NG_NODE_SET_PRIVATE(node, NULL); |