On 10/07/17(Mon) 08:04, Florian Obser wrote: > --- netinet6/in6.c > +++ netinet6/in6.c > @@ -897,25 +897,9 @@ in6_unlink_ifa(struct in6_ifaddr *ia6, struct ifnet *ifp) > { > struct ifaddr *ifa = &ia6->ia_ifa; > extern int ifatrash; > - int plen; > > NET_ASSERT_LOCKED(); > > - /* Release the reference to the base prefix. */ > - if (ia6->ia6_ndpr == NULL) { > - plen = in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL); > - if ((ifp->if_flags & IFF_LOOPBACK) == 0 && plen != 128) { > - rt_ifa_del(ifa, RTF_CLONING | RTF_CONNECTED, > - ifa->ifa_addr); > - }
This block should stay. It correspond to addresses configured with SIOCAIFADDR_IN6. See the corresponding rt_ifa_add() call in netinet6/in6.c > - } else { > - KASSERT(ia6->ia6_flags & IN6_IFF_AUTOCONF); > - ia6->ia6_flags &= ~IN6_IFF_AUTOCONF; > - if (--ia6->ia6_ndpr->ndpr_refcnt == 0) > - prelist_remove(ia6->ia6_ndpr); > - ia6->ia6_ndpr = NULL; > - } > - > rt_ifa_purge(ifa); > ifa_del(ifp, ifa); > > diff --git netinet6/nd6.c netinet6/nd6.c > index 7b32caec770..773e8e12b1f 100644 > --- netinet6/nd6.c > +++ netinet6/nd6.c > @@ -751,33 +667,8 @@ nd6_free(struct rtentry *rt, int gc) > ifp = if_get(rt->rt_ifidx); > > if (!ip6_forwarding) { > - dr = defrouter_lookup(&satosin6(rt_key(rt))->sin6_addr, > - rt->rt_ifidx); > - > - if (dr != NULL && dr->expire && > - ln->ln_state == ND6_LLINFO_STALE && gc) { > - /* > - * If the reason for the deletion is just garbage > - * collection, and the neighbor is an active default > - * router, do not delete it. Instead, reset the GC > - * timer using the router's lifetime. > - * Simply deleting the entry would affect default > - * router selection, which is not necessarily a good > - * thing, especially when we're using router preference > - * values. > - * XXX: the check for ln_state would be redundant, > - * but we intentionally keep it just in case. > - */ > - if (dr->expire > time_uptime) { > - nd6_llinfo_settimer(ln, > - dr->expire - time_uptime); > - } else > - nd6_llinfo_settimer(ln, nd6_gctimer); > - if_put(ifp); > - return (TAILQ_NEXT(ln, ln_list)); > - } > - > - if (ln->ln_router || dr) { > + /* XXXDEL? */ This comment isn't helping. I'd drop it. To answer your question I believe one has to study the state machine related to the IsRouter flag, RFC4861 Appendix D. > + if (ln->ln_router) { > /* > * rt6_flush must be called whether or not the neighbor > * is in the Default Router List. > @@ -1144,63 +993,18 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) > break; > case SIOCSNDFLUSH_IN6: /* XXX: the ioctl name is confusing... */ > /* sync kernel routing table with the default router list */ > - defrouter_reset(); > - defrouter_select(); > + error = ENOTSUP; > break; Could you send the related ndp(8) diff afterward? See below... > +/* XXXDEL? */ > int > nd6_sysctl(int name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) This whole function can be deleted, ndp(8) is the only userland program using them. That mean you'll be able to remove 'struct in6_prefix' as well, but that can be a second step 8) ok mpi if you keep the first chunk above, the rest can be done in a later diff.