Skip to content
Snippets Groups Projects
Commit 82bfcc3b authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Merge branch 'notify_ignore_same_serial' into 'master'

Notify ignore same serial

See merge request !635
parents 56aef54c 4d91b875
No related branches found
No related tags found
1 merge request!635Notify ignore same serial
......@@ -21,6 +21,7 @@
#include "knot/nameserver/internet.h"
#include "knot/nameserver/log.h"
#include "knot/nameserver/tsig_ctx.h"
#include "knot/zone/serial.h"
#include "dnssec/random.h"
#include "libknot/libknot.h"
......@@ -65,12 +66,18 @@ int notify_process_query(knot_pkt_t *pkt, struct query_data *qdata)
knot_pkt_reserve(pkt, knot_tsig_wire_maxsize(&qdata->sign.tsig_key));
/* SOA RR in answer may be included, recover serial. */
zone_t *zone = (zone_t *)qdata->zone;
const knot_pktsection_t *answer = knot_pkt_section(qdata->query, KNOT_ANSWER);
if (answer->count > 0) {
const knot_rrset_t *soa = knot_pkt_rr(answer, 0);
if (soa->type == KNOT_RRTYPE_SOA) {
uint32_t serial = knot_soa_serial(&soa->rrs);
uint32_t zone_serial = zone_contents_serial(zone->contents);
NOTIFY_IN_LOG(LOG_INFO, qdata, "received, serial %u", serial);
if (serial_compare(serial, zone_serial) == 0) {
// NOTIFY serial == zone serial => ignore, keep timers
return KNOT_STATE_DONE;
}
} else { /* Complain, but accept N/A record. */
NOTIFY_IN_LOG(LOG_NOTICE, qdata, "received, bad record in answer section");
}
......@@ -79,7 +86,6 @@ int notify_process_query(knot_pkt_t *pkt, struct query_data *qdata)
}
/* Incoming NOTIFY expires REFRESH timer and renews EXPIRE timer. */
zone_t *zone = (zone_t *)qdata->zone;
zone_set_preferred_master(zone, qdata->param->remote);
zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
......
$ORIGIN notify.
$TTL 3600
@ SOA dns1 hostmaster 2010111201 10800 3600 1209600 7200
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
$ORIGIN notify.
$TTL 3600
@ SOA dns1 hostmaster 2010111202 10800 3600 1209600 7200
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
node A 1.2.3.4
$ORIGIN notify.
$TTL 3600
@ SOA dns1 hostmaster 2010111203 10800 3600 1209600 7200
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
node A 1.2.3.4
$ORIGIN notify.
$TTL 3600
@ SOA dns1 hostmaster 2010111203 10800 3600 1209600 7200
NS dns1
NS dns2
MX 10 mail
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
mail A 192.0.2.3
AAAA 2001:DB8::3
node A 1.2.3.4
nonode A 1.2.3.5
#!/usr/bin/env python3
'''Test for NOTIFY: if serial is different, slave shall update, otherwise not'''
from dnstest.test import Test
t = Test()
master = t.server("knot")
slave = t.server("knot")
zone = t.zone("notify.", storage=".")
t.link(zone, master, slave)
t.start()
serial = master.zone_wait(zone)
slave.zone_wait(zone)
master.update_zonefile(zone, version=1)
master.reload()
serial = slave.zone_wait(zone, serial=serial, equal=False, greater=True)
resp = slave.dig("node.notify.", "A")
resp.check(rcode="NOERROR", rdata="1.2.3.4")
slave.update_zonefile(zone, version=2)
slave.reload()
master.update_zonefile(zone, version=3)
master.reload()
# master now sends NOTIFY with SOA=2010111203 which shall slave ignore
t.sleep(2)
resp = slave.dig("nonode.notify.", "A")
resp.check(rcode="NXDOMAIN", nordata="1.2.3.5")
t.end()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment