From: Mark Andrews Date: Fri, 7 Jun 2013 23:49:03 +0000 (+1000) Subject: 3589. [func] Report serial numbers in when starting zone transfers. X-Git-Tag: v9.10.0a1~304 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c6eb92beb1951b0634c349b24891522c273e9f69;p=thirdparty%2Fbind9.git 3589. [func] Report serial numbers in when starting zone transfers. Report accepted NOTIFY requests including serial. [RT# 33037] --- diff --git a/CHANGES b/CHANGES index 985ad412688..b870535f533 100644 --- 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] diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c index 40be669f67c..df22aa2d6cc 100644 --- a/bin/named/xfrout.c +++ b/bin/named/xfrout.c @@ -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, ¤t_soa_tuple)); + current_serial = dns_soa_getserial(¤t_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(¤t_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; diff --git a/bin/tests/system/notify/tests.sh b/bin/tests/system/notify/tests.sh index 256c852b455..0794e96dc93 100644 --- a/bin/tests/system/notify/tests.sh +++ b/bin/tests/system/notify/tests.sh @@ -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 diff --git a/lib/dns/zone.c b/lib/dns/zone.c index c5eb884ede8..ce7aea9b0c8 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -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;