In ng_bypass() add more protection against potential race

with ng_rmnode() and its followers.
This commit is contained in:
Gleb Smirnoff 2012-02-15 14:29:23 +00:00
parent 19afcd9829
commit c3189b3fb4

View File

@ -1161,6 +1161,10 @@ ng_bypass(hook_p hook1, hook_p hook2)
return (EINVAL);
}
mtx_lock(&ng_topo_mtx);
if (NG_HOOK_NOT_VALID(hook1) || NG_HOOK_NOT_VALID(hook2)) {
mtx_unlock(&ng_topo_mtx);
return (EINVAL);
}
hook1->hk_peer->hk_peer = hook2->hk_peer;
hook2->hk_peer->hk_peer = hook1->hk_peer;