dhclient - Fix interval handling.
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Thu, 2 Aug 2012 19:26:34 +0000 (21:26 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sun, 19 Aug 2012 14:30:38 +0000 (16:30 +0200)
- Start at initial_interval instead of exponentially backed
  off initial_interval.
- Don't hallucinate that we can send ARP packets without waiting.
- Don't claim to be waiting for ARP packets when not doing so.
- Correctly detect expiry of selecting period.
- Speeds up negotiations.

Taken-from: OpenBSD

sbin/dhclient/dhclient-script
sbin/dhclient/dhclient.c

index ea1026e..d97a1e8 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $OpenBSD: src/sbin/dhclient/dhclient-script,v 1.13 2009/01/24 13:59:43 krw Exp $
+# $OpenBSD: src/sbin/dhclient/dhclient-script,v 1.18 2011/03/27 12:15:46 krw Exp $
 #
 # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org>
 #
@@ -146,7 +146,13 @@ PREINIT)
        ifconfig $interface up
        ;;
 
-ARPCHECK|ARPSEND)
+ARPCHECK)
+       # Always succeed. i.e. accept lease.
+       ;;
+
+ARPSEND)
+       # Always fail. i.e. don't wait for ARP packet here.
+       exit 1
        ;;
 
 BOUND|RENEW|REBIND|REBOOT)
index 79baeec..09ee1ff 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.137 2010/10/15 09:51:15 jsg Exp $    */
+/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.138 2011/03/27 12:15:46 krw Exp $    */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -479,7 +479,7 @@ state_reboot(void)
        make_request(client->active);
        client->destination = iaddr_broadcast;
        client->first_sending = cur_time;
-       client->interval = config->initial_interval;
+       client->interval = 0;
 
        /* Zap the medium list... */
        client->medium = NULL;
@@ -502,7 +502,7 @@ state_init(void)
        client->destination = iaddr_broadcast;
        client->state = S_SELECTING;
        client->first_sending = cur_time;
-       client->interval = config->initial_interval;
+       client->interval = 0;
 
        /* Add an immediate timeout to cause the first DHCPDISCOVER packet
           to go out. */
@@ -583,7 +583,7 @@ freeit:
        client->destination = iaddr_broadcast;
        client->state = S_REQUESTING;
        client->first_sending = cur_time;
-       client->interval = config->initial_interval;
+       client->interval = 0;
 
        /* Make a DHCPREQUEST packet from the lease we picked. */
        make_request(picked);
@@ -724,7 +724,7 @@ state_bound(void)
                client->destination = iaddr_broadcast;
 
        client->first_sending = cur_time;
-       client->interval = config->initial_interval;
+       client->interval = 0;
        client->state = S_RENEWING;
 
        /* Send the first packet immediately. */
@@ -829,7 +829,7 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options)
        /* If the selecting interval has expired, go immediately to
           state_selecting().  Otherwise, time out into
           state_selecting at the select interval. */
-       if (stop_selecting <= 0)
+       if (stop_selecting <= cur_time)
                state_selecting();
        else {
                add_timeout(stop_selecting, state_selecting);