Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145371049
D52731.id162826.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D52731.id162826.diff
View Options
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -2604,8 +2604,6 @@
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);
@@ -2641,7 +2639,6 @@
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
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -44,7 +44,6 @@
#include <sys/rmlock.h>
#include <sys/syslog.h>
#include <sys/md5.h>
-#include <crypto/sha2/sha256.h>
#include <net/if.h>
#include <net/if_var.h>
@@ -72,6 +71,9 @@
#include <netinet6/mld6_var.h>
#include <netinet6/scope6_var.h>
+#include <crypto/sha2/sha256.h>
+#include <machine/atomic.h>
+
#ifdef IP6_AUTO_LINKLOCAL
VNET_DEFINE(int, ip6_auto_linklocal) = IP6_AUTO_LINKLOCAL;
#else
@@ -342,8 +344,8 @@
const uint8_t *netiface;
size_t netiface_len, hostuuid_len;
uint8_t hostuuid[HOSTUUIDLEN + 1], hmac_key[SHA256_BLOCK_LENGTH],
- hk_ipad[SHA256_BLOCK_LENGTH], hk_opad[SHA256_BLOCK_LENGTH];
- uint64_t dad_failures;
+ hk_ipad[SHA256_BLOCK_LENGTH], hk_opad[SHA256_BLOCK_LENGTH],
+ dad_failures;
SHA256_CTX ctxt;
switch (V_ip6_stableaddr_netifsource) {
@@ -377,7 +379,7 @@
}
hostuuid_len = strlen(hostuuid);
- dad_failures = counter_u64_fetch(DAD_FAILURES(ifp));
+ dad_failures = atomic_load_acq_8(&DAD_FAILURES(ifp));
/*
* RFC 7217 section 7
@@ -423,7 +425,7 @@
SHA256_Update(&ctxt, hk_ipad, sizeof(hk_ipad));
SHA256_Update(&ctxt, in6->s6_addr, prefixlen / 8);
SHA256_Update(&ctxt, netiface, netiface_len);
- SHA256_Update(&ctxt, (uint8_t *)&dad_failures, 8);
+ SHA256_Update(&ctxt, &dad_failures, 8);
SHA256_Update(&ctxt, hostuuid, hostuuid_len);
SHA256_Update(&ctxt, &offset, 1);
SHA256_Final(digest, &ctxt);
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -167,7 +167,7 @@
* 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(uint8_t, ip6_stableaddr_maxretries) = IP6_IDGEN_RETRIES;
#ifdef IPSTEALTH
VNET_DEFINE(int, ip6stealth) = 0;
@@ -317,7 +317,7 @@
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_U8(_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
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -106,7 +106,7 @@
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 */
+ uint8_t 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
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -344,7 +344,7 @@
#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(uint8_t, 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
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -77,6 +77,8 @@
#include <netinet/ip_carp.h>
#include <netinet6/send.h>
+#include <machine/atomic.h>
+
#define SDL(s) ((struct sockaddr_dl *)s)
struct dadq;
@@ -1473,7 +1475,7 @@
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_rel_8(&DAD_FAILURES(ifp), 0);
}
nd6log((LOG_DEBUG,
@@ -1522,10 +1524,10 @@
* 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));
+ uint32_t dad_failures = atomic_load_acq_8(&DAD_FAILURES(ifp));
if (dad_failures <= V_ip6_stableaddr_maxretries) {
- counter_u64_add(DAD_FAILURES(ifp), 1);
+ atomic_add_rel_8(&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
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -74,6 +74,8 @@
#include <netinet/icmp6.h>
#include <netinet6/scope6_var.h>
+#include <machine/atomic.h>
+
static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *);
static int prelist_update(struct nd_prefixctl *, struct nd_defrouter *,
struct mbuf *, int);
@@ -1757,7 +1759,7 @@
* 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_acq_8(&DAD_FAILURES(ifp)) <= V_ip6_stableaddr_maxretries &&
ifa6->ia6_flags & (IN6_IFF_DUPLICATED | IN6_IFF_TEMPORARY))
continue;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 19, 10:02 PM (5 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28892031
Default Alt Text
D52731.id162826.diff (6 KB)
Attached To
Mode
D52731: sys/netinet6: Use atomic(9) for dad_failures counter
Attached
Detach File
Event Timeline
Log In to Comment