summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2016-11-08 10:39:33 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2016-11-08 10:39:33 +0000
commit6210a5e0163341e80f8eeeab56ac3a1bfe859fcc (patch)
tree7e85527d79882295250866d8b74103fec9d160f1 /sys/net
parent7816a902634cd707722181d6b8dc83d6ac94a953 (diff)
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')
-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,