Fix prefix invalidation via nd6_timer

We cannot remove a prefix there. Instead just invalidate it; the prefix
will be removed when purging an associated address. This is the same as
the original behavior.
This commit is contained in:
ozaki-r 2017-02-22 03:02:55 +00:00
parent bee20f7c3c
commit 93f6b1d8be
3 changed files with 25 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.c,v 1.227 2017/02/14 03:05:06 ozaki-r Exp $ */
/* $NetBSD: nd6.c,v 1.228 2017/02/22 03:02:55 ozaki-r Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.227 2017/02/14 03:05:06 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.228 2017/02/22 03:02:55 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@ -715,13 +715,12 @@ nd6_timer_work(struct work *wk, void *arg)
*/
if (pr->ndpr_vltime != ND6_INFINITE_LIFETIME &&
time_uptime - pr->ndpr_lastupdate > pr->ndpr_vltime) {
/*
* address expiration and prefix expiration are
* separate. NEVER perform in6_purgeaddr here.
* Just invalidate the prefix here. Removing it
* will be done when purging an associated address.
*/
nd6_prelist_remove(pr);
KASSERT(pr->ndpr_refcnt > 0);
nd6_invalidate_prefix(pr);
}
}
ND6_UNLOCK();

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.h,v 1.82 2017/02/14 03:05:06 ozaki-r Exp $ */
/* $NetBSD: nd6.h,v 1.83 2017/02/22 03:02:55 ozaki-r Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@ -469,6 +469,7 @@ void nd6_defrouter_select(void);
void nd6_defrtrlist_del(struct nd_defrouter *, struct in6_ifextra *);
void nd6_prefix_unref(struct nd_prefix *);
void nd6_prelist_remove(struct nd_prefix *);
void nd6_invalidate_prefix(struct nd_prefix *);
void nd6_pfxlist_onlink_check(void);
struct nd_defrouter *nd6_defrouter_lookup(const struct in6_addr *, struct ifnet *);
void nd6_rt_flush(struct in6_addr *, struct ifnet *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_rtr.c,v 1.131 2017/01/16 15:44:47 christos Exp $ */
/* $NetBSD: nd6_rtr.c,v 1.132 2017/02/22 03:02:55 ozaki-r Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.131 2017/01/16 15:44:47 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.132 2017/02/22 03:02:55 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1035,14 +1035,11 @@ nd6_prefix_unref(struct nd_prefix *pr)
}
void
nd6_prelist_remove(struct nd_prefix *pr)
nd6_invalidate_prefix(struct nd_prefix *pr)
{
struct nd_pfxrouter *pfr, *next;
int e, s;
struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
int e;
ND6_ASSERT_WLOCK();
KASSERT(pr->ndpr_refcnt == 0);
/* make sure to invalidate the prefix until it is really freed. */
pr->ndpr_vltime = 0;
@ -1064,6 +1061,19 @@ nd6_prelist_remove(struct nd_prefix *pr)
pr->ndpr_plen, if_name(pr->ndpr_ifp), e);
/* what should we do? */
}
}
void
nd6_prelist_remove(struct nd_prefix *pr)
{
struct nd_pfxrouter *pfr, *next;
int s;
struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
ND6_ASSERT_WLOCK();
KASSERT(pr->ndpr_refcnt == 0);
nd6_invalidate_prefix(pr);
s = splsoftnet();
/* unlink ndpr_entry from nd_prefix list */