summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-06-06 09:31:54 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-06-06 09:31:54 +0000
commit54b9f6f5796ceb86047002b3844c7c7234ae5eb0 (patch)
treee0aac9ee8c21864d2e52d8b675b1c66296c62448
parent1991fd92e91db8be3dea3f762c0fa3d28aa54450 (diff)
Put the link-layer address back into the gateway field of RTF_LOCAL
routes. Since such routes are also flagged with RTF_LLINFO various code path assume correctly that they contain valid ARP or ND information. This fixes the "arpresolve: unresolved and rt_expire == 0" issue reported on tech@ by mxb <mxb AT alumni DOT chalmers DOT se>. ok claudio@, phessler@
-rw-r--r--sys/net/route.c32
-rw-r--r--sys/netinet6/nd6.c9
2 files changed, 14 insertions, 27 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index dc510860670..88e8134dc2e 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.212 2015/05/26 12:19:51 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.213 2015/06/06 09:31:53 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1121,27 +1121,23 @@ rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst,
int
rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst)
{
+ struct ifnet *ifp = ifa->ifa_ifp;
struct rtentry *rt, *nrt = NULL;
struct sockaddr_rtlabel sa_rl;
- struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK };
struct rt_addrinfo info;
- u_short rtableid = ifa->ifa_ifp->if_rdomain;
- u_int8_t prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
+ u_short rtableid = ifp->if_rdomain;
+ u_int8_t prio = ifp->if_priority + RTP_STATIC;
int error;
- sa_dl.sdl_type = ifa->ifa_ifp->if_type;
- sa_dl.sdl_index = ifa->ifa_ifp->if_index;
-
memset(&info, 0, sizeof(info));
info.rti_ifa = ifa;
info.rti_flags = flags | RTF_MPATH;
info.rti_info[RTAX_DST] = dst;
if (flags & RTF_LLINFO)
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
+ info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)ifp->if_sadl;
else
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_LABEL] =
- rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl);
+ info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
#ifdef MPLS
if ((flags & RTF_MPLS) == RTF_MPLS) {
@@ -1189,14 +1185,14 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst)
int
rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst)
{
+ struct ifnet *ifp = ifa->ifa_ifp;
struct rtentry *rt, *nrt = NULL;
struct mbuf *m = NULL;
struct sockaddr *deldst;
struct rt_addrinfo info;
struct sockaddr_rtlabel sa_rl;
- struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK };
- u_short rtableid = ifa->ifa_ifp->if_rdomain;
- u_int8_t prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
+ u_short rtableid = ifp->if_rdomain;
+ u_int8_t prio = ifp->if_priority + RTP_STATIC;
int error;
#ifdef MPLS
@@ -1227,19 +1223,13 @@ rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst)
}
}
- sa_dl.sdl_type = ifa->ifa_ifp->if_type;
- sa_dl.sdl_index = ifa->ifa_ifp->if_index;
-
memset(&info, 0, sizeof(info));
info.rti_ifa = ifa;
info.rti_flags = flags;
info.rti_info[RTAX_DST] = dst;
- if (flags & RTF_LLINFO)
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
- else
+ if ((flags & RTF_LLINFO) == 0)
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_LABEL] =
- rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl);
+ info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
if ((flags & RTF_HOST) == 0)
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index cea57b8c5de..4f87e5a6a8e 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.136 2015/05/15 12:00:57 claudio Exp $ */
+/* $OpenBSD: nd6.c,v 1.137 2015/06/06 09:31:53 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -651,7 +651,6 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp,
}
if (!rt) {
if (create && ifp) {
- struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK };
struct rt_addrinfo info;
int e;
@@ -667,9 +666,6 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp,
if (ifa == NULL)
return (NULL);
- sa_dl.sdl_type = ifp->if_type;
- sa_dl.sdl_index = ifp->if_index;
-
/*
* Create a new route. RTF_LLINFO is necessary
* to create a Neighbor Cache entry for the
@@ -679,7 +675,8 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp,
bzero(&info, sizeof(info));
info.rti_flags = RTF_UP | RTF_HOST | RTF_LLINFO;
info.rti_info[RTAX_DST] = sin6tosa(&sin6);
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
+ info.rti_info[RTAX_GATEWAY] =
+ (struct sockaddr *)ifp->if_sadl;
if ((e = rtrequest1(RTM_ADD, &info, RTP_CONNECTED,
&rt, rtableid)) != 0) {
#if 0