summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-10-22 15:37:48 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-10-22 15:37:48 +0000
commitcd0470e770532da488df19612134f01231b21b2e (patch)
treefeceac48a5b68b927fd09abf0a0a6b9929724c07
parentefda7364db1f8aac179ecbcaaaaee19ad75027bf (diff)
Inspired by satosin(), use inline functions to convert sockaddr dl.
Instead of casts they check wether the incoming object has the expected type. So introduce satosdl() and sdltosa() in the kernel. OK mpi@
-rw-r--r--sys/net/if.c4
-rw-r--r--sys/net/if_dl.h18
-rw-r--r--sys/net/if_enc.c5
-rw-r--r--sys/net/if_ethersubr.c7
-rw-r--r--sys/net/if_mpe.c5
-rw-r--r--sys/net/if_mpw.c5
-rw-r--r--sys/net/route.c12
-rw-r--r--sys/net/rtsock.c13
-rw-r--r--sys/netinet/if_ether.c20
-rw-r--r--sys/netinet6/icmp6.c4
-rw-r--r--sys/netinet6/in6_ifattach.c4
-rw-r--r--sys/netinet6/nd6.c17
-rw-r--r--sys/netinet6/nd6_nbr.c14
-rw-r--r--sys/netinet6/nd6_rtr.c4
14 files changed, 69 insertions, 63 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 7ea0265100f..fb1e0aecb8f 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.390 2015/10/22 10:46:26 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.391 2015/10/22 15:37:47 bluhm Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -1945,7 +1945,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
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)
diff --git a/sys/net/if_dl.h b/sys/net/if_dl.h
index 8a1f465b423..966506f6391 100644
--- a/sys/net/if_dl.h
+++ b/sys/net/if_dl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_dl.h,v 1.9 2015/09/15 09:13:33 guenther Exp $ */
+/* $OpenBSD: if_dl.h,v 1.10 2015/10/22 15:37:47 bluhm Exp $ */
/* $NetBSD: if_dl.h,v 1.8 1995/03/26 20:30:13 jtc Exp $ */
/*
@@ -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 *);
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index a49a6908041..4c1e308fb28 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_enc.c,v 1.60 2015/03/14 03:38:51 jsg Exp $ */
+/* $OpenBSD: if_enc.c,v 1.61 2015/10/22 15:37:47 bluhm Exp $ */
/*
* Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net>
@@ -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, int unit)
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
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index ee86161095f..0274d0009a1 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.228 2015/09/29 10:11:40 deraadt Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.229 2015/10/22 15:37:47 bluhm Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -222,10 +222,9 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
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:
diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c
index 1a4a6328477..53da65c4373 100644
--- a/sys/net/if_mpe.c
+++ b/sys/net/if_mpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpe.c,v 1.47 2015/09/12 20:50:17 mpi Exp $ */
+/* $OpenBSD: if_mpe.c,v 1.48 2015/10/22 15:37:47 bluhm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -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, int unit)
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;
diff --git a/sys/net/if_mpw.c b/sys/net/if_mpw.c
index 8626a1736e4..197bb54f9f0 100644
--- a/sys/net/if_mpw.c
+++ b/sys/net/if_mpw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpw.c,v 1.6 2015/09/12 20:50:17 mpi Exp $ */
+/* $OpenBSD: if_mpw.c,v 1.7 2015/10/22 15:37:47 bluhm Exp $ */
/*
* Copyright (c) 2015 Rafael Zalamena <rzalamena@openbsd.org>
@@ -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, int unit)
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;
diff --git a/sys/net/route.c b/sys/net/route.c
index 5e525ef25e8..518715705fc 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.254 2015/10/21 08:21:06 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.255 2015/10/22 15:37:47 bluhm Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -388,7 +388,7 @@ rt_sendmsg(struct rtentry *rt, int cmd, u_int rtableid)
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 sockaddr *dst, struct sockaddr *gateway,
}
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_int rtid)
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, u_int8_t prio,
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 */
@@ -1108,7 +1108,7 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst)
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);
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index d8a2d55e88e..15448a3fa93 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.171 2015/09/21 11:27:08 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.172 2015/10/22 15:37:47 bluhm Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -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 cmd)
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, void *v, unsigned int id)
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;
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 237b02769e2..d1c810caaf5 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.173 2015/10/22 13:30:29 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.174 2015/10/22 15:37:47 bluhm Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -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 *rt)
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 *rt)
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 rtentry *rt0, struct mbuf *m,
}
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 rtableid)
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);
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 42dc651222d..4f7034cbb84 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.173 2015/10/19 12:11:28 mpi Exp $ */
+/* $OpenBSD: icmp6.c,v 1.174 2015/10/22 15:37:47 bluhm Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -1693,7 +1693,7 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
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;
diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 461e2a381b7..ef4ed7a871f 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_ifattach.c,v 1.96 2015/09/12 20:50:17 mpi Exp $ */
+/* $OpenBSD: in6_ifattach.c,v 1.97 2015/10/22 15:37:47 bluhm Exp $ */
/* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */
/*
@@ -144,7 +144,7 @@ get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6)
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;
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 0083b44acad..41be0601bff 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.156 2015/10/22 10:27:22 mpi Exp $ */
+/* $OpenBSD: nd6.c,v 1.157 2015/10/22 15:37:47 bluhm Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -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 create, struct ifnet *ifp,
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)
@@ -1023,8 +1020,8 @@ nd6_rtrequest(int req, struct rtentry *rt)
__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 */
/*
@@ -1360,7 +1357,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) {
@@ -1765,7 +1762,7 @@ nd6_storelladdr(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
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__,
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index c578e844b8f..9a0694b03c6 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_nbr.c,v 1.96 2015/09/18 14:26:22 mpi Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.97 2015/10/22 15:37:47 bluhm Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -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, int icmp6len)
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, int icmp6len)
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, int icmp6len)
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, int icmp6len)
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 in6_addr *daddr6,
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);
}
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 4bc7686c840..6e85e6c3893 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.125 2015/09/18 14:26:22 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.126 2015/10/22 15:37:47 bluhm Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -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);