diff options
author | glebius <glebius@FreeBSD.org> | 2010-11-30 15:57:00 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2010-11-30 15:57:00 +0000 |
commit | bdd7d886f9757dc70bd9cac6002e46fab564d587 (patch) | |
tree | 8517ada49ac20c31d7eac89a89b485be46414507 | |
parent | 5b6b615a821bda72e166a8931463117f5f288973 (diff) | |
download | FreeBSD-src-bdd7d886f9757dc70bd9cac6002e46fab564d587.zip FreeBSD-src-bdd7d886f9757dc70bd9cac6002e46fab564d587.tar.gz |
Use time_uptime instead of non-monotonic time_second to drive ARP
timeouts.
Suggested by: bde
-rw-r--r-- | sys/netinet/if_ether.c | 10 | ||||
-rw-r--r-- | sys/netinet/in.c | 2 | ||||
-rw-r--r-- | usr.sbin/arp/arp.c | 8 |
3 files changed, 10 insertions, 10 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index ee5d8e0..df05c04 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -323,7 +323,7 @@ retry: } if ((la->la_flags & LLE_VALID) && - ((la->la_flags & LLE_STATIC) || la->la_expire > time_second)) { + ((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) { bcopy(&la->ll_addr, desten, ifp->if_addrlen); /* * If entry has an expiry time and it is approaching, @@ -331,7 +331,7 @@ retry: * arpt_down interval. */ if (!(la->la_flags & LLE_STATIC) && - time_second + la->la_preempt > la->la_expire) { + time_uptime + la->la_preempt > la->la_expire) { arprequest(ifp, NULL, &SIN(dst)->sin_addr, IF_LLADDR(ifp)); @@ -351,7 +351,7 @@ retry: goto done; } - renew = (la->la_asked == 0 || la->la_expire != time_second); + renew = (la->la_asked == 0 || la->la_expire != time_uptime); if ((renew || m != NULL) && (flags & LLE_EXCLUSIVE) == 0) { flags |= LLE_EXCLUSIVE; LLE_RUNLOCK(la); @@ -403,7 +403,7 @@ retry: int canceled; LLE_ADDREF(la); - la->la_expire = time_second; + la->la_expire = time_uptime; canceled = callout_reset(&la->la_timer, hz * V_arpt_down, arptimer, la); if (canceled) @@ -713,7 +713,7 @@ match: int canceled; LLE_ADDREF(la); - la->la_expire = time_second + V_arpt_keep; + la->la_expire = time_uptime + V_arpt_keep; canceled = callout_reset(&la->la_timer, hz * V_arpt_keep, arptimer, la); if (canceled) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 2ec54e2..d8c71f1 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1333,7 +1333,7 @@ in_lltable_new(const struct sockaddr *l3addr, u_int flags) * For IPv4 this will trigger "arpresolve" to generate * an ARP request. */ - lle->base.la_expire = time_second; /* mark expired */ + lle->base.la_expire = time_uptime; /* mark expired */ lle->l3_addr4 = *(const struct sockaddr_in *)l3addr; lle->base.lle_refcnt = 1; LLE_LOCK_INIT(&lle->base); diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 2ee9d67..32bfd9a 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -602,10 +602,10 @@ print_entry(struct sockaddr_dl *sdl, if (rtm->rtm_rmx.rmx_expire == 0) printf(" permanent"); else { - static struct timeval tv; - if (tv.tv_sec == 0) - gettimeofday(&tv, 0); - if ((expire_time = rtm->rtm_rmx.rmx_expire - tv.tv_sec) > 0) + static struct timespec tp; + if (tp.tv_sec == 0) + clock_gettime(CLOCK_MONOTONIC, &tp); + if ((expire_time = rtm->rtm_rmx.rmx_expire - tp.tv_sec) > 0) printf(" expires in %d seconds", (int)expire_time); else printf(" expired"); |