MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_bypass

Function ng_bypass

freebsd/netgraph/ng_base.c:1236–1262  ·  view source on GitHub ↗

* Take two hooks on a node and merge the connection so that the given node * is effectively bypassed. */

Source from the content-addressed store, hash-verified

1234 * is effectively bypassed.
1235 */
1236int
1237ng_bypass(hook_p hook1, hook_p hook2)
1238{
1239 if (hook1->hk_node != hook2->hk_node) {
1240 TRAP_ERROR();
1241 return (EINVAL);
1242 }
1243 TOPOLOGY_WLOCK();
1244 if (NG_HOOK_NOT_VALID(hook1) || NG_HOOK_NOT_VALID(hook2)) {
1245 TOPOLOGY_WUNLOCK();
1246 return (EINVAL);
1247 }
1248 hook1->hk_peer->hk_peer = hook2->hk_peer;
1249 hook2->hk_peer->hk_peer = hook1->hk_peer;
1250
1251 hook1->hk_peer = &ng_deadhook;
1252 hook2->hk_peer = &ng_deadhook;
1253 TOPOLOGY_WUNLOCK();
1254
1255 NG_HOOK_UNREF(hook1);
1256 NG_HOOK_UNREF(hook2);
1257
1258 /* XXX If we ever cache methods on hooks update them as well */
1259 ng_destroy_hook(hook1);
1260 ng_destroy_hook(hook2);
1261 return (0);
1262}
1263
1264/*
1265 * Install a new netgraph type

Callers 2

ngp_shutdownFunction · 0.70
ng_tee_closeFunction · 0.70

Calls 1

ng_destroy_hookFunction · 0.70

Tested by

no test coverage detected