2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-01 23:05:29 +00:00

[master] Add support for user selection of the from address for DDNS transactions

This commit is contained in:
Shawn Routhier
2013-12-11 08:08:42 -08:00
parent 51e2e60626
commit 61ef216b8d
13 changed files with 199 additions and 98 deletions

View File

@@ -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.

View File

@@ -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));

View File

@@ -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;

View File

@@ -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

View File

@@ -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);

View File

@@ -121,9 +121,12 @@ 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;
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.
@@ -145,13 +148,20 @@ dhcp_context_create(void) {
result = dns_lib_init();
if (result != ISC_R_SUCCESS)
goto cleanup;
#endif
#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;
#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);
result = isc_appctx_create(dhcp_gbl_ctx.mctx,
&dhcp_gbl_ctx.actx);
if (result != ISC_R_SUCCESS)
goto cleanup;
@@ -182,30 +192,39 @@ dhcp_context_create(void) {
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,
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);
&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;
#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;
}
#endif
return(ISC_R_SUCCESS);
cleanup:

View File

@@ -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));

View File

@@ -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));

View File

@@ -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) {

View File

@@ -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

View File

@@ -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 }
};

View File

@@ -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);

View File

@@ -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 ;;