From bf2238b064ed2398a9e9db27c6fb73f58c4db38a Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 12 Aug 2016 09:31:41 +1000 Subject: [PATCH] 4434. [protocol] Return EDNS EXPIRE option for master zones in addition to slave zones. [RT #43008] --- CHANGES | 3 +++ bin/named/query.c | 26 ++++++++++++++++---------- bin/tests/system/cacheclean/tests.sh | 7 +++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index caaabd520b..296fcac1ca 100644 --- 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] diff --git a/bin/named/query.c b/bin/named/query.c index ea4e1bad33..5382b50e91 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -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); } diff --git a/bin/tests/system/cacheclean/tests.sh b/bin/tests/system/cacheclean/tests.sh index 590107d9e1..fd455db14a 100644 --- a/bin/tests/system/cacheclean/tests.sh +++ b/bin/tests/system/cacheclean/tests.sh @@ -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