From 02a5d63eff8541df302bb7ced88f0f1df3f07386 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Wed, 19 Dec 2001 16:03:27 +0000 Subject: [PATCH] Only call rt_getifa() if we've either been passed a gateway or if we've been given an RTA_IFP or changed RTA_IFA sockaddr. This fixes the following bug: >/dev/tun100 >/dev/tun101 ifconfig tun100 1.2.3.4 5.6.7.8 ifconfig tun101 1.2.3.4 6.7.8.9 route change 6.7.8.9 -ifa 1.2.3.4 -iface -mtu 500 which erroneously changed tun101's host route to have an ifp of tun100 (rt_getifa() sets the ifp after calling ifa_ifwithnet(1.2.3.4)) This incarnation submitted by: ru --- sys/net/rtsock.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 84f38d64ec2..2de17fa42c6 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -424,8 +424,14 @@ route_output(m, so) /* new gateway could require new ifaddr, ifp; flags may also be different; ifp may be specified by ll sockaddr when protocol address is ambiguous */ - if ((error = rt_getifa(&info)) != 0) - senderr(error); +#define equal(a1, a2) (bcmp((caddr_t)(a1), (caddr_t)(a2), (a1)->sa_len) == 0) + if ((rt->rt_flags & RTF_GATEWAY && gate != NULL) || + ifpaddr != NULL || + (ifaaddr != NULL && + !equal(ifaaddr, rt->rt_ifa->ifa_addr))) { + if ((error = rt_getifa(&info)) != 0) + senderr(error); + } if (gate != NULL && (error = rt_setgate(rt, rt_key(rt), gate)) != 0) senderr(error);