diff options
author | 2004-06-21 23:50:35 +0000 | |
---|---|---|
committer | 2004-06-21 23:50:35 +0000 | |
commit | 3212dc310ec9c3aa2cd9e7180fe81d66a37e4443 (patch) | |
tree | b8b428eb79259cc5ab8e628e0b78b672af7aa38b /sys/netinet6 | |
parent | When in_ifinit fails and we've created a new address, clean it up before (diff) | |
download | wireguard-openbsd-3212dc310ec9c3aa2cd9e7180fe81d66a37e4443.tar.xz wireguard-openbsd-3212dc310ec9c3aa2cd9e7180fe81d66a37e4443.zip |
First step towards more sane time handling in the kernel -- this changes
things such that code that only need a second-resolution uptime or wall
time, and used to get that from time.tv_secs or mono_time.tv_secs now get
this from separate time_t globals time_second and time_uptime.
ok art@ niklas@ nordin@
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/icmp6.c | 6 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 18 | ||||
-rw-r--r-- | sys/netinet6/in6.h | 6 | ||||
-rw-r--r-- | sys/netinet6/ip6_forward.c | 10 | ||||
-rw-r--r-- | sys/netinet6/ip6_id.c | 6 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 4 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 12 | ||||
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 20 |
8 files changed, 41 insertions, 41 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 51b157e8e34..53292a309bb 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.82 2004/03/25 14:01:20 dhartmei Exp $ */ +/* $OpenBSD: icmp6.c,v 1.83 2004/06/21 23:50:37 tholo Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1843,8 +1843,8 @@ ni6_store_addrs(ni6, nni6, ifp0, resid) ltime = ND6_INFINITE_LIFETIME; else { if (ifa6->ia6_lifetime.ia6t_expire > - time.tv_sec) - ltime = htonl(ifa6->ia6_lifetime.ia6t_expire - time.tv_sec); + time_second) + ltime = htonl(ifa6->ia6_lifetime.ia6t_expire - time_second); else ltime = 0; } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 7d717f8b85c..8091fe9dbe8 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.56 2004/06/17 09:43:55 itojun Exp $ */ +/* $OpenBSD: in6.c,v 1.57 2004/06/21 23:50:37 tholo Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -528,11 +528,11 @@ in6_control(so, cmd, data, ifp, p) /* sanity for overflow - beware unsigned */ lt = &ifr->ifr_ifru.ifru_lifetime; if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME - && lt->ia6t_vltime + time.tv_sec < time.tv_sec) { + && lt->ia6t_vltime + time_second < time_second) { return EINVAL; } if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME - && lt->ia6t_pltime + time.tv_sec < time.tv_sec) { + && lt->ia6t_pltime + time_second < time_second) { return EINVAL; } break; @@ -626,12 +626,12 @@ in6_control(so, cmd, data, ifp, p) /* for sanity */ if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) { ia->ia6_lifetime.ia6t_expire = - time.tv_sec + ia->ia6_lifetime.ia6t_vltime; + time_second + ia->ia6_lifetime.ia6t_vltime; } else ia->ia6_lifetime.ia6t_expire = 0; if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) { ia->ia6_lifetime.ia6t_preferred = - time.tv_sec + ia->ia6_lifetime.ia6t_pltime; + time_second + ia->ia6_lifetime.ia6t_pltime; } else ia->ia6_lifetime.ia6t_preferred = 0; break; @@ -936,7 +936,7 @@ in6_update_ifa(ifp, ifra, ia) ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; ia->ia_addr.sin6_family = AF_INET6; ia->ia_addr.sin6_len = sizeof(ia->ia_addr); - ia->ia6_createtime = ia->ia6_updatetime = time.tv_sec; + ia->ia6_createtime = ia->ia6_updatetime = time_second; if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) { /* * XXX: some functions expect that ifa_dstaddr is not @@ -1008,12 +1008,12 @@ in6_update_ifa(ifp, ifra, ia) ia->ia6_lifetime = ifra->ifra_lifetime; if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) { ia->ia6_lifetime.ia6t_expire = - time.tv_sec + ia->ia6_lifetime.ia6t_vltime; + time_second + ia->ia6_lifetime.ia6t_vltime; } else ia->ia6_lifetime.ia6t_expire = 0; if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) { ia->ia6_lifetime.ia6t_preferred = - time.tv_sec + ia->ia6_lifetime.ia6t_pltime; + time_second + ia->ia6_lifetime.ia6t_pltime; } else ia->ia6_lifetime.ia6t_preferred = 0; @@ -1031,7 +1031,7 @@ in6_update_ifa(ifp, ifra, ia) */ if ((ifra->ifra_flags & IN6_IFF_DEPRECATED) != 0) { ia->ia6_lifetime.ia6t_pltime = 0; - ia->ia6_lifetime.ia6t_preferred = time.tv_sec; + ia->ia6_lifetime.ia6t_preferred = time_second; } /* * Make the address tentative before joining multicast addresses, diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 00bb5043c56..bf1e04e31af 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.35 2004/06/12 04:58:48 itojun Exp $ */ +/* $OpenBSD: in6.h,v 1.36 2004/06/21 23:50:37 tholo Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -355,11 +355,11 @@ extern const struct in6_addr in6addr_linklocal_allrouters; #define IFA6_IS_DEPRECATED(a) \ ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \ - (u_int32_t)((time.tv_sec - (a)->ia6_updatetime)) > \ + (u_int32_t)((time_second - (a)->ia6_updatetime)) > \ (a)->ia6_lifetime.ia6t_pltime) #define IFA6_IS_INVALID(a) \ ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \ - (u_int32_t)((time.tv_sec - (a)->ia6_updatetime)) > \ + (u_int32_t)((time_second - (a)->ia6_updatetime)) > \ (a)->ia6_lifetime.ia6t_vltime) #endif diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index bda61eb63e5..d3747a80a08 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_forward.c,v 1.29 2004/06/21 19:26:02 mcbride Exp $ */ +/* $OpenBSD: ip6_forward.c,v 1.30 2004/06/21 23:50:37 tholo Exp $ */ /* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */ /* @@ -115,8 +115,8 @@ ip6_forward(m, srcrt) IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) { ip6stat.ip6s_cantforward++; /* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */ - if (ip6_log_time + ip6_log_interval < time.tv_sec) { - ip6_log_time = time.tv_sec; + if (ip6_log_time + ip6_log_interval < time_second) { + ip6_log_time = time_second; log(LOG_DEBUG, "cannot forward " "from %s to %s nxt %d received on %s\n", @@ -289,8 +289,8 @@ ip6_forward(m, srcrt) ip6stat.ip6s_badscope++; in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard); - if (ip6_log_time + ip6_log_interval < time.tv_sec) { - ip6_log_time = time.tv_sec; + if (ip6_log_time + ip6_log_interval < time_second) { + ip6_log_time = time_second; log(LOG_DEBUG, "cannot forward " "src %s, dst %s, nxt %d, rcvif %s, outif %s\n", diff --git a/sys/netinet6/ip6_id.c b/sys/netinet6/ip6_id.c index fd36e46f3c3..9765b4c9689 100644 --- a/sys/netinet6/ip6_id.c +++ b/sys/netinet6/ip6_id.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_id.c,v 1.3 2003/12/12 06:57:12 itojun Exp $ */ +/* $OpenBSD: ip6_id.c,v 1.4 2004/06/21 23:50:37 tholo Exp $ */ /* $NetBSD: ip6_id.c,v 1.7 2003/09/13 21:32:59 itojun Exp $ */ /* $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $ */ @@ -210,7 +210,7 @@ initid(struct randomtab *p) p->ru_g = pmod(p->ru_gen, j, p->ru_n); p->ru_counter = 0; - p->ru_reseed = time.tv_sec + p->ru_out; + p->ru_reseed = time_second + p->ru_out; p->ru_msb = p->ru_msb ? 0 : (1U << (p->ru_bits - 1)); } @@ -219,7 +219,7 @@ randomid(struct randomtab *p) { int i, n; - if (p->ru_counter >= p->ru_max || time.tv_sec > p->ru_reseed) + if (p->ru_counter >= p->ru_max || time_second > p->ru_reseed) initid(p); /* Skip a random number of ids */ diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 801e25f58ec..eac4251a1ce 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1040,8 +1040,8 @@ ip6_mforward(ip6, ifp, m) */ if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) { ip6stat.ip6s_cantforward++; - if (ip6_log_time + ip6_log_interval < time.tv_sec) { - ip6_log_time = time.tv_sec; + if (ip6_log_time + ip6_log_interval < time_second) { + ip6_log_time = time_second; log(LOG_DEBUG, "cannot forward " "from %s to %s nxt %d received on %s\n", diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 36aca9bb729..22bd57c33d3 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.66 2004/05/19 17:48:19 itojun Exp $ */ +/* $OpenBSD: nd6.c,v 1.67 2004/06/21 23:50:37 tholo Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -380,7 +380,7 @@ nd6_llinfo_settimer(struct llinfo_nd6 *ln, long tick) ln->ln_ntick = 0; timeout_del(&ln->ln_timer_ch); } else { - ln->ln_expire = time.tv_sec + tick / hz; + ln->ln_expire = time_second + tick / hz; if (tick > INT_MAX) { ln->ln_ntick = tick - INT_MAX; timeout_add(&ln->ln_timer_ch, INT_MAX); @@ -523,7 +523,7 @@ nd6_timer(ignored_arg) /* expire default router list */ dr = TAILQ_FIRST(&nd_defrouter); while (dr) { - if (dr->expire && dr->expire < time.tv_sec) { + if (dr->expire && dr->expire < time_second) { struct nd_defrouter *t; t = TAILQ_NEXT(dr, dr_entry); defrtrlist_del(dr); @@ -566,7 +566,7 @@ nd6_timer(ignored_arg) * prefix is not necessary. */ if (pr->ndpr_vltime != ND6_INFINITE_LIFETIME && - time.tv_sec - pr->ndpr_lastupdate > pr->ndpr_vltime) { + time_second - pr->ndpr_lastupdate > pr->ndpr_vltime) { struct nd_prefix *t; t = pr->ndpr_next; @@ -863,9 +863,9 @@ nd6_free(rt, gc) * XXX: the check for ln_state would be redundant, * but we intentionally keep it just in case. */ - if (dr->expire > time.tv_sec * hz) { + if (dr->expire > time_second * hz) { nd6_llinfo_settimer(ln, - dr->expire - time.tv_sec * hz); + dr->expire - time_second * hz); } else nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz); splx(s); diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 9c5169ce2c0..d6edafcb7e8 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.30 2003/12/10 03:30:21 itojun Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.31 2004/06/21 23:50:37 tholo Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -244,7 +244,7 @@ nd6_ra_input(m, off, icmp6len) dr0.rtaddr = saddr6; dr0.flags = nd_ra->nd_ra_flags_reserved; dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime); - dr0.expire = time.tv_sec + dr0.rtlifetime; + dr0.expire = time_second + dr0.rtlifetime; dr0.ifp = ifp; /* unspecified or not? (RFC 2461 6.3.4) */ if (advreachable) { @@ -328,7 +328,7 @@ nd6_ra_input(m, off, 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.tv_sec; + pr.ndpr_lastupdate = time_second; if (in6_init_prefix_ltimes(&pr)) continue; /* prefix lifetime init failed */ @@ -1292,7 +1292,7 @@ prelist_update(new, dr, m) lt6_tmp = ifa6->ia6_lifetime; if (lt6_tmp.ia6t_vltime == ND6_INFINITE_LIFETIME) storedlifetime = ND6_INFINITE_LIFETIME; - else if (time.tv_sec - ifa6->ia6_updatetime > + else if (time_second - ifa6->ia6_updatetime > lt6_tmp.ia6t_vltime) { /* * The case of "invalid" address. We should usually @@ -1301,7 +1301,7 @@ prelist_update(new, dr, m) storedlifetime = 0; } else storedlifetime = lt6_tmp.ia6t_vltime - - (time.tv_sec - ifa6->ia6_updatetime); + (time_second - ifa6->ia6_updatetime); if (TWOHOUR < new->ndpr_vltime || storedlifetime < new->ndpr_vltime) { lt6_tmp.ia6t_vltime = new->ndpr_vltime; @@ -1332,7 +1332,7 @@ prelist_update(new, dr, m) in6_init_address_ltimes(pr, <6_tmp); ifa6->ia6_lifetime = lt6_tmp; - ifa6->ia6_updatetime = time.tv_sec; + ifa6->ia6_updatetime = time_second; } if (ia6_match == NULL && new->ndpr_vltime) { /* @@ -1882,11 +1882,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.tv_sec + ndpr->ndpr_pltime; + ndpr->ndpr_preferred = time_second + ndpr->ndpr_pltime; if (ndpr->ndpr_vltime == ND6_INFINITE_LIFETIME) ndpr->ndpr_expire = 0; else - ndpr->ndpr_expire = time.tv_sec + ndpr->ndpr_vltime; + ndpr->ndpr_expire = time_second + ndpr->ndpr_vltime; return 0; } @@ -1900,7 +1900,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.tv_sec; + lt6->ia6t_expire = time_second; lt6->ia6t_expire += lt6->ia6t_vltime; } @@ -1908,7 +1908,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.tv_sec; + lt6->ia6t_preferred = time_second; lt6->ia6t_preferred += lt6->ia6t_pltime; } } |