]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Add support for user selection of the from address for DDNS transactions
authorShawn Routhier <sar@isc.org>
Wed, 11 Dec 2013 16:08:42 +0000 (08:08 -0800)
committerShawn Routhier <sar@isc.org>
Wed, 11 Dec 2013 16:08:42 +0000 (08:08 -0800)
13 files changed:
RELNOTES
client/dhclient.c
dhcpctl/dhcpctl.c
includes/dhcpd.h
includes/omapip/isclib.h
omapip/isclib.c
omapip/test.c
relay/dhcrelay.c
server/dhcpd.c
server/dhcpd.conf.5
server/stables.c
server/tests/mdb6_unittest.c
util/bind.sh

index 8e47c2621f9d7a4566de4a82bd847ac41e426556..42f8c809a18058daa5572b1de15db41a882cbd31 100644 (file)
--- 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.
index 97b86a6f93c34caef7b34f31858f5874efa9e726..12d4ede402e14759783f306a48dc684e8219aad3 100644 (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));
index 5ec617adf712369b4f6df45173bb160766302bd8..ccef925ce299396ff1d6cd53101d6bab295e4038 100644 (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;
 
index 7d0cfb1bfdd763192e5a670c5f9a32bb09a6b928..32c2a89a974bfc64f3a625d5fecadeee2b9812c0 100644 (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
index fbd0d652ff6ee88bdc51cbb2a83c0311c90c0fc7..831047ae32a66fb05fb6aa673187b9b10d2029ff 100644 (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);
index 7ef1591f3407f044ef0ca7000f8df52233c32d86..700bd88cf4a3a8f119be9ceee71403750efa850b 100644 (file)
@@ -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:
index 1171317b989abcc4a2404975b85059edd877532c..9aadb9ba20c2704e0406fe207be54a74f772008b 100644 (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));
index b65731ced97715df3ce60ce9afd7c54ce1350190..e8cdcf3fcc6454cad1ef34202ddab41e1ed34f42 100644 (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));
index bfd84e004b3b204543688b50f71d0d1ac3d17d54..cafc77c2a442b5765fb42191ac8464339316a04d 100644 (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) {
index 84603c0fd37d8f81f61a23a0d68f680228d0e900..5906c11340550af256bc0b0d775fa81d3ec9d8ce 100644 (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
index 37758cc15d0a4ad2ea89d0713020a023347ff930..bac6f8dcb566c28347d0dff4345331d438a45b38 100644 (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 }
 };
 
index 56b47184d08a1274ddb9857b0a0efef5f315f00d..15858ffa9ff815158d71b3939a2121d3629100f1 100644 (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);
index 59ca3426c4dc76cccb9aa85250e1c77cc5392c9b..e432c3bea64c0f666588a5d958de2555474e49bb 100644 (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 ;;