From: Mukund Sivaraman Date: Fri, 17 Jan 2014 09:14:23 +0000 (+0530) Subject: Merge branch 'trac1283' X-Git-Tag: bind10-1.2.0beta1-release~132 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=312e27c04145572a62815627ed63d9dc4ef866cd;p=thirdparty%2Fkea.git Merge branch 'trac1283' Conflicts: src/lib/dhcp/iface_mgr.cc --- 312e27c04145572a62815627ed63d9dc4ef866cd diff --cc src/lib/dhcp/iface_mgr.cc index 8624c69b2a,6681cd7cb8..e3ffe48352 --- a/src/lib/dhcp/iface_mgr.cc +++ b/src/lib/dhcp/iface_mgr.cc @@@ -497,15 -414,12 +497,14 @@@ IfaceMgr::openSockets6(const uint16_t p for (Iface::AddressCollection::iterator addr = unicasts.begin(); addr != unicasts.end(); ++addr) { - sock = openSocket(iface->getName(), *addr, port); - if (sock < 0) { - const char* errstr = strerror(errno); - isc_throw(SocketConfigError, "failed to open unicast socket on " - << *addr << " on interface " << iface->getName() - << ", reason: " << errstr); + try { + openSocket(iface->getName(), *addr, port); - + } catch (const Exception& ex) { + IFACEMGR_ERROR(SocketConfigError, error_handler, + "Failed to open unicast socket on interface " + << iface->getName() << ", reason: " + << ex.what()); + continue; } count++; @@@ -531,36 -445,23 +530,35 @@@ continue; } - sock = openSocket(iface->getName(), *addr, port); - if (sock < 0) { - const char* errstr = strerror(errno); - isc_throw(SocketConfigError, "failed to open link-local socket on " - << *addr << " on interface " - << iface->getName() << ", reason: " << errstr); - } - - // Binding socket to unicast address and then joining multicast group - // works well on Mac OS (and possibly other BSDs), but does not work - // on Linux. - if ( !joinMulticast(sock, iface->getName(), - string(ALL_DHCP_RELAY_AGENTS_AND_SERVERS))) { - close(sock); - isc_throw(SocketConfigError, "Failed to join " - << ALL_DHCP_RELAY_AGENTS_AND_SERVERS - << " multicast group."); + // Open socket and join multicast group only if the interface + // is multicast-capable. + // @todo The DHCPv6 requires multicast so we may want to think + // whether we want to open the socket on a multicast-incapable + // interface or not. For now, we prefer to be liberal and allow + // it for some odd use cases which may utilize non-multicast + // interfaces. Perhaps a warning should be emitted if the + // interface is not a multicast one. + + // The sock variable will hold a socket descriptor. It may be + // used to close a socket if the function fails to bind to + // multicast address on Linux systems. Because we only bind + // a socket to multicast address on Linux, on other systems + // the sock variable will be initialized but unused. We have + // to suppress the cppcheck warning which shows up on non-Linux + // systems. + // cppcheck-suppress variableScope + int sock; + try { + // cppcheck-suppress unreadVariable + sock = openSocket(iface->getName(), *addr, port, + iface->flag_multicast_); + + } catch (const Exception& ex) { + IFACEMGR_ERROR(SocketConfigError, error_handler, + "Failed to open link-local socket on " + " interface " << iface->getName() << ": " + << ex.what()); + continue; - } count++;