1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

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
This commit is contained in:
kn 2022-12-02 15:35:35 +00:00
parent 24793c0c0b
commit abcde9bc42
4 changed files with 17 additions and 29 deletions

View File

@ -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);

View File

@ -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 */
};

View File

@ -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.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ndp.c,v 1.105 2022/11/28 19:13:36 kn Exp $ */
/* $OpenBSD: ndp.c,v 1.106 2022/12/02 15:35:35 kn Exp $ */
/* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */
/*
@ -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);
}