summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_sample.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-01-30 20:51:52 +0000
committerjulian <julian@FreeBSD.org>2001-01-30 20:51:52 +0000
commit829347d51049c2e13e3480a34b697ad0706f544d (patch)
tree3a9e298fda80b85b295437ee382beb9478e01b0b /sys/netgraph/ng_sample.c
parentc699ccaa2e2324716dbff91054e658cba135b735 (diff)
downloadFreeBSD-src-829347d51049c2e13e3480a34b697ad0706f544d.zip
FreeBSD-src-829347d51049c2e13e3480a34b697ad0706f544d.tar.gz
Implement direct support for semipersistant nodes.
(e.g. ethernet nodes are persistent until you rip out the hardware) Use this support in the ethernet and sample nodes. Add some more abstraction on the 'item's so that node and hook reference counting can be checked easier. Slight man page correction. Make pppoe type dependent on ethernet type. Clean up node shutdown a little. Move a mutex from MTX_SPIN to MTX_DEF (oops) Fix small ref-counting bug. remove warning on one2many type.
Diffstat (limited to 'sys/netgraph/ng_sample.c')
-rw-r--r--sys/netgraph/ng_sample.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/sys/netgraph/ng_sample.c b/sys/netgraph/ng_sample.c
index 8616dd6..eae2056 100644
--- a/sys/netgraph/ng_sample.c
+++ b/sys/netgraph/ng_sample.c
@@ -409,8 +409,14 @@ devintr()
/*
* Do local shutdown processing..
* All our links and the name have already been removed.
- * If we are a persistant device, we might refuse to go away, and
- * we'd create a new node immediatly.
+ * 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
+ * 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
+ * calling ng_rmnode_self().
*/
static int
ng_xxx_shutdown(node_p node)
@@ -418,35 +424,22 @@ ng_xxx_shutdown(node_p node)
const xxx_p privdata = NG_NODE_PRIVATE(node);
int error;
+#ifndef PERSISTANT_NODE
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(privdata->node);
-#ifndef PERSISTANT_NODE
FREE(privdata, M_NETGRAPH);
#else
- /*
- * Create a new node. This is basically what a device
- * driver would do in the attach routine.
- */
- error = ng_make_node_common(&typestruct, &node);
- if (node == NULL) {
- printf ("node recreation failed:");
- return (error);
- }
- if ( ng_name_node(node, "name")) { /* whatever name is needed */
- printf("something informative");
- NG_NODE_UNREF(node); /* drop it again */
- return (0);
- }
- privdata->packets_in = 0; /* reset stats */
- privdata->packets_out = 0;
- for (i = 0; i < XXX_NUM_DLCIS; i++) {
- privdata->channel[i].dlci = -2;
- privdata->channel[i].channel = i;
- }
-
- /* Link structs together; this counts as our one reference to node */
- privdata->node = node;
- NG_NODE_SET_PRIVATE(node, privdata);
+ if (node->nd_flags & NG_REALLY_DIE) {
+ /*
+ * WE came here because the widget card is being unloaded,
+ * so stop being persistant.
+ * Actually undo all the things we did on creation.
+ */
+ NG_NODE_SET_PRIVATE(node, NULL);
+ NG_NODE_UNREF(privdata->node);
+ FREE(privdata, M_NETGRAPH);
+ return (0);
+ }
node->nd_flags &= ~NG_INVALID; /* reset invalid flag */
#endif /* PERSISTANT_NODE */
return (0);
OpenPOWER on IntegriCloud