summaryrefslogtreecommitdiffstats
path: root/sys/net/route.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-11-08 10:39:32 +0000
committermpi <mpi@openbsd.org>2016-11-08 10:39:32 +0000
commit7c6c30ae9b20bcfabc30a160f304fc53a646abb2 (patch)
tree118cfb004acc2822210cfcdad4ff9f4a5ac57ddb /sys/net/route.c
parentRemove superfluous DMA synchronization now that the stack is doing it for (diff)
downloadwireguard-openbsd-7c6c30ae9b20bcfabc30a160f304fc53a646abb2.tar.xz
wireguard-openbsd-7c6c30ae9b20bcfabc30a160f304fc53a646abb2.zip
Use rtalloc(9) instead of ifa_ifwithnet().
ifa_ifwithnet() checks if a given address is directly connected. This function predates the introduction of the BSD routing table. Nowdays we can check if the route for the given address is marked as RTF_GATEWAY. This works on OpenBSD because we always install RTF_CONNECTED routes for subnets a and RTF_HOST route per p2p link. ok vgross@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index a04b0958d5f..b8d44c5a152 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.333 2016/10/06 19:09:08 bluhm Exp $ */
+/* $OpenBSD: route.c,v 1.334 2016/11/08 10:39:32 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -550,11 +550,16 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway,
splsoftassert(IPL_SOFTNET);
/* verify the gateway is directly reachable */
- if ((ifa = ifa_ifwithnet(gateway, rdomain)) == NULL) {
+ rt = rtalloc(gateway, 0, rdomain);
+ if (!rtisvalid(rt) || ISSET(rt->rt_flags, RTF_GATEWAY)) {
+ rtfree(rt);
error = ENETUNREACH;
goto out;
}
- ifidx = ifa->ifa_ifp->if_index;
+ ifidx = rt->rt_ifidx;
+ rtfree(rt);
+ rt = NULL;
+
rt = rtable_lookup(rdomain, dst, NULL, NULL, RTP_ANY);
/*
* If the redirect isn't from our current router for this dst,