diff options
author | Martin Vahlensieck <git@academicsolutions.ch> | 2024-04-17 18:51:40 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2024-04-24 12:44:50 +0000 |
commit | bb2ab7a374b9d81f8368acc506c9700af20a22d6 (patch) | |
tree | b537deb8b029eb2a7686fa51923670d2cb9c9d3f | |
parent | 8512311fb5004444f43701eb122b6d77c76d7564 (diff) | |
download | src-bb2ab7a374b9d81f8368acc506c9700af20a22d6.tar.gz src-bb2ab7a374b9d81f8368acc506c9700af20a22d6.zip |
ng_pipe: Remove node when all hooks are disconnected
This is the behavior described in the man page.
Signed-off-by: Martin Vahlensieck <git@academicsolutions.ch>
Discussed with: glebius
Reviewed by: markj
MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1181
-rw-r--r-- | sys/netgraph/ng_pipe.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/netgraph/ng_pipe.c b/sys/netgraph/ng_pipe.c index c2424e3db48a..7afaf24f5914 100644 --- a/sys/netgraph/ng_pipe.c +++ b/sys/netgraph/ng_pipe.c @@ -936,6 +936,7 @@ ngp_disconnect(hook_p hook) struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook); struct ngp_fifo *ngp_f; struct ngp_hdr *ngp_h; + priv_p priv; KASSERT(hinfo != NULL, ("%s: null info", __FUNCTION__)); hinfo->hook = NULL; @@ -962,6 +963,12 @@ ngp_disconnect(hook_p hook) if (hinfo->ber_p) free(hinfo->ber_p, M_NG_PIPE); + /* Destroy the node if all hooks are disconnected */ + priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + + if (priv->upper.hook == NULL && priv->lower.hook == NULL) + ng_rmnode_self(NG_HOOK_NODE(hook)); + return (0); } |