Date: Wed, 4 Sep 2024 16:21:10 GMT From: Eugene Grosbein <eugen@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 5d0ad5fffbb3 - stable/13 - MFC: ng_ksocket: fix upcall clearing on node shutdown Message-ID: <202409041621.484GLAH4066089@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=5d0ad5fffbb3b5a71405a47b9b74d7920f9428fd commit 5d0ad5fffbb3b5a71405a47b9b74d7920f9428fd Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2023-11-17 17:23:58 +0000 Commit: Eugene Grosbein <eugen@FreeBSD.org> CommitDate: 2024-09-04 16:20:18 +0000 MFC: ng_ksocket: fix upcall clearing on node shutdown Note: imho, the proper solution would be to guarantee that upcalls won't ever be called after soclose(), but this isn't the case, yet. This change at least makes the node work the way it always worked. Reviewed by: afedorov Differential Revision: https://reviews.freebsd.org/D42636 PR: 272319 PR: 275106 Fixes: 779f106aa169256b7010a1d8f963ff656b881e92 (cherry picked from commit efad7cbfdc06e92bcc589a6c0cae2f3bea0d5cb9) --- sys/netgraph/ng_ksocket.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c index 6e12415e449a..1acd9f78efbf 100644 --- a/sys/netgraph/ng_ksocket.c +++ b/sys/netgraph/ng_ksocket.c @@ -944,17 +944,24 @@ static int ng_ksocket_shutdown(node_p node) { const priv_p priv = NG_NODE_PRIVATE(node); + struct socket *so = priv->so; priv_p embryo; /* Close our socket (if any) */ if (priv->so != NULL) { - SOCKBUF_LOCK(&priv->so->so_rcv); - soupcall_clear(priv->so, SO_RCV); - SOCKBUF_UNLOCK(&priv->so->so_rcv); - SOCKBUF_LOCK(&priv->so->so_snd); - soupcall_clear(priv->so, SO_SND); - SOCKBUF_UNLOCK(&priv->so->so_snd); - soclose(priv->so); + if (SOLISTENING(so)) { + SOLISTEN_LOCK(so); + solisten_upcall_set(so, NULL, NULL); + SOLISTEN_UNLOCK(so); + } else { + SOCK_RECVBUF_LOCK(so); + soupcall_clear(so, SO_RCV); + SOCK_RECVBUF_UNLOCK(so); + SOCK_SENDBUF_LOCK(so); + soupcall_clear(so, SO_SND); + SOCK_SENDBUF_UNLOCK(so); + } + soclose(so); priv->so = NULL; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202409041621.484GLAH4066089>