search revision 499b34cea04a46823d003d4c0520c8b03e8513cb
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingCopyright (C) 1999-2001 Internet Software Consortium.
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingSee COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
f3220f54126b25e1cf93cc26c17177b7aef850fdfielding$Id: search,v 1.9 2001/01/09 21:46:53 bwelling Exp $
1708435e9c63465fd70c21025bd51cb44170d2dbdougmWhat follows is pseudocode for the zone and cache lookup algorithms, as they
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingwill work in the RBT DB.
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingNote: These algorithms differ in some respects from those discussed in
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingthe RFCs and drafts. I believe these algorithms provide better
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldinganswers in some cases.
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingPreliminary Stuff
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingBIND 9 zone databases are versioned, and every search is done in the
ff8c037448da2a14a00420b285ea3b8f2f4738e0fieldingcontext of some version. There are a number of ways of implementing
ff8c037448da2a14a00420b285ea3b8f2f4738e0fieldingversioning. The method that's going to be used in the RBT DB is to
ff8c037448da2a14a00420b285ea3b8f2f4738e0fieldingstore a serial number with every rdataset. All rdatasets added as the
ff8c037448da2a14a00420b285ea3b8f2f4738e0fieldingresult of a single database update have the same serial number. This
ff8c037448da2a14a00420b285ea3b8f2f4738e0fieldingserial number is not related to the SOA serial, since the SOA serial
75ad9d694b36c11047c0b747cf7fc31a4fdbf6e4dougmis under user control and can do weird things. The database serial
75ad9d694b36c11047c0b747cf7fc31a4fdbf6e4dougmnumber is a monotonically increasing value. When you go to retrieve
75ad9d694b36c11047c0b747cf7fc31a4fdbf6e4dougman rdataset, you may encounter many rdatasets of that type at any
75ad9d694b36c11047c0b747cf7fc31a4fdbf6e4dougmgiven node. The correct one to return, called the "active rdataset",
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldinghas the greatest serial number less than or equal to the serial number
1708435e9c63465fd70c21025bd51cb44170d2dbdougmused for the search. The version whose serial number is being used in
1708435e9c63465fd70c21025bd51cb44170d2dbdougmthe search is the "target version".
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingCache databases are not versioned. A search will always return the
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingmost recent value.
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingDKZC == Deepest Known Zone Cut. This is the zone cut closest to the
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingdesired name. In a zone, it's either a delegation out of authoritative
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingdata, or it's the top of the zone.
f3220f54126b25e1cf93cc26c17177b7aef850fdfieldingZC == "zone cut", a node not at the zone top which has an active NS
e5d6e4b6e930968edfdc8e94c67988eb34382619dougmrdataset, or a node (including the zone top) with an active DNAME
e5d6e4b6e930968edfdc8e94c67988eb34382619dougmZone Search Algorithm
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm Search name
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm Search rdata type (including ANY)
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm Search options
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm The search options parameter is a flags variable. Current
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm Glue OK If set, then the caller is
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm wants best match results for
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm the search name, even if it's
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm glue. If not set, the caller
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm will get a delegation if the
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm search name is glue.
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm Glue Validation Section 7.18 of RFC 2136
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm requires that certain data that
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm is not in the zone and is not
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm glue remain stored in the zone.
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm A search can never return this
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm data, but there might be glue
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm mixed in with it. Telling glue
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm from non glue involves some
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm work, especially since the
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm database is versioned. Often,
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm however, the caller will know
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm the name it's looking for is
e5d6e4b6e930968edfdc8e94c67988eb34382619dougm glue, so validation isn't
The database is bad, e.g. missing NXT records.
DKZC (since there might not be anything for rc.vix.com in the cache),
algorithm. Of course, the cache might have data for rc.vix.com
XXX what if the zone DKZC is better (i.e. deeper)? XXX