From 124ac52daa8ed7fe2a52a8aec45915979c37350f Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 21 Jun 2017 15:49:27 +0000 Subject: [PATCH] No need to manually check validity of ifi->active when REBOOT'ing. It will be pointing to a recorded lease if anything. So rely on get_recorded_lease() to return the next valid candidate lease, which might be the lease ifi->active was pointing at. --- sbin/dhclient/dhclient.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 95111d292c1..d025cf043e9 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.441 2017/06/21 15:24:34 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.442 2017/06/21 15:49:27 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -749,25 +749,17 @@ state_preboot(struct interface_info *ifi) void state_reboot(struct interface_info *ifi) { - char ifname[IF_NAMESIZE]; - time_t cur_time; - cancel_timeout(ifi); + deleting.s_addr = INADDR_ANY; adding.s_addr = INADDR_ANY; - time(&cur_time); - if (ifi->active) { - if (ifi->active->expiry <= cur_time) - ifi->active = NULL; - else if (addressinuse(ifi, ifi->active->address, ifname) && - strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) - ifi->active = NULL; - } else - ifi->active = get_recorded_lease(ifi); - - /* No active lease, or the lease is BOOTP, go straight to INIT. */ - if (!ifi->active || BOOTP_LEASE(ifi->active)) { + /* + * If there is no recorded lease or the lease is BOOTP then + * go straight to INIT and try to DISCOVER a new lease. + */ + ifi->active = get_recorded_lease(ifi); + if (ifi->active == NULL || BOOTP_LEASE(ifi->active)) { ifi->state = S_INIT; state_init(ifi); return; -- 2.20.1