Don't display the seconds until renewal. i.e. "em0: bound to 1.2.3.4
authorkrw <krw@openbsd.org>
Wed, 24 Jan 2018 19:12:49 +0000 (19:12 +0000)
committerkrw <krw@openbsd.org>
Wed, 24 Jan 2018 19:12:49 +0000 (19:12 +0000)
-- renewal in 300000 seconds" becomes simply "em0: bound to 1.2.3.4"

While here avoid setting timeouts before the current time.

ok florian@

sbin/dhclient/dhclient.c
sbin/dhclient/dispatch.c

index 278becb..f0393d0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dhclient.c,v 1.543 2017/12/20 18:51:14 krw Exp $      */
+/*     $OpenBSD: dhclient.c,v 1.544 2018/01/24 19:12:49 krw Exp $      */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -970,14 +970,12 @@ bind_lease(struct interface_info *ifi)
         * renewal == time to renew lease from server that provided it.
         * rebind  == time to renew lease from any server.
         *
-        * 0 <= renewal <= rebind <= expiry
-        * &&
-        * expiry >= MIN(time_max, 60)
+        * N.B.: renewal and/or rebind time could be < cur_time when the
+        *       lease was obtained from the leases file.
         */
        ifi->expiry = lease_expiry(lease);
        ifi->rebind = lease_rebind(lease);
-
-       renewal = lease_renewal(lease) - cur_time;
+       renewal = lease_renewal(lease);
 
        /*
         * A duplicate proposal once we are responsible & S_RENEWING means we
@@ -1015,8 +1013,8 @@ bind_lease(struct interface_info *ifi)
 
 newlease:
        write_resolv_conf();
-       log_info("%s: bound to %s -- renewal in %lld seconds", log_procname,
-           inet_ntoa(ifi->active->address), (long long)renewal);
+       log_info("%s: bound to %s", log_procname,
+           inet_ntoa(ifi->active->address));
        go_daemon(ifi->name);
        rewrite_option_db(ifi->name, ifi->active, lease);
        free_client_lease(lease);
@@ -1054,7 +1052,7 @@ newlease:
        ifi->state = S_BOUND;
 
        /* Set timeout to start the renewal process. */
-       set_timeout(ifi, renewal, state_bound);
+       set_timeout(ifi, renewal - cur_time, state_bound);
 }
 
 /*
index f5916c9..ef3005b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dispatch.c,v 1.146 2017/09/20 22:05:10 krw Exp $      */
+/*     $OpenBSD: dispatch.c,v 1.147 2018/01/24 19:12:49 krw Exp $      */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -325,7 +325,8 @@ set_timeout(struct interface_info *ifi, time_t secs,
     void (*where)(struct interface_info *))
 {
        time(&ifi->timeout);
-       ifi->timeout += secs;
+       if (secs > 0)
+               ifi->timeout += secs;
        ifi->timeout_func = where;
 }