summaryrefslogtreecommitdiff
path: root/sys/net/route.c
diff options
context:
space:
mode:
authorQing Li <qingli@FreeBSD.org>2006-05-16 19:11:11 +0000
committerQing Li <qingli@FreeBSD.org>2006-05-16 19:11:11 +0000
commite034e82c56ef32db77eb6baeda78b78400a89709 (patch)
tree42c4b29aadd6b9379f546347a3cb7b8d74cefb19 /sys/net/route.c
parent57caf3d61fef2a22d3412b1cf9b4bc370dfcec33 (diff)
downloadsrc-test2-e034e82c56ef32db77eb6baeda78b78400a89709.tar.gz
src-test2-e034e82c56ef32db77eb6baeda78b78400a89709.zip
Notes
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index ebfc640ff328..0e1085a9b28a 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -435,6 +435,7 @@ struct ifaddr *
ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway)
{
register struct ifaddr *ifa;
+ int not_found = 0;
if ((flags & RTF_GATEWAY) == 0) {
/*
@@ -463,8 +464,26 @@ ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway)
struct rtentry *rt = rtalloc1(gateway, 0, 0UL);
if (rt == NULL)
return (NULL);
+ /*
+ * dismiss a gateway that is reachable only
+ * through the default router
+ */
+ switch (gateway->sa_family) {
+ case AF_INET:
+ if (satosin(rt_key(rt))->sin_addr.s_addr == INADDR_ANY)
+ not_found = 1;
+ break;
+ case AF_INET6:
+ if (IN6_IS_ADDR_UNSPECIFIED(&satosin6(rt_key(rt))->sin6_addr))
+ not_found = 1;
+ break;
+ default:
+ break;
+ }
RT_REMREF(rt);
RT_UNLOCK(rt);
+ if (not_found)
+ return (NULL);
if ((ifa = rt->rt_ifa) == NULL)
return (NULL);
}