From: Roy Marples Date: Sat, 4 Jul 2009 00:06:25 +0000 (+0000) Subject: When we get an ACK we should close DHCP sockets so we don't handle any NAKs X-Git-Tag: v5.0.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d81486816806ccd79780b5c25a1ff0f9849fcdb4;p=thirdparty%2Fdhcpcd.git When we get an ACK we should close DHCP sockets so we don't handle any NAKs during ARP testing. This is important as some broken DHCP servers NAK immediately after an ACK in some situations. --- diff --git a/dhcpcd.c b/dhcpcd.c index daf4e0ba..31d06344 100644 --- 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) {