]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Scrub leases when they are re-balanced
authorThomas Markwalder <tmark@isc.org>
Mon, 13 Jun 2016 14:01:48 +0000 (10:01 -0400)
committerThomas Markwalder <tmark@isc.org>
Mon, 13 Jun 2016 14:01:48 +0000 (10:01 -0400)
    Merges in 42008.

RELNOTES
server/failover.c

index 06d420bb599ccc8447dec7c710c193432a655ee2..188b46d90726ad2deeb911a49f58a572768f9c9b 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -71,6 +71,12 @@ by Eric Young (eay@cryptsoft.com).
   otherwise harmless error message when running "make check".
   [ISC-Bugs #41883]
 
+- Leases are now scrubbed of certain prior use information when pool
+  re-balancing reassigns them from one FO peer to the other.  This
+  corrects an issue where leases that were offered but ignored retained
+  the client hostname from the original client.
+  [ISC-Bugs #42008]
+
                        Changes since 4.3.4b1
 
 - None
index b2cfa5c21cdf6fa0e30c0d045a973b95c8ec7675..12ba123d874bf1ef9d614f82bfef4ab7e7e9c98c 100644 (file)
@@ -48,6 +48,7 @@ static int dhcp_failover_pool_dobalance(dhcp_failover_state_t *state,
                                        isc_boolean_t *sendreq);
 static inline int secondary_not_hoarding(dhcp_failover_state_t *state,
                                         struct pool *p);
+static void scrub_lease(struct lease* lease, const char *file, int line);
 
 
 void dhcp_failover_startup ()
@@ -2618,6 +2619,7 @@ dhcp_failover_pool_dobalance(dhcp_failover_state_t *state,
                            lp->tstp = cur_time;
                            lp->starts = cur_time;
 
+                           scrub_lease(lp, MDL);
                            if (!supersede_lease(lp, NULL, 0, 1, 0, 0) ||
                                !write_lease(lp))
                                    log_error("can't commit lease %s on "
@@ -6502,3 +6504,48 @@ const char *binding_state_print (enum failover_state state)
                break;
        }
 }
+
+
+/*!
+ * \brief Given a char pointer, return always return a printable value
+ *
+ * This function is intended to be used in within log statements, such that
+ * its invocation only occurs if the logging level is enabled.
+ *
+ * \param value pointer the character to print
+ *
+ * \return If value is null, returns the string "<none>", if it contains
+ * non-printable bytes, returns the string "<unsuitable for printing>",
+ * otherwise it returns a const pointer to value
+ */
+const char *printable(const char* value) {
+       const char *print_value = "<none>";
+       if (value) {
+               if ((strlen (value) <= 64) &&
+                    db_printable((unsigned char*)value)) {
+                       print_value = value;
+               }
+                else {
+                        print_value = "<unsuitable for printing>";
+               }
+       }
+
+       return (print_value);
+}
+
+/*!
+ * \brief Remove information from a prior use of a lease
+ *
+ * Remove information from a lease that is not germain to lease affinity
+ *
+ * \param lease the lease to scrub
+ */
+void scrub_lease(struct lease* lease, const char *file, int line) {
+       log_debug ("%s(%d):scrubbing lease for %s, hostname: %s", file, line,
+                  piaddr(lease->ip_addr), printable(lease->client_hostname));
+
+        if (lease->client_hostname) {
+                dfree (lease->client_hostname, MDL);
+                lease->client_hostname = (char *)0;
+        }
+}