diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-06-24 01:47:31 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-06-24 01:47:31 +0000 |
commit | 393e3c5d09edf8d040ec692cb670fe7c239b4ba0 (patch) | |
tree | 553905812afe6a5439f7e81526ddc734adb24359 /sys/netgraph | |
parent | deac06df058b36a93187ced44821b61d6bb99731 (diff) | |
download | FreeBSD-src-393e3c5d09edf8d040ec692cb670fe7c239b4ba0.zip FreeBSD-src-393e3c5d09edf8d040ec692cb670fe7c239b4ba0.tar.gz |
Clean up use of ng_hdhasb_mtx a little:
- Assert the mutex in NG_IDHASH_FIND() since the mutex is required to
safely walk the node lists in the ng_ID_hash table.
- Acquire the ng_nodelist_mtx when walking ng_allnodes or ng_allhooks
to generate state dump output from the netgraph sysctls.
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/ng_base.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index d3acc01..f50f5f2 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -170,6 +170,7 @@ static struct mtx ng_idhash_mtx; #define NG_IDHASH_FN(ID) ((ID) % (NG_ID_HASH_SIZE)) #define NG_IDHASH_FIND(ID, node) \ do { \ + mtx_assert(&ng_idhash_mtx, MA_OWNED); \ LIST_FOREACH(node, &ng_ID_hash[NG_IDHASH_FN(ID)], \ nd_idnodes) { \ if (NG_NODE_IS_VALID(node) \ @@ -3231,10 +3232,12 @@ ng_dumpnodes(void) { node_p node; int i = 1; + mtx_lock(&ng_nodelist_mtx); SLIST_FOREACH(node, &ng_allnodes, nd_all) { printf("[%d] ", i++); dumpnode(node, NULL, 0); } + mtx_unlock(&ng_nodelist_mtx); } static void @@ -3242,10 +3245,12 @@ ng_dumphooks(void) { hook_p hook; int i = 1; + mtx_lock(&ng_nodelist_mtx); SLIST_FOREACH(hook, &ng_allhooks, hk_all) { printf("[%d] ", i++); dumphook(hook, NULL, 0); } + mtx_unlock(&ng_nodelist_mtx); } static int |