Serial Number Arithmetic
updates
Extracted elements (18)
RFC 1034 and RFC 1035 referenced 'sequence space arithmetic' from TCP (IEN-74), but IEN-74's definition was inadequate for DNS because it provided no general comparison operator. This document supplies the missing definition rather than relying on the TCP precedent.
Serial number arithmetic is defined generically (parameterised by SERIAL_BITS) so it can be reused by protocols other than DNS. Any document referencing 'Serial Number Arithmetic from RFC 1982' with a stated SERIAL_BITS value inherits the rules of sections 2–5.
The undefined comparison case (numbers exactly half the serial space apart) was left undefined rather than arbitrarily resolved because any fixed resolution would cause s1 < s2 while simultaneously s2 < s1 when the pair is reversed, making results depend on test order. A defined-but-arbitrary resolution would also produce the counterintuitive result s1 < s2 but (s1+1) > (s2+1).
Many DNS implementations have incorrectly treated SOA serial number zero as a special case with unusual properties. Caution should be exercised before setting the serial number to zero, as unexpected behaviour from those implementations may result.
Older implementations are known to have treated the SOA serial number as a plain unsigned integer with no sequence-space arithmetic and no wrapping. No interoperability accommodation for these implementations is defined; they are considered superseded.
Care SHOULD be taken that the SOA serial number not be incremented, in one or more steps, by more than 2^31 - 1 within the period given by SOA.expire. Exceeding this may leave secondary servers with out-of-date zones whose serial number appears greater than the primary's.
Each increment to the SOA serial number must be treated as the start of a new sequence of increments for the SOA.expire-period accounting, as well as a continuation of all previous sequences started within that period.
RFC 1034 and RFC 1035 are to be treated as if their references to 'sequence space arithmetic' are replaced by references to serial number arithmetic as defined in this document (RFC 1982).
The addend n in serial number addition MUST be within [0 .. 2^(SERIAL_BITS-1) - 1]. Addition of a value outside this range is undefined and implementations must not rely on any particular outcome.
A serial number is a non-negative integer drawn from a finite subset [0 .. 2^SERIAL_BITS - 1]. The parameter SERIAL_BITS defines the size of the space; no value has special significance, and every value has both a successor and a predecessor.
Corollary 1: For any serial number s and valid addend n, (s + n) >= s; equality holds only when n == 0. This means addition of a positive n always produces a strictly greater serial number.
Corollary 2: If s' = s + n (non-zero n) and s'' = s' + m, the relationship between s'' and s is undefined (though s'' != s). Two successive additions can yield a result whose ordering relative to the original is indeterminate.
For pairs of serial numbers exactly 2^(SERIAL_BITS-1) apart, comparison is undefined: s1 is neither equal to, greater than, nor less than s2. Implementations may return either result or flag an error.
s1 is greater than s2 if and only if (i1 < i2 and i2 - i1 > 2^(SERIAL_BITS-1)) or (i1 > i2 and i1 - i2 < 2^(SERIAL_BITS-1)). Equality holds iff i1 == i2.
s1 is less than s2 if and only if (i1 < i2 and i2 - i1 < 2^(SERIAL_BITS-1)) or (i1 > i2 and i1 - i2 > 2^(SERIAL_BITS-1)), where i1, i2 are the unbounded integer equivalents of s1, s2.
Serial number addition is defined as s' = (s + n) modulo (2^SERIAL_BITS), where n must be in the range [0 .. 2^(SERIAL_BITS-1) - 1]. Addition of a value outside this range is explicitly undefined.
The DNS SOA serial number is a Serial Number with SERIAL_BITS = 32, taking values in [0 .. 4294967295]. The maximum defined single increment is 2147483647 (2^31 - 1).
This document does not introduce or address any security considerations. It is not believed to add to or lessen any security issues that may exist with the DNS.