summaryrefslogtreecommitdiffstats
path: root/sys/net/route.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-06-08 13:26:06 +0000
committermpi <mpi@openbsd.org>2016-06-08 13:26:06 +0000
commit8bae1a7b2dbfa1a2ca21480451e2b5e79f5b34dd (patch)
treea6d74e4c2ef1de7734a701705d738dde85ccf57a /sys/net/route.c
parentMove ND resoluton logic from nd6_output() to nd6_storelladdr() and (diff)
downloadwireguard-openbsd-8bae1a7b2dbfa1a2ca21480451e2b5e79f5b34dd.tar.xz
wireguard-openbsd-8bae1a7b2dbfa1a2ca21480451e2b5e79f5b34dd.zip
Revert previous, it breaks regression tests.
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 519d9e01d63..ac6b9cfb4cd 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.306 2016/06/07 08:30:01 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.307 2016/06/08 13:26:06 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -744,16 +744,20 @@ ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway,
ifa = ifaof_ifpforaddr(dst, ifp);
if_put(ifp);
} else {
- struct rtentry *rt;
-
- rt = rtalloc(gateway, RT_RESOLVE, rtableid);
- if (rt != NULL)
- ifa = rt->rt_ifa;
+ ifa = ifa_ifwithnet(gateway, rtableid);
+ }
+ }
+ if (ifa == NULL) {
+ struct rtentry *rt = rtalloc(gateway, 0, rtableid);
+ /* The gateway must be local if the same address family. */
+ if (!rtisvalid(rt) || ((rt->rt_flags & RTF_GATEWAY) &&
+ rt_key(rt)->sa_family == dst->sa_family)) {
rtfree(rt);
+ return (NULL);
}
+ ifa = rt->rt_ifa;
+ rtfree(rt);
}
- if (ifa == NULL)
- return (NULL);
if (ifa->ifa_addr->sa_family != dst->sa_family) {
struct ifaddr *oifa = ifa;
ifa = ifaof_ifpforaddr(dst, ifa->ifa_ifp);