diff options
author | zec <zec@FreeBSD.org> | 2010-05-05 22:06:05 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2010-05-05 22:06:05 +0000 |
commit | fc65bde07d9854848d689e2c1fefa55448b3880a (patch) | |
tree | a12bc1a8023da35bc5ab9ba5c3811bbb1dcca19d /sys/netgraph/ng_bridge.c | |
parent | f3856c6cf2fb115757967b7e32bdeb21bd27d1ee (diff) | |
download | FreeBSD-src-fc65bde07d9854848d689e2c1fefa55448b3880a.zip FreeBSD-src-fc65bde07d9854848d689e2c1fefa55448b3880a.tar.gz |
Add an optional "persistent" flag to ng_hub and ng_bridge, which if set,
disables automatic node shutdown when the last hook gets disconnected.
Reviewed by: julian
Diffstat (limited to 'sys/netgraph/ng_bridge.c')
-rw-r--r-- | sys/netgraph/ng_bridge.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 35e1392..0bf0866 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -84,7 +84,7 @@ #include <netgraph/ng_bridge.h> #ifdef NG_SEPARATE_MALLOC -MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", "netgraph bridge node "); +MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", "netgraph bridge node"); #else #define M_NETGRAPH_BRIDGE M_NETGRAPH #endif @@ -106,6 +106,7 @@ struct ng_bridge_private { u_int numBuckets; /* num buckets in table */ u_int hashMask; /* numBuckets - 1 */ int numLinks; /* num connected links */ + int persistent; /* can exist w/o hooks */ struct callout timer; /* one second periodic timer */ }; typedef struct ng_bridge_private *priv_p; @@ -271,6 +272,13 @@ static const struct ng_cmdlist ng_bridge_cmdlist[] = { NULL, &ng_bridge_host_ary_type }, + { + NGM_BRIDGE_COOKIE, + NGM_BRIDGE_SET_PERSISTENT, + "setpersistent", + NULL, + NULL + }, { 0 } }; @@ -495,6 +503,11 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) } break; } + case NGM_BRIDGE_SET_PERSISTENT: + { + priv->persistent = 1; + break; + } default: error = EINVAL; break; @@ -800,7 +813,8 @@ ng_bridge_disconnect(hook_p hook) /* If no more hooks, go away */ if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) - && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) { + && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))) + && !priv->persistent) { ng_rmnode_self(NG_HOOK_NODE(hook)); } return (0); |