BIND 10 #3288: IfaceMgr::openSockets6 requires fixes for Linux-specific code.

BIND 10 Development do-not-reply at isc.org
Wed Jan 15 10:06:35 UTC 2014


#3288: IfaceMgr::openSockets6 requires fixes for Linux-specific code.
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:
  marcin                             |                Status:  new
                       Type:         |             Milestone:  DHCP-
  defect                             |  Kea1.0-proposed
                   Priority:         |              Keywords:
  medium                             |             Sensitive:  0
                  Component:  dhcp   |           Sub-Project:  DHCP
               CVSS Scoring:         |  Estimated Difficulty:  0
            Defect Severity:         |           Total Hours:  0
  Medium                             |
Feature Depending on Ticket:         |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------
 There are at least two issues with the following segment of code in
 !IfaceMgr::openSockets6:

 {{{
             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++;

             /// @todo: Remove this ifdef once we start supporting BSD
 systems.
 #if defined(OS_LINUX)
             // To receive multicast traffic, Linux requires binding socket
 to
             // a multicast group. That in turn doesn't work on NetBSD.
             if (iface->flag_multicast_) {
                 try {
                     openSocket(iface->getName(),
 IOAddress(ALL_DHCP_RELAY_AGENTS_AND_SERVERS),
                                port);
                 } catch (const Exception& ex) {
                     // Delete previously opened socket.
                     iface->delSocket(sock);
                     IFACEMGR_ERROR(SocketConfigError, error_handler,
                                    "Failed to open multicast socket on"
                                    " interface " << iface->getName()
                                    << ", reason: " << ex.what());
                     continue;
                 }
             }
 #endif

 }}}

 The sock variable is always initialized but is only used for Linux-
 specific code. This causes cppcheck errors (about unused) variable. Even
 though the errors are suppressed with cppcheck inline suppression, this
 doesn't appear to work everywhere. Perhaps the type of error or the code
 line where the error should be suppressed differs on different OSes. For
 this reason it may be better to have a Linux-specific code moved to
 iface_mgr_linux.cc, BSD specific code moved to iface_mgr_bsd.cc etc. That
 way we could get rid of the #ifdef section in the iface_mgr.cc.

 The other problem with this code is that the counter is increased after
 link-local socket is open, but before multicast socket is open. If the
 multicast socket fails to open, the counter is already increased,
 indicating that the socket has been opened. In fact, the link-local socket
 is closed when the multicast one fails to open and thus the counter should
 not be increased.

-- 
Ticket URL: <http://bind10.isc.org/ticket/3288>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list