]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3589. [func] Report serial numbers in when starting zone transfers.
authorMark Andrews <marka@isc.org>
Fri, 7 Jun 2013 23:49:03 +0000 (09:49 +1000)
committerMark Andrews <marka@isc.org>
Fri, 7 Jun 2013 23:49:03 +0000 (09:49 +1000)
                        Report accepted NOTIFY requests including serial.
                        [RT# 33037]

CHANGES
bin/named/xfrout.c
bin/tests/system/notify/tests.sh
lib/dns/zone.c

diff --git a/CHANGES b/CHANGES
index 985ad412688cfcfbb9fc9333af9c62d2de82ec3d..b870535f53361777fea14993e0234e03358fc15b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3589.  [func]          Report serial numbers in when starting zone transfers.
+                       Report accepted NOTIFY requests including serial.
+                       [RT# 33037]
+
 3588.  [bug]           dig: addressed a memory leak in the sigchase code
                        that could cause a shutdown crash.  [RT #33733]
 
index 40be669f67cf01422854c2e5c3c611989636abf5..df22aa2d6cc355b604dc6f07a5e9b3e713011aec 100644 (file)
@@ -755,6 +755,8 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
        char keyname[DNS_NAME_FORMATSIZE];
        isc_boolean_t is_poll = ISC_FALSE;
        isc_boolean_t is_dlz = ISC_FALSE;
+       isc_boolean_t is_ixfr = ISC_FALSE;
+       isc_uint32_t begin_serial = 0, current_serial;
 
        switch (reqtype) {
        case dns_rdatatype_axfr:
@@ -952,8 +954,8 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
        CHECK(dns_db_createsoatuple(db, ver, mctx, DNS_DIFFOP_EXISTS,
                                    &current_soa_tuple));
 
+       current_serial = dns_soa_getserial(&current_soa_tuple->rdata);
        if (reqtype == dns_rdatatype_ixfr) {
-               isc_uint32_t begin_serial, current_serial;
                isc_boolean_t provide_ixfr;
 
                /*
@@ -971,7 +973,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                              "IXFR request missing SOA");
 
                begin_serial = dns_soa_getserial(&soa_rdata);
-               current_serial = dns_soa_getserial(&current_soa_tuple->rdata);
 
                /*
                 * RFC1995 says "If an IXFR query with the same or
@@ -1010,10 +1011,10 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                        goto axfr_fallback;
                }
                CHECK(result);
+               is_ixfr = ISC_TRUE;
        } else {
        axfr_fallback:
-               CHECK(axfr_rrstream_create(mctx, db, ver,
-                                          &data_stream));
+               CHECK(axfr_rrstream_create(mctx, db, ver, &data_stream));
        }
 
        /*
@@ -1071,10 +1072,16 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                xfrout_log1(client, question_name, question_class,
                            ISC_LOG_DEBUG(1), "IXFR poll up to date%s%s",
                            (xfr->tsigkey != NULL) ? ": TSIG " : "", keyname);
+       else if (is_ixfr)
+               xfrout_log1(client, question_name, question_class,
+                           ISC_LOG_INFO, "%s started%s%s (serial %u -> %u)",
+                           mnemonic, (xfr->tsigkey != NULL) ? ": TSIG " : "",
+                           keyname, begin_serial, current_serial);
        else
                xfrout_log1(client, question_name, question_class,
-                           ISC_LOG_INFO, "%s started%s%s", mnemonic,
-                           (xfr->tsigkey != NULL) ? ": TSIG " : "", keyname);
+                           ISC_LOG_INFO, "%s started%s%s (serial %u)",
+                           mnemonic, (xfr->tsigkey != NULL) ? ": TSIG " : "",
+                           keyname, current_serial);
 
        /*
         * Hand the context over to sendstream().  Set xfr to NULL;
index 256c852b4550799e4df7c55bac70c35a640c5c21..0794e96dc93da2929f7e900ec80f0a44389564f3 100644 (file)
@@ -62,6 +62,13 @@ cp -f ns2/example2.db ns2/example.db
 kill -HUP `cat ns2/named.pid`
 sleep 45
 
+n=`expr $n + 1`
+echo "I:checking notify message was logged ($n)"
+ret=0
+grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 2$' ns3/named.run > /dev/null || ret=1
+[ $ret = 0 ] || echo "I:failed"
+status=`expr $ret + $status`
+
 n=`expr $n + 1`
 echo "I:checking example2 loaded ($n)"
 ret=0
@@ -98,6 +105,13 @@ $PERL $SYSTEMTESTTOP/start.pl --noclean --restart . ns2
 
 sleep 45
 
+n=`expr $n + 1`
+echo "I:checking notify message was logged ($n)"
+ret=0
+grep 'notify from 10.53.0.2#[0-9][0-9]*: serial 4$' ns3/named.run > /dev/null || ret=1
+[ $ret = 0 ] || echo "I:failed"
+status=`expr $ret + $status`
+
 n=`expr $n + 1`
 echo "I:checking example4 loaded ($n)"
 ret=0
index c5eb884ede81510b56997eea6242171b91839e95..ce7aea9b0c8838a1e8e8507e572ebcdab61aec3f 100644 (file)
@@ -12011,6 +12011,8 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
        int match = 0;
        isc_netaddr_t netaddr;
        isc_sockaddr_t local, remote;
+       isc_uint32_t serial = 0;
+       isc_boolean_t have_serial = ISC_FALSE;
 
        REQUIRE(DNS_ZONE_VALID(zone));
 
@@ -12128,13 +12130,14 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
                if (result == ISC_R_SUCCESS)
                        result = dns_rdataset_first(rdataset);
                if (result == ISC_R_SUCCESS) {
-                       isc_uint32_t serial = 0, oldserial;
+                       isc_uint32_t oldserial;
                        unsigned int soacount;
 
                        dns_rdataset_current(rdataset, &rdata);
                        result = dns_rdata_tostruct(&rdata, &soa, NULL);
                        RUNTIME_CHECK(result == ISC_R_SUCCESS);
                        serial = soa.serial;
+                       have_serial = ISC_TRUE;
                        /*
                         * The following should safely be performed without DB
                         * lock and succeed in this context.
@@ -12165,12 +12168,23 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
                DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDREFRESH);
                zone->notifyfrom = *from;
                UNLOCK_ZONE(zone);
-               dns_zone_log(zone, ISC_LOG_INFO,
-                            "notify from %s: refresh in progress, "
-                            "refresh check queued",
-                            fromtext);
+               if (have_serial)
+                       dns_zone_log(zone, ISC_LOG_INFO,
+                                    "notify from %s: serial %u: refresh in "
+                                    "progress, refresh check queued",
+                                     fromtext, serial);
+               else
+                       dns_zone_log(zone, ISC_LOG_INFO,
+                                    "notify from %s: refresh in progress, "
+                                    "refresh check queued", fromtext);
                return (ISC_R_SUCCESS);
        }
+       if (have_serial)
+               dns_zone_log(zone, ISC_LOG_INFO, "notify from %s: serial %u",
+                            fromtext, serial);
+       else
+               dns_zone_log(zone, ISC_LOG_INFO, "notify from %s: no serial",
+                            fromtext);
        zone->notifyfrom = *from;
        local = zone->masteraddr;
        remote = zone->sourceaddr;