From: Christian Hofstaedtler Date: Thu, 6 Oct 2016 22:04:40 +0000 (+0200) Subject: INCEPTION-INCREMENT: avoid jumping by two on every increase X-Git-Tag: dnsdist-1.3.0~168^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f613d2420ab805c2bc6295d1a544e278a047ee0e;p=pdns INCEPTION-INCREMENT: avoid jumping by two on every increase Fixes #2377 (which is now also seen by pdnsutil increase-serial). --- diff --git a/pdns/serialtweaker.cc b/pdns/serialtweaker.cc index 8475a0c6f..06a036536 100644 --- a/pdns/serialtweaker.cc +++ b/pdns/serialtweaker.cc @@ -47,8 +47,11 @@ uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName if(old_serial < inception_serial - 1) { /* less than 00 */ return inception_serial; /* return 01 (skipping 00 as possible value) */ + } else if (old_serial < inception_serial+1) { + /* "00" and "01" are reserved for inception increasing, so jump to "02" */ + return inception_serial+1; } else if(old_serial <= dont_increment_after) { /* >= 00 but <= 99 */ - return (old_serial + 2); /* "00" and "01" are reserved for inception increasing, so increment sd.serial by two */ + return old_serial + 1; } } else if(pdns_iequals(kind,"INCREMENT-WEEKS")) { diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index e5ef9cf73..ece4a0df2 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -148,6 +148,27 @@ class AuthZones(ApiTestCase, AuthZonesHelperMixin): soa_serial = get_first_rec(data, name, 'SOA')['content'].split(' ')[2] # These particular settings lead to the first serial set to YYYYMMDD01. self.assertEquals(soa_serial[-2:], '01') + rrset = { + 'changetype': 'replace', + 'name': name, + 'type': 'A', + 'ttl': 3600, + 'records': [ + { + "content": "127.0.0.1", + "disabled": False + } + ] + } + payload = {'rrsets': [rrset]} + self.session.patch( + self.url("/api/v1/servers/localhost/zones/" + data['id']), + data=json.dumps(payload), + headers={'content-type': 'application/json'}) + r = self.session.get(self.url("/api/v1/servers/localhost/zones/" + data['id'])) + data = r.json() + soa_serial = get_first_rec(data, name, 'SOA')['content'].split(' ')[2] + self.assertEquals(soa_serial[-2:], '02') def test_create_zone_with_records(self): name = unique_zone_name()