diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2022-12-02 15:35:36 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2022-12-02 15:35:36 +0000 |
commit | f6e5daf90c96e2a058c4052397d8e21960aec9f4 (patch) | |
tree | 139f703ac902fb47d6cc3740fe48dc01cf44c47a /sys/netinet6 | |
parent | 8907f19aa772041d0862fc1297c656303ea97df3 (diff) |
Remove constant basereachable and retrans members from struct nd_ifinfo
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.
Nothing else in base, incl. regress, uses SIOCGIFINFO_IN6 or `ndp -i'.
OK bluhm
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/nd6.c | 19 | ||||
-rw-r--r-- | sys/netinet6/nd6.h | 5 | ||||
-rw-r--r-- | sys/netinet6/nd6_nbr.c | 14 |
3 files changed, 15 insertions, 23 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 8cedafd1d35..e51b11fc04e 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.256 2022/11/28 19:13:36 kn Exp $ */ +/* $OpenBSD: nd6.c,v 1.257 2022/12/02 15:35:35 kn Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -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; } @@ -356,7 +354,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; @@ -403,13 +401,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 { @@ -1285,8 +1283,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 @@ -1294,7 +1291,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(); @@ -1403,7 +1400,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 6f29de0fe72..d096ccd4fb8 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.h,v 1.90 2022/11/28 19:13:36 kn Exp $ */ +/* $OpenBSD: nd6.h,v 1.91 2022/12/02 15:35:35 kn Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -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 d3c627484f5..09a9e5e4e95 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.137 2022/12/02 12:58:37 kn Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.138 2022/12/02 15:35:35 kn Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -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); } /* @@ -1202,7 +1200,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 sufficient number of DAD packets. |