summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqingli <qingli@FreeBSD.org>2005-06-28 23:32:22 +0000
committerqingli <qingli@FreeBSD.org>2005-06-28 23:32:22 +0000
commit37efc775b590475026ff6366785a1b78bcb697f5 (patch)
treed4adf73bad1444fdc622195906349ade3ca6e145
parent59032ef458fae9ee6d8a1bd23739f5d489a4d467 (diff)
downloadFreeBSD-src-37efc775b590475026ff6366785a1b78bcb697f5.zip
FreeBSD-src-37efc775b590475026ff6366785a1b78bcb697f5.tar.gz
Require gateways for routes to be of the same address family as the
route itself. It fixes a bug where an IPv4 route for example has an IPv6 gateway specified: route add 10.1.1.1 -inet6 fe80::1%fxp0 Destination Gateway Flags Refs Use Netif Expire 10.1.1.1 fe80::1%fxp0 UGHS 0 0 fxp0 The fix rejects these illegal combinations: route: writing to routing socket: Invalid argument add host 10.1.1.1: gateway fe80::1%fxp0: Invalid argument Reviewed by: KAME jinmei@isl.rdc.toshiba.co.jp Reviewed by: andre (mentor) Approved by: re MFC after: 5
-rw-r--r--sys/net/route.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 57d0e53..1cb1c1c 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -744,7 +744,10 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
case RTM_ADD:
if ((flags & RTF_GATEWAY) && !gateway)
- panic("rtrequest: GATEWAY but no gateway");
+ senderr(EINVAL);
+ if (dst && gateway && (dst->sa_family != gateway->sa_family) &&
+ (gateway->sa_family != AF_UNSPEC) && (gateway->sa_family != AF_LINK))
+ senderr(EINVAL);
if (info->rti_ifa == NULL && (error = rt_getifa(info)))
senderr(error);
OpenPOWER on IntegriCloud