From nobody Mon Feb 16 17:30:06 2026 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 4fF8t63cvSz6S5Q9 for ; Mon, 16 Feb 2026 17:30:06 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fF8t60r2sz3SqR for ; Mon, 16 Feb 2026 17:30:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771263006; 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=XEaIFYtFUY9mLur/ijIFOxpSUVQJnmMp/F8V7G5PgjU=; b=Bd0iEklf1yXm59w9q6kDAh+KRqYKQjm00uDyYaflQBszL1J8MemmDQXs2A/zHEsEUYOP6h Kut+pH1ZIj7osOhHf7mRqA7k0C+h3Xra5boW6ISM5OG6k/6VFiFmPxhrHdXDlCV7f05gZ4 wYDlAXRtpSRvBw6+T+m9KGXhITtkoh955qllXWrxrVoK/INESoW/cpnB4fJNbXUGhUVioL vCS8GYigLOwGQv6LsmTOpvkXrWJc/8XRXqeHn32CNBdPJk493Rmz3jkzQLgb/IWdkynVQE Vv0cvNrOMT+bLy8VnFFnG9Nv0AZO155IhQlkxZIKXo2OEOJy5x+AFGM82vzpSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1771263006; a=rsa-sha256; cv=none; b=xGJpZ1axMD0G9VMt/oNRDSBA/C9Yf1FzItC2X5vSQW5Gw2WXj6X3nkeCk2gEIMchoNz0qk fRQSa5wdkAIJLzwEgnZFpcecH7p8D3TlKEZvKDw5yHVdQiQvTMD1RAk9k+IEMga8b2l2Su leZ5RkmVWZjxplVFm6NNTGlFnE+h3pENV69TU5UckJjnoZ1vVvYEzR01TFYsei6LDQayA2 /ELlcPy2NfyS/twm5kr4Fpaywf3qEz9TiOJQAjw9F0yw7C19ehyvRGPLTU4BX/2vbpHeoV QicqCZLCUHvHyrpdmuThof6FvzWESjuyQSU2899J6Wcuc0vVx1cNLmHWp62J1w== 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=1771263006; 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=XEaIFYtFUY9mLur/ijIFOxpSUVQJnmMp/F8V7G5PgjU=; b=FnWZO+GdHkoNqZLCnX8v5bxm5Y7/VzGLTkf/bgUwKK+zumEHjC/bSFmQQnMrB0r6Kpt3At /8zWi8yiEnfeyR2NC73Do9/Ai/PWUNOgEws/PfGR1/fuQVoRVhcSOxaa4+XwY5cW52U1xe 7EyiSCk0eRpjqHNI4Ga1cvNyxiJLC0lnkuzF0PQ84xYZUZUUERERBka24ja2RR3rghLgZQ 5WUyhhu2QFw4ocHMduTiJpDl5zkhWBiv4sBe0SJoxkpdKpRDnvfS2Ox7Z8igQuzJodhqmZ nt525wkhffsZ1MPivBnMIdar3CKf+Vv5IhA+UQA1Pit3dcqzNKm0vC/mM8UkPw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fF8t60MPfzZMs for ; Mon, 16 Feb 2026 17:30:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 33101 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Feb 2026 17:30:06 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guido Falsi Subject: git: 4c7357aaf5d2 - stable/15 - sys/netinet6: Use atomic(9) for dad_failures counter 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: madpilot X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 4c7357aaf5d2fbe85eb6d86b59efe11c6f0e8c9a Auto-Submitted: auto-generated Date: Mon, 16 Feb 2026 17:30:06 +0000 Message-Id: <6993541e.33101.16a0270e@gitrepo.freebsd.org> The branch stable/15 has been updated by madpilot: URL: https://cgit.FreeBSD.org/src/commit/?id=4c7357aaf5d2fbe85eb6d86b59efe11c6f0e8c9a commit 4c7357aaf5d2fbe85eb6d86b59efe11c6f0e8c9a Author: Guido Falsi AuthorDate: 2025-10-03 10:09:42 +0000 Commit: Guido Falsi CommitDate: 2026-02-16 17:27:41 +0000 sys/netinet6: Use atomic(9) for dad_failures counter Replace counter(9) usage with more lightweight atomic(9) in the code handling RFC 7217 SLAAC address generation. Also, use `u_int` types with this. Leaving `dad_failures` local to `in6_get_stableifid()` as a `uint64_t` to avoid changing the generated addresses from previous code; this also gives some headroom for future changes. While here, moved some `#include` lines to adhere to style(9). Reviewed by: glebius, jhibbits, jtl, zlei Approved by: glebius, jtl, zlei Differential Revision: https://reviews.freebsd.org/D52731 (cherry picked from commit 0c94dc9da7c238603e43c55ca6da64c417fc2204) Reviewed by: glebius, kp, pouria, zlei Approved by: glebius, pouria Relnotes: yes Differential Revision: https://reviews.freebsd.org/D54382 --- sys/netinet6/in6.c | 3 --- sys/netinet6/in6_ifattach.c | 6 ++++-- sys/netinet6/in6_proto.c | 4 ++-- sys/netinet6/in6_var.h | 2 +- sys/netinet6/ip6_var.h | 2 +- sys/netinet6/nd6_nbr.c | 8 +++++--- sys/netinet6/nd6_rtr.c | 4 +++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index abb880e5c2c1..bdee1eefaa3f 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2629,8 +2629,6 @@ in6_domifattach(struct ifnet *ifp) COUNTER_ARRAY_ALLOC(ext->icmp6_ifstat, sizeof(struct icmp6_ifstat) / sizeof(uint64_t), M_WAITOK); - ext->dad_failures = counter_u64_alloc(M_WAITOK); - ext->nd_ifinfo = nd6_ifattach(ifp); ext->scope6_id = scope6_ifattach(ifp); ext->lltable = in6_lltattach(ifp); @@ -2666,7 +2664,6 @@ in6_domifdetach(struct ifnet *ifp, void *aux) COUNTER_ARRAY_FREE(ext->icmp6_ifstat, sizeof(struct icmp6_ifstat) / sizeof(uint64_t)); free(ext->icmp6_ifstat, M_IFADDR); - counter_u64_free(ext->dad_failures); free(ext, M_IFADDR); } diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 538f34a267b4..b487c80a6667 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -72,6 +71,9 @@ #include #include +#include +#include + #ifdef IP6_AUTO_LINKLOCAL VNET_DEFINE(int, ip6_auto_linklocal) = IP6_AUTO_LINKLOCAL; #else @@ -378,7 +380,7 @@ in6_get_stableifid(struct ifnet *ifp, struct in6_addr *in6, int prefixlen) } hostuuid_len = strlen(hostuuid); - dad_failures = counter_u64_fetch(DAD_FAILURES(ifp)); + dad_failures = atomic_load_int(&DAD_FAILURES(ifp)); /* * RFC 7217 section 7 diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 6669a2ba56ce..f567b42b42ca 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -167,7 +167,7 @@ VNET_DEFINE(int, ip6_rr_prune) = 5; /* router renumbering prefix * walk list every 5 sec. */ VNET_DEFINE(int, ip6_mcast_pmtu) = 0; /* enable pMTU discovery for multicast? */ VNET_DEFINE(int, ip6_v6only) = 1; -VNET_DEFINE(int, ip6_stableaddr_maxretries) = IP6_IDGEN_RETRIES; +VNET_DEFINE(u_int, ip6_stableaddr_maxretries) = IP6_IDGEN_RETRIES; #ifdef IPSTEALTH VNET_DEFINE(int, ip6stealth) = 0; @@ -317,7 +317,7 @@ SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, use_tempaddr, SYSCTL_BOOL(_net_inet6_ip6, IPV6CTL_USESTABLEADDR, use_stableaddr, CTLFLAG_VNET | CTLFLAG_RWTUN, &VNET_NAME(ip6_use_stableaddr), 0, "Create RFC7217 semantically opaque address for autoconfigured addresses (default for new interfaces)"); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_STABLEADDR_MAXRETRIES, stableaddr_maxretries, +SYSCTL_UINT(_net_inet6_ip6, IPV6CTL_STABLEADDR_MAXRETRIES, stableaddr_maxretries, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_stableaddr_maxretries), IP6_IDGEN_RETRIES, "RFC7217 semantically opaque address DAD max retries"); SYSCTL_INT(_net_inet6_ip6, IPV6CTL_STABLEADDR_NETIFSRC, stableaddr_netifsource, diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index e511ead24f08..1414cc71388d 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -106,7 +106,7 @@ struct in6_ifextra { struct scope6_id *scope6_id; struct lltable *lltable; struct mld_ifsoftc *mld_ifinfo; - counter_u64_t dad_failures; /* DAD failures when using RFC 7217 stable addresses */ + u_int dad_failures; /* DAD failures when using RFC 7217 stable addresses */ }; #define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable) diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index c28bfa5a9d08..db1631736c4a 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -344,7 +344,7 @@ VNET_DECLARE(bool, ip6_use_stableaddr); /* Whether to use stable address generat #define V_ip6_use_stableaddr VNET(ip6_use_stableaddr) #define IP6_IDGEN_RETRIES 3 /* RFC 7217 section 7 default max retries */ -VNET_DECLARE(int, ip6_stableaddr_maxretries); +VNET_DECLARE(u_int, ip6_stableaddr_maxretries); #define V_ip6_stableaddr_maxretries VNET(ip6_stableaddr_maxretries) #define IP6_STABLEADDR_NETIFSRC_NAME 0 diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index e2db192bca15..29151b29a071 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -77,6 +77,8 @@ #include #include +#include + #define SDL(s) ((struct sockaddr_dl *)s) struct dadq; @@ -1460,7 +1462,7 @@ nd6_dad_timer(void *arg) if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) == 0) { ia->ia6_flags &= ~IN6_IFF_TENTATIVE; if ((ND_IFINFO(ifp)->flags & ND6_IFF_STABLEADDR) && !(ia->ia6_flags & IN6_IFF_TEMPORARY)) - counter_u64_zero(DAD_FAILURES(ifp)); + atomic_store_int(&DAD_FAILURES(ifp), 0); } nd6log((LOG_DEBUG, @@ -1509,10 +1511,10 @@ nd6_dad_duplicated(struct ifaddr *ifa, struct dadq *dp) * More addresses will be generated as long as retries are not exhausted. */ if ((ND_IFINFO(ifp)->flags & ND6_IFF_STABLEADDR) && !(ia->ia6_flags & IN6_IFF_TEMPORARY)) { - uint64_t dad_failures = counter_u64_fetch(DAD_FAILURES(ifp)); + u_int dad_failures = atomic_load_int(&DAD_FAILURES(ifp)); if (dad_failures <= V_ip6_stableaddr_maxretries) { - counter_u64_add(DAD_FAILURES(ifp), 1); + atomic_add_int(&DAD_FAILURES(ifp), 1); /* if retries exhausted, output an informative error message */ if (dad_failures == V_ip6_stableaddr_maxretries) log(LOG_ERR, "%s: manual intervention required, consider disabling \"stableaddr\" on the interface" diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 2ac883729c12..2556ed101a90 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -74,6 +74,8 @@ #include #include +#include + static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *); static int prelist_update(struct nd_prefixctl *, struct nd_defrouter *, struct mbuf *, int); @@ -1709,7 +1711,7 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr, * to fail and no further retries should happen. */ if (ND_IFINFO(ifp)->flags & ND6_IFF_STABLEADDR && - counter_u64_fetch(DAD_FAILURES(ifp)) <= V_ip6_stableaddr_maxretries && + atomic_load_int(&DAD_FAILURES(ifp)) <= V_ip6_stableaddr_maxretries && ifa6->ia6_flags & (IN6_IFF_DUPLICATED | IN6_IFF_TEMPORARY)) continue;