]> 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:26:24 +0000 (10:26 -0400)
committerThomas Markwalder <tmark@isc.org>
Mon, 13 Jun 2016 14:26:24 +0000 (10:26 -0400)
    Merges in 42008.

RELNOTES
server/failover.c

index 720994d931609767e1f712ca98fc04ea22cb994a..11106063164fd893136aefa9903f874a51348673 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -69,6 +69,12 @@ by Eric Young (eay@cryptsoft.com).
   returned in responses.
   [ISC-Bugs #29246]
 
+- 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.1-ESV-R13b1
 
 - None
index d7ac4cd37fa4ac17459eebb17ecb698ebaaf6220..778c2a3efed166284920350562902f39c95fedd2 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 ()
@@ -2565,6 +2566,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 "
@@ -6358,3 +6360,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;
+        }
+}