Index: sys/netinet6/in6.c =================================================================== --- sys/netinet6/in6.c +++ sys/netinet6/in6.c @@ -649,6 +649,8 @@ if (ia->ia6_ndpr == NULL) { ia->ia6_ndpr = pr; pr->ndpr_addrcnt++; + if (ia->ia6_flags & IN6_IFF_AUTOCONF) + pr->ndpr_num_autoconf_addrs++; /* * If this is the first autoconf address from the @@ -1355,6 +1357,8 @@ "%s has no prefix\n", ip6_sprintf(ip6buf, IA6_IN6(ia)))); } else { ia->ia6_ndpr->ndpr_addrcnt--; + if (ia->ia6_flags & IN6_IFF_AUTOCONF) + ia->ia6_ndpr->ndpr_num_autoconf_addrs--; /* Do not delete lles within prefix if refcont != 0 */ if (ia->ia6_ndpr->ndpr_addrcnt == 0) remove_lle = 1; Index: sys/netinet6/nd6.h =================================================================== --- sys/netinet6/nd6.h +++ sys/netinet6/nd6.h @@ -237,6 +237,7 @@ LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs; u_char ndpr_plen; int ndpr_addrcnt; /* count of derived addresses */ + int ndpr_num_autoconf_addrs; /* count of derived addresses, related to autoconf */ volatile u_int ndpr_refcnt; }; Index: sys/netinet6/nd6.c =================================================================== --- sys/netinet6/nd6.c +++ sys/netinet6/nd6.c @@ -1782,7 +1782,8 @@ ND6_WLOCK(); LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, next) { - if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr)) + if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr) + || (pr->ndpr_num_autoconf_addrs != pr->ndpr_addrcnt)) continue; /* XXX */ nd6_prefix_unlink(pr, &prl); } Index: sys/netinet6/nd6_rtr.c =================================================================== --- sys/netinet6/nd6_rtr.c +++ sys/netinet6/nd6_rtr.c @@ -1349,6 +1349,7 @@ if (new == NULL) return (ENOMEM); refcount_init(&new->ndpr_refcnt, newp != NULL ? 2 : 1); + new->ndpr_num_autoconf_addrs = 0; new->ndpr_ifp = pr->ndpr_ifp; new->ndpr_prefix = pr->ndpr_prefix; new->ndpr_plen = pr->ndpr_plen; @@ -1741,6 +1742,8 @@ * note that we should use pr (not new) for reference. */ pr->ndpr_addrcnt++; + if (ia6->ia6_flags & IN6_IFF_AUTOCONF) + pr->ndpr_num_autoconf_addrs++; ia6->ia6_ndpr = pr; /* @@ -2378,6 +2381,8 @@ } newia->ia6_ndpr = ia0->ia6_ndpr; newia->ia6_ndpr->ndpr_addrcnt++; + if (ifra.ifra_flags & IN6_IFF_AUTOCONF) + newia->ia6_ndpr->ndpr_num_autoconf_addrs++; ifa_free(&newia->ia_ifa); /*