[dhcp] Check lease for unexpired addresses prior to confirming it (#585418)

Jiří Popelka jpopelka at fedoraproject.org
Thu Oct 7 12:02:14 UTC 2010


commit 290660e57ac83a56ea5afbb4f15e771226af4140
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Thu Oct 7 13:48:09 2010 +0200

    Check lease for unexpired addresses prior to confirming it (#585418)

 dhcp-4.2.0-honor-expired.patch |   52 ++++++++++++++++++++++++++++++++++++++++
 dhcp.spec                      |   11 +++++++-
 2 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/dhcp-4.2.0-honor-expired.patch b/dhcp-4.2.0-honor-expired.patch
new file mode 100644
index 0000000..45eadfa
--- /dev/null
+++ b/dhcp-4.2.0-honor-expired.patch
@@ -0,0 +1,52 @@
+diff -up dhcp-4.2.0/client/dhc6.c.honor-expired dhcp-4.2.0/client/dhc6.c
+--- dhcp-4.2.0/client/dhc6.c.honor-expired	2010-10-07 12:55:37.000000000 +0200
++++ dhcp-4.2.0/client/dhc6.c	2010-10-07 12:56:43.000000000 +0200
+@@ -1405,6 +1405,35 @@ start_info_request6(struct client_state 
+ 		go_daemon();
+ }
+ 
++/* Run through the addresses in lease and return true if there's any unexpired.
++ * Return false otherwise.
++ */
++isc_boolean_t
++unexpired_address_in_lease(struct dhc6_lease *lease)
++{
++	struct dhc6_ia *ia;
++	struct dhc6_addr *addr;
++
++	if (lease == NULL)
++		return;
++
++	for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
++		for (addr = ia->addrs ; addr != NULL ; addr = addr->next) {
++			if (addr->flags & DHC6_ADDR_EXPIRED)
++				continue;
++
++			if (addr->starts + addr->max_life > cur_time) {
++				return ISC_TRUE;
++			}
++		}
++	}
++
++	log_info("PRC: Previous lease is devoid of active addresses."
++		 "  Re-initializing.");
++
++	return ISC_FALSE;
++}
++
+ /*
+  * start_confirm6() kicks off an "init-reboot" version of the process, at
+  * startup to find out if old bindings are 'fair' and at runtime whenever
+@@ -1417,8 +1446,10 @@ start_confirm6(struct client_state *clie
+ 
+ 	/* If there is no active lease, there is nothing to check. */
+ 	if ((client->active_lease == NULL) ||
+-	    !active_prefix(client) ||
+-	    client->active_lease->released) {
++		!active_prefix(client) ||
++		client->active_lease->released ||
++		!unexpired_address_in_lease(client->active_lease)) {
++		dhc6_lease_destroy(&client->active_lease, MDL);
+ 		start_init6(client);
+ 		return;
+ 	}
diff --git a/dhcp.spec b/dhcp.spec
index 2447364..cd571d1 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -7,7 +7,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.2.0
-Release:  9%{?dist}
+Release:  10%{?dist}
 # NEVER CHANGE THE EPOCH on this package.  The previous maintainer (prior to
 # dcantrell maintaining the package) made incorrect use of the epoch and
 # that's why it is at 12 now.  It should have never been used, but it was.
@@ -55,6 +55,7 @@ Patch26:  dhcp-4.2.0-initialization-delay.patch
 Patch27:  dhcp-4.2.0-parse_date.patch
 Patch28:  dhcp-4.2.0-rfc3442-classless-static-routes.patch
 Patch29:  dhcp-4.2.0-PIE-RELRO.patch
+Patch30:  dhcp-4.2.0-honor-expired.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: autoconf
@@ -234,6 +235,10 @@ libdhcpctl and libomapi static libraries are also included in this package.
 # hardening dhcpd/dhcrelay/dhclient by making them PIE & RELRO
 %patch29 -p1 -b .PIE-RELRO
 
+# check whether there is any unexpired address in previous lease
+# prior to confirming (INIT-REBOOT) the lease (#585418)
+%patch30 -p1 -b .honor-expired
+
 # Copy in the Fedora/RHEL dhclient script
 %{__install} -p -m 0755 %{SOURCE4} client/scripts/linux
 %{__install} -p -m 0644 %{SOURCE5} .
@@ -515,6 +520,10 @@ fi
 %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
 
 %changelog
+* Thu Oct 07 2010 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.0-10
+- Check whether there is any unexpired address in previous lease
+  prior to confirming (INIT-REBOOT) the lease (#585418)
+
 * Mon Oct 04 2010 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.0-9
 - RFC 3442 - ignore Router option only if
   Classless Static Routes option contains default router


More information about the scm-commits mailing list