From: Marcin Siodelski Date: Thu, 21 Aug 2014 18:54:25 +0000 (+0200) Subject: [3527] Fixed the failing IfaceMgrTest::detectIfaces. X-Git-Tag: trac3482_base~17^2~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83b5c2c9b25d22d9b8f7deb35159ecd9bc499549;p=thirdparty%2Fkea.git [3527] Fixed the failing IfaceMgrTest::detectIfaces. The updated code uses interface index to match the interface detected by the test with the interface found by the IfaceMgr. This is to avoid issues on Linux whereby Netlink-based implementation doesn't return the virtual interface names, but rather physical interface names. --- diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc index 45148b5802..ac9f685176 100644 --- a/src/lib/dhcp/tests/iface_mgr_unittest.cc +++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc @@ -2362,7 +2362,20 @@ TEST_F(IfaceMgrTest, detectIfaces) { // Go over all interfaces detected by the unit test and see if they // match with the interfaces detected by IfaceMgr. for (ifptr = iflist; ifptr != 0; ifptr = ifptr->ifa_next) { - Iface* i = ifacemgr.getIface(std::string(ifptr->ifa_name)); + // When more than one IPv4 address is assigned to the particular + // physical interface, virtual interfaces may be created for each + // additional IPv4 address. For example, when multiple addresses + // are assigned to the eth0 interface, additional virtual interfaces + // will be eth0:0, eth0:1 etc. This is the case on some Linux + // distributions. The getifaddrs will return virtual interfaces, + // with single address each, but the Netlink-based implementation + // (used by IfaceMgr) will rather hold a list of physical interfaces + // with multiple IPv4 addresses assigned. This means that the test + // can't use a name of the interface returned by getifaddrs to match + // with the interface name held by IfaceMgr. Instead, we use the + // index of the interface because the virtual interfaces have the + // same indexes as the physical interfaces. + Iface* i = ifacemgr.getIface(if_nametoindex(ifptr->ifa_name)); // If the given interface was also detected by the IfaceMgr, // check that its properties are correct.