1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 20:29:03 +00:00

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.
This commit is contained in:
david
2013-07-01 02:06:09 +00:00
parent b415564df9
commit 9ac1bffad2

View File

@@ -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) {