summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2013-12-11 08:08:42 -0800
committerShawn Routhier <sar@isc.org>2013-12-11 08:08:42 -0800
commit61ef216b8dc05bc4245b61eee812038757d12ffe (patch)
tree5ad2e69325a491a95cbdf6bbb44be23c61764992
parent51e2e60626f0b86e4303ad4c68ba5106a7de8152 (diff)
downloadisc-dhcp-61ef216b8dc05bc4245b61eee812038757d12ffe.tar.gz
[master] Add support for user selection of the from address for DDNS transactions
-rw-r--r--RELNOTES6
-rw-r--r--client/dhclient.c3
-rw-r--r--dhcpctl/dhcpctl.c6
-rw-r--r--includes/dhcpd.h2
-rw-r--r--includes/omapip/isclib.h6
-rw-r--r--omapip/isclib.c165
-rw-r--r--omapip/test.c5
-rw-r--r--relay/dhcrelay.c3
-rw-r--r--server/dhcpd.c36
-rw-r--r--server/dhcpd.conf.514
-rw-r--r--server/stables.c4
-rw-r--r--server/tests/mdb6_unittest.c33
-rw-r--r--util/bind.sh4
13 files changed, 194 insertions, 93 deletions
diff --git a/RELNOTES b/RELNOTES
index 8e47c262..42f8c809 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -117,6 +117,12 @@ work on other platforms. Please report any problems and suggested fixes to
appropriate zone statements rather than using this functionality.
[ISC-Bugs #30461]
+- Add support for specifying the address from which to send
+ DDNS updates on the DHCP server. There are two new options
+ "ddns-local-address4" and "ddns-local-address6" that each take
+ one instance of their respective address types.
+ [ISC-Bugs #34779]
+
Changes since 4.2.5
- Address static analysis warnings.
diff --git a/client/dhclient.c b/client/dhclient.c
index 97b86a6f..12d4ede4 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -147,7 +147,8 @@ main(int argc, char **argv) {
#endif
/* Set up the isc and dns library managers */
- status = dhcp_context_create();
+ status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
if (status != ISC_R_SUCCESS)
log_fatal("Can't initialize context: %s",
isc_result_totext(status));
diff --git a/dhcpctl/dhcpctl.c b/dhcpctl/dhcpctl.c
index 5ec617ad..ccef925c 100644
--- a/dhcpctl/dhcpctl.c
+++ b/dhcpctl/dhcpctl.c
@@ -3,7 +3,8 @@
Subroutines providing general support for objects. */
/*
- * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2013 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -48,7 +49,8 @@ dhcpctl_status dhcpctl_initialize ()
isc_result_t status;
/* Set up the isc and dns library managers */
- status = dhcp_context_create();
+ status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
if (status != ISC_R_SUCCESS)
return status;
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index 7d0cfb1b..32c2a89a 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -733,6 +733,8 @@ struct lease_state {
#endif
#define SV_CACHE_THRESHOLD 78
#define SV_DONT_USE_FSYNC 79
+#define SV_DDNS_LOCAL_ADDRESS4 80
+#define SV_DDNS_LOCAL_ADDRESS6 81
#if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1
diff --git a/includes/omapip/isclib.h b/includes/omapip/isclib.h
index fbd0d652..831047ae 100644
--- a/includes/omapip/isclib.h
+++ b/includes/omapip/isclib.h
@@ -118,7 +118,11 @@ isclib_make_dst_key(char *inname,
int length,
dst_key_t **dstkey);
-isc_result_t dhcp_context_create(void);
+#define DHCP_CONTEXT_PRE_DB 1
+#define DHCP_CONTEXT_POST_DB 2
+isc_result_t dhcp_context_create(int flags,
+ struct in_addr *local4,
+ struct in6_addr *local6);
void isclib_cleanup(void);
void dhcp_signal_handler(int signal);
diff --git a/omapip/isclib.c b/omapip/isclib.c
index 7ef1591f..700bd88c 100644
--- a/omapip/isclib.c
+++ b/omapip/isclib.c
@@ -121,91 +121,110 @@ isclib_cleanup(void)
}
isc_result_t
-dhcp_context_create(void) {
+dhcp_context_create(int flags,
+ struct in_addr *local4,
+ struct in6_addr *local6) {
isc_result_t result;
- /*
- * Set up the error messages, this isn't the right place
- * for this call but it is convienent for now.
- */
- result = dhcp_result_register();
- if (result != ISC_R_SUCCESS) {
- log_fatal("register_table() %s: %u", "failed", result);
- }
+ if ((flags & DHCP_CONTEXT_PRE_DB) != 0) {
+ /*
+ * Set up the error messages, this isn't the right place
+ * for this call but it is convienent for now.
+ */
+ result = dhcp_result_register();
+ if (result != ISC_R_SUCCESS) {
+ log_fatal("register_table() %s: %u", "failed", result);
+ }
- memset(&dhcp_gbl_ctx, 0, sizeof (dhcp_gbl_ctx));
+ memset(&dhcp_gbl_ctx, 0, sizeof (dhcp_gbl_ctx));
- isc_lib_register();
+ isc_lib_register();
- /* get the current time for use as the random seed */
- gettimeofday(&cur_tv, (struct timezone *)0);
- isc_random_seed(cur_tv.tv_sec);
+ /* get the current time for use as the random seed */
+ gettimeofday(&cur_tv, (struct timezone *)0);
+ isc_random_seed(cur_tv.tv_sec);
#if defined (NSUPDATE)
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-#endif
-
- result = isc_mem_create(0, 0, &dhcp_gbl_ctx.mctx);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_appctx_create(dhcp_gbl_ctx.mctx, &dhcp_gbl_ctx.actx);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
+ result = dns_lib_init();
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+#else
+ /* The dst library is inited as part of dns_lib_init, we don't
+ * need it if NSUPDATE is enabled */
+ result = dst_lib_init(dhcp_gbl_ctx.mctx, NULL, 0);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
- result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
- if (result != ISC_R_SUCCESS)
- return (result);
- dhcp_gbl_ctx.actx_started = ISC_TRUE;
-
- result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- 1, 0,
- &dhcp_gbl_ctx.taskmgr);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_socketmgr_createinctx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- &dhcp_gbl_ctx.socketmgr);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_timermgr_createinctx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- &dhcp_gbl_ctx.timermgr);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = isc_task_create(dhcp_gbl_ctx.taskmgr, 0, &dhcp_gbl_ctx.task);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
+#endif
+ result = isc_mem_create(0, 0, &dhcp_gbl_ctx.mctx);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_appctx_create(dhcp_gbl_ctx.mctx,
+ &dhcp_gbl_ctx.actx);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
+ if (result != ISC_R_SUCCESS)
+ return (result);
+ dhcp_gbl_ctx.actx_started = ISC_TRUE;
+
+ result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ 1, 0,
+ &dhcp_gbl_ctx.taskmgr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_socketmgr_createinctx(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ &dhcp_gbl_ctx.socketmgr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_timermgr_createinctx(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ &dhcp_gbl_ctx.timermgr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = isc_task_create(dhcp_gbl_ctx.taskmgr, 0, &dhcp_gbl_ctx.task);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+ }
#if defined (NSUPDATE)
- result = dns_client_createx(dhcp_gbl_ctx.mctx,
- dhcp_gbl_ctx.actx,
- dhcp_gbl_ctx.taskmgr,
- dhcp_gbl_ctx.socketmgr,
- dhcp_gbl_ctx.timermgr,
- 0,
- &dhcp_gbl_ctx.dnsclient);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
- result = dhcp_dns_client_setservers();
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
-#else
- /* The dst library is inited as part of dns_lib_init, we don't
- * need it if NSUPDATE is enabled */
- result = dst_lib_init(dhcp_gbl_ctx.mctx, NULL, 0);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
+ if ((flags & DHCP_CONTEXT_POST_DB) != 0) {
+ isc_sockaddr_t localaddr4, *localaddr4_ptr = NULL;
+ isc_sockaddr_t localaddr6, *localaddr6_ptr = NULL;
+ if (local4 != NULL) {
+ isc_sockaddr_fromin(&localaddr4, local4, 0);
+ localaddr4_ptr = &localaddr4;
+ }
+ if (local6 != NULL) {
+ isc_sockaddr_fromin6(&localaddr6, local6, 0);
+ localaddr6_ptr = &localaddr6;
+ }
+ result = dns_client_createx2(dhcp_gbl_ctx.mctx,
+ dhcp_gbl_ctx.actx,
+ dhcp_gbl_ctx.taskmgr,
+ dhcp_gbl_ctx.socketmgr,
+ dhcp_gbl_ctx.timermgr,
+ 0,
+ &dhcp_gbl_ctx.dnsclient,
+ localaddr4_ptr,
+ localaddr6_ptr);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+
+ result = dhcp_dns_client_setservers();
+ if (result != ISC_R_SUCCESS)
+ goto cleanup;
+ }
#endif
+
return(ISC_R_SUCCESS);
cleanup:
diff --git a/omapip/test.c b/omapip/test.c
index 1171317b..9aadb9ba 100644
--- a/omapip/test.c
+++ b/omapip/test.c
@@ -3,7 +3,7 @@
Test code for omapip... */
/*
- * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2010,2013 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
@@ -51,7 +51,8 @@ int main (int argc, char **argv)
omapi_object_t *connection = (omapi_object_t*)0;
isc_result_t status;
- status = dhcp_context_create();
+ status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
if (status != ISC_R_SUCCESS) {
fprintf(stderr, "Can't initialize context: %s\n",
isc_result_totext(status));
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index b65731ce..e8cdcf3f 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -210,7 +210,8 @@ main(int argc, char **argv) {
#endif
/* Set up the isc and dns library managers */
- status = dhcp_context_create();
+ status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
if (status != ISC_R_SUCCESS)
log_fatal("Can't initialize context: %s",
isc_result_totext(status));
diff --git a/server/dhcpd.c b/server/dhcpd.c
index bfd84e00..cafc77c2 100644
--- a/server/dhcpd.c
+++ b/server/dhcpd.c
@@ -204,7 +204,8 @@ main(int argc, char **argv) {
close(fd);
/* Set up the isc and dns library managers */
- status = dhcp_context_create();
+ status = dhcp_context_create(DHCP_CONTEXT_PRE_DB,
+ NULL, NULL);
if (status != ISC_R_SUCCESS)
log_fatal("Can't initialize context: %s",
isc_result_totext(status));
@@ -807,6 +808,10 @@ void postconf_initialization (int quiet)
char *s;
isc_result_t result;
int tmp;
+#if defined (NSUPDATE)
+ struct in_addr local4, *local4_ptr = NULL;
+ struct in6_addr local6, *local6_ptr = NULL;
+#endif
/* Now try to get the lease file name. */
option_state_allocate(&options, MDL);
@@ -969,6 +974,35 @@ void postconf_initialization (int quiet)
if (ddns_update_style == DDNS_UPDATE_STYLE_AD_HOC) {
log_fatal("ddns-update-style ad_hoc no longer supported");
}
+
+ oc = lookup_option(&server_universe, options, SV_DDNS_LOCAL_ADDRESS4);
+ if (oc) {
+ if (evaluate_option_cache(&db, NULL, NULL, NULL, options, NULL,
+ &global_scope, oc, MDL)) {
+ if (db.len == 4) {
+ memcpy(&local4, db.data, 4);
+ local4_ptr = &local4;
+ }
+ data_string_forget(&db, MDL);
+ }
+ }
+
+ oc = lookup_option(&server_universe, options, SV_DDNS_LOCAL_ADDRESS6);
+ if (oc) {
+ if (evaluate_option_cache(&db, NULL, NULL, NULL, options, NULL,
+ &global_scope, oc, MDL)) {
+ if (db.len == 16) {
+ memcpy(&local6, db.data, 16);
+ local6_ptr = &local6;
+ }
+ data_string_forget(&db, MDL);
+ }
+ }
+
+ if (dhcp_context_create(DHCP_CONTEXT_POST_DB, local4_ptr, local6_ptr)
+ != ISC_R_SUCCESS)
+ log_fatal("Unable to complete ddns initialization");
+
#else
/* If we don't have support for updates compiled in tell the user */
if (ddns_update_style != DDNS_UPDATE_STYLE_NONE) {
diff --git a/server/dhcpd.conf.5 b/server/dhcpd.conf.5
index 84603c0f..5906c113 100644
--- a/server/dhcpd.conf.5
+++ b/server/dhcpd.conf.5
@@ -1973,10 +1973,23 @@ appended to the client's hostname to form a fully-qualified
domain-name (FQDN).
.RE
.PP
+The \fddns-local-address4\fR and \fddns-local-address6\fR statements
+.RS 0.25i
+.PP
+.B ddns-local-address4 \fIaddress\fB;\fR
+.PP
+.B ddns-local-address6 \fIaddress\fB;\fR
+.PP
+The \fIaddress\fR parameter should be the local IPv4 or IPv6 address
+the server should use as the from address when sending DDNS update
+requests.
+.RE
+.PP
The \fIddns-rev-domainname\fR statement
.RS 0.25i
.PP
.B ddns-rev-domainname \fIname\fB;\fR
+.PP
The \fIname\fR parameter should be the domain name that will be
appended to the client's reversed IP address to produce a name for use
in the client's PTR record. By default, this is "in-addr.arpa.", but
@@ -2043,6 +2056,7 @@ statements
.RS 0.25i
.PP
.B delayed-ack \fIcount\fR\fB;\fR
+.PP
.B max-ack-delay \fImicroseconds\fR\fB;\fR
.PP
.I Count
diff --git a/server/stables.c b/server/stables.c
index 37758cc1..bac6f8dc 100644
--- a/server/stables.c
+++ b/server/stables.c
@@ -268,6 +268,10 @@ static struct option server_options[] = {
#endif /* LDAP_CONFIGURATION */
{ "dhcp-cache-threshold", "B", &server_universe, 78, 1 },
{ "dont-use-fsync", "f", &server_universe, 79, 1 },
+
+ { "ddns-local-address4", "I", &server_universe, 80, 1 },
+ { "ddns-local-address6", "6", &server_universe, 81, 1 },
+
{ NULL, NULL, NULL, 0, 0 }
};
diff --git a/server/tests/mdb6_unittest.c b/server/tests/mdb6_unittest.c
index 56b47184..15858ffa 100644
--- a/server/tests/mdb6_unittest.c
+++ b/server/tests/mdb6_unittest.c
@@ -51,7 +51,8 @@ ATF_TC_BODY(iaaddr_basic, tc)
struct iasubopt *iaaddr_copy;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
iaaddr = NULL;
@@ -95,7 +96,8 @@ ATF_TC_BODY(iaaddr_negative, tc)
struct iasubopt *iaaddr_copy;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* tests */
/* bogus allocate arguments */
@@ -156,7 +158,8 @@ ATF_TC_BODY(ia_na_basic, tc)
struct iasubopt *iaaddr;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
iaid = 666;
@@ -219,7 +222,8 @@ ATF_TC_BODY(ia_na_manyaddrs, tc)
int i;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* tests */
/* lots of iaaddr that we delete */
@@ -294,7 +298,8 @@ ATF_TC_BODY(ia_na_negative, tc)
struct ia_xx *ia_na_copy;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* tests */
/* bogus allocate arguments */
@@ -370,7 +375,8 @@ ATF_TC_BODY(ipv6_pool_basic, tc)
unsigned int attempts;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
inet_pton(AF_INET6, "1:2:3:4::", &addr);
@@ -515,7 +521,8 @@ ATF_TC_BODY(ipv6_pool_negative, tc)
struct ipv6_pool *pool_copy;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
inet_pton(AF_INET6, "1:2:3:4::", &addr);
@@ -574,7 +581,8 @@ ATF_TC_BODY(expire_order, tc)
unsigned int attempts;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
inet_pton(AF_INET6, "1:2:3:4::", &addr);
@@ -673,7 +681,8 @@ ATF_TC_BODY(expire_order_reduce, tc)
unsigned int attempts;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
inet_pton(AF_INET6, "1:2:3:4::", &addr);
@@ -794,7 +803,8 @@ ATF_TC_BODY(small_pool, tc)
unsigned int attempts;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
inet_pton(AF_INET6, "1:2:3:4::", &addr);
@@ -865,7 +875,8 @@ ATF_TC_BODY(many_pools, tc)
struct ipv6_pool *pool;
/* set up dhcp globals */
- dhcp_context_create();
+ dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB,
+ NULL, NULL);
/* and other common arguments */
inet_pton(AF_INET6, "1:2:3:4::", &addr);
diff --git a/util/bind.sh b/util/bind.sh
index 59ca3426..e432c3be 100644
--- a/util/bind.sh
+++ b/util/bind.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2009-2012 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2009-2013 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -50,6 +50,7 @@ case $# in
### be used to chdir down into the directory that is unpacked.
###
v4_2) noSNAP=snapshot BINDTAG=v9_8 ;;
+ v4_3) noSNAP=snapshot BINDTAG=v9_9 ;;
### change to using the head of v9_9 until we upgrade DHCP
### to use shared libraries
HEAD|v[0-9]_[0-9].*) noSNAP=snapshot BINDTAG=v9_9 ;;
@@ -58,6 +59,7 @@ case $# in
### For ease of use, this records the sticky tag of versions
### released with each point release.
###
+ 4.3.0a1) BINDTAG=v9_9 ;;
4.2.6b1) BINDTAG=v9_8_6 ;;
4.2.5b1|4.2.5rc1) BINDTAG=v9_8_4_P1 ;;
4.2.4rc2|4.2.4) BINDTAG=v9_8_3 ;;