The list of IPv6 addresses to perfom Duplicate Address Detection on is
entirely static to nd6_nbr.c incl. its state vars with the exception of
ip6_dad_pending aka. the net.inet6.ip6.dad_pending sysctl(2).
Statically initialise the list head, pull dad_init from the middle to
the file up to where the rest is and set it =1 rather than incrementing
as it is only used as early bail-out check (!dad_init).
Leave the global ip6_dad_pending and its in/decrement semantic as-is.
This should be a tad clearer and simpler; no function change.
Feedback? Objection? OK?
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 0597c8d0d9a..d8fdc5b9bd6 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -62,7 +62,8 @@
#include <netinet/ip_carp.h>
#endif
-TAILQ_HEAD(dadq_head, dadq);
+static TAILQ_HEAD(, dadq) dadq =
+ TAILQ_HEAD_INITIALIZER(dadq); /* list of addresses to run DAD on */
struct dadq {
TAILQ_ENTRY(dadq) dad_list;
struct ifaddr *dad_ifa;
@@ -84,6 +85,7 @@ void nd6_dad_duplicated(struct dadq *);
int nd6_isneighbor(const struct ifnet *, const struct in6_addr *);
+static int dad_init = 0;
static int dad_maxtry = 15; /* max # of *tries* to transmit DAD packet */
/*
@@ -1036,9 +1038,6 @@ nd6_ifptomac(struct ifnet *ifp)
}
}
-static struct dadq_head dadq;
-static int dad_init = 0;
-
struct dadq *
nd6_dad_find(struct ifaddr *ifa)
{
@@ -1078,10 +1077,8 @@ nd6_dad_start(struct ifaddr *ifa)
NET_ASSERT_LOCKED();
- if (!dad_init) {
- TAILQ_INIT(&dadq);
- dad_init++;
- }
+ if (!dad_init)
+ dad_init = 1;
/*
* If we don't need DAD, don't do it.