From nobody Wed Dec 3 14:43:34 2025 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 4dM0kZ6lF1z6JW1v for ; Wed, 03 Dec 2025 14:43:34 +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 4dM0kZ4D5lz3PSX for ; Wed, 03 Dec 2025 14:43:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764773014; 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=c5RwiEkwVryWGUtASb2cCFseUt6YVWSRuV3nD4ZeonM=; b=KjXFKDXeLXRZ0RuiO6NLJRt+v2XBk/CJqgVfaC4diG34X/Pdwy0+Zzg7msfqfxor8p7DLG c8gArZC0G+tsGDrDyOo+h9iORlE7huaSBy0tJfWRH2JfDWj8dXf1mdq5AVSMsTtk6tT/QC vtTzQZiDemOl9WKXv7WRkZIg9r5VOAORUtWxNfAQW6EzdAJ4qomZa19nOmYTDq2nYs3J7t 9waMqmMfsDXfB9Allwwi4FBYBNlJV73hPIzDzmzgexV8c8YEGwScSYWypAdoTf+aHTtH5d E3hgh75qnrmfGN6Epl6EUYxnO7nje/f98zS2ry6JEc4cKxmlBd/S/bNc9vZuSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764773014; 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=c5RwiEkwVryWGUtASb2cCFseUt6YVWSRuV3nD4ZeonM=; b=ZTwKuaiwmyR2WPSEtkNV+7HdCusDnfiEtF2ZpIFZrfGz2YuQyJDGbifpKZGT8FWjrsDVNy fwGz5V3fw47K7FFd0QfMmXWt8JoCKcrJS4a2NeNSsfF/kRiT14gH2+V4CFgIOFWpdRbw5c VKPHLmg7wTrPcMYfJB0rVxmWt9/0fvdxHqJeJodaRPrzTlOyfA+TvaP+ateyF1WIQAjWpS 1APYHJwhiSu8NU9UnThyLd92AwLBZYOx3pQzLwwnKJfxl2nXed9cr/p2kGZd8Nm/ghFMB7 nwt/Ohs0a/KzmBvnWIJIXfySKwX+96h0zzifDoOFfbN9q/x64YGZKEMOf6yU0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764773014; a=rsa-sha256; cv=none; b=d6k8AnV4KqQDZUijhczzijapBN5rNffxhXfFLZjwjBH2QVUQh+pLKq09kyBjd+R2rC8D1G m05aJsSLHO8FzZWlwAJbTuuMpOZ/aO06sULBRu3xMgpm3drY6ssD5nP5aMyZuGkQMWcteT zuFj13T//XIpKDFL+d1MOdGzbqNPs3UZ0yauFVqpTAQcRagqzzAMebtnU8jpRRy7OV6RPy NHA6gmkeUHFU1wex00SC+VaD7ozcKyf37MbaIe9vokfWHa7wKrPHBBpAXtg0KoXPaKxKbR BwgW3F5LF9qsmuKAVH6rzWqkwS0g3x+CHleSfDd1eOKKDJgk2EVuhZ8pop/RXg== 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 4dM0kZ3qB6zj4D for ; Wed, 03 Dec 2025 14:43:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2abaa by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 03 Dec 2025 14:43:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 74f7e916211a - main - divert: Use CK_SLISTs for the divcb hash table 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 74f7e916211acafd10af05efd893ccbac1881119 Auto-Submitted: auto-generated Date: Wed, 03 Dec 2025 14:43:34 +0000 Message-Id: <69304c96.2abaa.24faa50f@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=74f7e916211acafd10af05efd893ccbac1881119 commit 74f7e916211acafd10af05efd893ccbac1881119 Author: Mark Johnston AuthorDate: 2025-12-03 13:43:04 +0000 Commit: Mark Johnston CommitDate: 2025-12-03 13:43:04 +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 --- 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 a88497a71019..9f1d862a0531 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -34,6 +34,7 @@ #include "opt_sctp.h" #include +#include #include #include #include @@ -136,7 +137,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) }; @@ -146,7 +147,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) @@ -272,7 +273,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; @@ -600,7 +601,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(); @@ -619,16 +620,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); @@ -667,7 +668,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;