From nobody Thu Dec 11 18:05:52 2025 X-Original-To: dev-commits-src-branches@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 4dS0rJ5cRhz6K7nm for ; Thu, 11 Dec 2025 18:05: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dS0rJ3N44z46JG for ; Thu, 11 Dec 2025 18:05:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765476352; 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=tHJx026Qxu5cdPbgX0AkzoV3HQeryVd3l2p47vSWTgg=; b=SoDz+sabAJyk10bRG9Rfm7IGLAFCkTq+TjUAMObBbiOUEZ+ILdJrglRplICjd0wmgO4LTM 4p2to4vQRslIAkNzgPB8Ut5NnPuitQOfgP8hXhYe4ll2LPCmxayU+O9Sd1sc2VyZMsNsRD T/yxoz0Dh8Muoo+mDgNZGPKh6pgJxyNRsT+q9CXcu3NZ4gG1lc2VL6DW2whnRo+Hls8XLG vdWgl8DGbmTXTCS2iuVA1UUBNlCqIJ3R1v6nuNl3Hj+eZ1vfRRY2pHWmWwjZ0Mo1djCign Fjz2g6Ys0ICXDfwiOFdcS8zuWBU1QijxpIbHXOftJ6Bxf+ZeQgW37022s0uRJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765476352; 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=tHJx026Qxu5cdPbgX0AkzoV3HQeryVd3l2p47vSWTgg=; b=iYeKqz8PPYtSqpeMbVy8C+83llgbGpPWV9CfLCNdhQoci7nPtnprp5yARCsPQD+TgElmyG pK+0ZQNTRxHKQeETLrIVSn2xxdf+sGhYHQ+s6bzKF2E5uaWUgme9QeTVIr9cZ6GYzLV+YG d3d88HOjyoClql0PrNHPIiyTLRtLKP9iG7BaX3nlmjkvbg2sZSiCoaBDv+jhbgSqiwK4Wq uRpU4Zd58ldkqBryxF4TMWCnRthHbTydZWyFq1vg2TpsrmulCzRfvizDnwVflEi+wkrkA1 Qipoqt1gG3ThGYS/j/35/P+SMCGH0orJ63MVrKll8gyQa0GkPbALDqDGHLYQBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765476352; a=rsa-sha256; cv=none; b=oXNa3ovNAhLdqUciYTXvQh4aryy8skoOHpeLFm4MhN3kSSQSFNizEfO3yG714tG3UbXX+B s+CQndXr8M2YpkKfpiITtQ3VAM5GePDw+nZgw4bQpq3D0br6toa+proSdpFNvJ+Rb26YwE LaELIUD/fy+WT5h8Snp5xWM7fA8iLwoLLoLJag5vjmuEw9RCwtyH7tI3V3/q2kE5QTS+Zq fDIPwaboOubtPM4HxByy1fCSuamPra31tBZledAsjgVccHWn8RFyOPhO8WUqyykiprq4JR nq+05qRg86/aaHw1ulNxBTouic5mxQ1mp9RrbI2gJc8zELvxP/8S0POowj67nw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dS0rJ2VBFzj7Z for ; Thu, 11 Dec 2025 18:05:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21788 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 11 Dec 2025 18:05:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e29fe1c251a1 - stable/15 - divert: Use CK_SLISTs for the divcb hash table List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e29fe1c251a1a95ccb989779d0d7921666c038d4 Auto-Submitted: auto-generated Date: Thu, 11 Dec 2025 18:05:52 +0000 Message-Id: <693b0800.21788.53469aa1@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e29fe1c251a1a95ccb989779d0d7921666c038d4 commit e29fe1c251a1a95ccb989779d0d7921666c038d4 Author: Mark Johnston AuthorDate: 2025-12-03 13:43:04 +0000 Commit: Mark Johnston CommitDate: 2025-12-11 17:59:09 +0000 divert: Use CK_SLISTs for the divcb hash table The hash table is accessed in ip_divert_packet(), and there the accesses are synchronized only by the net epoch, so plain SLIST is not safe. Reviewed by: ae MFC after: 1 week Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54011 (cherry picked from commit 74f7e916211acafd10af05efd893ccbac1881119) --- sys/netinet/ip_divert.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 5a561814cdb5..f98a599e7554 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -35,6 +35,7 @@ #include "opt_sctp.h" #include +#include #include #include #include @@ -137,7 +138,7 @@ static int div_output_outbound(int family, struct socket *so, struct mbuf *m); struct divcb { union { - SLIST_ENTRY(divcb) dcb_next; + CK_SLIST_ENTRY(divcb) dcb_next; intptr_t dcb_bound; #define DCB_UNBOUND ((intptr_t)-1) }; @@ -147,7 +148,7 @@ struct divcb { struct epoch_context dcb_epochctx; }; -SLIST_HEAD(divhashhead, divcb); +CK_SLIST_HEAD(divhashhead, divcb); VNET_DEFINE_STATIC(struct divhashhead, divhash[DIVHASHSIZE]) = {}; #define V_divhash VNET(divhash) @@ -273,7 +274,7 @@ divert_packet(struct mbuf *m, bool incoming) } /* Put packet on socket queue, if any */ - SLIST_FOREACH(dcb, &V_divhash[DIVHASH(nport)], dcb_next) + CK_SLIST_FOREACH(dcb, &V_divhash[DIVHASH(nport)], dcb_next) if (dcb->dcb_port == nport) break; @@ -601,7 +602,7 @@ div_detach(struct socket *so) so->so_pcb = NULL; DIVERT_LOCK(); if (dcb->dcb_bound != DCB_UNBOUND) - SLIST_REMOVE(&V_divhash[DCBHASH(dcb)], dcb, divcb, dcb_next); + CK_SLIST_REMOVE(&V_divhash[DCBHASH(dcb)], dcb, divcb, dcb_next); V_dcb_count--; V_dcb_gencnt++; DIVERT_UNLOCK(); @@ -620,16 +621,16 @@ div_bind(struct socket *so, struct sockaddr *nam, struct thread *td) return EINVAL; port = ((struct sockaddr_in *)nam)->sin_port; DIVERT_LOCK(); - SLIST_FOREACH(dcb, &V_divhash[DIVHASH(port)], dcb_next) + CK_SLIST_FOREACH(dcb, &V_divhash[DIVHASH(port)], dcb_next) if (dcb->dcb_port == port) { DIVERT_UNLOCK(); return (EADDRINUSE); } dcb = so->so_pcb; if (dcb->dcb_bound != DCB_UNBOUND) - SLIST_REMOVE(&V_divhash[DCBHASH(dcb)], dcb, divcb, dcb_next); + CK_SLIST_REMOVE(&V_divhash[DCBHASH(dcb)], dcb, divcb, dcb_next); dcb->dcb_port = port; - SLIST_INSERT_HEAD(&V_divhash[DIVHASH(port)], dcb, dcb_next); + CK_SLIST_INSERT_HEAD(&V_divhash[DIVHASH(port)], dcb, dcb_next); DIVERT_UNLOCK(); return (0); @@ -668,7 +669,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS) DIVERT_LOCK(); for (int i = 0; i < DIVHASHSIZE; i++) - SLIST_FOREACH(dcb, &V_divhash[i], dcb_next) { + CK_SLIST_FOREACH(dcb, &V_divhash[i], dcb_next) { if (dcb->dcb_gencnt <= xig.xig_gen) { struct xinpcb xi;