From 8d964ad4e971aa9fa8725fc0eb85651d458fb5b9 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 26 Sep 2011 22:26:50 +0000 Subject: [PATCH] Consider IFF_LOOPBACK before IFF_BROADCAST. The IPv6 loopback interface on AIX has both IFF_BROADCAST and IFF_LOOPBACK set. Checking IFF_BROADCAST first erroneously makes it appear as an Ethernet device. --- libdnet-stripped/NMAP_MODIFICATIONS | 21 +++++++++++++++++++++ libdnet-stripped/src/intf.c | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libdnet-stripped/NMAP_MODIFICATIONS b/libdnet-stripped/NMAP_MODIFICATIONS index 719c3793f..7dc896b51 100644 --- a/libdnet-stripped/NMAP_MODIFICATIONS +++ b/libdnet-stripped/NMAP_MODIFICATIONS @@ -575,6 +575,27 @@ o Allowed reading interface indexes that exceed 255 on Linux. &idx, &bits, &scope, &flags, name); if (strcmp(name, entry->intf_name) == 0) { +o Gave priority to the IFF_LOOPBACK flag when setting interface type. + +--- libdnet-stripped/src/intf.c ++++ libdnet-stripped/src/intf.c +@@ -374,12 +374,12 @@ intf_set(intf_t *intf, const struct intf_entry *entry) + static void + _intf_set_type(struct intf_entry *entry) + { +- if ((entry->intf_flags & INTF_FLAG_BROADCAST) != 0) ++ if ((entry->intf_flags & INTF_FLAG_LOOPBACK) != 0) ++ entry->intf_type = INTF_TYPE_LOOPBACK; ++ else if ((entry->intf_flags & INTF_FLAG_BROADCAST) != 0) + entry->intf_type = INTF_TYPE_ETH; + else if ((entry->intf_flags & INTF_FLAG_POINTOPOINT) != 0) + entry->intf_type = INTF_TYPE_TUN; +- else if ((entry->intf_flags & INTF_FLAG_LOOPBACK) != 0) +- entry->intf_type = INTF_TYPE_LOOPBACK; + else + entry->intf_type = INTF_TYPE_OTHER; + } + ===CHANGES ALREADY MERGED TO UPSTREAM LIBDNET GO BELOW THIS LINE=== o Fixed the ip6_pack_hdr macro with respect to traffic class and flow diff --git a/libdnet-stripped/src/intf.c b/libdnet-stripped/src/intf.c index 236e1bcb4..ad0880d16 100644 --- a/libdnet-stripped/src/intf.c +++ b/libdnet-stripped/src/intf.c @@ -374,12 +374,12 @@ intf_set(intf_t *intf, const struct intf_entry *entry) static void _intf_set_type(struct intf_entry *entry) { - if ((entry->intf_flags & INTF_FLAG_BROADCAST) != 0) + if ((entry->intf_flags & INTF_FLAG_LOOPBACK) != 0) + entry->intf_type = INTF_TYPE_LOOPBACK; + else if ((entry->intf_flags & INTF_FLAG_BROADCAST) != 0) entry->intf_type = INTF_TYPE_ETH; else if ((entry->intf_flags & INTF_FLAG_POINTOPOINT) != 0) entry->intf_type = INTF_TYPE_TUN; - else if ((entry->intf_flags & INTF_FLAG_LOOPBACK) != 0) - entry->intf_type = INTF_TYPE_LOOPBACK; else entry->intf_type = INTF_TYPE_OTHER; }