philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-dns_client_cancelupdate.patch

54343e
diff -up dhcp-4.2.5/client/dhclient.c.dns_client_cancelupdate dhcp-4.2.5/client/dhclient.c
54343e
--- dhcp-4.2.5/client/dhclient.c.dns_client_cancelupdate	2015-06-25 14:31:27.309035906 +0200
54343e
+++ dhcp-4.2.5/client/dhclient.c	2015-06-25 14:34:26.477642016 +0200
54343e
@@ -121,6 +121,8 @@ static int check_option_values(struct un
54343e
 			       const char *ptr, size_t len);
54343e
 
54343e
 static void setup_ib_interface(struct interface_info *ip);
54343e
+static void dhclient_ddns_cb_free(dhcp_ddns_cb_t *ddns_cb,
54343e
+                                   char* file, int line);
54343e
 
54343e
 int
54343e
 main(int argc, char **argv) {
54343e
@@ -4306,7 +4308,7 @@ client_dns_remove_action(dhcp_ddns_cb_t
54343e
 	}
54343e
 
54343e
 	/* If we are done or have an error clean up */
54343e
-	ddns_cb_free(ddns_cb, MDL);
54343e
+	dhclient_ddns_cb_free(ddns_cb, MDL);
54343e
 	return;
54343e
 }
54343e
 
54343e
@@ -4335,7 +4337,7 @@ client_dns_remove(struct client_state *c
54343e
 		result = client_dns_update(client, ddns_cb);
54343e
 
54343e
 		if (result != ISC_R_TIMEDOUT) {
54343e
-			ddns_cb_free(ddns_cb, MDL);
54343e
+			dhclient_ddns_cb_free(ddns_cb, MDL);
54343e
 		}
54343e
 	}
54343e
 }
54343e
@@ -4418,10 +4420,7 @@ client_dns_update_timeout (void *cp)
54343e
 	 * the control block and should free it.
54343e
 	 */
54343e
 	if (status != ISC_R_TIMEDOUT) {
54343e
-		if (client != NULL) {
54343e
-			client->ddns_cb = NULL;
54343e
-		}
54343e
-		ddns_cb_free(ddns_cb, MDL);
54343e
+		dhclient_ddns_cb_free(ddns_cb, MDL);
54343e
 	}
54343e
 }
54343e
 
54343e
@@ -4510,7 +4509,7 @@ client_dns_update_action(dhcp_ddns_cb_t
54343e
 		return;
54343e
 	}
54343e
 
54343e
-	ddns_cb_free(ddns_cb, MDL);
54343e
+	dhclient_ddns_cb_free(ddns_cb, MDL);
54343e
 	return;
54343e
 }
54343e
 
54343e
@@ -4873,3 +4872,17 @@ add_reject(struct packet *packet) {
54343e
 	 */
54343e
 	log_info("Server added to list of rejected servers.");
54343e
 }
54343e
+
54343e
+/* Wrapper function around common ddns_cb_free function that ensures
54343e
+ * we set the client_state pointer to the control block to NULL. */
54343e
+static void
54343e
+dhclient_ddns_cb_free(dhcp_ddns_cb_t *ddns_cb, char* file, int line) {
54343e
+    if (ddns_cb) {
54343e
+        struct client_state *client = (struct client_state *)ddns_cb->lease;
54343e
+        if (client != NULL) {
54343e
+            client->ddns_cb = NULL;
54343e
+        }
54343e
+
54343e
+        ddns_cb_free(ddns_cb, file, line);
54343e
+    }
54343e
+}