diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-10-03 12:33:22 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-10-03 12:33:22 +0000 |
commit | 2ccbc991cb3c0ab5161657b9618933487f2e78a4 (patch) | |
tree | 0a565920444959cdd6ca3b107811406e2dc5f039 /sys/netinet6/nd6_rtr.c | |
parent | ae60c1c6b0fa997314e9c82471a6e0ac2a7f1ea1 (diff) |
Convert some of the remaining usages of time_second to time_uptime.
time_second is unix time so it can be affected by clock changes.
time_uptime is monotonic so it isnt affected by clock changes. that
in turn means route expiries wont jump with clock changes if set
against time_uptime.
the expiry is translated into unix time for export to userland though.
Should fix mismatch between route timers that were already converted
and ND default routers that were still using time_second.
Tested by matthieu@ and sthen@
ok sthen@, dlg@
Diffstat (limited to 'sys/netinet6/nd6_rtr.c')
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index e9695f601a1..c46625b7eb3 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.147 2016/09/30 06:27:21 florian Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.148 2016/10/03 12:33:21 mpi Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -428,7 +428,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) dr0.rtaddr = saddr6; dr0.flags = nd_ra->nd_ra_flags_reserved; dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime); - dr0.expire = time_second + dr0.rtlifetime; + dr0.expire = time_uptime + dr0.rtlifetime; dr0.ifp = ifp; /* unspecified or not? (RFC 2461 6.3.4) */ if (advreachable) { @@ -518,7 +518,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) pr.ndpr_plen = pi->nd_opt_pi_prefix_len; pr.ndpr_vltime = ntohl(pi->nd_opt_pi_valid_time); pr.ndpr_pltime = ntohl(pi->nd_opt_pi_preferred_time); - pr.ndpr_lastupdate = time_second; + pr.ndpr_lastupdate = time_uptime; if (in6_init_prefix_ltimes(&pr)) continue; /* prefix lifetime init failed */ @@ -1350,7 +1350,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m) if (lt6_tmp.ia6t_vltime == ND6_INFINITE_LIFETIME) storedlifetime = ND6_INFINITE_LIFETIME; - else if (time_second - ia6->ia6_updatetime > + else if (time_uptime - ia6->ia6_updatetime > lt6_tmp.ia6t_vltime) { /* * The case of "invalid" address. We should usually @@ -1359,7 +1359,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m) storedlifetime = 0; } else storedlifetime = lt6_tmp.ia6t_vltime - - (time_second - ia6->ia6_updatetime); + (time_uptime - ia6->ia6_updatetime); if (TWOHOUR < new->ndpr_vltime || storedlifetime < new->ndpr_vltime) { lt6_tmp.ia6t_vltime = new->ndpr_vltime; @@ -1390,7 +1390,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m) in6_init_address_ltimes(pr, <6_tmp); ia6->ia6_lifetime = lt6_tmp; - ia6->ia6_updatetime = time_second; + ia6->ia6_updatetime = time_uptime; } if ((!autoconf || ((ifp->if_xflags & IFXF_INET6_NOPRIVACY) == 0 && @@ -1978,11 +1978,11 @@ in6_init_prefix_ltimes(struct nd_prefix *ndpr) if (ndpr->ndpr_pltime == ND6_INFINITE_LIFETIME) ndpr->ndpr_preferred = 0; else - ndpr->ndpr_preferred = time_second + ndpr->ndpr_pltime; + ndpr->ndpr_preferred = time_uptime + ndpr->ndpr_pltime; if (ndpr->ndpr_vltime == ND6_INFINITE_LIFETIME) ndpr->ndpr_expire = 0; else - ndpr->ndpr_expire = time_second + ndpr->ndpr_vltime; + ndpr->ndpr_expire = time_uptime + ndpr->ndpr_vltime; return 0; } @@ -1996,7 +1996,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6) if (lt6->ia6t_vltime == ND6_INFINITE_LIFETIME) lt6->ia6t_expire = 0; else { - lt6->ia6t_expire = time_second; + lt6->ia6t_expire = time_uptime; lt6->ia6t_expire += lt6->ia6t_vltime; } @@ -2004,7 +2004,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6) if (lt6->ia6t_pltime == ND6_INFINITE_LIFETIME) lt6->ia6t_preferred = 0; else { - lt6->ia6t_preferred = time_second; + lt6->ia6t_preferred = time_uptime; lt6->ia6t_preferred += lt6->ia6t_pltime; } } |