summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2021-03-15 16:23:06 -0400
committerThomas Markwalder <tmark@isc.org>2021-03-15 16:23:06 -0400
commitde65604549d27a145e2868e19a5cad52ebb749a4 (patch)
tree2ddb22f96e658e3a3fdd3921dc49f6efebeb1900
parent79110e525e0584d195327d31f4ee67e6a5e2fe7a (diff)
downloadisc-dhcp-164-allow-update-conflict-detection-to-be-specified-at-class-scope.tar.gz
[#164] restore scope to update-conflict-detection164-allow-update-conflict-detection-to-be-specified-at-class-scope
server/ddns.c - ddns_updates() - replaced use oc copy_conflict_flags() with get_conflict_mask(). - ddns_removals() - changed logic to use conflict flags from pre-existing ddns_cb (if one) - get_conflict_mask() - altered to do a scoped look up of update-conflict-detection includes/dhcpd.h - Updated get_conflict_mask() declaration. server/dhcpd.c - postconf_initialization - updated call to get_conflict_mask() - added patch_string to version output
-rw-r--r--includes/dhcpd.h3
-rw-r--r--server/ddns.c48
-rw-r--r--server/dhcpd.c12
3 files changed, 40 insertions, 23 deletions
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index f9217ea8..5afa5f53 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -2241,7 +2241,8 @@ int ddns_updates(struct packet *, struct lease *, struct lease *,
struct iasubopt *, struct iasubopt *, struct option_state *);
isc_result_t ddns_removals(struct lease *, struct iasubopt *,
struct dhcp_ddns_cb *, isc_boolean_t);
-u_int16_t get_conflict_mask(struct option_state *input_options);
+void get_conflict_mask(u_int16_t *mask, struct binding_scope **scope,
+ struct option_state *options, struct packet *packet);
#if defined (TRACING)
void trace_ddns_init(void);
#endif
diff --git a/server/ddns.c b/server/ddns.c
index aecc3d38..fc6093eb 100644
--- a/server/ddns.c
+++ b/server/ddns.c
@@ -4,8 +4,7 @@
/*
*
- * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 2000-2003 by Internet Software Consortium
+ * Copyright (c) 2000-2021 by Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -604,7 +603,8 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old,
*/
if (ddns_cb->flags & DDNS_UPDATE_ADDR) {
- copy_conflict_flags(&ddns_cb->flags, ddns_conflict_mask);
+ /* Set the conflict behavior mask. */
+ get_conflict_mask(&ddns_cb->flags, scope, options, packet);
}
/*
@@ -2027,8 +2027,14 @@ ddns_removals(struct lease *lease,
goto cleanup;
}
- /* Set the conflict detection flags based on global configuration */
- copy_conflict_flags(&ddns_cb->flags, ddns_conflict_mask);
+ if (add_ddns_cb) {
+ /* Use the same flags we used on the associated add */
+ ddns_cb->flags = add_ddns_cb->flags;
+ }
+ else {
+ /* Set the conflict detection flags based on global configuration */
+ copy_conflict_flags(&ddns_cb->flags, ddns_conflict_mask);
+ }
/*
* For v4 we flag static leases so we don't try
@@ -2255,24 +2261,28 @@ void copy_conflict_flags(u_int16_t *target,
* Given an option_state, create a mask of conflict detection flags based
* on the appropriate configuration parameters within the option state.
*/
-u_int16_t
-get_conflict_mask(struct option_state *options) {
+void
+get_conflict_mask(uint16_t *mask, struct binding_scope **scope,
+ struct option_state *options, struct packet *packet) {
int ddns_update_conflict_detection = 1; /* default on */
int ddns_dual_stack_mixed_mode = 0; /* default off */
int ddns_guard_id_must_match = 1; /* default on */
int ddns_other_guard_is_dynamic = 0; /* default off */
struct option_cache *oc = NULL;
+ int ignorep = 0;
- u_int16_t mask = 0;
oc = lookup_option(&server_universe, options, SV_DDNS_CONFLICT_DETECT);
if (oc) {
+ struct option_state *in_options = (packet != NULL ?
+ packet->options : NULL);
ddns_update_conflict_detection =
- evaluate_boolean_option_cache(NULL, NULL, NULL, NULL, options,
- NULL, &global_scope, oc, MDL);
+ evaluate_boolean_option_cache(&ignorep, NULL, NULL,
+ NULL, in_options, NULL,
+ scope, oc, MDL);
}
- set_flag(&mask, DDNS_CONFLICT_DETECTION,
+ set_flag(mask, DDNS_CONFLICT_DETECTION,
ddns_update_conflict_detection);
if (!ddns_update_conflict_detection) {
@@ -2280,10 +2290,10 @@ get_conflict_mask(struct option_state *options) {
log_info ("DDNS conflict detection: off");
#endif
/* Turn the rest of the conflict related flags off */
- set_flag(&mask, DDNS_DUAL_STACK_MIXED_MODE, 0);
- set_flag(&mask, DDNS_GUARD_ID_MUST_MATCH, 0);
- set_flag(&mask, DDNS_OTHER_GUARD_IS_DYNAMIC, 0);
- return (mask);
+ set_flag(mask, DDNS_DUAL_STACK_MIXED_MODE, 0);
+ set_flag(mask, DDNS_GUARD_ID_MUST_MATCH, 0);
+ set_flag(mask, DDNS_OTHER_GUARD_IS_DYNAMIC, 0);
+ return;
}
// Get the values
@@ -2312,13 +2322,13 @@ get_conflict_mask(struct option_state *options) {
}
// Set the flags
- set_flag(&mask, DDNS_DUAL_STACK_MIXED_MODE,
+ set_flag(mask, DDNS_DUAL_STACK_MIXED_MODE,
ddns_dual_stack_mixed_mode);
- set_flag(&mask, DDNS_GUARD_ID_MUST_MATCH,
+ set_flag(mask, DDNS_GUARD_ID_MUST_MATCH,
ddns_guard_id_must_match);
- set_flag(&mask, DDNS_OTHER_GUARD_IS_DYNAMIC,
+ set_flag(mask, DDNS_OTHER_GUARD_IS_DYNAMIC,
ddns_other_guard_is_dynamic);
#if defined (DEBUG_DNS_UPDATES)
@@ -2334,7 +2344,7 @@ get_conflict_mask(struct option_state *options) {
ddns_guard_id_must_match,
ddns_other_guard_is_dynamic);
#endif
- return (mask);
+ return;
}
#if defined (DEBUG_DNS_UPDATES)
diff --git a/server/dhcpd.c b/server/dhcpd.c
index 6c2ceedd..de73cdf2 100644
--- a/server/dhcpd.c
+++ b/server/dhcpd.c
@@ -3,8 +3,7 @@
DHCP Server Daemon. */
/*
- * Copyright (c) 2004-2020 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-2003 by Internet Software Consortium
+ * Copyright (c) 1996-2021 by Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -204,9 +203,12 @@ static void omapi_listener_start (void *foo)
*/
static char use_noarg[] = "No argument for command: %s ";
+static char patch_string[] = " - patched for gitlab #164";
+
static void
usage(const char *sfmt, const char *sarg) {
log_info("%s %s", message, PACKAGE_VERSION);
+ log_info(patch_string);
log_info(copyright);
log_info(arr);
log_info(url);
@@ -336,6 +338,8 @@ main(int argc, char **argv) {
PACKAGE_VERSION,
strlen(PACKAGE_VERSION)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
+ IGNORE_RET(write(STDERR_FILENO, patch_string, strlen(patch_string)));
+ IGNORE_RET(write(STDERR_FILENO, "\n", 1));
exit (0);
} else if (!strcmp(argv[i], "--help") ||
!strcmp(argv[i], "-h")) {
@@ -612,6 +616,7 @@ main(int argc, char **argv) {
if (!quiet) {
log_info("%s %s", message, PACKAGE_VERSION);
+ log_info(patch_string);
log_info (copyright);
log_info (arr);
log_info (url);
@@ -1304,7 +1309,8 @@ void postconf_initialization (int quiet)
/* Set the conflict detection flag mask based on globally
* defined DDNS configuration params. This mask should be
* to init ddns_cb::flags before for every DDNS transaction. */
- ddns_conflict_mask = get_conflict_mask(options);
+ ddns_conflict_mask = 0;
+ get_conflict_mask(&ddns_conflict_mask, &global_scope, options, NULL);
#else
/* If we don't have support for updates compiled in tell the user */