* Take two hooks on a node and merge the connection so that the given node * is effectively bypassed. */
| 1240 | * is effectively bypassed. |
| 1241 | */ |
| 1242 | int |
| 1243 | ng_bypass(hook_p hook1, hook_p hook2) |
| 1244 | { |
| 1245 | if (hook1->hk_node != hook2->hk_node) { |
| 1246 | TRAP_ERROR(); |
| 1247 | return (EINVAL); |
| 1248 | } |
| 1249 | TOPOLOGY_WLOCK(); |
| 1250 | if (NG_HOOK_NOT_VALID(hook1) || NG_HOOK_NOT_VALID(hook2)) { |
| 1251 | TOPOLOGY_WUNLOCK(); |
| 1252 | return (EINVAL); |
| 1253 | } |
| 1254 | hook1->hk_peer->hk_peer = hook2->hk_peer; |
| 1255 | hook2->hk_peer->hk_peer = hook1->hk_peer; |
| 1256 | |
| 1257 | hook1->hk_peer = &ng_deadhook; |
| 1258 | hook2->hk_peer = &ng_deadhook; |
| 1259 | TOPOLOGY_WUNLOCK(); |
| 1260 | |
| 1261 | NG_HOOK_UNREF(hook1); |
| 1262 | NG_HOOK_UNREF(hook2); |
| 1263 | |
| 1264 | /* XXX If we ever cache methods on hooks update them as well */ |
| 1265 | ng_destroy_hook(hook1); |
| 1266 | ng_destroy_hook(hook2); |
| 1267 | return (0); |
| 1268 | } |
| 1269 | |
| 1270 | /* |
| 1271 | * Install a new netgraph type |
nothing calls this directly
no test coverage detected