diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2018-02-07 01:03:11 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2018-02-07 01:03:11 +0000 |
commit | 8e1cda935e652bbbddcc679878fb39b60baa10b1 (patch) | |
tree | 178710e5508a1d4800ab9d02a260917c518278e7 /sbin | |
parent | 3006c43c444754ca61b618a05b637710bbe1dfab (diff) |
Keep track of the last proposal used to configure the interface and
compare that to the offered proposal to determine if there are any
changes to configure. Simpler, and fixes issue where using a recorded
lease meant the interface was continually being configured with the
same information.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.c | 45 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 3 |
2 files changed, 20 insertions, 28 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 0dbcfd75947..51522ad0687 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.559 2018/02/06 23:45:15 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.560 2018/02/07 01:03:10 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -945,7 +945,6 @@ void bind_lease(struct interface_info *ifi) { struct client_lease *lease, *pl; - struct proposal *active_proposal = NULL; struct proposal *offered_proposal = NULL; struct proposal *effective_proposal = NULL; char *msg; @@ -975,39 +974,32 @@ bind_lease(struct interface_info *ifi) ifi->rebind = lease_rebind(lease); renewal = lease_renewal(lease); - /* - * A duplicate proposal once we are responsible & S_RENEWING means we - * don't need to change the interface, routing table or resolv.conf. - */ - if ((ifi->flags & IFI_IN_CHARGE) && ifi->state == S_RENEWING) { - active_proposal = lease_as_proposal(ifi->active); - offered_proposal = lease_as_proposal(ifi->offer); - if (memcmp(active_proposal, offered_proposal, - sizeof(*active_proposal)) == 0) { - ifi->active = ifi->offer; - ifi->offer = NULL; - goto newlease; - } - } - /* Replace the old active lease with the accepted offer. */ ifi->active = ifi->offer; ifi->offer = NULL; + effective_proposal = lease_as_proposal(lease); + if (ifi->configured != NULL) { + if (memcmp(ifi->configured, effective_proposal, + sizeof(*ifi->configured)) == 0) + goto newlease; + } + free(ifi->configured); + ifi->configured = effective_proposal; + effective_proposal = NULL; set_resolv_conf(ifi->name, - effective_proposal->rtsearch, - effective_proposal->rtsearch_len, - effective_proposal->rtdns, - effective_proposal->rtdns_len); + ifi->configured->rtsearch, + ifi->configured->rtsearch_len, + ifi->configured->rtdns, + ifi->configured->rtdns_len); - set_mtu(effective_proposal->inits, effective_proposal->mtu); + set_mtu(ifi->configured->inits, ifi->configured->mtu); - set_address(ifi->name, effective_proposal->ifa, - effective_proposal->netmask); + set_address(ifi->name, ifi->configured->ifa, ifi->configured->netmask); - set_routes(effective_proposal->ifa, effective_proposal->netmask, - effective_proposal->rtstatic, effective_proposal->rtstatic_len); + set_routes(ifi->configured->ifa, ifi->configured->netmask, + ifi->configured->rtstatic, ifi->configured->rtstatic_len); rslt = asprintf(&msg, "bound to %s from %s", inet_ntoa(ifi->active->address), @@ -1032,7 +1024,6 @@ newlease: go_daemon(); rewrite_option_db(ifi->name, ifi->active, lease); free_client_lease(lease); - free(active_proposal); free(offered_proposal); free(effective_proposal); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 22de7fee676..8ea19c15124 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.251 2018/02/06 21:09:10 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.252 2018/02/07 01:03:10 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -146,6 +146,7 @@ struct interface_info { struct client_lease *active; struct client_lease *offer; char *offer_src; + struct proposal *configured; struct client_lease_tq lease_db; }; |