]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4434. [protocol] Return EDNS EXPIRE option for master zones in addition
authorMark Andrews <marka@isc.org>
Thu, 11 Aug 2016 23:31:41 +0000 (09:31 +1000)
committerMark Andrews <marka@isc.org>
Thu, 11 Aug 2016 23:31:41 +0000 (09:31 +1000)
                        to slave zones. [RT #43008]

CHANGES
bin/named/query.c
bin/tests/system/cacheclean/tests.sh

diff --git a/CHANGES b/CHANGES
index caaabd520b3f8617b1bed324e338d69deb8bf60d..296fcac1caf0a3b456ee63cc314de5b1d4371510 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4434.  [protocol]      Return EDNS EXPIRE option for master zones in addition
+                       to slave zones. [RT #43008]
+
 4433.  [cleanup]       Report an error when passing an invalid option or
                        view name to "rndc dumpdb". [RT #42958]
 
index ea4e1bad33486b0f68653eba756990248423894c..5382b50e91f82f097ab59f6ba3ac207f047c2186 100644 (file)
@@ -8699,21 +8699,17 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
                        client->query.attributes &= ~NS_QUERYATTR_NOADDITIONAL;
 
                /*
-                * Return the time to expire for slave zones.
+                * Return the time to expire for slave and master zones.
                 */
-               if (zone != NULL) {
+               if (zone != NULL && is_zone && qtype == dns_rdatatype_soa &&
+                   (client->attributes & NS_CLIENTATTR_WANTEXPIRE) != 0 &&
+                   client->query.restarts == 0) {
                        dns_zone_t *raw = NULL, *mayberaw;
 
-                       if (is_zone)
-                               dns_zone_getraw(zone, &raw);
+                       dns_zone_getraw(zone, &raw);
                        mayberaw = (raw != NULL) ? raw : zone;
 
-                       if (is_zone && qtype == dns_rdatatype_soa &&
-                           ((client->attributes &
-                             NS_CLIENTATTR_WANTEXPIRE) != 0) &&
-                           client->query.restarts == 0 &&
-                           dns_zone_gettype(mayberaw) == dns_zone_slave)
-                       {
+                       if (dns_zone_gettype(mayberaw) == dns_zone_slave) {
                                isc_time_t expiretime;
                                isc_uint32_t secs;
                                dns_zone_getexpiretime(zone, &expiretime);
@@ -8725,6 +8721,16 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
                                        client->expire = secs - client->now;
                                }
                        }
+                       if (dns_zone_gettype(mayberaw) == dns_zone_master) {
+                               dns_rdata_soa_t soa;
+                               result = dns_rdataset_first(rdataset);
+                               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+                               dns_rdataset_current(rdataset, &rdata);
+                               result = dns_rdata_tostruct(&rdata, &soa, NULL);
+                               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+                               client->expire = soa.expire;
+                               client->attributes |= NS_CLIENTATTR_HAVEEXPIRE;
+                       }
                        if (raw != NULL)
                                dns_zone_detach(&raw);
                }
index 590107d9e101d2bad2ac769c8946a5701aca056c..fd455db14aad373fea81ba741f19a415436ca840 100644 (file)
@@ -208,6 +208,13 @@ awk '/plain success\/timeout/ {getline; getline; if ($2 == "ns.flushtest.example
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+echo "I:check expire option returned from master zone"
+ret=0
+$DIG @10.53.0.1 -p 5300 +expire soa expire-test > dig.out.expire
+grep EXPIRE: dig.out.expire > /dev/null || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:check expire option returned from slave zone"
 ret=0
 $DIG @10.53.0.2 -p 5300 +expire soa expire-test > dig.out.expire