]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
When we get an ACK we should close DHCP sockets so we don't handle any NAKs
authorRoy Marples <roy@marples.name>
Sat, 4 Jul 2009 00:06:25 +0000 (00:06 +0000)
committerRoy Marples <roy@marples.name>
Sat, 4 Jul 2009 00:06:25 +0000 (00:06 +0000)
during ARP testing.

This is important as some broken DHCP servers NAK immediately after an ACK
in some situations.

dhcpcd.c

index daf4e0bada4c270a5e8edb612b87f9dee6313705..31d0634469f0473ebcce57afd877c665904b1ddb 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -497,7 +497,8 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp)
                lease->addr.s_addr = dhcp->yiaddr;
                lease->server.s_addr = INADDR_ANY;
                if (type != 0)
-                       get_option_addr(&lease->server.s_addr, dhcp, DHO_SERVERID);
+                       get_option_addr(&lease->server.s_addr,
+                           dhcp, DHO_SERVERID);
                log_dhcp(LOG_INFO, "offered", iface, dhcp);
                free(state->offer);
                state->offer = dhcp;
@@ -551,6 +552,11 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp)
        lease->frominfo = 0;
 
        delete_timeout(NULL, iface);
+       /* We now have an offer, so close the DHCP sockets.
+        * This allows us to safely ARP when broken DHCP servers send an ACK
+        * follows by an invalid NAK. */
+       close_sockets(iface);
+
        if (ifo->options & DHCPCD_ARP &&
            iface->addr.s_addr != state->offer->yiaddr)
        {