From: krw Date: Wed, 24 Jan 2018 19:12:49 +0000 (+0000) Subject: Don't display the seconds until renewal. i.e. "em0: bound to 1.2.3.4 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1eb4aacd246191f64ac35aa5f309a947789a1d7b;p=openbsd Don't display the seconds until renewal. i.e. "em0: bound to 1.2.3.4 -- renewal in 300000 seconds" becomes simply "em0: bound to 1.2.3.4" While here avoid setting timeouts before the current time. ok florian@ --- diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 278becb16e0..f0393d0aa0b 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -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 @@ -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); } /* diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index f5916c9be55..ef3005baf92 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -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 @@ -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; }