From nobody Fri Nov 17 17:24:52 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SX3gS432Gz51B93; Fri, 17 Nov 2023 17:24:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SX3gS3bysz4Th2; Fri, 17 Nov 2023 17:24:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700241892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=h4f/ubEIQg4T4FYF+RM1iBT7Syt5a5yqpdmoLoJ0/jI=; b=qIIcNsMkjWlmeXbWAhorFsw8rBdOhhlA+T+bN2cWj+OXtxggjHEaA99X382YkXgHQdtzzy LjgEWx2iK/pl0197wBv34CsyDHfMwJgGM+3/qiHSDM7oNFDR7M/nNZQTEjHE9IXM+1WZfx 5ITfkkzyeRalxHRx7KRyIS9ycCA5oIdUzSht9Ok41ir7M2aEGtzONnV9Vm9UqsbBWqhyZz iJngaEfi0t6FAZ6qFQKs50vw8MqzBtCDCiic4sgNq2l0phpKEpkiXzzXFUsHQPIcl74iXe 3xU6gWG3haJmr9nZrIApjTsxCTY6bkpSvL06x/ErIjqtReJk/MyBrIe84sfrug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700241892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=h4f/ubEIQg4T4FYF+RM1iBT7Syt5a5yqpdmoLoJ0/jI=; b=I3Biq3aPYcAhRCcp++47wS5bO///GP8yi9tfYK5eZ/E0TyXqnLsbMe08i+xxmDrgwjlttE Oc+hr16js9GIr+VdDD6wqkiaPKrCv99LV9E0nJIKa8dLogtDBLYj0+/pl0PIbwfagWFcue zbUxqzzp0NsQyV2fJpqeAq1woEjE6Ti7ujNozN4sM1YlT98hmYSaGCotJYESYFEwO8j/b8 eniyhnP9BttH0YedOP41YkCh6dbrGErwPJY94K6AEzrO80x2TDsNUl8A/0VbCwPvbzu1ro dxNM3KfpQcUHKbyTPc5pfN44HLIpGk0tGvAfK1TmL80V9KagssDyVovE9uuucA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700241892; a=rsa-sha256; cv=none; b=bRUCVrgdfTfLCuEribG+AXh2cNrHmYzBeXTlOTNOmxEbVWI0xDPT9eJZP5De/vIN5j46+S SsU8qL6oB6Q4z66wYr7N8q2nF1dpPwviMzpWWOyIGZdbiPDD4nThJZoLNPAypjGmf0015w yzSiF4i+oxLUT0jo4fPuCTaJgFhZqqRm2OIaJunfCej0oqyX8+J9Cgr5v2/ygE2O6XtoJL YaFhbGmWKqUKh5BbyQ+IKm4dOz9/q/U/qnJ/21z3Xb4C/CxF9whu0ymMAEnlO1SVQ3oskY LxX0oFDzVNWs+hNg6PsX/VDdiN+bJQZpFxsiWlNTnbmh0LdT8vhjoTRn9j9geQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SX3gS2WW4zryd; Fri, 17 Nov 2023 17:24:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AHHOqg6008225; Fri, 17 Nov 2023 17:24:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AHHOqxh008222; Fri, 17 Nov 2023 17:24:52 GMT (envelope-from git) Date: Fri, 17 Nov 2023 17:24:52 GMT Message-Id: <202311171724.3AHHOqxh008222@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: efad7cbfdc06 - main - ng_ksocket: fix upcall clearing on node shutdown List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: efad7cbfdc06e92bcc589a6c0cae2f3bea0d5cb9 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=efad7cbfdc06e92bcc589a6c0cae2f3bea0d5cb9 commit efad7cbfdc06e92bcc589a6c0cae2f3bea0d5cb9 Author: Gleb Smirnoff AuthorDate: 2023-11-17 17:23:58 +0000 Commit: Gleb Smirnoff CommitDate: 2023-11-17 17:23:58 +0000 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 --- 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 7e5be8c211ae..337248789473 100644 --- a/sys/netgraph/ng_ksocket.c +++ b/sys/netgraph/ng_ksocket.c @@ -929,17 +929,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; }