BIND 10 #2765: b10-dhcp4 silently fails if bootp/dhcp4 port is already used on one interface

BIND 10 Development do-not-reply at isc.org
Mon Dec 2 11:50:27 UTC 2013


#2765: b10-dhcp4 silently fails if bootp/dhcp4 port is already used on one
interface
-------------------------------------+-------------------------------------
            Reporter:  cas           |                        Owner:
                Type:  defect        |  UnAssigned
            Priority:  medium        |                       Status:
           Component:  dhcp4         |  reviewing
            Keywords:                |                    Milestone:
           Sensitive:  0             |  Sprint-DHCP-20131204
         Sub-Project:  DHCP          |                   Resolution:
Estimated Difficulty:  0             |                 CVSS Scoring:
         Total Hours:  0             |              Defect Severity:  N/A
                                     |  Feature Depending on Ticket:
                                     |          Add Hours to Ticket:  0
                                     |                    Internal?:  0
-------------------------------------+-------------------------------------
Changes (by marcin):

 * owner:  marcin => UnAssigned


Comment:

 dclink, many thanks for providing a patch. That was a good idea to open
 another socket to check if there is anything already bound. The problem I
 found with the patch was that IP/UDP socket was closed as soon as we
 checked that there is no other process bound to the address/port. If we
 close the socket and leave the raw socket, the kernel doesn't know that
 Kea is listening to the DHCP traffic and it is possible to open another
 DHCP server instance and bind to the same address and port. In order to
 make it a little bit better I decided that the IP/udp socket remains open
 as long as the raw socket is open. Following the terminology of the isc-
 dhcp, I refer to it as !''fallback!'' socket. So, neither the fallback
 socket will open if there is another DHCP instance bound to the
 address/port nor any other instance will bind to the same address/port as
 Kea if Kea's socket is already bound. Obviously, if the other DHCP
 instance uses raw sockets only, it can still listen on the same
 address/port.

 Another important change that comes with this ticket is to gracefully
 handle failures to open a socket. In other words, we usually don't want
 the IfaceMgr::openSockets4 to throw an exception when socket fails to open
 because this will effectively mean that no other sockets (on other
 interfaces) will open. Instead we should log warning. The libdhcp++
 doesn't have any logger associated with it and it communicates errors
 through exceptions. I was wondering how to extend the
 IfaceMgr::openSockets4 function not to throw an exception when it fails to
 open a socket, but in the same time to communicate the error to the
 server. I realized that having an error handler function which would be
 called on error, is the simplest and the most flexible approach. If the
 handler is not installed, the default behaviour is preserved: exception is
 thrown. The error handler function on the server side will simply print
 the warning.

 When I was writing unit tests for the new callback functionality I
 realized that IfaceMgr::openSockets4 has NO unit tests. Unit testing this
 function is not trivial because function's behavior depends on the network
 interfaces present. I created the test which removes any existing
 interfaces and configures the !IfaceMgr with a set of well known fake
 interfaces. In order to use fictitious interfaces I had to inject the
 customized code for opening the sockets on them etc. I used a class
 derived from isc::dhcp::!PktFilter to provide a no-op version of
 openSocket4.

 Note, that the !PktFilter-derived objects are used for DHCPv4. Therefore,
 it is impossible to use the same testing approach for openSockets6 at the
 moment. I submitted this ticket: http://bind10.isc.org/ticket/3251 to
 resolve the problem for DHCPv6.

 Another new ticket: http://bind10.isc.org/ticket/3252 has been submitted
 to extend the IfaceMgr::openSockets6 function to not throw an exception
 when failed to open a socket.

 Proposed !ChangeLog entry for #2765:
 {{{
 XXX.    [func]          marcin,dclink
         b10-dhcp4: If server failed to open a socket on one interface it
         will log a warning and continue to open sockets on other
 interfaces.
         The warning message is communicated from the libdhcp++ via the
         error handler function supplied by the DHCPv4 server. Thanks to
         David Carlier for providing a patch.
         (Trac #2765, git abc)

 }}}

-- 
Ticket URL: <http://bind10.isc.org/ticket/2765#comment:9>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list