]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] skip unnecesary also-notify data
authorEvan Hunt <each@isc.org>
Mon, 20 Jan 2014 23:53:51 +0000 (15:53 -0800)
committerEvan Hunt <each@isc.org>
Mon, 20 Jan 2014 23:53:51 +0000 (15:53 -0800)
3713. [bug] Save memory by not storing "also-notify" addresses
in zone objects that are configured not to send
notify requests. [RT #35195]

CHANGES
bin/named/zoneconf.c
bin/tests/system/checkconf/notify.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh
lib/bind9/check.c

diff --git a/CHANGES b/CHANGES
index 079d3298d29a5ef68aa08ac151b4215a2c3aae86..4c254f2f01c671180e1b8241051b52f0be114176 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3713.  [bug]           Save memory by not storing "also-notify" addresses
+                       in zone objects that are configured not to send
+                       notify requests. [RT #35195]
+
 3712.  [placeholder]
 
 3711.  [placeholder]
index 313599fc9fce2c1ceecedbc43e99aa1f990cccfc..a98f0eb66350b41ab2a726dfa540d1ee7fe7f8a3 100644 (file)
@@ -1101,7 +1101,12 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
 
                obj = NULL;
                result = ns_config_get(maps, "also-notify", &obj);
-               if (result == ISC_R_SUCCESS) {
+               if (result == ISC_R_SUCCESS &&
+                   (notifytype == dns_notifytype_yes ||
+                    notifytype == dns_notifytype_explicit ||
+                    (notifytype == dns_notifytype_masteronly &&
+                     ztype == dns_zone_master)))
+               {
                        isc_uint32_t addrcount;
                        addrs = NULL;
                        keynames = NULL;
diff --git a/bin/tests/system/checkconf/notify.conf b/bin/tests/system/checkconf/notify.conf
new file mode 100644 (file)
index 0000000..339def7
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2014  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
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+view one {
+       notify master-only;
+
+        # also-notify inconsistent with master-only notify option
+       zone "slave" {
+               type slave;
+               masters { 1.2.3.4; };
+               also-notify { 5.6.7.8; };
+       };
+
+        # OK
+       zone "master" {
+               type master;
+               file "filename";
+               also-notify { 5.6.7.8; };
+       };
+};
+
+view two {
+       notify no;
+
+        # also-notify inconsistent with notify option at the view level
+       zone "slave" {
+               type slave;
+               masters { 1.2.3.4; };
+               also-notify { 5.6.7.8; };
+       };
+
+        # OK
+       zone "master" {
+               type master;
+               file "filename";
+               notify yes;
+               also-notify { 5.6.7.8; };
+       };
+};
+
+view three {
+        # also-notify inconsistent with notify option at the zone level
+       zone "slave" {
+               type slave;
+               masters { 1.2.3.4; };
+               notify no;
+               also-notify { 5.6.7.8; };
+       };
+
+        # OK
+       zone "master" {
+               type master;
+               file "filename";
+               also-notify { 5.6.7.8; };
+       };
+};
+
+view four {
+        also-notify { 5.6.7.8; };
+
+        # OK
+       zone "slave" {
+               type slave;
+               masters { 1.2.3.4; };
+               notify master-only;
+       };
+
+        # OK
+       zone "master" {
+               type master;
+               file "filename";
+                notify no;
+       };
+};
index 080e58f32a4a8eb7643ab995f4a46b10867ce5d2..3d07b2a43509cb3b74694795ca050c3e301c6588 100644 (file)
@@ -65,6 +65,13 @@ $CHECKCONF range.conf > /dev/null 2>&1 && ret=1
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+echo "I: checking that named-checkconf warns of notify inconsistencies"
+ret=0
+warnings=`$CHECKCONF notify.conf 2>&1 | grep "'notify' is disabled" | wc -l`
+[ $warnings -eq 3 ] || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I: checking named-checkconf dnssec warnings"
 ret=0
 $CHECKCONF dnssec.1 2>&1 | grep 'validation yes.*enable no' > /dev/null || ret=1
index 13b051b116ca28ec28a5b17463e295ac31276954..ae9a38ab15b4eace4e4433ded04a5c9f33c5fe4c 100644 (file)
@@ -1664,12 +1664,36 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
        }
 
        /*
-        * Master & slave zones must have a "also-notify" field.
+        * Master & slave zones may have an "also-notify" field, but
+        * shouldn't if notify is disabled.
         */
        if (ztype == MASTERZONE || ztype == SLAVEZONE ) {
+               isc_boolean_t donotify = ISC_TRUE;
+
                obj = NULL;
-               tresult = cfg_map_get(zoptions, "also-notify", &obj);
+               tresult = cfg_map_get(zoptions, "notify", &obj);
+               if (tresult != ISC_R_SUCCESS && voptions != NULL)
+                       tresult = cfg_map_get(voptions, "notify", &obj);
+               if (tresult != ISC_R_SUCCESS && goptions != NULL)
+                       tresult = cfg_map_get(goptions, "notify", &obj);
                if (tresult == ISC_R_SUCCESS) {
+                       if (cfg_obj_isboolean(obj))
+                               donotify = cfg_obj_asboolean(obj);
+                       else {
+                               const char *notifystr = cfg_obj_asstring(obj);
+                               if (ztype != MASTERZONE &&
+                                   strcasecmp(notifystr, "master-only") == 0)
+                                       donotify = ISC_FALSE;
+                       }
+               }
+
+               obj = NULL;
+               tresult = cfg_map_get(zoptions, "also-notify", &obj);
+               if (tresult == ISC_R_SUCCESS && !donotify) {
+                       cfg_obj_log(zoptions, logctx, ISC_LOG_WARNING,
+                                   "zone '%s': 'also-notify' set but "
+                                   "'notify' is disabled", znamestr);
+               } else if (tresult == ISC_R_SUCCESS) {
                        isc_uint32_t count;
                        tresult = validate_masters(obj, config, &count,
                                                   logctx, mctx);