From 9ac1bffad23b7e3e7d23447158da55f6715a833f Mon Sep 17 00:00:00 2001 From: david Date: Mon, 1 Jul 2013 02:06:09 +0000 Subject: [PATCH] Ignore down interfaces at route_dst time, not when building routing table. The previous code to ignore down interfaces didn't account for implicit routes that come from interface addresses and netmasks. You can force the use of a route using a down interface with -e. --- libnetutil/netutil.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index e7d5a5bfc..18856edc8 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -1556,8 +1556,6 @@ static struct dnet_collector_route_nfo *sysroutes_dnet_find_interfaces(struct dn routeaddr = &dcrn->routes[i].gw; for (j = 0; j < numifaces; j++) { - if (!ifaces[j].device_up) - continue; if (sockaddr_equal_netmask(&ifaces[j].addr, routeaddr, ifaces[j].netmask_bits)) { dcrn->routes[i].device = &ifaces[j]; break; @@ -3369,6 +3367,9 @@ static int route_dst_generic(const struct sockaddr_storage *dst, if (iface != NULL && strcmp(loopback->devname, iface->devname) != 0) continue; + if (iface == NULL && !loopback->device_up) + continue; + rnfo->ii = *loopback; rnfo->direct_connect = 1; /* But the source address we want to use is the target address. */ @@ -3389,6 +3390,9 @@ static int route_dst_generic(const struct sockaddr_storage *dst, if (iface != NULL && strcmp(routes[i].device->devname, iface->devname) != 0) continue; + if (iface == NULL && !routes[i].device->device_up) + continue; + rnfo->ii = *routes[i].device; /* At this point we don't whether this route is direct or indirect ("G" flag in netstat). We guess that a route is direct when the gateway address is @@ -3413,6 +3417,9 @@ static int route_dst_generic(const struct sockaddr_storage *dst, if (iface != NULL && strcmp(ifaces[i].devname, iface->devname) != 0) continue; + if (iface == NULL && !ifaces[i].device_up) + continue; + rnfo->ii = ifaces[i]; rnfo->direct_connect = 1; if (!spoofss) {