From nobody Sun Apr 12 18:35:33 2026 X-Original-To: dev-commits-src-main@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 4ftzkF68G0z6YW7J for ; Sun, 12 Apr 2026 18:35:33 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ftzkF3cYKz3ZWm for ; Sun, 12 Apr 2026 18:35:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776018933; 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=a5OT1lgCYppDtMilx7JdH0Rr2WbohCtvIvuwQ9rOGkk=; b=cmVmE+ZfaXEhcd4AwKqixWel+kekYSEl43IkPXDBjqGD6LjvcLtRsQ0iJ9ovlsbCL6qwYd HNY7GlthjVMPsW8zwQZ1yctLmEPtxuER2GyT3uTeTvxeQ1alwiuGbYhrB/afFqdvWh3h2U VbI/0ZgFzLaB44HswE87qx8ZbWmwZ6qKqQQrFx8UyCWsECq3RGGvZKZ1uv3TocvyYVOVPK iBFC+zbhHUabTNl3vSRIF5oj59H+r84ossj1ep42qPF/qQsdmE+1mMUK6yHwQfsHLydXa1 ztk1j2updSqHVXfCpvbNFFIGrikONBCBNqedMvG7wYYAI6x/AGPnTI7nt4pkEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776018933; a=rsa-sha256; cv=none; b=HvUDFj05rANJglJJEA+uaS7YbZkhQP3KeFjMlY43b22EsQ1K3jWuW7CQ13XjZjgsn92g5p qmKNxUPIyT/k86sBq55vEJL6s4xk23lcHcsXt+KNUPy/zhtIU2lD/CyZOyF1kag1QA3FsK YGdro/DB/OEBjl5jwEivkIz5FEjaQP87vjirAxk4Qi4oIX5jQ9XIlUXr8ZUgRqnti2lQLs 4i4Nb9IZFuujvNrfM6J/IAEDGB2wBGg3aMYkkeI8MTuTktN7xmx5JBcL3IdEM9sfEGwsuf 4N48Q0SYj5j1DQ2yasi8diLAcLjd4r+hu0Z47Q55YqynfO0iyh4Rhx4dKZ7T7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776018933; 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=a5OT1lgCYppDtMilx7JdH0Rr2WbohCtvIvuwQ9rOGkk=; b=lu7eik+vOj6+QgcHP+kUoXH3zBpmRTSgQA5oUm2C/NSfeXWBlwe8hlrO6PYaadF1fMhf/g xdRV3af6z+viAWIHZwW6Uxrx3FIfxBQt7jYuoxoSpeVNvFbf5UzUHVmi+pxFnjv9DW6ZrS K0d+9XoOxLI1HEivFpCaStri5/Ey/Jw3IXRgsmRLUB+6gHoc6B2F2DcmHJKKRSGr94Asrw scEgUB0euLLie5kbQw/3LHrTe7e7nDVh3cxSwWORzdjnoKijcg0cjl6Phcbxlij7/EnIKx 3aDgAtL52UFvQEb/toSq5yLUK8ujKMW2vM1F/I7e94S/bzvhDkY1ZjQMsyVkIg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4ftzkF3B4TzDJP for ; Sun, 12 Apr 2026 18:35:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 39053 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 12 Apr 2026 18:35:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 0ba87ded9d07 - main - inpcb: make in_pcbdisconnect() acquire the hash lock internally List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 0ba87ded9d072b7b0605d2f4e8a7232b33b8787e Auto-Submitted: auto-generated Date: Sun, 12 Apr 2026 18:35:33 +0000 Message-Id: <69dbe5f5.39053.241f63d@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=0ba87ded9d072b7b0605d2f4e8a7232b33b8787e commit 0ba87ded9d072b7b0605d2f4e8a7232b33b8787e Author: Gleb Smirnoff AuthorDate: 2026-04-12 18:32:06 +0000 Commit: Gleb Smirnoff CommitDate: 2026-04-12 18:32:06 +0000 inpcb: make in_pcbdisconnect() acquire the hash lock internally Should be no functional change. Reviewed by: pouria, markj Differential Revision: https://reviews.freebsd.org/D55968 --- sys/netinet/in_pcb.c | 3 ++- sys/netinet/udp_usrreq.c | 12 ------------ sys/netinet6/in6_pcb.c | 3 ++- sys/netinet6/udp6_usrreq.c | 12 ------------ 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index cb5b7fa274f6..8bc90de239c2 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1423,13 +1423,14 @@ in_pcbdisconnect(struct inpcb *inp) { INP_WLOCK_ASSERT(inp); - INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); KASSERT(inp->inp_smr == SMR_SEQ_INVALID, ("%s: inp %p was already disconnected", __func__, inp)); + INP_HASH_WLOCK(inp->inp_pcbinfo); in_pcbremhash(inp); CK_LIST_INSERT_HEAD(&inp->inp_pcbinfo->ipi_list_unconn, inp, inp_unconn_list); + INP_HASH_WUNLOCK(inp->inp_pcbinfo); if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) { /* See the comment in in_pcbinshash(). */ diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index eb37ceddace0..e425af92048d 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1528,16 +1528,12 @@ void udp_abort(struct socket *so) { struct inpcb *inp; - struct inpcbinfo *pcbinfo; - pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp_abort: inp == NULL")); INP_WLOCK(inp); if (inp->inp_faddr.s_addr != INADDR_ANY) { - INP_HASH_WLOCK(pcbinfo); in_pcbdisconnect(inp); - INP_HASH_WUNLOCK(pcbinfo); soisdisconnected(so); } INP_WUNLOCK(inp); @@ -1638,16 +1634,12 @@ static void udp_close(struct socket *so) { struct inpcb *inp; - struct inpcbinfo *pcbinfo; - pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp_close: inp == NULL")); INP_WLOCK(inp); if (inp->inp_faddr.s_addr != INADDR_ANY) { - INP_HASH_WLOCK(pcbinfo); in_pcbdisconnect(inp); - INP_HASH_WUNLOCK(pcbinfo); soisdisconnected(so); } INP_WUNLOCK(inp); @@ -1710,9 +1702,7 @@ int udp_disconnect(struct socket *so) { struct inpcb *inp; - struct inpcbinfo *pcbinfo; - pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp_disconnect: inp == NULL")); INP_WLOCK(inp); @@ -1720,9 +1710,7 @@ udp_disconnect(struct socket *so) INP_WUNLOCK(inp); return (ENOTCONN); } - INP_HASH_WLOCK(pcbinfo); in_pcbdisconnect(inp); - INP_HASH_WUNLOCK(pcbinfo); SOCK_LOCK(so); so->so_state &= ~SS_ISCONNECTED; /* XXX */ SOCK_UNLOCK(so); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 8a644f96f72e..bc21c31bf446 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -504,13 +504,14 @@ in6_pcbdisconnect(struct inpcb *inp) { INP_WLOCK_ASSERT(inp); - INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); KASSERT(inp->inp_smr == SMR_SEQ_INVALID, ("%s: inp %p was already disconnected", __func__, inp)); + INP_HASH_WLOCK(inp->inp_pcbinfo); in_pcbremhash(inp); CK_LIST_INSERT_HEAD(&inp->inp_pcbinfo->ipi_list_unconn, inp, inp_unconn_list); + INP_HASH_WUNLOCK(inp->inp_pcbinfo); if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) { /* See the comment in in_pcbinshash(). */ diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 729be392668a..715f43f0d47c 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -986,9 +986,7 @@ static void udp6_abort(struct socket *so) { struct inpcb *inp; - struct inpcbinfo *pcbinfo; - pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_abort: inp == NULL")); @@ -1002,9 +1000,7 @@ udp6_abort(struct socket *so) #endif if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { - INP_HASH_WLOCK(pcbinfo); in6_pcbdisconnect(inp); - INP_HASH_WUNLOCK(pcbinfo); soisdisconnected(so); } INP_WUNLOCK(inp); @@ -1104,9 +1100,7 @@ static void udp6_close(struct socket *so) { struct inpcb *inp; - struct inpcbinfo *pcbinfo; - pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_close: inp == NULL")); @@ -1119,9 +1113,7 @@ udp6_close(struct socket *so) } #endif if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { - INP_HASH_WLOCK(pcbinfo); in6_pcbdisconnect(inp); - INP_HASH_WUNLOCK(pcbinfo); soisdisconnected(so); } INP_WUNLOCK(inp); @@ -1243,9 +1235,7 @@ static int udp6_disconnect(struct socket *so) { struct inpcb *inp; - struct inpcbinfo *pcbinfo; - pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_disconnect: inp == NULL")); @@ -1263,9 +1253,7 @@ udp6_disconnect(struct socket *so) return (ENOTCONN); } - INP_HASH_WLOCK(pcbinfo); in6_pcbdisconnect(inp); - INP_HASH_WUNLOCK(pcbinfo); SOCK_LOCK(so); so->so_state &= ~SS_ISCONNECTED; /* XXX */ SOCK_UNLOCK(so);