diff options
author | 2001-02-23 08:01:14 +0000 | |
---|---|---|
committer | 2001-02-23 08:01:14 +0000 | |
commit | be4e9e12eabe25e9a305b95d28f83a83097ce193 (patch) | |
tree | 510cc624423f54382122d29dea550380ae03f6f3 | |
parent | I tried to figure out how to have tmp_mnt get created automatically (diff) | |
download | wireguard-openbsd-be4e9e12eabe25e9a305b95d28f83a83097ce193.tar.xz wireguard-openbsd-be4e9e12eabe25e9a305b95d28f83a83097ce193.zip |
garbage-collect stale ND entries (default: 1 day).
RFC 2461 5.3. sync with kame.
-rw-r--r-- | sys/netinet6/nd6.c | 27 | ||||
-rw-r--r-- | sys/netinet6/nd6.h | 3 | ||||
-rw-r--r-- | sys/netinet6/nd6_nbr.c | 16 |
3 files changed, 32 insertions, 14 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 2a4df082f46..b50985c644b 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.28 2001/02/23 06:40:20 itojun Exp $ */ +/* $OpenBSD: nd6.c,v 1.29 2001/02/23 08:01:14 itojun Exp $ */ /* $KAME: nd6.c,v 1.131 2001/02/21 16:28:18 itojun Exp $ */ /* @@ -84,6 +84,7 @@ int nd6_delay = 5; /* delay first probe time 5 second */ int nd6_umaxtries = 3; /* maximum unicast query */ int nd6_mmaxtries = 3; /* maximum multicast query */ int nd6_useloopback = 1; /* use loopback interface for local traffic */ +int nd6_gctimer = (60 * 60 * 24); /* 1 day: garbage collection timer */ /* preventing too many loops in ND option parsing */ int nd6_maxndopt = 10; /* max # of ND options allowed */ @@ -474,13 +475,18 @@ nd6_timer(ignored_arg) } break; case ND6_LLINFO_REACHABLE: - if (ln->ln_expire) + if (ln->ln_expire) { ln->ln_state = ND6_LLINFO_STALE; + ln->ln_expire = time_second + nd6_gctimer; + } break; - /* - * ND6_LLINFO_STALE state requires nothing for timer - * routine. - */ + + case ND6_LLINFO_STALE: + /* Garbage Collection(RFC 2461 5.3) */ + if (ln->ln_expire) + next = nd6_free(rt); + break; + case ND6_LLINFO_DELAY: if (ndi && (ndi->flags & ND6_IFF_PERFORMNUD) != 0) { /* We need NUD */ @@ -491,8 +497,10 @@ nd6_timer(ignored_arg) nd6_ns_output(ifp, &dst->sin6_addr, &dst->sin6_addr, ln, 0); - } else + } else { ln->ln_state = ND6_LLINFO_STALE; /* XXX */ + ln->ln_expire = time_second + nd6_gctimer; + } break; case ND6_LLINFO_PROBE: if (ln->ln_asked < nd6_umaxtries) { @@ -1650,6 +1658,7 @@ fail: #endif ln->ln_hold = 0; } + ln->ln_expire = time_second + nd6_gctimer; } else if (ln->ln_state == ND6_LLINFO_INCOMPLETE) { /* probe right away */ ln->ln_expire = time_second; @@ -1878,8 +1887,10 @@ nd6_output(ifp, origifp, m0, dst, rt0) /* We don't have to do link-layer address resolution on a p2p link. */ if ((ifp->if_flags & IFF_POINTOPOINT) != 0 && - ln->ln_state < ND6_LLINFO_REACHABLE) + ln->ln_state < ND6_LLINFO_REACHABLE) { ln->ln_state = ND6_LLINFO_STALE; + ln->ln_expire = time_second + nd6_gctimer; + } /* * The first time we send a packet to a neighbor whose entry is diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 066a896cc98..ed425358c94 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.h,v 1.13 2001/02/23 06:40:20 itojun Exp $ */ +/* $OpenBSD: nd6.h,v 1.14 2001/02/23 08:01:15 itojun Exp $ */ /* $KAME: nd6.h,v 1.52 2001/02/19 04:40:37 itojun Exp $ */ /* @@ -240,6 +240,7 @@ extern int nd6_umaxtries; extern int nd6_mmaxtries; extern int nd6_useloopback; extern int nd6_maxnudhint; +extern int nd6_gctimer; extern struct llinfo_nd6 llinfo_nd6; extern struct nd_ifinfo *nd_ifinfo; extern struct nd_drhead nd_defrouter; diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 7543f6ee3fb..2cea5d8c037 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: nd6_nbr.c,v 1.15 2001/02/16 16:08:01 itojun Exp $ */ -/* $KAME: nd6_nbr.c,v 1.58 2001/02/08 10:57:00 itojun Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.16 2001/02/23 08:01:15 itojun Exp $ */ +/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -653,8 +653,10 @@ nd6_na_input(m, off, icmp6len) if (ln->ln_expire) ln->ln_expire = time.tv_sec + nd_ifinfo[rt->rt_ifp->if_index].reachable; - } else + } else { ln->ln_state = ND6_LLINFO_STALE; + ln->ln_expire = time.tv_sec + nd6_gctimer; + } ln->ln_router = is_router; } else { int llchange; @@ -698,8 +700,10 @@ nd6_na_input(m, off, icmp6len) * If state is REACHABLE, make it STALE. * no other updates should be done. */ - if (ln->ln_state == ND6_LLINFO_REACHABLE) + if (ln->ln_state == ND6_LLINFO_REACHABLE) { ln->ln_state = ND6_LLINFO_STALE; + ln->ln_expire = time.tv_sec + nd6_gctimer; + } goto freeit; } else if (is_override /* (2a) */ || (!is_override && (lladdr && !llchange)) /* (2b) */ @@ -725,8 +729,10 @@ nd6_na_input(m, off, icmp6len) nd_ifinfo[ifp->if_index].reachable; } } else { - if (lladdr && llchange) + if (lladdr && llchange) { ln->ln_state = ND6_LLINFO_STALE; + ln->ln_expire = time.tv_sec + nd6_gctimer; + } } } |