On Wed, Nov 23, 2022 at 11:04:55AM +0000, Klemens Nanni wrote:
> Feedback? Objection? OK?
OK bluhm@
> diff --git a/sys/net/if.c b/sys/net/if.c
> index f3fba33de3f..a540f564887 100644
> --- a/sys/net/if.c
> +++ b/sys/net/if.c
> @@ -461,6 +461,10 @@ if_attachsetup(struct ifnet *ifp)
> if_addgroup(ifp, IFG_ALL);
>
> if_attachdomain(ifp);
> +#ifdef INET6
> + ifp->if_nd = nd6_ifattach(ifp);
> +#endif
> +
> #if NPF > 0
> pfi_attach_ifnet(ifp);
> #endif
> @@ -1127,6 +1131,9 @@ if_detach(struct ifnet *ifp)
> (*dp->dom_ifdetach)(ifp,
> ifp->if_afdata[dp->dom_family]);
> }
> +#ifdef INET6
> + nd6_ifdetach(ifp->if_nd);
> +#endif
>
> /* Announce that the interface is gone. */
> rtm_ifannounce(ifp, IFAN_DEPARTURE);
> diff --git a/sys/net/if_var.h b/sys/net/if_var.h
> index 3a418bf0547..3bf07ed3071 100644
> --- a/sys/net/if_var.h
> +++ b/sys/net/if_var.h
> @@ -187,6 +187,7 @@ struct ifnet { /* and the
> entries */
> struct sockaddr_dl *if_sadl; /* [N] pointer to our sockaddr_dl */
>
> void *if_afdata[AF_MAX];
> + struct nd_ifinfo *if_nd; /* [I] IPv6 Neighour Discovery info */
> };
> #define if_mtu if_data.ifi_mtu
> #define if_type if_data.ifi_type
> diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
> index d45944116f6..913ff3e72e0 100644
> --- a/sys/netinet6/in6.c
> +++ b/sys/netinet6/in6.c
> @@ -1606,15 +1606,3 @@ in6if_do_dad(struct ifnet *ifp)
> return (1);
> }
> }
> -
> -void *
> -in6_domifattach(struct ifnet *ifp)
> -{
> - return nd6_ifattach(ifp);
> -}
> -
> -void
> -in6_domifdetach(struct ifnet *ifp, void *aux)
> -{
> - nd6_ifdetach(aux);
> -}
> diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
> index 808422f6eab..e302f39cddf 100644
> --- a/sys/netinet6/in6_proto.c
> +++ b/sys/netinet6/in6_proto.c
> @@ -338,8 +338,6 @@ const struct domain inet6domain = {
> .dom_sasize = sizeof(struct sockaddr_in6),
> .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr),
> .dom_maxplen = 128,
> - .dom_ifattach = in6_domifattach,
> - .dom_ifdetach = in6_domifdetach
> };
>
> /*
> diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
> index f108927f9e1..9adb0c700f6 100644
> --- a/sys/netinet6/nd6.h
> +++ b/sys/netinet6/nd6.h
> @@ -77,7 +77,7 @@ struct in6_ndireq {
> #include <sys/queue.h>
>
> #define ND_IFINFO(ifp) \
> - ((struct nd_ifinfo *)(ifp)->if_afdata[AF_INET6])
> + ((ifp)->if_nd)
>
> struct llinfo_nd6 {
> TAILQ_ENTRY(llinfo_nd6) ln_list;