Both are initalised with compile-time constants and never written to.
They are part of the Neighbour Discovery machinery and only surface
through the single-user SIOCGIFINFO_IN6:
$ ndp -i lo0
basereachable=30s0ms, reachable=39s, retrans=1s0ms
These values are read-only since 2017 sys/netinet6/nd6.c r1.217
usr.sbin/ndp/ndp.c r1.85
Remove knob and always do neighbor unreachable detection
Inline the macros (to keep meaningful names), shrink the per-interface
allocated struct nd_ifinfo to what is actually needed and inline
nd6_dad_starttimer()'s constant `msec' argument.
This makes it clear how SIOCGIFINFO_IN6 is less useful than it seems:
$ ./obj/ndp -i lo0
reachable=39s
Nothing else in base, incl. regress, uses SIOCGIFINFO_IN6 or `ndp -i'.
Feedback? Objection? OK?
(Sorry for the header/ABI churn, I could've cleaned this up earlier...
if I had seen this right away between all the other dead code.)
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 10753026d4b..0a1d5fb24c7 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -124,9 +124,7 @@ nd6_ifattach(struct ifnet *ifp)
nd = malloc(sizeof(*nd), M_IP6NDP, M_WAITOK | M_ZERO);
- nd->basereachable = REACHABLE_TIME;
- nd->reachable = ND_COMPUTE_RTIME(nd->basereachable);
- nd->retrans = RETRANS_TIMER;
+ nd->reachable = ND_COMPUTE_RTIME(REACHABLE_TIME);
ifp->if_nd = nd;
}
@@ -349,7 +347,7 @@ nd6_llinfo_timer(struct rtentry *rt)
case ND6_LLINFO_INCOMPLETE:
if (ln->ln_asked < nd6_mmaxtries) {
ln->ln_asked++;
- nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
+ nd6_llinfo_settimer(ln, RETRANS_TIMER / 1000);
nd6_ns_output(ifp, NULL, &dst->sin6_addr, ln, 0);
} else {
struct mbuf *m = ln->ln_hold;
@@ -396,13 +394,13 @@ nd6_llinfo_timer(struct rtentry *rt)
/* We need NUD */
ln->ln_asked = 1;
ln->ln_state = ND6_LLINFO_PROBE;
- nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
+ nd6_llinfo_settimer(ln, RETRANS_TIMER / 1000);
nd6_ns_output(ifp, &dst->sin6_addr, &dst->sin6_addr, ln, 0);
break;
case ND6_LLINFO_PROBE:
if (ln->ln_asked < nd6_umaxtries) {
ln->ln_asked++;
- nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
+ nd6_llinfo_settimer(ln, RETRANS_TIMER / 1000);
nd6_ns_output(ifp, &dst->sin6_addr,
&dst->sin6_addr, ln, 0);
} else {
@@ -1281,8 +1279,7 @@ nd6_slowtimo(void *ignored_arg)
TAILQ_FOREACH(ifp, &ifnetlist, if_list) {
nd6if = ifp->if_nd;
- if (nd6if->basereachable && /* already initialized */
- (nd6if->recalctm -= ND6_SLOWTIMER_INTERVAL) <= 0) {
+ if ((nd6if->recalctm -= ND6_SLOWTIMER_INTERVAL) <= 0) {
/*
* Since reachable time rarely changes by router
* advertisements, we SHOULD insure that a new random
@@ -1290,7 +1287,7 @@ nd6_slowtimo(void *ignored_arg)
* (RFC 2461, 6.3.4)
*/
nd6if->recalctm = ND6_RECALC_REACHTM_INTERVAL;
- nd6if->reachable =
ND_COMPUTE_RTIME(nd6if->basereachable);
+ nd6if->reachable = ND_COMPUTE_RTIME(REACHABLE_TIME);
}
}
NET_UNLOCK();
@@ -1399,7 +1396,7 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0,
struct mbuf *m,
*/
if (!ND6_LLINFO_PERMANENT(ln) && ln->ln_asked == 0) {
ln->ln_asked++;
- nd6_llinfo_settimer(ln, ifp->if_nd->retrans / 1000);
+ nd6_llinfo_settimer(ln, RETRANS_TIMER / 1000);
nd6_ns_output(ifp, NULL, &satosin6(dst)->sin6_addr, ln, 0);
}
return (EAGAIN);
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index d55bab0027e..897147e5501 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -45,14 +45,11 @@
/*
* Locks used to protect struct members in this file:
- * I immutable after creation
* N net lock
*/
struct nd_ifinfo {
- u_int32_t basereachable; /* [I] BaseReachableTime */
u_int32_t reachable; /* [N] Reachable Time */
- u_int32_t retrans; /* [I] Retrans Timer */
int recalctm; /* [N] BaseReachable recalc timer */
};
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index e68ccbd4944..6046b90dcb9 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -76,7 +76,7 @@ struct dadq {
};
struct dadq *nd6_dad_find(struct ifaddr *);
-void nd6_dad_starttimer(struct dadq *, int);
+void nd6_dad_starttimer(struct dadq *);
void nd6_dad_stoptimer(struct dadq *);
void nd6_dad_timer(void *);
void nd6_dad_ns_output(struct dadq *, struct ifaddr *);
@@ -1050,17 +1050,15 @@ nd6_dad_find(struct ifaddr *ifa)
}
void
-nd6_dad_starttimer(struct dadq *dp, int msec)
+nd6_dad_starttimer(struct dadq *dp)
{
-
timeout_set_proc(&dp->dad_timer_ch, nd6_dad_timer, dp->dad_ifa);
- timeout_add_msec(&dp->dad_timer_ch, msec);
+ timeout_add_msec(&dp->dad_timer_ch, RETRANS_TIMER);
}
void
nd6_dad_stoptimer(struct dadq *dp)
{
-
timeout_del(&dp->dad_timer_ch);
}
@@ -1122,7 +1120,7 @@ nd6_dad_start(struct ifaddr *ifa)
dp->dad_ns_icount = dp->dad_na_icount = 0;
dp->dad_ns_ocount = dp->dad_ns_tcount = 0;
nd6_dad_ns_output(dp, ifa);
- nd6_dad_starttimer(dp, ifa->ifa_ifp->if_nd->retrans);
+ nd6_dad_starttimer(dp);
}
/*
@@ -1201,7 +1199,7 @@ nd6_dad_timer(void *xifa)
* We have more NS to go. Send NS packet for DAD.
*/
nd6_dad_ns_output(dp, ifa);
- nd6_dad_starttimer(dp, ifa->ifa_ifp->if_nd->retrans);
+ nd6_dad_starttimer(dp);
} else {
/*
* We have transmitted enough DAD packets.
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index 83147f7d748..13898e24b54 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -888,11 +888,7 @@ ifinfo(const char *ifname)
if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) == -1)
err(1, "ioctl(SIOCGIFINFO_IN6)");
- printf("basereachable=%ds%dms",
- nd.ndi.basereachable / 1000, nd.ndi.basereachable % 1000);
- printf(", reachable=%ds", nd.ndi.reachable);
- printf(", retrans=%ds%dms\n", nd.ndi.retrans / 1000,
- nd.ndi.retrans % 1000);
+ printf("reachable=%ds\n", nd.ndi.reachable);
close(s);
}