On Wed, Nov 23, 2022 at 02:54:08PM +0000, Klemens Nanni wrote: > Do it like the rest of at/detach routines which modify a struct ifnet > pointer without returning anything. > > OK? > > diff --git a/sys/net/if.c b/sys/net/if.c > index c30d7e30e4f..3cb8bbf9176 100644 > --- a/sys/net/if.c > +++ b/sys/net/if.c > @@ -460,7 +460,7 @@ if_attachsetup(struct ifnet *ifp) > if_addgroup(ifp, IFG_ALL); > > #ifdef INET6 > - ifp->if_nd = nd6_ifattach(ifp); > + nd6_ifattach(ifp); > #endif > > #if NPF > 0 > @@ -1105,7 +1105,7 @@ if_detach(struct ifnet *ifp) > KASSERT(TAILQ_EMPTY(&ifp->if_detachhooks)); > > #ifdef INET6 > - nd6_ifdetach(ifp->if_nd); > + nd6_ifdetach(ifp); > #endif > > /* Announce that the interface is gone. */ > diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c > index 97c3536be9d..1924c36c813 100644 > --- a/sys/netinet6/nd6.c > +++ b/sys/netinet6/nd6.c > @@ -126,7 +126,7 @@ nd6_init(void) > timeout_set(&nd6_expire_timeout, nd6_expire_timer, NULL); > } > > -struct nd_ifinfo * > +void > nd6_ifattach(struct ifnet *ifp) > { > struct nd_ifinfo *nd; > @@ -139,12 +139,13 @@ nd6_ifattach(struct ifnet *ifp) > nd->reachable = ND_COMPUTE_RTIME(nd->basereachable); > nd->retrans = RETRANS_TIMER; > > - return nd; > + ifp->if_nd = nd; > } > > void > -nd6_ifdetach(struct nd_ifinfo *nd) > +nd6_ifdetach(struct ifnet *ifp) > { > + struct nd_ifinfo *nd = ifp->if_nd; >
Would it make sense to set ifp->if_nd = NULL; here? > free(nd, M_IP6NDP, sizeof(*nd)); > } > diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h > index 9adb0c700f6..53913e67bab 100644 > --- a/sys/netinet6/nd6.h > +++ b/sys/netinet6/nd6.h > @@ -135,8 +135,8 @@ union nd_opts { > #define nd_opts_done nd_opt_each.done > > void nd6_init(void); > -struct nd_ifinfo *nd6_ifattach(struct ifnet *); > -void nd6_ifdetach(struct nd_ifinfo *); > +void nd6_ifattach(struct ifnet *); > +void nd6_ifdetach(struct ifnet *); > int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *); > void nd6_option_init(void *, int, union nd_opts *); > struct nd_opt_hdr *nd6_option(union nd_opts *); > Apart from that ok -- :wq Claudio