On 15/10/15(Thu) 22:51, Alexander Bluhm wrote:
> Hi,
>
> Inspired by the satosin() functions, I think it is better to have
> inline functions than casts to convert between sockaddrs. They
> check if the incoming object has the expected type. So introduce
> satosdl() and sdltosa() to the kernel.
I like this very much, ok mpi@.
I general I'd like to see more uses of "sockaddr_dl" and stop violating
the ifp layer by using ac_enaddr in most of the places. This cleanup
will help with that.
> Index: net/if.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/if.c,v
> retrieving revision 1.389
> diff -u -p -r1.389 if.c
> --- net/if.c 12 Oct 2015 13:17:58 -0000 1.389
> +++ net/if.c 15 Oct 2015 20:40:39 -0000
> @@ -1945,7 +1945,7 @@ ifioctl(struct socket *so, u_long cmd, c
> case SIOCSIFLLADDR:
> if ((error = suser(p, 0)))
> return (error);
> - sdl = (struct sockaddr_dl *)ifp->if_sadl;
> + sdl = ifp->if_sadl;
> if (sdl == NULL)
> return (EINVAL);
> if (ifr->ifr_addr.sa_len != ETHER_ADDR_LEN)
> Index: net/if_dl.h
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_dl.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 if_dl.h
> --- net/if_dl.h 15 Sep 2015 09:13:33 -0000 1.9
> +++ net/if_dl.h 15 Oct 2015 20:39:13 -0000
> @@ -71,7 +71,21 @@ struct sockaddr_dl {
>
> #define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
>
> -#ifndef _KERNEL
> +#ifdef _KERNEL
> +
> +static __inline struct sockaddr_dl *
> +satosdl(struct sockaddr *sa)
> +{
> + return ((struct sockaddr_dl *)(sa));
> +}
> +
> +static __inline struct sockaddr *
> +sdltosa(struct sockaddr_dl *sdl)
> +{
> + return ((struct sockaddr *)(sdl));
> +}
> +
> +#else /* _KERNEL */
>
> __BEGIN_DECLS
> char *link_ntoa(const struct sockaddr_dl *);
> Index: net/if_enc.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_enc.c,v
> retrieving revision 1.60
> diff -u -p -r1.60 if_enc.c
> --- net/if_enc.c 14 Mar 2015 03:38:51 -0000 1.60
> +++ net/if_enc.c 15 Oct 2015 20:40:40 -0000
> @@ -27,6 +27,7 @@
> #include <sys/mbuf.h>
>
> #include <net/if.h>
> +#include <net/if_dl.h>
> #include <net/if_var.h>
> #include <net/if_enc.h>
> #include <net/if_types.h>
> @@ -104,7 +105,7 @@ enc_clone_create(struct if_clone *ifc, i
> if_alloc_sadl(ifp);
> sc->sc_ifa.ifa_ifp = ifp;
> sc->sc_ifa.ifa_rtrequest = link_rtrequest;
> - sc->sc_ifa.ifa_addr = (struct sockaddr *)ifp->if_sadl;
> + sc->sc_ifa.ifa_addr = sdltosa(ifp->if_sadl);
> sc->sc_ifa.ifa_netmask = NULL;
>
> #if NBPFILTER > 0
> Index: net/if_ethersubr.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_ethersubr.c,v
> retrieving revision 1.228
> diff -u -p -r1.228 if_ethersubr.c
> --- net/if_ethersubr.c 29 Sep 2015 10:11:40 -0000 1.228
> +++ net/if_ethersubr.c 15 Oct 2015 20:41:54 -0000
> @@ -222,10 +222,9 @@ ether_output(struct ifnet *ifp, struct m
>
> switch (dst->sa_family) {
> case AF_LINK:
> - if (((struct sockaddr_dl *)dst)->sdl_alen <
> - sizeof(edst))
> + if (satosdl(dst)->sdl_alen < sizeof(edst))
> senderr(EHOSTUNREACH);
> - memcpy(edst, LLADDR((struct sockaddr_dl *)dst),
> + memcpy(edst, LLADDR(satosdl(dst)),
> sizeof(edst));
> break;
> case AF_INET:
> Index: net/if_mpe.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_mpe.c,v
> retrieving revision 1.47
> diff -u -p -r1.47 if_mpe.c
> --- net/if_mpe.c 12 Sep 2015 20:50:17 -0000 1.47
> +++ net/if_mpe.c 15 Oct 2015 20:40:40 -0000
> @@ -25,6 +25,7 @@
> #include <sys/ioctl.h>
>
> #include <net/if.h>
> +#include <net/if_dl.h>
> #include <net/if_var.h>
> #include <net/if_types.h>
> #include <net/netisr.h>
> @@ -105,7 +106,7 @@ mpe_clone_create(struct if_clone *ifc, i
>
> mpeif->sc_ifa.ifa_ifp = ifp;
> mpeif->sc_ifa.ifa_rtrequest = link_rtrequest;
> - mpeif->sc_ifa.ifa_addr = (struct sockaddr *) ifp->if_sadl;
> + mpeif->sc_ifa.ifa_addr = sdltosa(ifp->if_sadl);
> mpeif->sc_smpls.smpls_len = sizeof(mpeif->sc_smpls);
> mpeif->sc_smpls.smpls_family = AF_MPLS;
>
> Index: net/if_mpw.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_mpw.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 if_mpw.c
> --- net/if_mpw.c 12 Sep 2015 20:50:17 -0000 1.6
> +++ net/if_mpw.c 15 Oct 2015 20:40:40 -0000
> @@ -27,6 +27,7 @@
> #include <sys/errno.h>
>
> #include <net/if.h>
> +#include <net/if_dl.h>
> #include <net/if_types.h>
> #include <net/route.h>
>
> @@ -105,7 +106,7 @@ mpw_clone_create(struct if_clone *ifc, i
>
> sc->sc_ifa.ifa_ifp = ifp;
> sc->sc_ifa.ifa_rtrequest = link_rtrequest;
> - sc->sc_ifa.ifa_addr = (struct sockaddr *) ifp->if_sadl;
> + sc->sc_ifa.ifa_addr = sdltosa(ifp->if_sadl);
> sc->sc_smpls.smpls_len = sizeof(sc->sc_smpls);
> sc->sc_smpls.smpls_family = AF_MPLS;
>
> Index: net/route.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.c,v
> retrieving revision 1.252
> diff -u -p -r1.252 route.c
> --- net/route.c 14 Oct 2015 10:18:03 -0000 1.252
> +++ net/route.c 15 Oct 2015 20:43:06 -0000
> @@ -388,7 +388,7 @@ rt_sendmsg(struct rtentry *rt, int cmd,
> info.rti_info[RTAX_NETMASK] = rt_mask(rt);
> info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl);
> if (rt->rt_ifp != NULL) {
> - info.rti_info[RTAX_IFP] =(struct sockaddr *)rt->rt_ifp->if_sadl;
> + info.rti_info[RTAX_IFP] = sdltosa(rt->rt_ifp->if_sadl);
> info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
> }
>
> @@ -612,7 +612,7 @@ ifa_ifwithroute(int flags, struct sockad
> }
> if (ifa == NULL) {
> if (gateway->sa_family == AF_LINK) {
> - struct sockaddr_dl *sdl = (struct sockaddr_dl *)gateway;
> + struct sockaddr_dl *sdl = satosdl(gateway);
> struct ifnet *ifp = if_get(sdl->sdl_index);
>
> if (ifp != NULL)
> @@ -656,7 +656,7 @@ rt_getifa(struct rt_addrinfo *info, u_in
> if (info->rti_info[RTAX_IFP] != NULL) {
> struct sockaddr_dl *sdl;
>
> - sdl = (struct sockaddr_dl *)info->rti_info[RTAX_IFP];
> + sdl = satosdl(info->rti_info[RTAX_IFP]);
> ifp = if_get(sdl->sdl_index);
> }
>
> @@ -808,7 +808,7 @@ rtrequest1(int req, struct rt_addrinfo *
>
> info->rti_flags = rt->rt_flags | (RTF_CLONED|RTF_HOST);
> info->rti_flags &= ~(RTF_CLONING|RTF_CONNECTED|RTF_STATIC);
> - info->rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
> + info->rti_info[RTAX_GATEWAY] = sdltosa(&sa_dl);
> info->rti_info[RTAX_LABEL] =
> rtlabel_id2sa(rt->rt_labelid, &sa_rl2);
> /* FALLTHROUGH */
> @@ -1117,7 +1117,7 @@ rt_ifa_add(struct ifaddr *ifa, int flags
> info.rti_flags = flags | RTF_MPATH;
> info.rti_info[RTAX_DST] = dst;
> if (flags & RTF_LLINFO)
> - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)ifp->if_sadl;
> + info.rti_info[RTAX_GATEWAY] = sdltosa(ifp->if_sadl);
> else
> info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
> info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
> Index: net/rtsock.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.171
> diff -u -p -r1.171 rtsock.c
> --- net/rtsock.c 21 Sep 2015 11:27:08 -0000 1.171
> +++ net/rtsock.c 15 Oct 2015 20:40:40 -0000
> @@ -72,6 +72,7 @@
> #include <sys/protosw.h>
>
> #include <net/if.h>
> +#include <net/if_dl.h>
> #include <net/if_var.h>
> #include <net/route.h>
> #include <net/raw_cb.h>
> @@ -703,8 +704,7 @@ report:
> info.rti_info[RTAX_IFA] = NULL;
> if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA) &&
> (ifp = rt->rt_ifp) != NULL) {
> - info.rti_info[RTAX_IFP] =
> - (struct sockaddr *)ifp->if_sadl;
> + info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
> info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
> if (ifp->if_flags & IFF_POINTOPOINT)
> info.rti_info[RTAX_BRD] =
> @@ -1144,7 +1144,7 @@ rt_sendaddrmsg(struct rtentry *rt, int c
>
> memset(&info, 0, sizeof(info));
> info.rti_info[RTAX_IFA] = ifa->ifa_addr;
> - info.rti_info[RTAX_IFP] = (struct sockaddr *)ifp->if_sadl;
> + info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
> info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
> info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
> if ((m = rt_msg1(cmd, &info)) == NULL)
> @@ -1220,8 +1220,7 @@ sysctl_dumpentry(struct rtentry *rt, voi
> info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
> info.rti_info[RTAX_NETMASK] = rt_mask(rt);
> if (rt->rt_ifp) {
> - info.rti_info[RTAX_IFP] =
> - (struct sockaddr *)rt->rt_ifp->if_sadl;
> + info.rti_info[RTAX_IFP] = sdltosa(rt->rt_ifp->if_sadl);
> info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
> if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
> info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
> @@ -1275,7 +1274,7 @@ sysctl_iflist(int af, struct walkarg *w)
> if (w->w_arg && w->w_arg != ifp->if_index)
> continue;
> /* Copy the link-layer address first */
> - info.rti_info[RTAX_IFP] = (struct sockaddr *)ifp->if_sadl;
> + info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
> len = rt_msg2(RTM_IFINFO, RTM_VERSION, &info, 0, w);
> if (w->w_where && w->w_tmem && w->w_needed <= 0) {
> struct if_msghdr *ifm;
> Index: netinet/if_ether.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/if_ether.c,v
> retrieving revision 1.172
> diff -u -p -r1.172 if_ether.c
> --- netinet/if_ether.c 13 Oct 2015 10:21:27 -0000 1.172
> +++ netinet/if_ether.c 15 Oct 2015 20:42:52 -0000
> @@ -69,8 +69,6 @@
> #include <net/if_bridge.h>
> #endif
>
> -#define SDL(s) ((struct sockaddr_dl *)s)
> -
> /*
> * ARP trailer negotiation. Trailer protocol is not IP specific,
> * but ARP request/response use IP addresses.
> @@ -198,7 +196,7 @@ arp_rtrequest(int req, struct rtentry *r
> arprequest(ifp,
> &satosin(rt_key(rt))->sin_addr.s_addr,
> &satosin(rt_key(rt))->sin_addr.s_addr,
> - (u_char *)LLADDR(SDL(gate)));
> + (u_char *)LLADDR(satosdl(gate)));
> /*FALLTHROUGH*/
> case RTM_RESOLVE:
> if (gate->sa_family != AF_LINK ||
> @@ -207,8 +205,8 @@ arp_rtrequest(int req, struct rtentry *r
> ifp->if_xname);
> break;
> }
> - SDL(gate)->sdl_type = ifp->if_type;
> - SDL(gate)->sdl_index = ifp->if_index;
> + satosdl(gate)->sdl_type = ifp->if_type;
> + satosdl(gate)->sdl_index = ifp->if_index;
> if (la != 0)
> break; /* This happens on a route change */
> /*
> @@ -373,7 +371,7 @@ arpresolve(struct ifnet *ifp, struct rte
> }
> if (la == NULL || rt == NULL)
> goto bad;
> - sdl = SDL(rt->rt_gateway);
> + sdl = satosdl(rt->rt_gateway);
> if (sdl->sdl_alen > 0 && sdl->sdl_alen != ETHER_ADDR_LEN) {
> log(LOG_DEBUG, "%s: %s: incorrect arp information\n", __func__,
> inet_ntop(AF_INET, &satosin(dst)->sin_addr,
> @@ -635,7 +633,7 @@ in_arpinput(struct mbuf *m)
> }
> rt = arplookup(isaddr.s_addr, itaddr.s_addr == myaddr.s_addr, 0,
> rtable_l2(m->m_pkthdr.ph_rtableid));
> - if (rt != NULL && (sdl = SDL(rt->rt_gateway)) != NULL) {
> + if (rt != NULL && (sdl = satosdl(rt->rt_gateway)) != NULL) {
> la = (struct llinfo_arp *)rt->rt_llinfo;
> if (sdl->sdl_alen) {
> if (memcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) {
> @@ -743,7 +741,7 @@ out:
> if (rt->rt_ifp->if_type == IFT_CARP && ifp->if_type != IFT_CARP)
> goto out;
> memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha));
> - sdl = SDL(rt->rt_gateway);
> + sdl = satosdl(rt->rt_gateway);
> memcpy(ea->arp_sha, LLADDR(sdl), sizeof(ea->arp_sha));
> rtfree(rt);
> }
> @@ -775,7 +773,7 @@ void
> arptfree(struct rtentry *rt)
> {
> struct llinfo_arp *la = (struct llinfo_arp *)rt->rt_llinfo;
> - struct sockaddr_dl *sdl = SDL(rt->rt_gateway);
> + struct sockaddr_dl *sdl = satosdl(rt->rt_gateway);
>
> if ((sdl != NULL) && (sdl->sdl_family == AF_LINK)) {
> sdl->sdl_alen = 0;
> @@ -831,7 +829,7 @@ arpproxy(struct in_addr in, unsigned int
> return (0);
>
> /* Check that arp information are correct. */
> - sdl = (struct sockaddr_dl *)rt->rt_gateway;
> + sdl = satosdl(rt->rt_gateway);
> if (sdl->sdl_alen != ETHER_ADDR_LEN) {
> rtfree(rt);
> return (0);
> Index: netinet6/icmp6.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/icmp6.c,v
> retrieving revision 1.172
> diff -u -p -r1.172 icmp6.c
> --- netinet6/icmp6.c 18 Sep 2015 14:26:22 -0000 1.172
> +++ netinet6/icmp6.c 15 Oct 2015 20:40:39 -0000
> @@ -1692,7 +1692,7 @@ icmp6_redirect_output(struct mbuf *m0, s
> if ((nrt != NULL) &&
> (nrt->rt_flags & (RTF_GATEWAY|RTF_LLINFO)) == RTF_LLINFO &&
> (nrt->rt_gateway->sa_family == AF_LINK) &&
> - (sdl = (struct sockaddr_dl *)nrt->rt_gateway) &&
> + (sdl = satosdl(nrt->rt_gateway)) &&
> sdl->sdl_alen) {
> nd_opt = (struct nd_opt_hdr *)p;
> nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
> Index: netinet6/in6_ifattach.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_ifattach.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 in6_ifattach.c
> --- netinet6/in6_ifattach.c 12 Sep 2015 20:50:17 -0000 1.96
> +++ netinet6/in6_ifattach.c 15 Oct 2015 20:40:39 -0000
> @@ -144,7 +144,7 @@ get_hw_ifid(struct ifnet *ifp, struct in
> static u_int8_t allone[8] =
> { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
>
> - sdl = (struct sockaddr_dl *)ifp->if_sadl;
> + sdl = ifp->if_sadl;
> if (sdl == NULL || sdl->sdl_alen == 0)
> return -1;
>
> Index: netinet6/nd6.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6.c,v
> retrieving revision 1.155
> diff -u -p -r1.155 nd6.c
> --- netinet6/nd6.c 1 Oct 2015 09:10:22 -0000 1.155
> +++ netinet6/nd6.c 15 Oct 2015 20:40:40 -0000
> @@ -64,8 +64,6 @@
> #define ND6_SLOWTIMER_INTERVAL (60 * 60) /* 1 hour */
> #define ND6_RECALC_REACHTM_INTERVAL (60 * 120) /* 2 hours */
>
> -#define SDL(s) ((struct sockaddr_dl *)s)
> -
> /* timer values */
> int nd6_prune = 1; /* walk list every 1 seconds */
> int nd6_delay = 5; /* delay first probe time 5 second */
> @@ -608,7 +606,7 @@ nd6_purge(struct ifnet *ifp)
> rt = ln->ln_rt;
> if (rt && rt->rt_gateway &&
> rt->rt_gateway->sa_family == AF_LINK) {
> - sdl = (struct sockaddr_dl *)rt->rt_gateway;
> + sdl = satosdl(rt->rt_gateway);
> if (sdl->sdl_index == ifp->if_index)
> nln = nd6_free(rt, 0);
> }
> @@ -669,8 +667,7 @@ nd6_lookup(struct in6_addr *addr6, int c
> bzero(&info, sizeof(info));
> info.rti_flags = RTF_HOST | RTF_LLINFO;
> info.rti_info[RTAX_DST] = sin6tosa(&sin6);
> - info.rti_info[RTAX_GATEWAY] =
> - (struct sockaddr *)ifp->if_sadl;
> + info.rti_info[RTAX_GATEWAY] = sdltosa(ifp->if_sadl);
> error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, &rt,
> rtableid);
> if (error)
> @@ -1028,8 +1025,8 @@ nd6_rtrequest(int req, struct rtentry *r
> __func__, ifp->if_xname);
> break;
> }
> - SDL(gate)->sdl_type = ifp->if_type;
> - SDL(gate)->sdl_index = ifp->if_index;
> + satosdl(gate)->sdl_type = ifp->if_type;
> + satosdl(gate)->sdl_index = ifp->if_index;
> if (ln != NULL)
> break; /* This happens on a route change */
> /*
> @@ -1365,7 +1362,7 @@ fail:
> goto fail;
> if (rt->rt_gateway->sa_family != AF_LINK)
> goto fail;
> - sdl = SDL(rt->rt_gateway);
> + sdl = satosdl(rt->rt_gateway);
>
> olladdr = (sdl->sdl_alen) ? 1 : 0;
> if (olladdr && lladdr) {
> @@ -1770,7 +1767,7 @@ nd6_storelladdr(struct ifnet *ifp, struc
> m_freem(m);
> return (EINVAL);
> }
> - sdl = SDL(rt->rt_gateway);
> + sdl = satosdl(rt->rt_gateway);
> if (sdl->sdl_alen != ETHER_ADDR_LEN) {
> char addr[INET6_ADDRSTRLEN];
> log(LOG_DEBUG, "%s: %s: incorrect nd6 information\n", __func__,
> Index: netinet6/nd6_nbr.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6_nbr.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 nd6_nbr.c
> --- netinet6/nd6_nbr.c 18 Sep 2015 14:26:22 -0000 1.96
> +++ netinet6/nd6_nbr.c 15 Oct 2015 20:40:40 -0000
> @@ -61,8 +61,6 @@
> #include <netinet/ip_carp.h>
> #endif
>
> -#define SDL(s) ((struct sockaddr_dl *)s)
> -
> TAILQ_HEAD(dadq_head, dadq);
> struct dadq {
> TAILQ_ENTRY(dadq) dad_list;
> @@ -242,7 +240,7 @@ nd6_ns_input(struct mbuf *m, int off, in
> IN6_IFF_NOTREADY | IN6_IFF_ANYCAST)->ia_ifa;
> if (ifa) {
> proxy = 1;
> - proxydl = SDL(rt->rt_gateway);
> + proxydl = satosdl(rt->rt_gateway);
> router = 0; /* XXX */
> }
> }
> @@ -317,7 +315,7 @@ nd6_ns_input(struct mbuf *m, int off, in
> nd6_na_output(ifp, &saddr6, &taddr6,
> ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
> (router ? ND_NA_FLAG_ROUTER : 0),
> - tlladdr, (struct sockaddr *)proxydl);
> + tlladdr, sdltosa(proxydl));
> goto freeit;
> }
>
> @@ -326,7 +324,7 @@ nd6_ns_input(struct mbuf *m, int off, in
> nd6_na_output(ifp, &saddr6, &taddr6,
> ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
> (router ? ND_NA_FLAG_ROUTER : 0) | ND_NA_FLAG_SOLICITED,
> - tlladdr, (struct sockaddr *)proxydl);
> + tlladdr, sdltosa(proxydl));
> freeit:
> m_freem(m);
> if_put(ifp);
> @@ -711,7 +709,7 @@ nd6_na_input(struct mbuf *m, int off, in
> rt = nd6_lookup(&taddr6, 0, ifp, ifp->if_rdomain);
> if ((rt == NULL) ||
> ((ln = (struct llinfo_nd6 *)rt->rt_llinfo) == NULL) ||
> - ((sdl = SDL(rt->rt_gateway)) == NULL))
> + ((sdl = satosdl(rt->rt_gateway)) == NULL))
> goto freeit;
>
> if (ln->ln_state == ND6_LLINFO_INCOMPLETE) {
> @@ -1033,7 +1031,7 @@ nd6_na_output(struct ifnet *ifp, struct
> mac = nd6_ifptomac(ifp);
> } else if (sdl0->sa_family == AF_LINK) {
> struct sockaddr_dl *sdl;
> - sdl = (struct sockaddr_dl *)sdl0;
> + sdl = satosdl(sdl0);
> if (sdl->sdl_alen == ifp->if_addrlen)
> mac = LLADDR(sdl);
> }
> Index: netinet6/nd6_rtr.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6_rtr.c,v
> retrieving revision 1.125
> diff -u -p -r1.125 nd6_rtr.c
> --- netinet6/nd6_rtr.c 18 Sep 2015 14:26:22 -0000 1.125
> +++ netinet6/nd6_rtr.c 15 Oct 2015 20:39:13 -0000
> @@ -58,8 +58,6 @@
> #include <netinet6/nd6.h>
> #include <netinet/icmp6.h>
>
> -#define SDL(s) ((struct sockaddr_dl *)s)
> -
> int rtpref(struct nd_defrouter *);
> struct nd_defrouter *defrtrlist_update(struct nd_defrouter *);
> struct in6_ifaddr *in6_ifadd(struct nd_prefix *, int);
>