Remove the mastefile-format map option

As previously announced, this commit removes the masterfile-format
format 'map' from named, all the tools, the documentation and the
system tests.
This commit is contained in:
Ondřej Surý 2021-09-16 11:46:13 +02:00
parent 1cc866fdef
commit edee9440d0
67 changed files with 127 additions and 2458 deletions

View file

@ -571,96 +571,6 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
return (ISC_R_SUCCESS);
}
/*% scan the zone for oversize TTLs */
static isc_result_t
check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
isc_result_t result;
dns_db_t *db = NULL;
dns_dbversion_t *version = NULL;
dns_dbnode_t *node = NULL;
dns_dbiterator_t *dbiter = NULL;
dns_rdatasetiter_t *rdsiter = NULL;
dns_rdataset_t rdataset;
dns_fixedname_t fname;
dns_name_t *name;
name = dns_fixedname_initname(&fname);
dns_rdataset_init(&rdataset);
CHECK(dns_zone_getdb(zone, &db));
INSIST(db != NULL);
CHECK(dns_db_newversion(db, &version));
CHECK(dns_db_createiterator(db, 0, &dbiter));
for (result = dns_dbiterator_first(dbiter); result == ISC_R_SUCCESS;
result = dns_dbiterator_next(dbiter))
{
result = dns_dbiterator_current(dbiter, &node, name);
if (result == DNS_R_NEWORIGIN) {
result = ISC_R_SUCCESS;
}
CHECK(result);
CHECK(dns_db_allrdatasets(db, node, version, 0, &rdsiter));
for (result = dns_rdatasetiter_first(rdsiter);
result == ISC_R_SUCCESS;
result = dns_rdatasetiter_next(rdsiter))
{
dns_rdatasetiter_current(rdsiter, &rdataset);
if (rdataset.ttl > maxttl) {
char nbuf[DNS_NAME_FORMATSIZE];
char tbuf[255];
isc_buffer_t b;
isc_region_t r;
dns_name_format(name, nbuf, sizeof(nbuf));
isc_buffer_init(&b, tbuf, sizeof(tbuf) - 1);
CHECK(dns_rdatatype_totext(rdataset.type, &b));
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
dns_zone_log(zone, ISC_LOG_ERROR,
"%s/%s TTL %d exceeds "
"maximum TTL %d",
nbuf, tbuf, rdataset.ttl, maxttl);
dns_rdataset_disassociate(&rdataset);
CHECK(ISC_R_RANGE);
}
dns_rdataset_disassociate(&rdataset);
}
if (result == ISC_R_NOMORE) {
result = ISC_R_SUCCESS;
}
CHECK(result);
dns_rdatasetiter_destroy(&rdsiter);
dns_db_detachnode(db, &node);
}
if (result == ISC_R_NOMORE) {
result = ISC_R_SUCCESS;
}
cleanup:
if (node != NULL) {
dns_db_detachnode(db, &node);
}
if (rdsiter != NULL) {
dns_rdatasetiter_destroy(&rdsiter);
}
if (dbiter != NULL) {
dns_dbiterator_destroy(&dbiter);
}
if (version != NULL) {
dns_db_closeversion(db, &version, false);
}
if (db != NULL) {
dns_db_detach(&db);
}
return (result);
}
/*% load the zone */
isc_result_t
load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
@ -724,14 +634,6 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
CHECK(dns_zone_load(zone, false));
/*
* When loading map files we can't catch oversize TTLs during
* load, so we check for them here.
*/
if (fileformat == dns_masterformat_map && maxttl != 0) {
CHECK(check_ttls(zone, maxttl));
}
if (zonep != NULL) {
*zonep = zone;
zone = NULL;

View file

@ -435,8 +435,6 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
masterformat = dns_masterformat_text;
} else if (strcasecmp(masterformatstr, "raw") == 0) {
masterformat = dns_masterformat_raw;
} else if (strcasecmp(masterformatstr, "map") == 0) {
masterformat = dns_masterformat_map;
} else {
INSIST(0);
ISC_UNREACHABLE();

View file

@ -454,8 +454,6 @@ main(int argc, char **argv) {
inputformat = dns_masterformat_raw;
fprintf(stderr, "WARNING: input format raw, version "
"ignored\n");
} else if (strcasecmp(inputformatstr, "map") == 0) {
inputformat = dns_masterformat_map;
} else {
fprintf(stderr, "unknown file format: %s\n",
inputformatstr);
@ -478,8 +476,6 @@ main(int argc, char **argv) {
fprintf(stderr, "unknown raw format version\n");
exit(1);
}
} else if (strcasecmp(outputformatstr, "map") == 0) {
outputformat = dns_masterformat_map;
} else {
fprintf(stderr, "unknown file format: %s\n",
outputformatstr);

View file

@ -101,8 +101,8 @@ Options
Mode ``none`` disables the checks.
``-f format``
This option specifies the format of the zone file. Possible formats are ``text``
(the default), ``raw``, and ``map``.
This option specifies the format of the zone file. Possible formats are
``text`` (the default), and ``raw``.
``-F format``
This option specifies the format of the output file specified. For
@ -110,12 +110,11 @@ Options
the zone contents.
Possible formats are ``text`` (the default), which is the standard
textual representation of the zone, and ``map``, ``raw``, and
``raw=N``, which store the zone in a binary format for rapid
loading by ``named``. ``raw=N`` specifies the format version of the
raw zone file: if ``N`` is 0, the raw file can be read by any version of
``named``; if N is 1, the file can only be read by release 9.9.0 or
higher. The default is 1.
textual representation of the zone, and ``raw`` and ``raw=N``, which
store the zone in a binary format for rapid loading by ``named``.
``raw=N`` specifies the format version of the raw zone file: if ``N`` is
0, the raw file can be read by any version of ``named``; if N is 1, the
file can only be read by release 9.9.0 or higher. The default is 1.
``-k mode``
This option performs ``check-names`` checks with the specified failure mode.
@ -128,7 +127,7 @@ Options
is similar to using the ``max-zone-ttl`` option in ``named.conf``.
``-L serial``
When compiling a zone to ``raw`` or ``map`` format, this option sets the "source
When compiling a zone to ``raw`` format, this option sets the "source
serial" value in the header to the specified serial number. This is
expected to be used primarily for testing purposes.

View file

@ -3741,8 +3741,6 @@ main(int argc, char *argv[]) {
if (inputformatstr != NULL) {
if (strcasecmp(inputformatstr, "text") == 0) {
inputformat = dns_masterformat_text;
} else if (strcasecmp(inputformatstr, "map") == 0) {
inputformat = dns_masterformat_map;
} else if (strcasecmp(inputformatstr, "raw") == 0) {
inputformat = dns_masterformat_raw;
} else if (strncasecmp(inputformatstr, "raw=", 4) == 0) {
@ -3760,8 +3758,6 @@ main(int argc, char *argv[]) {
} else if (strcasecmp(outputformatstr, "full") == 0) {
outputformat = dns_masterformat_text;
masterstyle = &dns_master_style_full;
} else if (strcasecmp(outputformatstr, "map") == 0) {
outputformat = dns_masterformat_map;
} else if (strcasecmp(outputformatstr, "raw") == 0) {
outputformat = dns_masterformat_raw;
} else if (strncasecmp(outputformatstr, "raw=", 4) == 0) {

View file

@ -62,8 +62,8 @@ Options
``dnssec-signzone``, i.e., RRSIG, NSEC, NSEC3 and NSEC3PARAM records, should be included in the output.
If smart signing (``-S``) is used, DNSKEY records are also included.
The resulting file can be included in the original zone file with
``$INCLUDE``. This option cannot be combined with ``-O raw``,
``-O map``, or serial-number updating.
``$INCLUDE``. This option cannot be combined with ``-O raw``
or serial-number updating.
``-E engine``
This option specifies the hardware to use for cryptographic
@ -157,8 +157,8 @@ Options
less than 7.5 days, they are replaced.
``-I input-format``
This option sets the format of the input zone file. Possible formats are ``text``
(the default), ``raw``, and ``map``. This option is primarily
This option sets the format of the input zone file. Possible formats are
``text`` (the default), and ``raw``. This option is primarily
intended to be used for dynamic signed zones, so that the dumped zone
file in a non-text format containing updates can be signed directly.
This option is not useful for non-dynamic zones.
@ -179,7 +179,7 @@ Options
same time.
``-L serial``
When writing a signed zone to "raw" or "map" format, this option sets the "source
When writing a signed zone to "raw" format, this option sets the "source
serial" value in the header to the specified ``serial`` number. (This is
expected to be used primarily for testing purposes.)
@ -215,15 +215,14 @@ Options
assumed to be the origin.
``-O output-format``
This option sets the format of the output file containing the signed zone. Possible
formats are ``text`` (the default), which is the standard textual
representation of the zone; ``full``, which is text output in a
format suitable for processing by external scripts; and ``map``,
``raw``, and ``raw=N``, which store the zone in binary formats
for rapid loading by ``named``. ``raw=N`` specifies the format
version of the raw zone file: if N is 0, the raw file can be read by
any version of ``named``; if N is 1, the file can be read by release
9.9.0 or higher. The default is 1.
This option sets the format of the output file containing the signed
zone. Possible formats are ``text`` (the default), which is the standard
textual representation of the zone; ``full``, which is text output in a
format suitable for processing by external scripts; and ``raw`` and
``raw=N``, which store the zone in binary formats for rapid loading by
``named``. ``raw=N`` specifies the format version of the raw zone file:
if N is 0, the raw file can be read by any version of ``named``; if N is
1, the file can be read by release 9.9.0 or higher. The default is 1.
``-P``
This option disables post-sign verification tests.

View file

@ -303,7 +303,7 @@ OPTIONS
lmdb-mapsize sizeval;
lock-file ( quoted_string | none );
managed-keys-directory quoted_string;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-mapped-addresses boolean;
max-cache-size ( default | unlimited | sizeval | percentage );
@ -712,7 +712,7 @@ VIEW
) integer integer
integer
quoted_string; ... };, deprecated
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-clients { address_match_element; ... };
match-destinations { address_match_element; ... };
@ -931,7 +931,7 @@ VIEW
ixfr-from-differences boolean;
journal quoted_string;
key-directory quoted_string;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port integer ] [ dscp integer ] { (
remote-servers | ipv4_address [ port integer ] |
@ -1048,7 +1048,7 @@ ZONE
ixfr-from-differences boolean;
journal quoted_string;
key-directory quoted_string;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port integer ] [ dscp integer ] { ( remote-servers
| ipv4_address [ port integer ] | ipv6_address [ port

View file

@ -1051,11 +1051,6 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
masterformat = dns_masterformat_text;
} else if (strcasecmp(masterformatstr, "raw") == 0) {
masterformat = dns_masterformat_raw;
} else if (strcasecmp(masterformatstr, "map") == 0) {
masterformat = dns_masterformat_map;
cfg_obj_log(obj, named_g_lctx, ISC_LOG_WARNING,
"masterfile-format: format 'map' is "
"deprecated");
} else {
INSIST(0);
ISC_UNREACHABLE();
@ -1088,14 +1083,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
obj = NULL;
result = named_config_get(maps, "max-zone-ttl", &obj);
if (result == ISC_R_SUCCESS && masterformat == dns_masterformat_map) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
"zone '%s': 'max-zone-ttl' is not compatible "
"with 'masterfile-format map'",
zname);
return (ISC_R_FAILURE);
} else if (result == ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS) {
dns_ttl_t maxttl = 0; /* unlimited */
if (cfg_obj_isduration(obj)) {
@ -1772,26 +1760,10 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
}
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKWILDCARD, check);
/*
* With map files, the default is ignore duplicate
* records. With other master formats, the default is
* taken from the global configuration.
*/
obj = NULL;
if (masterformat != dns_masterformat_map) {
result = named_config_get(maps, "check-dup-records",
&obj);
INSIST(result == ISC_R_SUCCESS && obj != NULL);
dupcheck = cfg_obj_asstring(obj);
} else {
result = named_config_get(nodefault,
"check-dup-records", &obj);
if (result == ISC_R_SUCCESS) {
dupcheck = cfg_obj_asstring(obj);
} else {
dupcheck = "ignore";
}
}
result = named_config_get(maps, "check-dup-records", &obj);
INSIST(result == ISC_R_SUCCESS && obj != NULL);
dupcheck = cfg_obj_asstring(obj);
if (strcasecmp(dupcheck, "warn") == 0) {
fail = false;
check = true;
@ -1823,28 +1795,11 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMX, check);
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMXFAIL, fail);
/*
* With map files, the default is *not* to check
* integrity. With other master formats, the default is
* taken from the global configuration.
*/
obj = NULL;
if (masterformat != dns_masterformat_map) {
result = named_config_get(maps, "check-integrity",
&obj);
INSIST(result == ISC_R_SUCCESS && obj != NULL);
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
cfg_obj_asboolean(obj));
} else {
check = false;
result = named_config_get(nodefault, "check-integrity",
&obj);
if (result == ISC_R_SUCCESS) {
check = cfg_obj_asboolean(obj);
}
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
check);
}
result = named_config_get(maps, "check-integrity", &obj);
INSIST(result == ISC_R_SUCCESS && obj != NULL);
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
cfg_obj_asboolean(obj));
obj = NULL;
result = named_config_get(maps, "check-mx-cname", &obj);

View file

@ -11,7 +11,7 @@
zone example {
type master;
masterfile-format map;
masterfile-format raw;
file "example.db";
max-ixfr-ratio 0.9;
};

View file

@ -11,7 +11,7 @@
zone example {
type master;
masterfile-format map;
masterfile-format raw;
file "example.db";
max-ixfr-ratio 0%;
};

View file

@ -1,17 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
zone example {
type master;
masterfile-format map;
file "example.db";
max-zone-ttl 3600;
};

View file

@ -11,7 +11,7 @@
zone example {
type master;
masterfile-format map;
masterfile-format raw;
file "example.db";
max-ixfr-ratio 50%;
};

View file

@ -11,7 +11,7 @@
zone example {
type master;
masterfile-format map;
masterfile-format raw;
file "example.db";
max-ixfr-ratio unlimited;
};

View file

@ -571,24 +571,6 @@ grep "not recommended" < checkconf.out$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; ret=1; fi
status=`expr $status + $ret`
n=$((n+1))
echo_i "check that masterfile-format map generates deprecation warning ($n)"
ret=0
$CHECKCONF deprecated-masterfile-format-map.conf > checkconf.out$n 2>/dev/null || ret=1
grep "is deprecated" < checkconf.out$n >/dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; ret=1; fi
status=$((status+ret))
n=$((n+1))
echo_i "check that masterfile-format text and raw don't generate deprecation warning ($n)"
ret=0
$CHECKCONF good-masterfile-format-text.conf > checkconf.out$n 2>/dev/null || ret=1
grep "is deprecated" < checkconf.out$n >/dev/null && ret=1
$CHECKCONF good-masterfile-format-raw.conf > checkconf.out$n 2>/dev/null || ret=1
grep "is deprecated" < checkconf.out$n >/dev/null && ret=1
if [ $ret != 0 ]; then echo_i "failed"; ret=1; fi
status=$((status+ret))
rmdir keys
echo_i "exit status: $status"

View file

@ -11,7 +11,7 @@
zone example {
type master;
masterfile-format map;
masterfile-format raw;
file "example.db";
max-ixfr-ratio 101%;
};

View file

@ -7,6 +7,6 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
rm -f test.* good1.db.map good1.db.raw named-compilezone
rm -f test.* good1.db.raw named-compilezone
rm -f ns*/named.lock
rm -f zones/zone1_*.txt

View file

@ -13,5 +13,3 @@ ln -s $CHECKZONE named-compilezone
./named-compilezone -D -F raw -o good1.db.raw example \
zones/good1.db > /dev/null 2>&1
./named-compilezone -D -F map -o good1.db.map example \
zones/good1.db > /dev/null 2>&1

View file

@ -96,14 +96,6 @@ n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "checking with max ttl (map) ($n)"
ret=0
$CHECKZONE -f map -l 300 example good1.db.map > test.out1.$n 2>&1 && ret=1
$CHECKZONE -f map -l 600 example good1.db.map > test.out2.$n 2>&1 || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "checking for no 'inherited owner' warning on '\$INCLUDE file' with no new \$ORIGIN ($n)"
ret=0
$CHECKZONE example zones/nowarn.inherited.owner.db > test.out1.$n 2>&1 || ret=1

View file

@ -128,15 +128,6 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
return (ISC_R_SUCCESS);
}
static isc_result_t
serialize(dns_db_t *db, dns_dbversion_t *version, FILE *file) {
sampledb_t *sampledb = (sampledb_t *)db;
REQUIRE(VALID_SAMPLEDB(sampledb));
return (dns_db_serialize(sampledb->rbtdb, version, file));
}
static isc_result_t
dump(dns_db_t *db, dns_dbversion_t *version, const char *filename,
dns_masterformat_t masterformat) {
@ -546,7 +537,6 @@ static dns_dbmethods_t sampledb_methods = {
detach,
beginload,
endload,
serialize,
dump,
currentversion,
newversion,

View file

@ -13,7 +13,7 @@ rm -f ./ns1/example.db.raw*
rm -f ./ns1/example.db.compat
rm -f ./ns1/example.db.serial.raw
rm -f ./ns1/large.db ./ns1/large.db.raw
rm -f ./ns1/example.db.map ./ns1/signed.db.map
rm -f ./ns1/signed.db.raw
rm -f ./ns1/session.key
rm -f ./dig.out.*
rm -f ./dig.out
@ -25,8 +25,8 @@ rm -f ./ns2/transfer.db.*
rm -f ./ns2/formerly-text.db
rm -f ./ns2/db-*
rm -f ./ns2/large.bk
rm -f ./ns3/example.db.map ./ns3/dynamic.db.map
rm -f ./baseline.txt ./text.* ./raw.* ./map.* ./badmap
rm -f ./ns3/example.db.raw ./ns3/dynamic.db.raw
rm -f ./baseline.txt ./text.* ./raw.*
rm -f ./ns1/Ksigned.* ./ns1/dsset-signed. ./ns1/signed.db.signed
rm -f ./rndc.out
rm -f ./ns*/named.lock

View file

@ -14,9 +14,9 @@
$CHECKZONE -D -F raw -o example.db.raw example \
example.db > /dev/null 2>&1
$CHECKZONE -D -F map -o ../ns3/example.db.map example \
$CHECKZONE -D -F raw -o ../ns3/example.db.raw example \
example.db > /dev/null 2>&1
$CHECKZONE -D -F map -o ../ns3/dynamic.db.map dynamic \
$CHECKZONE -D -F raw -o ../ns3/dynamic.db.raw dynamic \
example.db > /dev/null 2>&1
$CHECKZONE -D -F raw=1 -o example.db.raw1 example-explicit \
example.db > /dev/null 2>&1
@ -25,10 +25,8 @@ $CHECKZONE -D -F raw=0 -o example.db.compat example-compat \
$CHECKZONE -D -F raw -L 3333 -o example.db.serial.raw example \
example.db > /dev/null 2>&1
$CHECKZONE -D -F raw -o large.db.raw large large.db > /dev/null 2>&1
$CHECKZONE -D -F map -o example.db.map example-map \
example.db > /dev/null 2>&1
$KEYGEN -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -f KSK signed > /dev/null 2>&1
$KEYGEN -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" signed > /dev/null 2>&1
$SIGNER -S -f signed.db.signed -o signed signed.db > /dev/null
$CHECKZONE -D -F map -o signed.db.map signed signed.db.signed > /dev/null 2>&1
$CHECKZONE -D -F raw -o signed.db.raw signed signed.db.signed > /dev/null 2>&1

View file

@ -77,8 +77,8 @@ zone "large" {
zone "signed" {
type primary;
file "signed.db.map";
masterfile-format map;
file "signed.db.raw";
masterfile-format raw;
allow-transfer { any; };
update-policy local;
auto-dnssec maintain;

View file

@ -31,13 +31,13 @@ controls {
zone "example" {
type primary;
masterfile-format map;
file "example.db.map";
masterfile-format raw;
file "example.db.raw";
};
zone "dynamic" {
type primary;
masterfile-format map;
file "dynamic.db.map";
masterfile-format raw;
file "dynamic.db.raw";
allow-update { any; };
};

View file

@ -15,15 +15,6 @@
status=0
n=1
ismap () {
# shellcheck disable=SC2016
$PERL -e 'binmode STDIN;
read(STDIN, $input, 8);
($style, $version) = unpack("NN", $input);
exit 1 if ($style != 3 || $version > 1);' < "$1"
return $?
}
israw () {
# shellcheck disable=SC2016
$PERL -e 'binmode STDIN;
@ -49,7 +40,7 @@ rawversion () {
if (length($input) < 8) { print "not raw\n"; exit 0; };
($style, $version) = unpack("NN", $input);
print ($style == 2 || $style == 3 ? "$version\n" :
"not raw or map\n");' < "$1"
"not raw\n");' < "$1"
}
sourceserial () {
@ -124,11 +115,9 @@ ret=0
israw ns1/example.db.raw || ret=1
israw ns1/example.db.raw1 || ret=1
israw ns1/example.db.compat || ret=1
ismap ns1/example.db.map || ret=1
[ "$(rawversion ns1/example.db.raw)" -eq 1 ] || ret=1
[ "$(rawversion ns1/example.db.raw1)" -eq 1 ] || ret=1
[ "$(rawversion ns1/example.db.compat)" -eq 0 ] || ret=1
[ "$(rawversion ns1/example.db.map)" -eq 1 ] || ret=1
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
@ -199,28 +188,17 @@ n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking format transitions: text->raw->map->text ($n)"
echo_i "checking format transitions: text->raw->text ($n)"
ret=0
$CHECKZONE -D -f text -F text -o baseline.txt example.nil ns1/example.db > /dev/null
$CHECKZONE -D -f text -F raw -o raw.1 example.nil baseline.txt > /dev/null
$CHECKZONE -D -f raw -F map -o map.1 example.nil raw.1 > /dev/null
$CHECKZONE -D -f map -F text -o text.1 example.nil map.1 > /dev/null
$CHECKZONE -D -f raw -F text -o text.1 example.nil raw.1 > /dev/null
cmp -s baseline.txt text.1 || ret=0
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking format transitions: text->map->raw->text ($n)"
ret=0
$CHECKZONE -D -f text -F map -o map.2 example.nil baseline.txt > /dev/null
$CHECKZONE -D -f map -F raw -o raw.2 example.nil map.2 > /dev/null
$CHECKZONE -D -f raw -F text -o text.2 example.nil raw.2 > /dev/null
cmp -s baseline.txt text.2 || ret=0
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking map format loading with journal file rollforward ($n)"
echo_i "checking raw format loading with journal file rollforward ($n)"
ret=0
$NSUPDATE <<END > /dev/null || status=1
server 10.53.0.3 ${PORT}
@ -248,7 +226,7 @@ n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking map format file dumps correctly ($n)"
echo_i "checking raw format file dumps correctly ($n)"
ret=0
$NSUPDATE <<END > /dev/null || status=1
server 10.53.0.3 ${PORT}
@ -274,44 +252,7 @@ n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
# stomp on the file header
echo_i "checking corrupt map files fail to load (bad file header) ($n)"
ret=0
$CHECKZONE -D -f text -F map -o map.5 example.nil baseline.txt > /dev/null
cp map.5 badmap
stomp badmap 0 32 99
$CHECKZONE -D -f map -F text -o text.5 example.nil badmap > /dev/null
[ $? = 1 ] || ret=1
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
# stomp on the file data so it hashes differently.
# these are small and subtle changes, so that the resulting file
# would appear to be a legitimate map file and would not trigger an
# assertion failure if loaded into memory, but should still fail to
# load because of a SHA1 hash mismatch.
echo_i "checking corrupt map files fail to load (bad node header) ($n)"
ret=0
cp map.5 badmap
stomp badmap 2754 2 99
$CHECKZONE -D -f map -F text -o text.5 example.nil badmap > /dev/null
[ $? = 1 ] || ret=1
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking corrupt map files fail to load (bad node data) ($n)"
ret=0
cp map.5 badmap
stomp badmap 2897 5 127
$CHECKZONE -D -f map -F text -o text.5 example.nil badmap > /dev/null
[ $? = 1 ] || ret=1
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking map format zone is scheduled for resigning (compilezone) ($n)"
echo_i "checking raw format zone is scheduled for resigning (compilezone) ($n)"
ret=0
rndccmd 10.53.0.1 zonestatus signed > rndc.out 2>&1 || ret=1
grep 'next resign' rndc.out > /dev/null 2>&1 || ret=1
@ -319,10 +260,10 @@ n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
echo_i "checking map format zone is scheduled for resigning (signzone) ($n)"
echo_i "checking raw format zone is scheduled for resigning (signzone) ($n)"
ret=0
rndccmd 10.53.0.1 freeze signed > rndc.out 2>&1 || ret=1
(cd ns1 || exit 1; $SIGNER -S -O map -f signed.db.map -o signed signed.db > /dev/null)
(cd ns1 || exit 1; $SIGNER -S -O raw -f signed.db.raw -o signed signed.db > /dev/null)
rndc_reload ns1 10.53.0.1 signed
rndccmd 10.53.0.1 zonestatus signed > rndc.out 2>&1 || ret=1
grep 'next resign' rndc.out > /dev/null 2>&1 || ret=1
@ -330,22 +271,5 @@ n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
# The following test is disabled by default because it is very slow.
if [ -n "${TEST_LARGE_MAP}" ]; then
echo_i "checking map file size > 2GB can be loaded ($n)"
ret=0
$PERL ../../startperf/mkzonefile.pl test 9000000 > text.$n
# convert to map
$CHECKZONE -D -f text -F map -o map.$n test text.$n > /dev/null || ret=1
# check map file size is over 2GB to ensure the test is valid
size=$(ls -l map.$n | awk '{print $5}')
[ "$size" -gt 2147483648 ] || ret=1
# convert back to text
$CHECKZONE -f map test map.$n > /dev/null || ret=1
n=$((n+1))
[ $ret -eq 0 ] || echo_i "failed"
status=$((status+ret))
fi
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1

View file

@ -66,7 +66,7 @@ zone "tsigzone" {
zone "mapped" {
type secondary;
primaries { 10.53.0.2; };
masterfile-format map;
masterfile-format raw;
file "mapped.bk";
};

View file

@ -33,23 +33,6 @@ AC_DEFINE([PACKAGE_VERSION_EXTRA], ["][bind_VERSION_EXTRA]["], [BIND 9 Extra par
AC_DEFINE([PACKAGE_DESCRIPTION], [m4_ifnblank(bind_DESCRIPTION, [" ]bind_DESCRIPTION["], [])], [An extra string to print after PACKAGE_STRING])
AC_DEFINE([PACKAGE_SRCID], ["][bind_SRCID]["], [A short hash from git])
# This value should be increased whenever changing the structure of
# any object that will appear in a type 'map' master file (which
# contains a working memory image of an RBT database), as loading
# an incorrect memory image produces an inconsistent and probably
# nonfunctional database. These structures include but are not
# necessarily limited to dns_masterrawheader, rbtdb_file_header,
# rbt_file_header, dns_rbtdb, dns_rbt, dns_rbtnode, rdatasetheader.
#
# Err on the side of caution: if anything in the RBTDB is changed,
# bump the value. Making map files unreadable protects the system
# from instability; it's a feature not a bug.
#
# Whenever releasing a new major release of BIND9, set this value
# back to 1.0 when releasing the first alpha. Map files are *never*
# compatible across major releases.
AC_DEFINE([MAPAPI], ["3.0"], [BIND 9 MAPAPI Version])
bind_CONFIGARGS="${ac_configure_args:-default}"
AC_DEFINE_UNQUOTED([PACKAGE_CONFIGARGS], ["$bind_CONFIGARGS"], [Either 'defaults' or used ./configure options])
@ -358,11 +341,6 @@ AS_CASE([$host],
AC_CHECK_FUNCS([sysctlbyname])
#
# Check for the existence of mmap to enable the fast format zones
#
AC_CHECK_FUNCS(mmap)
#
# Older versions of HP/UX don't define seteuid() and setegid()
#

View file

@ -1551,9 +1551,6 @@ default is used.
have expired from caches. The ``max-zone-ttl`` option guarantees that
the largest TTL in the zone is no higher than the set value.
(Note: because ``map``-format files load directly into memory, this
option cannot be used with them.)
The default value is ``unlimited``. A ``max-zone-ttl`` of zero is
treated as ``unlimited``.
@ -3594,12 +3591,6 @@ Tuning
and ``raw``. Zone files in binary formats should be generated with the
same check level as that specified in the ``named`` configuration file.
``map`` format files are loaded directly into memory via memory mapping,
with only minimal validity checking. Because they are not guaranteed to
be compatible from one version of BIND 9 to another, and are not
compatible from one system architecture to another, they should be used
with caution. See :ref:`zonefile_format` for further discussion.
When configured in ``options``, this statement sets the
``masterfile-format`` for all zones, but it can be overridden on a
per-zone or per-view basis by including a ``masterfile-format``
@ -4014,8 +4005,7 @@ the view, or among the global options if there is no ``response-policy``
option for the view. Response policy zones are ordinary DNS zones
containing RRsets that can be queried normally if allowed. It is usually
best to restrict those queries with something like
``allow-query { localhost; };``. Note that zones using
``masterfile-format map`` cannot be used as policy zones.
``allow-query { localhost; };``.
A ``response-policy`` option can support multiple policy zones. To
maximize performance, a radix tree is used to quickly identify response
@ -5159,9 +5149,6 @@ The following options can be specified in a ``dnssec-policy`` statement:
guarantees that the largest TTL in the zone is no higher than the
set value.
.. note:: Because ``map``-format files load directly into memory,
this option cannot be used with them.
The default value is ``PT24H`` (24 hours). A ``max-zone-ttl`` of
zero is treated as if the default value were in use.
@ -6592,52 +6579,21 @@ The ``raw`` format is a binary representation of zone data in a manner
similar to that used in zone transfers. Since it does not require
parsing text, load time is significantly reduced.
An even faster alternative is the ``map`` format, which is an image of a
BIND 9 in-memory zone database; it can be loaded directly into memory via
the ``mmap()`` function and the zone can begin serving queries almost
immediately. Because records are not indivdually processed when loading a
``map`` file, zones using this format cannot be used in ``response-policy``
statements.
For a primary server, a zone file in ``raw`` or ``map`` format is expected
For a primary server, a zone file in ``raw`` format is expected
to be generated from a text zone file by the ``named-compilezone`` command.
For a secondary server or a dynamic zone, the zone file is automatically
generated when ``named`` dumps the zone contents after zone transfer or
when applying prior updates, if one of these formats is specified by the
``masterfile-format`` option.
If a zone file in a binary format needs manual modification, it first must
If a zone file in ``raw`` format needs manual modification, it first must
be converted to ``text`` format by the ``named-compilezone`` command,
then converted back after editing. For example:
::
named-compilezone -f map -F text -o zonefile.text <origin> zonefile.map
named-compilezone -f raw -F text -o zonefile.text <origin> zonefile.raw
[edit zonefile.text]
named-compilezone -f text -F map -o zonefile.map <origin> zonefile.text
Note that the ``map`` format is highly architecture-specific. A ``map``
file *cannot* be used on a system with different pointer size, endianness,
or data alignment than the system on which it was generated, and should in
general be used only inside a single system.
The ``map`` format is also dependent on the internal memory representation
of a zone database, which may change from one release of BIND 9 to another.
``map`` files are never compatible across major releases, and may not be
compatible across minor releases; any upgrade to BIND 9 may cause ``map``
files to be rejected when loading. If a ``map`` file is being used for a
primary zone, it will need to be regenerated from text before restarting
the server. If it used for a secondary zone, this is unnecessary; the
rejection of the file will trigger a retransfer of the zone from the
primary. (To avoid a spike in traffic upon restart, it may be desirable in
some cases to convert ``map`` files to ``text`` format using
``named-compilezone`` before an upgrade, then back to ``map`` format with
the new version of ``named-compilezone`` afterward.)
``raw`` format uses network byte order and avoids architecture-
dependent data alignment so that it is as portable as possible, but it is
still primarily expected to be used inside the same single system. To
export a zone file in either ``raw`` or ``map`` format, or make a portable
backup of such a file, conversion to ``text`` format is recommended.
named-compilezone -f text -F raw -o zonefile.raw <origin> zonefile.text
.. _statistics:

View file

@ -62,8 +62,8 @@ This option indicates that only those record types automatically managed by
\fBdnssec\-signzone\fP, i.e., RRSIG, NSEC, NSEC3 and NSEC3PARAM records, should be included in the output.
If smart signing (\fB\-S\fP) is used, DNSKEY records are also included.
The resulting file can be included in the original zone file with
\fB$INCLUDE\fP\&. This option cannot be combined with \fB\-O raw\fP,
\fB\-O map\fP, or serial\-number updating.
\fB$INCLUDE\fP\&. This option cannot be combined with \fB\-O raw\fP
or serial\-number updating.
.TP
.B \fB\-E engine\fP
This option specifies the hardware to use for cryptographic
@ -157,8 +157,8 @@ days. Therefore, if any existing RRSIG records are due to expire in
less than 7.5 days, they are replaced.
.TP
.B \fB\-I input\-format\fP
This option sets the format of the input zone file. Possible formats are \fBtext\fP
(the default), \fBraw\fP, and \fBmap\fP\&. This option is primarily
This option sets the format of the input zone file. Possible formats are
\fBtext\fP (the default), and \fBraw\fP\&. This option is primarily
intended to be used for dynamic signed zones, so that the dumped zone
file in a non\-text format containing updates can be signed directly.
This option is not useful for non\-dynamic zones.
@ -179,7 +179,7 @@ less congestion than if all validators need to refetch at around the
same time.
.TP
.B \fB\-L serial\fP
When writing a signed zone to "raw" or "map" format, this option sets the "source
When writing a signed zone to "raw" format, this option sets the "source
serial" value in the header to the specified \fBserial\fP number. (This is
expected to be used primarily for testing purposes.)
.TP
@ -217,15 +217,14 @@ This option sets the zone origin. If not specified, the name of the zone file is
assumed to be the origin.
.TP
.B \fB\-O output\-format\fP
This option sets the format of the output file containing the signed zone. Possible
formats are \fBtext\fP (the default), which is the standard textual
representation of the zone; \fBfull\fP, which is text output in a
format suitable for processing by external scripts; and \fBmap\fP,
\fBraw\fP, and \fBraw=N\fP, which store the zone in binary formats
for rapid loading by \fBnamed\fP\&. \fBraw=N\fP specifies the format
version of the raw zone file: if N is 0, the raw file can be read by
any version of \fBnamed\fP; if N is 1, the file can be read by release
9.9.0 or higher. The default is 1.
This option sets the format of the output file containing the signed
zone. Possible formats are \fBtext\fP (the default), which is the standard
textual representation of the zone; \fBfull\fP, which is text output in a
format suitable for processing by external scripts; and \fBraw\fP and
\fBraw=N\fP, which store the zone in binary formats for rapid loading by
\fBnamed\fP\&. \fBraw=N\fP specifies the format version of the raw zone file:
if N is 0, the raw file can be read by any version of \fBnamed\fP; if N is
1, the file can be read by release 9.9.0 or higher. The default is 1.
.TP
.B \fB\-P\fP
This option disables post\-sign verification tests.

View file

@ -103,8 +103,8 @@ respectively.
Mode \fBnone\fP disables the checks.
.TP
.B \fB\-f format\fP
This option specifies the format of the zone file. Possible formats are \fBtext\fP
(the default), \fBraw\fP, and \fBmap\fP\&.
This option specifies the format of the zone file. Possible formats are
\fBtext\fP (the default), and \fBraw\fP\&.
.TP
.B \fB\-F format\fP
This option specifies the format of the output file specified. For
@ -112,12 +112,11 @@ This option specifies the format of the output file specified. For
the zone contents.
.sp
Possible formats are \fBtext\fP (the default), which is the standard
textual representation of the zone, and \fBmap\fP, \fBraw\fP, and
\fBraw=N\fP, which store the zone in a binary format for rapid
loading by \fBnamed\fP\&. \fBraw=N\fP specifies the format version of the
raw zone file: if \fBN\fP is 0, the raw file can be read by any version of
\fBnamed\fP; if N is 1, the file can only be read by release 9.9.0 or
higher. The default is 1.
textual representation of the zone, and \fBraw\fP and \fBraw=N\fP, which
store the zone in a binary format for rapid loading by \fBnamed\fP\&.
\fBraw=N\fP specifies the format version of the raw zone file: if \fBN\fP is
0, the raw file can be read by any version of \fBnamed\fP; if N is 1, the
file can only be read by release 9.9.0 or higher. The default is 1.
.TP
.B \fB\-k mode\fP
This option performs \fBcheck\-names\fP checks with the specified failure mode.
@ -130,7 +129,7 @@ TTL higher than this value causes the zone to be rejected. This
is similar to using the \fBmax\-zone\-ttl\fP option in \fBnamed.conf\fP\&.
.TP
.B \fB\-L serial\fP
When compiling a zone to \fBraw\fP or \fBmap\fP format, this option sets the "source
When compiling a zone to \fBraw\fP format, this option sets the "source
serial" value in the header to the specified serial number. This is
expected to be used primarily for testing purposes.
.TP

View file

@ -103,8 +103,8 @@ respectively.
Mode \fBnone\fP disables the checks.
.TP
.B \fB\-f format\fP
This option specifies the format of the zone file. Possible formats are \fBtext\fP
(the default), \fBraw\fP, and \fBmap\fP\&.
This option specifies the format of the zone file. Possible formats are
\fBtext\fP (the default), and \fBraw\fP\&.
.TP
.B \fB\-F format\fP
This option specifies the format of the output file specified. For
@ -112,12 +112,11 @@ This option specifies the format of the output file specified. For
the zone contents.
.sp
Possible formats are \fBtext\fP (the default), which is the standard
textual representation of the zone, and \fBmap\fP, \fBraw\fP, and
\fBraw=N\fP, which store the zone in a binary format for rapid
loading by \fBnamed\fP\&. \fBraw=N\fP specifies the format version of the
raw zone file: if \fBN\fP is 0, the raw file can be read by any version of
\fBnamed\fP; if N is 1, the file can only be read by release 9.9.0 or
higher. The default is 1.
textual representation of the zone, and \fBraw\fP and \fBraw=N\fP, which
store the zone in a binary format for rapid loading by \fBnamed\fP\&.
\fBraw=N\fP specifies the format version of the raw zone file: if \fBN\fP is
0, the raw file can be read by any version of \fBnamed\fP; if N is 1, the
file can only be read by release 9.9.0 or higher. The default is 1.
.TP
.B \fB\-k mode\fP
This option performs \fBcheck\-names\fP checks with the specified failure mode.
@ -130,7 +129,7 @@ TTL higher than this value causes the zone to be rejected. This
is similar to using the \fBmax\-zone\-ttl\fP option in \fBnamed.conf\fP\&.
.TP
.B \fB\-L serial\fP
When compiling a zone to \fBraw\fP or \fBmap\fP format, this option sets the "source
When compiling a zone to \fBraw\fP format, this option sets the "source
serial" value in the header to the specified serial number. This is
expected to be used primarily for testing purposes.
.TP

View file

@ -370,7 +370,7 @@ options {
lmdb\-mapsize sizeval;
lock\-file ( quoted_string | none );
managed\-keys\-directory quoted_string;
masterfile\-format ( map | raw | text );
masterfile\-format ( raw | text );
masterfile\-style ( full | relative );
match\-mapped\-addresses boolean;
max\-cache\-size ( default | unlimited | sizeval | percentage );
@ -815,7 +815,7 @@ view string [ class ] {
) integer integer
integer
quoted_string; ... };, deprecated
masterfile\-format ( map | raw | text );
masterfile\-format ( raw | text );
masterfile\-style ( full | relative );
match\-clients { address_match_element; ... };
match\-destinations { address_match_element; ... };
@ -1034,7 +1034,7 @@ view string [ class ] {
ixfr\-from\-differences boolean;
journal quoted_string;
key\-directory quoted_string;
masterfile\-format ( map | raw | text );
masterfile\-format ( raw | text );
masterfile\-style ( full | relative );
masters [ port integer ] [ dscp integer ] { (
remote\-servers | ipv4_address [ port integer ] |
@ -1155,7 +1155,7 @@ zone string [ class ] {
ixfr\-from\-differences boolean;
journal quoted_string;
key\-directory quoted_string;
masterfile\-format ( map | raw | text );
masterfile\-format ( raw | text );
masterfile\-style ( full | relative );
masters [ port integer ] [ dscp integer ] { ( remote\-servers
| ipv4_address [ port integer ] | ipv6_address [ port

View file

@ -33,7 +33,7 @@ zone <string> [ <class> ] {
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
max-ixfr-ratio ( unlimited | <percentage> );
max-journal-size ( default | unlimited | <sizeval> );

View file

@ -35,7 +35,7 @@
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
max-ixfr-ratio ( unlimited | <percentage> );
max-journal-size ( default | unlimited | <sizeval> );

View file

@ -13,7 +13,7 @@ zone <string> [ <class> ] {
file <quoted_string>;
ixfr-from-differences <boolean>;
journal <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-ixfr-ratio ( unlimited | <percentage> );

View file

@ -15,7 +15,7 @@
file <quoted_string>;
ixfr-from-differences <boolean>;
journal <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-ixfr-ratio ( unlimited | <percentage> );

View file

@ -291,7 +291,7 @@ OPTIONS
lmdb-mapsize sizeval;
lock-file ( quoted_string | none );
managed-keys-directory quoted_string;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-mapped-addresses boolean;
max-cache-size ( default | unlimited | sizeval | percentage );
@ -648,7 +648,7 @@ VIEW
) integer integer
integer
quoted_string; ... };, deprecated
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-clients { address_match_element; ... };
match-destinations { address_match_element; ... };
@ -860,7 +860,7 @@ VIEW
ixfr-from-differences boolean;
journal quoted_string;
key-directory quoted_string;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port integer ] [ dscp integer ] { ( masters
| ipv4_address [ port integer ] | ipv6_address [
@ -963,7 +963,7 @@ ZONE
ixfr-from-differences boolean;
journal quoted_string;
key-directory quoted_string;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port integer ] [ dscp integer ] { ( masters |
ipv4_address [ port integer ] | ipv6_address [ port

View file

@ -227,7 +227,7 @@ options {
lmdb-mapsize <sizeval>;
lock-file ( <quoted_string> | none );
managed-keys-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-mapped-addresses <boolean>;
max-cache-size ( default | unlimited | <sizeval> | <percentage> );
@ -591,7 +591,7 @@ view <string> [ <class> ] {
) <integer> <integer>
<integer>
<quoted_string>; ... }; // may occur multiple times, deprecated
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-clients { <address_match_element>; ... };
match-destinations { <address_match_element>; ... };
@ -812,7 +812,7 @@ view <string> [ <class> ] {
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { (
<remote-servers> | <ipv4_address> [ port <integer> ] |
@ -925,7 +925,7 @@ zone <string> [ <class> ] {
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers>
| <ipv4_address> [ port <integer> ] | <ipv6_address> [ port

View file

@ -226,7 +226,7 @@ options {
lmdb-mapsize <sizeval>;
lock-file ( <quoted_string> | none );
managed-keys-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-mapped-addresses <boolean>;
max-cache-size ( default | unlimited | <sizeval> | <percentage> );
@ -588,7 +588,7 @@ view <string> [ <class> ] {
) <integer> <integer>
<integer>
<quoted_string>; ... }; // may occur multiple times, deprecated
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-clients { <address_match_element>; ... };
match-destinations { <address_match_element>; ... };
@ -807,7 +807,7 @@ view <string> [ <class> ] {
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { (
<remote-servers> | <ipv4_address> [ port <integer> ] |
@ -919,7 +919,7 @@ zone <string> [ <class> ] {
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers>
| <ipv4_address> [ port <integer> ] | <ipv6_address> [ port

View file

@ -146,7 +146,7 @@
lmdb-mapsize <sizeval>;
lock-file ( <quoted_string> | none );
managed-keys-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
match-mapped-addresses <boolean>;
max-cache-size ( default | unlimited | <sizeval> | <percentage> );

View file

@ -4,7 +4,7 @@ zone <string> [ <class> ] {
allow-query-on { <address_match_element>; ... };
dlz <string>;
file <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-records <integer>;

View file

@ -6,7 +6,7 @@
allow-query-on { <address_match_element>; ... };
dlz <string>;
file <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-records <integer>;

View file

@ -25,7 +25,7 @@ zone <string> [ <class> ] {
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-ixfr-ratio ( unlimited | <percentage> );

View file

@ -27,7 +27,7 @@
ixfr-from-differences <boolean>;
journal <quoted_string>;
key-directory <quoted_string>;
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-ixfr-ratio ( unlimited | <percentage> );

View file

@ -9,7 +9,7 @@ zone <string> [ <class> ] {
file <quoted_string>;
forward ( first | only );
forwarders [ port <integer> ] [ dscp <integer> ] { ( <ipv4_address> | <ipv6_address> ) [ port <integer> ] [ dscp <integer> ]; ... };
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-records <integer>;

View file

@ -11,7 +11,7 @@
file <quoted_string>;
forward ( first | only );
forwarders [ port <integer> ] [ dscp <integer> ] { ( <ipv4_address> | <ipv6_address> ) [ port <integer> ] [ dscp <integer> ]; ... };
masterfile-format ( map | raw | text );
masterfile-format ( raw | text );
masterfile-style ( full | relative );
masters [ port <integer> ] [ dscp <integer> ] { ( <remote-servers> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ] [ tls <string> ]; ... };
max-records <integer>;

View file

@ -2636,7 +2636,6 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
bool ula = false;
const cfg_listelt_t *element;
bool dlz;
dns_masterformat_t masterformat;
bool ddns = false;
bool has_dnssecpolicy = false;
const void *clauses = NULL;
@ -3445,47 +3444,6 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
}
}
/*
* Check that max-zone-ttl isn't used with masterfile-format map
*/
masterformat = dns_masterformat_text;
obj = NULL;
(void)cfg_map_get(zoptions, "masterfile-format", &obj);
if (obj != NULL) {
const char *masterformatstr = cfg_obj_asstring(obj);
if (strcasecmp(masterformatstr, "text") == 0) {
masterformat = dns_masterformat_text;
} else if (strcasecmp(masterformatstr, "raw") == 0) {
masterformat = dns_masterformat_raw;
} else if (strcasecmp(masterformatstr, "map") == 0) {
masterformat = dns_masterformat_map;
cfg_obj_log(obj, logctx, ISC_LOG_WARNING,
"masterfile-format: format 'map' is "
"deprecated");
} else {
INSIST(0);
ISC_UNREACHABLE();
}
}
if (masterformat == dns_masterformat_map) {
obj = NULL;
(void)cfg_map_get(zoptions, "max-zone-ttl", &obj);
if (obj == NULL && voptions != NULL) {
(void)cfg_map_get(voptions, "max-zone-ttl", &obj);
}
if (obj == NULL && goptions != NULL) {
(void)cfg_map_get(goptions, "max-zone-ttl", &obj);
}
if (obj != NULL) {
cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
"zone '%s': 'max-zone-ttl' is not "
"compatible with 'masterfile-format map'",
znamestr);
result = ISC_R_FAILURE;
}
}
/*
* Warn if key-directory doesn't exist
*/

View file

@ -334,15 +334,6 @@ dns_db_load(dns_db_t *db, const char *filename, dns_masterformat_t format,
return (result);
}
isc_result_t
dns_db_serialize(dns_db_t *db, dns_dbversion_t *version, FILE *file) {
REQUIRE(DNS_DB_VALID(db));
if (db->methods->serialize == NULL) {
return (ISC_R_NOTIMPLEMENTED);
}
return ((db->methods->serialize)(db, version, file));
}
isc_result_t
dns_db_dump(dns_db_t *db, dns_dbversion_t *version, const char *filename) {
return ((db->methods->dump)(db, version, filename,

View file

@ -924,7 +924,6 @@ static dns_dbmethods_t rpsdb_db_methods = {
rpsdb_detach,
NULL, /* beginload */
NULL, /* endload */
NULL, /* serialize */
NULL, /* dump */
NULL, /* currentversion */
NULL, /* newversion */

View file

@ -40,12 +40,6 @@ struct dns_rdatacallbacks {
*/
dns_addrdatasetfunc_t add;
/*%
* This is called when reading in a database image from a 'map'
* format zone file.
*/
dns_deserializefunc_t deserialize;
/*%
* dns_master_load*() call this when loading a raw zonefile,
* to pass back information obtained from the file header
@ -65,7 +59,6 @@ struct dns_rdatacallbacks {
* Private data handles for use by the above callback functions.
*/
void *add_private;
void *deserialize_private;
void *error_private;
void *warn_private;
};

View file

@ -74,8 +74,6 @@ typedef struct dns_dbmethods {
isc_result_t (*beginload)(dns_db_t * db,
dns_rdatacallbacks_t *callbacks);
isc_result_t (*endload)(dns_db_t *db, dns_rdatacallbacks_t *callbacks);
isc_result_t (*serialize)(dns_db_t *db, dns_dbversion_t *version,
FILE *file);
isc_result_t (*dump)(dns_db_t *db, dns_dbversion_t *version,
const char * filename,
dns_masterformat_t masterformat);
@ -499,8 +497,6 @@ dns_db_beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks);
* suitable for loading records into 'db' from a raw or text zone
* file. callbacks->add_private will be a valid DB load context
* which should be used as 'arg' when callbacks->add is called.
* callbacks->deserialize will be a valid dns_deserialize_func_t
* suitable for loading 'db' from a map format zone file.
*
* Returns:
*
@ -567,26 +563,6 @@ dns_db_load(dns_db_t *db, const char *filename, dns_masterformat_t format,
* implementation used, syntax errors in the master file, etc.
*/
isc_result_t
dns_db_serialize(dns_db_t *db, dns_dbversion_t *version, FILE *rbtfile);
/*%<
* Dump version 'version' of 'db' to map-format file 'filename'.
*
* Requires:
*
* \li 'db' is a valid database.
*
* \li 'version' is a valid version.
*
* Returns:
*
* \li #ISC_R_SUCCESS
* \li #ISC_R_NOMEMORY
*
* \li Other results are possible, depending upon the database
* implementation used, OS file errors, etc.
*/
isc_result_t
dns_db_dump(dns_db_t *db, dns_dbversion_t *version, const char *filename);
/*%<

View file

@ -79,9 +79,7 @@ ISC_LANG_BEGINDECLS
/* Common header */
struct dns_masterrawheader {
uint32_t format; /* must be
* dns_masterformat_raw
* or
* dns_masterformat_map */
* dns_masterformat_raw */
uint32_t version; /* compatibility for future
* extensions */
uint32_t dumptime; /* timestamp on creation

View file

@ -98,21 +98,6 @@ struct dns_rbtnode {
unsigned int oldnamelen : 8; /*%< range is 1..255 */
/*@}*/
/* flags needed for serialization to file */
unsigned int is_mmapped : 1;
unsigned int parent_is_relative : 1;
unsigned int left_is_relative : 1;
unsigned int right_is_relative : 1;
unsigned int down_is_relative : 1;
unsigned int data_is_relative : 1;
/*
* full name length; set during serialization, and used
* during deserialization to calculate database size.
* should be cleared after use.
*/
unsigned int fullnamelen : 8; /*%< range is 1..255 */
/* node needs to be cleaned from rpz */
unsigned int rpz : 1;
unsigned int : 0; /* end of bitfields c/o tree lock */
@ -722,42 +707,6 @@ dns_rbt_destroy2(dns_rbt_t **rbtp, unsigned int quantum);
* \li ISC_R_QUOTA if 'quantum' nodes have been destroyed.
*/
off_t
dns_rbt_serialize_align(off_t target);
/*%<
* Align the provided integer to a pointer-size boundary.
* This should be used if, during serialization of data to a will-be
* mmap()ed file, a pointer alignment is needed for some data.
*/
isc_result_t
dns_rbt_serialize_tree(FILE *file, dns_rbt_t *rbt,
dns_rbtdatawriter_t datawriter, void *writer_arg,
off_t *offset);
/*%<
* Write out the RBT structure and its data to a file.
*
* Notes:
* \li The file must be an actual file which allows seek() calls, so it cannot
* be a stream. Returns ISC_R_INVALIDFILE if not.
*/
isc_result_t
dns_rbt_deserialize_tree(void *base_address, size_t filesize,
off_t header_offset, isc_mem_t *mctx,
dns_rbtdeleter_t deleter, void *deleter_arg,
dns_rbtdatafixer_t datafixer, void *fixer_arg,
dns_rbtnode_t **originp, dns_rbt_t **rbtp);
/*%<
* Read a RBT structure and its data from a file.
*
* If 'originp' is not NULL, then it is pointed to the root node of the RBT.
*
* Notes:
* \li The file must be an actual file which allows seek() calls, so it cannot
* be a stream. This condition is not checked in the code.
*/
void
dns_rbt_printtext(dns_rbt_t *rbt, void (*data_printer)(FILE *, void *),
FILE * f);

View file

@ -208,7 +208,6 @@ typedef enum {
dns_masterformat_none = 0,
dns_masterformat_text = 1,
dns_masterformat_raw = 2,
dns_masterformat_map = 3
} dns_masterformat_t;
/*
@ -421,8 +420,6 @@ typedef bool (*dns_isselffunc_t)(dns_view_t *, dns_tsigkey_t *,
const isc_sockaddr_t *, const isc_sockaddr_t *,
dns_rdataclass_t, void *);
typedef isc_result_t (*dns_deserializefunc_t)(void *, FILE *, off_t);
typedef void (*dns_nseclog_t)(void *val, int, const char *, ...);
#endif /* DNS_TYPES_H */

View file

@ -185,12 +185,6 @@ openfile_raw(dns_loadctx_t *lctx, const char *master_file);
static isc_result_t
load_raw(dns_loadctx_t *lctx);
static isc_result_t
openfile_map(dns_loadctx_t *lctx, const char *master_file);
static isc_result_t
load_map(dns_loadctx_t *lctx);
static isc_result_t
pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t *lctx);
@ -543,10 +537,6 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
lctx->openfile = openfile_raw;
lctx->load = load_raw;
break;
case dns_masterformat_map:
lctx->openfile = openfile_map;
lctx->load = load_map;
break;
default:
INSIST(0);
ISC_UNREACHABLE();
@ -2251,9 +2241,7 @@ load_header(dns_loadctx_t *lctx) {
REQUIRE(DNS_LCTX_VALID(lctx));
if (lctx->format != dns_masterformat_raw &&
lctx->format != dns_masterformat_map)
{
if (lctx->format != dns_masterformat_raw) {
return (ISC_R_NOTIMPLEMENTED);
}
@ -2276,10 +2264,7 @@ load_header(dns_loadctx_t *lctx) {
if (header.format != lctx->format) {
(*callbacks->error)(callbacks,
"dns_master_load: "
"file format mismatch (not %s)",
lctx->format == dns_masterformat_map ? "map"
: "ra"
"w");
"file format mismatch (not raw)");
return (ISC_R_NOTIMPLEMENTED);
}
@ -2321,46 +2306,6 @@ load_header(dns_loadctx_t *lctx) {
return (ISC_R_SUCCESS);
}
static isc_result_t
openfile_map(dns_loadctx_t *lctx, const char *master_file) {
isc_result_t result;
result = isc_stdio_open(master_file, "rb", &lctx->f);
if (result != ISC_R_SUCCESS && result != ISC_R_FILENOTFOUND) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_stdio_open() failed: %s",
isc_result_totext(result));
}
return (result);
}
/*
* Load a map format file, using mmap() to access RBT trees directly
*/
static isc_result_t
load_map(dns_loadctx_t *lctx) {
isc_result_t result = ISC_R_SUCCESS;
dns_rdatacallbacks_t *callbacks;
REQUIRE(DNS_LCTX_VALID(lctx));
callbacks = lctx->callbacks;
if (lctx->first) {
result = load_header(lctx);
if (result != ISC_R_SUCCESS) {
return (result);
}
result = (*callbacks->deserialize)(
callbacks->deserialize_private, lctx->f,
sizeof(dns_masterrawheader_t));
}
return (result);
}
static isc_result_t
openfile_raw(dns_loadctx_t *lctx, const char *master_file) {
isc_result_t result;

View file

@ -1313,20 +1313,6 @@ dump_rdatasets_raw(isc_mem_t *mctx, const dns_name_t *owner_name,
return (result);
}
static isc_result_t
dump_rdatasets_map(isc_mem_t *mctx, const dns_name_t *name,
dns_rdatasetiter_t *rdsiter, dns_totext_ctx_t *ctx,
isc_buffer_t *buffer, FILE *f) {
UNUSED(mctx);
UNUSED(name);
UNUSED(rdsiter);
UNUSED(ctx);
UNUSED(buffer);
UNUSED(f);
return (ISC_R_NOTIMPLEMENTED);
}
/*
* Initial size of text conversion buffer. The buffer is used
* for several purposes: converting origin names, rdatasets,
@ -1592,9 +1578,6 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
case dns_masterformat_raw:
dctx->dumpsets = dump_rdatasets_raw;
break;
case dns_masterformat_map:
dctx->dumpsets = dump_rdatasets_map;
break;
default:
INSIST(0);
ISC_UNREACHABLE();
@ -1687,7 +1670,6 @@ writeheader(dns_dumpctx_t *dctx) {
}
break;
case dns_masterformat_raw:
case dns_masterformat_map:
r.base = (unsigned char *)&rawheader;
r.length = sizeof(rawheader);
isc_buffer_region(&buffer, &r);
@ -1742,17 +1724,6 @@ dumptostream(dns_dumpctx_t *dctx) {
CHECK(writeheader(dctx));
/*
* Fast format is not currently written incrementally,
* so we make the call to dns_db_serialize() here.
* If the database is anything other than an rbtdb,
* this should result in not implemented
*/
if (dctx->format == dns_masterformat_map) {
result = dns_db_serialize(dctx->db, dctx->version, dctx->f);
goto cleanup;
}
result = dns_dbiterator_first(dctx->dbiter);
if (result != ISC_R_SUCCESS && result != ISC_R_NOMORE) {
goto cleanup;

View file

@ -95,120 +95,6 @@ struct dns_rbt {
#define RED 0
#define BLACK 1
/*
* This is the header for map-format RBT images. It is populated,
* and then written, as the LAST thing done to the file before returning.
* Writing this last (with zeros in the header area initially) will ensure
* that the header is only valid when the RBT image is also valid.
*/
typedef struct file_header file_header_t;
/* Pad to 32 bytes */
static char FILE_VERSION[32] = "\0";
/* Header length, always the same size regardless of structure size */
#define HEADER_LENGTH 1024
struct file_header {
char version1[32];
uint64_t first_node_offset; /* usually 1024 */
/*
* information about the system on which the map file was generated
* will be used to tell if we can load the map file or not
*/
uint32_t ptrsize;
unsigned int bigendian : 1; /* big or little endian system */
unsigned int rdataset_fixed : 1; /* compiled with
* --enable-rrset-fixed
*/
unsigned int nodecount; /* shadow from rbt structure */
uint64_t crc;
char version2[32]; /* repeated; must match version1 */
};
/*
* The following declarations are for the serialization of an RBT:
*
* step one: write out a zeroed header of 1024 bytes
* step two: walk the tree in a depth-first, left-right-down order, writing
* out the nodes, reserving space as we go, correcting addresses to point
* at the proper offset in the file, and setting a flag for each pointer to
* indicate that it is a reference to a location in the file, rather than in
* memory.
* step three: write out the header, adding the information that will be
* needed to re-create the tree object itself.
*
* The RBTDB object will do this three times, once for each of the three
* RBT objects it contains.
*
* Note: 'file' must point an actual open file that can be mmapped
* and fseeked, not to a pipe or stream
*/
static isc_result_t
dns_rbt_zero_header(FILE *file);
static isc_result_t
write_header(FILE *file, dns_rbt_t *rbt, uint64_t first_node_offset,
uint64_t crc);
static bool
match_header_version(file_header_t *header);
static isc_result_t
serialize_node(FILE *file, dns_rbtnode_t *node, uintptr_t left, uintptr_t right,
uintptr_t down, uintptr_t parent, uintptr_t data, uint64_t *crc);
static isc_result_t
serialize_nodes(FILE *file, dns_rbtnode_t *node, uintptr_t parent,
dns_rbtdatawriter_t datawriter, void *writer_arg,
uintptr_t *where, uint64_t *crc);
/*
* The following functions allow you to get the actual address of a pointer
* without having to use an if statement to check to see if that address is
* relative or not
*/
static inline dns_rbtnode_t *
getparent(dns_rbtnode_t *node, file_header_t *header) {
char *adjusted_address = (char *)(node->parent);
adjusted_address += node->parent_is_relative * (uintptr_t)header;
return ((dns_rbtnode_t *)adjusted_address);
}
static inline dns_rbtnode_t *
getleft(dns_rbtnode_t *node, file_header_t *header) {
char *adjusted_address = (char *)(node->left);
adjusted_address += node->left_is_relative * (uintptr_t)header;
return ((dns_rbtnode_t *)adjusted_address);
}
static inline dns_rbtnode_t *
getright(dns_rbtnode_t *node, file_header_t *header) {
char *adjusted_address = (char *)(node->right);
adjusted_address += node->right_is_relative * (uintptr_t)header;
return ((dns_rbtnode_t *)adjusted_address);
}
static inline dns_rbtnode_t *
getdown(dns_rbtnode_t *node, file_header_t *header) {
char *adjusted_address = (char *)(node->down);
adjusted_address += node->down_is_relative * (uintptr_t)header;
return ((dns_rbtnode_t *)adjusted_address);
}
static inline dns_rbtnode_t *
getdata(dns_rbtnode_t *node, file_header_t *header) {
char *adjusted_address = (char *)(node->data);
adjusted_address += node->data_is_relative * (uintptr_t)header;
return ((dns_rbtnode_t *)adjusted_address);
}
/*%
* Elements of the rbtnode structure.
*/
@ -315,29 +201,6 @@ Name(dns_rbtnode_t *node) {
return (name);
}
static void
hexdump(const char *desc, unsigned char *data, size_t size) {
char hexdump[BUFSIZ * 2 + 1];
isc_buffer_t b;
isc_region_t r;
isc_result_t result;
size_t bytes;
fprintf(stderr, "%s: ", desc);
do {
isc_buffer_init(&b, hexdump, sizeof(hexdump));
r.base = data;
r.length = bytes = (size > BUFSIZ) ? BUFSIZ : size;
result = isc_hex_totext(&r, 0, "", &b);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_putuint8(&b, 0);
fprintf(stderr, "%s", hexdump);
data += bytes;
size -= bytes;
} while (size > 0);
fprintf(stderr, "\n");
}
#endif /* DEBUG */
/*
@ -349,28 +212,6 @@ get_upper_node(dns_rbtnode_t *node) {
return (UPPERNODE(node));
}
static void
fixup_uppernodes_helper(dns_rbtnode_t *node, dns_rbtnode_t *uppernode) {
if (node == NULL) {
return;
}
UPPERNODE(node) = uppernode;
fixup_uppernodes_helper(LEFT(node), uppernode);
fixup_uppernodes_helper(RIGHT(node), uppernode);
fixup_uppernodes_helper(DOWN(node), node);
}
/*
* This function is used to fixup uppernode members of all dns_rbtnodes
* after deserialization.
*/
static void
fixup_uppernodes(dns_rbt_t *rbt) {
fixup_uppernodes_helper(rbt->root, NULL);
}
size_t
dns__rbtnode_getdistance(dns_rbtnode_t *node) {
size_t nodes = 1;
@ -420,11 +261,6 @@ addonlevel(dns_rbtnode_t *node, dns_rbtnode_t *current, int order,
static void
deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp);
static isc_result_t
treefix(dns_rbt_t *rbt, void *base, size_t size, dns_rbtnode_t *n,
const dns_name_t *name, dns_rbtdatafixer_t datafixer, void *fixer_arg,
uint64_t *crc);
static void
deletetreeflat(dns_rbt_t *rbt, unsigned int quantum, bool unhash,
dns_rbtnode_t **nodep);
@ -435,103 +271,6 @@ printnodename(dns_rbtnode_t *node, bool quoted, FILE *f);
static void
freenode(dns_rbt_t *rbt, dns_rbtnode_t **nodep);
static isc_result_t
dns_rbt_zero_header(FILE *file) {
/*
* Write out a zeroed header as a placeholder. Doing this ensures
* that the file will not read while it is partially written, should
* writing fail or be interrupted.
*/
char buffer[HEADER_LENGTH];
isc_result_t result;
memset(buffer, 0, HEADER_LENGTH);
result = isc_stdio_write(buffer, 1, HEADER_LENGTH, file, NULL);
if (result != ISC_R_SUCCESS) {
return (result);
}
result = fflush(file);
if (result != ISC_R_SUCCESS) {
return (result);
}
return (ISC_R_SUCCESS);
}
static isc_once_t once = ISC_ONCE_INIT;
static void
init_file_version(void) {
int n;
memset(FILE_VERSION, 0, sizeof(FILE_VERSION));
n = snprintf(FILE_VERSION, sizeof(FILE_VERSION), "RBT Image %s %s",
PACKAGE_VERSION_MAJOR, MAPAPI);
INSIST(n > 0 && (unsigned int)n < sizeof(FILE_VERSION));
}
/*
* Write out the real header, including NodeDump version information
* and the offset of the first node.
*
* Any information stored in the rbt object itself should be stored
* here.
*/
static isc_result_t
write_header(FILE *file, dns_rbt_t *rbt, uint64_t first_node_offset,
uint64_t crc) {
file_header_t header;
isc_result_t result;
off_t location;
RUNTIME_CHECK(isc_once_do(&once, init_file_version) == ISC_R_SUCCESS);
memset(&header, 0, sizeof(file_header_t));
memmove(header.version1, FILE_VERSION, sizeof(header.version1));
memmove(header.version2, FILE_VERSION, sizeof(header.version2));
header.first_node_offset = first_node_offset;
header.ptrsize = (uint32_t)sizeof(void *);
header.bigendian = (1 == htonl(1)) ? 1 : 0;
#ifdef DNS_RDATASET_FIXED
header.rdataset_fixed = 1;
#else /* ifdef DNS_RDATASET_FIXED */
header.rdataset_fixed = 0;
#endif /* ifdef DNS_RDATASET_FIXED */
header.nodecount = rbt->nodecount;
header.crc = crc;
CHECK(isc_stdio_tell(file, &location));
location = dns_rbt_serialize_align(location);
CHECK(isc_stdio_seek(file, location, SEEK_SET));
CHECK(isc_stdio_write(&header, 1, sizeof(file_header_t), file, NULL));
CHECK(fflush(file));
/* Ensure we are always at the end of the file. */
CHECK(isc_stdio_seek(file, 0, SEEK_END));
cleanup:
return (result);
}
static bool
match_header_version(file_header_t *header) {
RUNTIME_CHECK(isc_once_do(&once, init_file_version) == ISC_R_SUCCESS);
if (memcmp(header->version1, FILE_VERSION, sizeof(header->version1)) !=
0 ||
memcmp(header->version2, FILE_VERSION, sizeof(header->version1)) !=
0)
{
return (false);
}
return (true);
}
unsigned int
dns__rbtnode_namelen(dns_rbtnode_t *node) {
dns_name_t current;
@ -556,435 +295,6 @@ dns__rbtnode_namelen(dns_rbtnode_t *node) {
return (len);
}
static isc_result_t
serialize_node(FILE *file, dns_rbtnode_t *node, uintptr_t left, uintptr_t right,
uintptr_t down, uintptr_t parent, uintptr_t data,
uint64_t *crc) {
isc_result_t result;
dns_rbtnode_t temp_node;
off_t file_position;
unsigned char *node_data = NULL;
size_t datasize;
#ifdef DEBUG
dns_name_t nodename;
#endif /* ifdef DEBUG */
INSIST(node != NULL);
CHECK(isc_stdio_tell(file, &file_position));
file_position = dns_rbt_serialize_align(file_position);
CHECK(isc_stdio_seek(file, file_position, SEEK_SET));
temp_node = *node;
temp_node.down_is_relative = 0;
temp_node.left_is_relative = 0;
temp_node.right_is_relative = 0;
temp_node.parent_is_relative = 0;
temp_node.data_is_relative = 0;
temp_node.is_mmapped = 1;
/*
* If the next node is not NULL, calculate the next node's location
* in the file. Note that this will have to change when the data
* structure changes, and it also assumes that we always write the
* nodes out in list order (which we currently do.)
*/
if (temp_node.parent != NULL) {
temp_node.parent = (dns_rbtnode_t *)(parent);
temp_node.parent_is_relative = 1;
}
if (temp_node.left != NULL) {
temp_node.left = (dns_rbtnode_t *)(left);
temp_node.left_is_relative = 1;
}
if (temp_node.right != NULL) {
temp_node.right = (dns_rbtnode_t *)(right);
temp_node.right_is_relative = 1;
}
if (temp_node.down != NULL) {
temp_node.down = (dns_rbtnode_t *)(down);
temp_node.down_is_relative = 1;
}
if (temp_node.data != NULL) {
temp_node.data = (dns_rbtnode_t *)(data);
temp_node.data_is_relative = 1;
}
temp_node.fullnamelen = dns__rbtnode_namelen(node);
node_data = (unsigned char *)node + sizeof(dns_rbtnode_t);
datasize = NODE_SIZE(node) - sizeof(dns_rbtnode_t);
CHECK(isc_stdio_write(&temp_node, 1, sizeof(dns_rbtnode_t), file,
NULL));
CHECK(isc_stdio_write(node_data, 1, datasize, file, NULL));
#ifdef DEBUG
dns_name_init(&nodename, NULL);
NODENAME(node, &nodename);
fprintf(stderr, "serialize ");
dns_name_print(&nodename, stderr);
fprintf(stderr, "\n");
hexdump("node header", (unsigned char *)&temp_node,
sizeof(dns_rbtnode_t));
hexdump("node data", node_data, datasize);
#endif /* ifdef DEBUG */
isc_crc64_update(crc, (const uint8_t *)&temp_node,
sizeof(dns_rbtnode_t));
isc_crc64_update(crc, (const uint8_t *)node_data, datasize);
cleanup:
return (result);
}
static isc_result_t
serialize_nodes(FILE *file, dns_rbtnode_t *node, uintptr_t parent,
dns_rbtdatawriter_t datawriter, void *writer_arg,
uintptr_t *where, uint64_t *crc) {
uintptr_t left = 0, right = 0, down = 0, data = 0;
off_t location = 0, offset_adjust;
isc_result_t result;
if (node == NULL) {
if (where != NULL) {
*where = 0;
}
return (ISC_R_SUCCESS);
}
/* Reserve space for current node. */
CHECK(isc_stdio_tell(file, &location));
location = dns_rbt_serialize_align(location);
CHECK(isc_stdio_seek(file, location, SEEK_SET));
offset_adjust = dns_rbt_serialize_align(location + NODE_SIZE(node));
CHECK(isc_stdio_seek(file, offset_adjust, SEEK_SET));
/*
* Serialize the rest of the tree.
*
* WARNING: A change in the order (from left, right, down)
* will break the way the crc hash is computed.
*/
CHECK(serialize_nodes(file, getleft(node, NULL), location, datawriter,
writer_arg, &left, crc));
CHECK(serialize_nodes(file, getright(node, NULL), location, datawriter,
writer_arg, &right, crc));
CHECK(serialize_nodes(file, getdown(node, NULL), location, datawriter,
writer_arg, &down, crc));
if (node->data != NULL) {
off_t ret;
CHECK(isc_stdio_tell(file, &ret));
ret = dns_rbt_serialize_align(ret);
CHECK(isc_stdio_seek(file, ret, SEEK_SET));
data = ret;
datawriter(file, node->data, writer_arg, crc);
}
/* Seek back to reserved space. */
CHECK(isc_stdio_seek(file, location, SEEK_SET));
/* Serialize the current node. */
CHECK(serialize_node(file, node, left, right, down, parent, data, crc));
/* Ensure we are always at the end of the file. */
CHECK(isc_stdio_seek(file, 0, SEEK_END));
if (where != NULL) {
*where = (uintptr_t)location;
}
cleanup:
return (result);
}
off_t
dns_rbt_serialize_align(off_t target) {
off_t offset = target % 8;
if (offset == 0) {
return (target);
} else {
return (target + 8 - offset);
}
}
isc_result_t
dns_rbt_serialize_tree(FILE *file, dns_rbt_t *rbt,
dns_rbtdatawriter_t datawriter, void *writer_arg,
off_t *offset) {
isc_result_t result;
off_t header_position, node_position, end_position;
uint64_t crc;
REQUIRE(file != NULL);
CHECK(isc_file_isplainfilefd(fileno(file)));
isc_crc64_init(&crc);
CHECK(isc_stdio_tell(file, &header_position));
/* Write dummy header */
CHECK(dns_rbt_zero_header(file));
/* Serialize nodes */
CHECK(isc_stdio_tell(file, &node_position));
CHECK(serialize_nodes(file, rbt->root, 0, datawriter, writer_arg, NULL,
&crc));
CHECK(isc_stdio_tell(file, &end_position));
if (node_position == end_position) {
CHECK(isc_stdio_seek(file, header_position, SEEK_SET));
*offset = 0;
return (ISC_R_SUCCESS);
}
isc_crc64_final(&crc);
#ifdef DEBUG
hexdump("serializing CRC", (unsigned char *)&crc, sizeof(crc));
#endif /* ifdef DEBUG */
/* Serialize header */
CHECK(isc_stdio_seek(file, header_position, SEEK_SET));
CHECK(write_header(file, rbt, HEADER_LENGTH, crc));
/* Ensure we are always at the end of the file. */
CHECK(isc_stdio_seek(file, 0, SEEK_END));
*offset = dns_rbt_serialize_align(header_position);
cleanup:
return (result);
}
#define CONFIRM(a) \
do { \
if (!(a)) { \
result = ISC_R_INVALIDFILE; \
goto cleanup; \
} \
} while (0);
static isc_result_t
treefix(dns_rbt_t *rbt, void *base, size_t filesize, dns_rbtnode_t *n,
const dns_name_t *name, dns_rbtdatafixer_t datafixer, void *fixer_arg,
uint64_t *crc) {
isc_result_t result = ISC_R_SUCCESS;
dns_fixedname_t fixed;
dns_name_t nodename, *fullname = NULL;
unsigned char *node_data = NULL;
dns_rbtnode_t header;
size_t nodemax = filesize - sizeof(dns_rbtnode_t);
size_t datasize;
if (n == NULL) {
return (ISC_R_SUCCESS);
}
CONFIRM((void *)n >= base);
CONFIRM((size_t)((char *)n - (char *)base) <= nodemax);
CONFIRM(DNS_RBTNODE_VALID(n));
dns_name_init(&nodename, NULL);
NODENAME(n, &nodename);
fullname = &nodename;
CONFIRM(dns_name_isvalid(fullname));
if (!dns_name_isabsolute(&nodename)) {
fullname = dns_fixedname_initname(&fixed);
CHECK(dns_name_concatenate(&nodename, name, fullname, NULL));
}
/* memorize header contents prior to fixup */
memmove(&header, n, sizeof(header));
if (n->left_is_relative) {
CONFIRM(n->left <= (dns_rbtnode_t *)nodemax);
n->left = getleft(n, rbt->mmap_location);
n->left_is_relative = 0;
CONFIRM(DNS_RBTNODE_VALID(n->left));
} else {
CONFIRM(n->left == NULL);
}
if (n->right_is_relative) {
CONFIRM(n->right <= (dns_rbtnode_t *)nodemax);
n->right = getright(n, rbt->mmap_location);
n->right_is_relative = 0;
CONFIRM(DNS_RBTNODE_VALID(n->right));
} else {
CONFIRM(n->right == NULL);
}
if (n->down_is_relative) {
CONFIRM(n->down <= (dns_rbtnode_t *)nodemax);
n->down = getdown(n, rbt->mmap_location);
n->down_is_relative = 0;
CONFIRM(n->down > (dns_rbtnode_t *)n);
CONFIRM(DNS_RBTNODE_VALID(n->down));
} else {
CONFIRM(n->down == NULL);
}
if (n->parent_is_relative) {
CONFIRM(n->parent <= (dns_rbtnode_t *)nodemax);
n->parent = getparent(n, rbt->mmap_location);
n->parent_is_relative = 0;
CONFIRM(n->parent < (dns_rbtnode_t *)n);
CONFIRM(DNS_RBTNODE_VALID(n->parent));
} else {
CONFIRM(n->parent == NULL);
}
if (n->data_is_relative) {
CONFIRM(n->data <= (void *)filesize);
n->data = getdata(n, rbt->mmap_location);
n->data_is_relative = 0;
CONFIRM(n->data > (void *)n);
} else {
CONFIRM(n->data == NULL);
}
hash_node(rbt, n, fullname);
/* a change in the order (from left, right, down) will break hashing*/
if (n->left != NULL) {
CHECK(treefix(rbt, base, filesize, n->left, name, datafixer,
fixer_arg, crc));
}
if (n->right != NULL) {
CHECK(treefix(rbt, base, filesize, n->right, name, datafixer,
fixer_arg, crc));
}
if (n->down != NULL) {
CHECK(treefix(rbt, base, filesize, n->down, fullname, datafixer,
fixer_arg, crc));
}
if (datafixer != NULL && n->data != NULL) {
CHECK(datafixer(n, base, filesize, fixer_arg, crc));
}
rbt->nodecount++;
node_data = (unsigned char *)n + sizeof(dns_rbtnode_t);
datasize = NODE_SIZE(n) - sizeof(dns_rbtnode_t);
#ifdef DEBUG
fprintf(stderr, "deserialize ");
dns_name_print(&nodename, stderr);
fprintf(stderr, "\n");
hexdump("node header", (unsigned char *)&header, sizeof(dns_rbtnode_t));
hexdump("node data", node_data, datasize);
#endif /* ifdef DEBUG */
isc_crc64_update(crc, (const uint8_t *)&header, sizeof(dns_rbtnode_t));
isc_crc64_update(crc, (const uint8_t *)node_data, datasize);
cleanup:
return (result);
}
isc_result_t
dns_rbt_deserialize_tree(void *base_address, size_t filesize,
off_t header_offset, isc_mem_t *mctx,
dns_rbtdeleter_t deleter, void *deleter_arg,
dns_rbtdatafixer_t datafixer, void *fixer_arg,
dns_rbtnode_t **originp, dns_rbt_t **rbtp) {
isc_result_t result = ISC_R_SUCCESS;
file_header_t *header;
dns_rbt_t *rbt = NULL;
uint64_t crc;
unsigned int host_big_endian;
REQUIRE(originp == NULL || *originp == NULL);
REQUIRE(rbtp != NULL && *rbtp == NULL);
isc_crc64_init(&crc);
CHECK(dns_rbt_create(mctx, deleter, deleter_arg, &rbt));
rbt->mmap_location = base_address;
header = (file_header_t *)((char *)base_address + header_offset);
if (!match_header_version(header)) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
#ifdef DNS_RDATASET_FIXED
if (header->rdataset_fixed != 1) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
#else /* ifdef DNS_RDATASET_FIXED */
if (header->rdataset_fixed != 0) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
#endif /* ifdef DNS_RDATASET_FIXED */
if (header->ptrsize != (uint32_t)sizeof(void *)) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
host_big_endian = (1 == htonl(1));
if (header->bigendian != host_big_endian) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
/* Copy other data items from the header into our rbt. */
rbt->root = (dns_rbtnode_t *)((char *)base_address + header_offset +
header->first_node_offset);
if ((header->nodecount * sizeof(dns_rbtnode_t)) > filesize) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
maybe_rehash(rbt, header->nodecount);
CHECK(treefix(rbt, base_address, filesize, rbt->root, dns_rootname,
datafixer, fixer_arg, &crc));
isc_crc64_final(&crc);
#ifdef DEBUG
hexdump("deserializing CRC", (unsigned char *)&crc, sizeof(crc));
#endif /* ifdef DEBUG */
/* Check file hash */
if (header->crc != crc) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
if (header->nodecount != rbt->nodecount) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
fixup_uppernodes(rbt);
*rbtp = rbt;
if (originp != NULL) {
*originp = rbt->root;
}
cleanup:
if (result != ISC_R_SUCCESS && rbt != NULL) {
rbt->root = NULL;
rbt->nodecount = 0;
dns_rbt_destroy(&rbt);
}
return (result);
}
/*
* Initialize a red/black tree of trees.
*/
@ -2267,12 +1577,6 @@ create_node(isc_mem_t *mctx, const dns_name_t *name, dns_rbtnode_t **nodep) {
LEFT(node) = NULL;
DOWN(node) = NULL;
DATA(node) = NULL;
node->is_mmapped = 0;
node->down_is_relative = 0;
node->left_is_relative = 0;
node->right_is_relative = 0;
node->parent_is_relative = 0;
node->data_is_relative = 0;
node->rpz = 0;
HASHNEXT(node) = NULL;
@ -2867,9 +2171,7 @@ freenode(dns_rbt_t *rbt, dns_rbtnode_t **nodep) {
dns_rbtnode_t *node = *nodep;
*nodep = NULL;
if (node->is_mmapped == 0) {
isc_mem_put(rbt->mctx, node, NODE_SIZE(node));
}
isc_mem_put(rbt->mctx, node, NODE_SIZE(node));
rbt->nodecount--;
}
@ -3075,13 +2377,6 @@ dns_rbt_printnodeinfo(dns_rbtnode_t *n, FILE *f) {
fprintf(f, "n = %p\n", n);
fprintf(f, "Relative pointers: %s%s%s%s%s\n",
(n->parent_is_relative == 1 ? " P" : ""),
(n->right_is_relative == 1 ? " R" : ""),
(n->left_is_relative == 1 ? " L" : ""),
(n->down_is_relative == 1 ? " D" : ""),
(n->data_is_relative == 1 ? " T" : ""));
fprintf(f, "node lock address = %u\n", n->locknum);
fprintf(f, "Parent: %p\n", n->parent);

View file

@ -74,28 +74,6 @@
goto failure; \
} while (0)
/*
* This is the map file header for RBTDB images. It is populated, and then
* written, as the LAST thing done to the file. Writing this last (with
* zeros in the header area initially) will ensure that the header is only
* valid when the RBTDB image is also valid.
*/
typedef struct rbtdb_file_header rbtdb_file_header_t;
/* Header length, always the same size regardless of structure size */
#define RBTDB_HEADER_LENGTH 1024
struct rbtdb_file_header {
char version1[32];
uint32_t ptrsize;
unsigned int bigendian : 1;
uint64_t tree;
uint64_t nsec;
uint64_t nsec3;
char version2[32]; /* repeated; must match version1 */
};
/*%
* Note that "impmagic" is not the first four bytes of the struct, so
* ISC_MAGIC_VALID cannot be used.
@ -200,10 +178,7 @@ typedef struct rdatasetheader {
atomic_uint_fast32_t last_refresh_fail_ts;
struct noqname *noqname;
struct noqname *closest;
unsigned int is_mmapped : 1;
unsigned int next_is_relative : 1;
unsigned int node_is_relative : 1;
unsigned int resign_lsb : 1;
unsigned int resign_lsb : 1;
/*%<
* We don't use the LIST macros, because the LIST structure has
* both head and tail pointers, and is doubly linked.
@ -512,12 +487,6 @@ struct dns_rbtdb {
isc_mem_t *hmctx;
isc_heap_t **heaps;
/*
* Base values for the mmap() code.
*/
void *mmap_location;
size_t mmap_size;
/* Locked by tree_lock. */
dns_rbt_t *tree;
dns_rbt_t *nsec;
@ -739,12 +708,6 @@ setnsec3parameters(dns_db_t *db, rbtdb_version_t *version);
static void
setownercase(rdatasetheader_t *header, const dns_name_t *name);
static bool
match_header_version(rbtdb_file_header_t *header);
/* Pad to 32 bytes */
static char FILE_VERSION[32] = "\0";
/*%
* 'init_count' is used to initialize 'newheader->count' which inturn
* is used to determine where in the cycle rrset-order cyclic starts.
@ -780,34 +743,6 @@ static atomic_uint_fast32_t init_count = ATOMIC_VAR_INIT(0);
* For zone databases the node for the origin of the zone MUST NOT be deleted.
*/
/*
* Debugging routines
*/
#ifdef DEBUG
static void
hexdump(const char *desc, unsigned char *data, size_t size) {
char hexdump[BUFSIZ * 2 + 1];
isc_buffer_t b;
isc_region_t r;
isc_result_t result;
size_t bytes;
fprintf(stderr, "%s: ", desc);
do {
isc_buffer_init(&b, hexdump, sizeof(hexdump));
r.base = data;
r.length = bytes = (size > BUFSIZ) ? BUFSIZ : size;
result = isc_hex_totext(&r, 0, "", &b);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_putuint8(&b, 0);
fprintf(stderr, "%s", hexdump);
data += bytes;
size -= bytes;
} while (size > 0);
fprintf(stderr, "\n");
}
#endif /* ifdef DEBUG */
/* Fixed RRSet helper macros */
#define DNS_RDATASET_LENGTH 2;
@ -1203,10 +1138,6 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log, isc_event_t *event) {
rbtdb->common.impmagic = 0;
isc_mem_detach(&rbtdb->hmctx);
if (rbtdb->mmap_location != NULL) {
isc_file_munmap(rbtdb->mmap_location, (size_t)rbtdb->mmap_size);
}
for (listener = ISC_LIST_HEAD(rbtdb->common.update_listeners);
listener != NULL; listener = listener_next)
{
@ -1444,9 +1375,6 @@ static inline void
init_rdataset(dns_rbtdb_t *rbtdb, rdatasetheader_t *h) {
ISC_LINK_INIT(h, link);
h->heap_index = 0;
h->is_mmapped = 0;
h->next_is_relative = 0;
h->node_is_relative = 0;
atomic_init(&h->attributes, 0);
atomic_init(&h->last_refresh_fail_ts, 0);
@ -1463,23 +1391,8 @@ init_rdataset(dns_rbtdb_t *rbtdb, rdatasetheader_t *h) {
#endif /* if TRACE_HEADER */
}
/*
* Update the copied values of 'next' and 'node' if they are relative.
*/
static void
update_newheader(rdatasetheader_t *newh, rdatasetheader_t *old) {
char *p;
if (old->next_is_relative) {
p = (char *)old;
p += (uintptr_t)old->next;
newh->next = (rdatasetheader_t *)p;
}
if (old->node_is_relative) {
p = (char *)old;
p += (uintptr_t)old->node;
newh->node = (dns_rbtnode_t *)p;
}
if (CASESET(old)) {
uint_least16_t attr = RDATASET_ATTR_GET(
old,
@ -1539,10 +1452,6 @@ free_rdataset(dns_rbtdb_t *rbtdb, isc_mem_t *mctx, rdatasetheader_t *rdataset) {
sizeof(*rdataset));
}
if (rdataset->is_mmapped == 1) {
return;
}
isc_mem_put(mctx, rdataset, size);
}
@ -7516,186 +7425,6 @@ loading_addrdataset(void *arg, const dns_name_t *name,
return (result);
}
static isc_result_t
rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, void *arg,
uint64_t *crc) {
isc_result_t result;
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)arg;
rdatasetheader_t *header;
unsigned char *limit = ((unsigned char *)base) + filesize;
REQUIRE(rbtnode != NULL);
REQUIRE(VALID_RBTDB(rbtdb));
for (header = rbtnode->data; header != NULL; header = header->next) {
unsigned char *p = (unsigned char *)header;
size_t size = dns_rdataslab_size(p, sizeof(*header));
isc_crc64_update(crc, p, size);
#ifdef DEBUG
hexdump("hashing header", p, sizeof(rdatasetheader_t));
hexdump("hashing slab", p + sizeof(rdatasetheader_t),
size - sizeof(rdatasetheader_t));
#endif /* ifdef DEBUG */
header->serial = 1;
header->is_mmapped = 1;
header->node = rbtnode;
header->node_is_relative = 0;
if (RESIGN(header) &&
(header->resign != 0 || header->resign_lsb != 0)) {
int idx = header->node->locknum;
result = isc_heap_insert(rbtdb->heaps[idx], header);
if (result != ISC_R_SUCCESS) {
return (result);
}
}
if (header->next != NULL) {
size_t cooked = dns_rbt_serialize_align(size);
if ((uintptr_t)header->next !=
(p - (unsigned char *)base) + cooked) {
return (ISC_R_INVALIDFILE);
}
header->next = (rdatasetheader_t *)(p + cooked);
header->next_is_relative = 0;
if ((header->next < (rdatasetheader_t *)base) ||
(header->next > (rdatasetheader_t *)limit))
{
return (ISC_R_INVALIDFILE);
}
}
update_recordsandxfrsize(true, rbtdb->current_version, header,
rbtnode->fullnamelen);
}
/* We're done deserializing; clear fullnamelen */
rbtnode->fullnamelen = 0;
return (ISC_R_SUCCESS);
}
/*
* Load the RBT database from the image in 'f'
*/
static isc_result_t
deserialize(void *arg, FILE *f, off_t offset) {
isc_result_t result;
rbtdb_load_t *loadctx = arg;
dns_rbtdb_t *rbtdb = loadctx->rbtdb;
rbtdb_file_header_t *header;
int fd;
off_t filesize = 0;
char *base;
dns_rbt_t *tree = NULL, *nsec = NULL, *nsec3 = NULL;
int protect, flags;
dns_rbtnode_t *origin_node = NULL;
REQUIRE(VALID_RBTDB(rbtdb));
/*
* TODO CKB: since this is read-write (had to be to add nodes later)
* we will need to lock the file or the nodes in it before modifying
* the nodes in the file.
*/
/* Map in the whole file in one go */
fd = fileno(f);
isc_file_getsizefd(fd, &filesize);
protect = PROT_READ | PROT_WRITE;
flags = MAP_PRIVATE;
#ifdef MAP_FILE
flags |= MAP_FILE;
#endif /* ifdef MAP_FILE */
base = isc_file_mmap(NULL, filesize, protect, flags, fd, 0);
if (base == NULL || base == MAP_FAILED) {
return (ISC_R_FAILURE);
}
header = (rbtdb_file_header_t *)(base + offset);
if (!match_header_version(header)) {
result = ISC_R_INVALIDFILE;
goto cleanup;
}
if (header->tree != 0) {
result = dns_rbt_deserialize_tree(
base, filesize, (off_t)header->tree, rbtdb->common.mctx,
delete_callback, rbtdb, rbt_datafixer, rbtdb, NULL,
&tree);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
result = dns_rbt_findnode(tree, &rbtdb->common.origin, NULL,
&origin_node, NULL,
DNS_RBTFIND_EMPTYDATA, NULL, NULL);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
}
if (header->nsec != 0) {
result = dns_rbt_deserialize_tree(
base, filesize, (off_t)header->nsec, rbtdb->common.mctx,
delete_callback, rbtdb, rbt_datafixer, rbtdb, NULL,
&nsec);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
}
if (header->nsec3 != 0) {
result = dns_rbt_deserialize_tree(
base, filesize, (off_t)header->nsec3,
rbtdb->common.mctx, delete_callback, rbtdb,
rbt_datafixer, rbtdb, NULL, &nsec3);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
}
/*
* We have a successfully loaded all the rbt trees now update
* rbtdb to use them.
*/
rbtdb->mmap_location = base;
rbtdb->mmap_size = (size_t)filesize;
if (tree != NULL) {
dns_rbt_destroy(&rbtdb->tree);
rbtdb->tree = tree;
rbtdb->origin_node = origin_node;
}
if (nsec != NULL) {
dns_rbt_destroy(&rbtdb->nsec);
rbtdb->nsec = nsec;
}
if (nsec3 != NULL) {
dns_rbt_destroy(&rbtdb->nsec3);
rbtdb->nsec3 = nsec3;
}
return (ISC_R_SUCCESS);
cleanup:
if (tree != NULL) {
dns_rbt_destroy(&tree);
}
if (nsec != NULL) {
dns_rbt_destroy(&nsec);
}
if (nsec3 != NULL) {
dns_rbt_destroy(&nsec3);
}
isc_file_munmap(base, (size_t)filesize);
return (result);
}
static isc_result_t
beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
rbtdb_load_t *loadctx;
@ -7724,8 +7453,6 @@ beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
callbacks->add = loading_addrdataset;
callbacks->add_private = loadctx;
callbacks->deserialize = deserialize;
callbacks->deserialize_private = loadctx;
return (ISC_R_SUCCESS);
}
@ -7763,226 +7490,12 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
callbacks->add = NULL;
callbacks->add_private = NULL;
callbacks->deserialize = NULL;
callbacks->deserialize_private = NULL;
isc_mem_put(rbtdb->common.mctx, loadctx, sizeof(*loadctx));
return (ISC_R_SUCCESS);
}
/*
* helper function to handle writing out the rdataset data pointed to
* by the void *data pointer in the dns_rbtnode
*/
static isc_result_t
rbt_datawriter(FILE *rbtfile, unsigned char *data, void *arg, uint64_t *crc) {
rbtdb_version_t *version = (rbtdb_version_t *)arg;
rbtdb_serial_t serial;
rdatasetheader_t newheader;
rdatasetheader_t *header = (rdatasetheader_t *)data, *next;
off_t where;
size_t cooked, size;
unsigned char *p;
isc_result_t result = ISC_R_SUCCESS;
char pad[sizeof(char *)];
uintptr_t off;
REQUIRE(rbtfile != NULL);
REQUIRE(data != NULL);
REQUIRE(version != NULL);
serial = version->serial;
for (; header != NULL; header = next) {
next = header->next;
do {
if (header->serial <= serial && !IGNORE(header)) {
if (NONEXISTENT(header)) {
header = NULL;
}
break;
} else {
header = header->down;
}
} while (header != NULL);
if (header == NULL) {
continue;
}
CHECK(isc_stdio_tell(rbtfile, &where));
size = dns_rdataslab_size((unsigned char *)header,
sizeof(rdatasetheader_t));
p = (unsigned char *)header;
memmove(&newheader, p, sizeof(rdatasetheader_t));
newheader.down = NULL;
newheader.next = NULL;
off = where;
if ((off_t)off != where) {
return (ISC_R_RANGE);
}
newheader.node = (dns_rbtnode_t *)off;
newheader.node_is_relative = 1;
newheader.serial = 1;
/*
* Round size up to the next pointer sized offset so it
* will be properly aligned when read back in.
*/
cooked = dns_rbt_serialize_align(size);
if (next != NULL) {
newheader.next = (rdatasetheader_t *)(off + cooked);
newheader.next_is_relative = 1;
}
#ifdef DEBUG
hexdump("writing header", (unsigned char *)&newheader,
sizeof(rdatasetheader_t));
hexdump("writing slab", p + sizeof(rdatasetheader_t),
size - sizeof(rdatasetheader_t));
#endif /* ifdef DEBUG */
isc_crc64_update(crc, (unsigned char *)&newheader,
sizeof(rdatasetheader_t));
CHECK(isc_stdio_write(&newheader, sizeof(rdatasetheader_t), 1,
rbtfile, NULL));
isc_crc64_update(crc, p + sizeof(rdatasetheader_t),
size - sizeof(rdatasetheader_t));
CHECK(isc_stdio_write(p + sizeof(rdatasetheader_t),
size - sizeof(rdatasetheader_t), 1,
rbtfile, NULL));
/*
* Pad to force alignment.
*/
if (size != (size_t)cooked) {
memset(pad, 0, sizeof(pad));
CHECK(isc_stdio_write(pad, cooked - size, 1, rbtfile,
NULL));
}
}
failure:
return (result);
}
/*
* Write out a zeroed header as a placeholder. Doing this ensures
* that the file will not read while it is partially written, should
* writing fail or be interrupted.
*/
static isc_result_t
rbtdb_zero_header(FILE *rbtfile) {
char buffer[RBTDB_HEADER_LENGTH];
isc_result_t result;
memset(buffer, 0, RBTDB_HEADER_LENGTH);
result = isc_stdio_write(buffer, 1, RBTDB_HEADER_LENGTH, rbtfile, NULL);
fflush(rbtfile);
return (result);
}
static isc_once_t once = ISC_ONCE_INIT;
static void
init_file_version(void) {
int n;
memset(FILE_VERSION, 0, sizeof(FILE_VERSION));
n = snprintf(FILE_VERSION, sizeof(FILE_VERSION), "RBTDB Image %s %s",
PACKAGE_VERSION_MAJOR, MAPAPI);
INSIST(n > 0 && (unsigned int)n < sizeof(FILE_VERSION));
}
/*
* Write the file header out, recording the locations of the three
* RBT's used in the rbtdb: tree, nsec, and nsec3, and including NodeDump
* version information and any information stored in the rbtdb object
* itself that should be stored here.
*/
static isc_result_t
rbtdb_write_header(FILE *rbtfile, off_t tree_location, off_t nsec_location,
off_t nsec3_location) {
rbtdb_file_header_t header;
isc_result_t result;
RUNTIME_CHECK(isc_once_do(&once, init_file_version) == ISC_R_SUCCESS);
memset(&header, 0, sizeof(rbtdb_file_header_t));
memmove(header.version1, FILE_VERSION, sizeof(header.version1));
memmove(header.version2, FILE_VERSION, sizeof(header.version2));
header.ptrsize = (uint32_t)sizeof(void *);
header.bigendian = (1 == htonl(1)) ? 1 : 0;
header.tree = (uint64_t)tree_location;
header.nsec = (uint64_t)nsec_location;
header.nsec3 = (uint64_t)nsec3_location;
result = isc_stdio_write(&header, 1, sizeof(rbtdb_file_header_t),
rbtfile, NULL);
fflush(rbtfile);
return (result);
}
static bool
match_header_version(rbtdb_file_header_t *header) {
RUNTIME_CHECK(isc_once_do(&once, init_file_version) == ISC_R_SUCCESS);
if (memcmp(header->version1, FILE_VERSION, sizeof(header->version1)) !=
0 ||
memcmp(header->version2, FILE_VERSION, sizeof(header->version1)) !=
0)
{
return (false);
}
return (true);
}
static isc_result_t
serialize(dns_db_t *db, dns_dbversion_t *ver, FILE *rbtfile) {
rbtdb_version_t *version = (rbtdb_version_t *)ver;
dns_rbtdb_t *rbtdb;
isc_result_t result;
off_t tree_location, nsec_location, nsec3_location, header_location;
rbtdb = (dns_rbtdb_t *)db;
REQUIRE(VALID_RBTDB(rbtdb));
REQUIRE(rbtfile != NULL);
/* Ensure we're writing to a plain file */
CHECK(isc_file_isplainfilefd(fileno(rbtfile)));
/*
* first, write out a zeroed header to store rbtdb information
*
* then for each of the three trees, store the current position
* in the file and call dns_rbt_serialize_tree
*
* finally, write out the rbtdb header, storing the locations of the
* rbtheaders
*
* NOTE: need to do something better with the return codes, &= will
* not work.
*/
CHECK(isc_stdio_tell(rbtfile, &header_location));
CHECK(rbtdb_zero_header(rbtfile));
CHECK(dns_rbt_serialize_tree(rbtfile, rbtdb->tree, rbt_datawriter,
version, &tree_location));
CHECK(dns_rbt_serialize_tree(rbtfile, rbtdb->nsec, rbt_datawriter,
version, &nsec_location));
CHECK(dns_rbt_serialize_tree(rbtfile, rbtdb->nsec3, rbt_datawriter,
version, &nsec3_location));
CHECK(isc_stdio_seek(rbtfile, header_location, SEEK_SET));
CHECK(rbtdb_write_header(rbtfile, tree_location, nsec_location,
nsec3_location));
failure:
return (result);
}
static isc_result_t
dump(dns_db_t *db, dns_dbversion_t *version, const char *filename,
dns_masterformat_t masterformat) {
@ -8481,7 +7994,6 @@ static dns_dbmethods_t zone_methods = { attach,
detach,
beginload,
endload,
serialize,
dump,
currentversion,
newversion,
@ -8533,7 +8045,6 @@ static dns_dbmethods_t cache_methods = { attach,
detach,
beginload,
endload,
NULL, /* serialize */
dump,
currentversion,
newversion,

View file

@ -1266,7 +1266,6 @@ static dns_dbmethods_t sdb_methods = {
detach,
beginload,
endload,
NULL, /* serialize */
dump,
currentversion,
newversion,

View file

@ -1238,7 +1238,6 @@ static dns_dbmethods_t sdlzdb_methods = {
detach,
beginload,
endload,
NULL, /* serialize */
dump,
currentversion,
newversion,

View file

@ -31,7 +31,6 @@ check_PROGRAMS = \
nsec3param_test \
peer_test \
private_test \
rbt_serialize_test \
rbt_test \
rbtdb_test \
rdata_test \

View file

@ -1,487 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#if HAVE_CMOCKA
#include <fcntl.h>
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
#define UNIT_TESTING
#include <cmocka.h>
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/commandline.h>
#include <isc/file.h>
#include <isc/hash.h>
#include <isc/mem.h>
#include <isc/os.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>
#include <dns/compress.h>
#include <dns/fixedname.h>
#include <dns/log.h>
#include <dns/name.h>
#include <dns/rbt.h>
#include <dns/result.h>
#include <dst/dst.h>
#include "dnstest.h"
#ifndef MAP_FILE
#define MAP_FILE 0
#endif /* ifndef MAP_FILE */
/* Set to true (or use -v option) for verbose output */
static bool verbose = false;
static int
_setup(void **state) {
isc_result_t result;
UNUSED(state);
result = dns_test_begin(NULL, false);
assert_int_equal(result, ISC_R_SUCCESS);
return (0);
}
static int
_teardown(void **state) {
UNUSED(state);
dns_test_end();
return (0);
}
typedef struct data_holder {
int len;
const char *data;
} data_holder_t;
typedef struct rbt_testdata {
const char *name;
size_t name_len;
data_holder_t data;
} rbt_testdata_t;
#define DATA_ITEM(name) \
{ \
(name), sizeof(name) - 1, { sizeof(name), (name) } \
}
rbt_testdata_t testdata[] = { DATA_ITEM("first.com."),
DATA_ITEM("one.net."),
DATA_ITEM("two.com."),
DATA_ITEM("three.org."),
DATA_ITEM("asdf.com."),
DATA_ITEM("ghjkl.com."),
DATA_ITEM("1.edu."),
DATA_ITEM("2.edu."),
DATA_ITEM("3.edu."),
DATA_ITEM("123.edu."),
DATA_ITEM("1236.com."),
DATA_ITEM("and_so_forth.com."),
DATA_ITEM("thisisalongname.com."),
DATA_ITEM("a.b."),
DATA_ITEM("test.net."),
DATA_ITEM("whoknows.org."),
DATA_ITEM("blargh.com."),
DATA_ITEM("www.joe.com."),
DATA_ITEM("test.com."),
DATA_ITEM("isc.org."),
DATA_ITEM("uiop.mil."),
DATA_ITEM("last.fm."),
{ NULL, 0, { 0, NULL } } };
static void
delete_data(void *data, void *arg) {
UNUSED(arg);
UNUSED(data);
}
static isc_result_t
write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
isc_result_t result;
size_t ret = 0;
data_holder_t *data;
data_holder_t temp;
off_t where;
UNUSED(arg);
REQUIRE(file != NULL);
REQUIRE(crc != NULL);
REQUIRE(datap != NULL);
data = (data_holder_t *)datap;
REQUIRE((data->len == 0 && data->data == NULL) ||
(data->len != 0 && data->data != NULL));
result = isc_stdio_tell(file, &where);
if (result != ISC_R_SUCCESS) {
return (result);
}
temp = *data;
temp.data = (data->len == 0 ? NULL
: (char *)((uintptr_t)where +
sizeof(data_holder_t)));
isc_crc64_update(crc, (void *)&temp, sizeof(temp));
ret = fwrite(&temp, sizeof(data_holder_t), 1, file);
if (ret != 1) {
return (ISC_R_FAILURE);
}
if (data->len > 0) {
isc_crc64_update(crc, (const void *)data->data, data->len);
ret = fwrite(data->data, data->len, 1, file);
if (ret != 1) {
return (ISC_R_FAILURE);
}
}
return (ISC_R_SUCCESS);
}
static isc_result_t
fix_data(dns_rbtnode_t *p, void *base, size_t max, void *arg, uint64_t *crc) {
data_holder_t *data;
size_t size;
UNUSED(base);
UNUSED(max);
UNUSED(arg);
REQUIRE(crc != NULL);
REQUIRE(p != NULL);
data = p->data;
if (data == NULL || (data->len == 0 && data->data != NULL) ||
(data->len != 0 && data->data == NULL))
{
return (ISC_R_INVALIDFILE);
}
size = max - ((char *)p - (char *)base);
if (data->len > (int)size || data->data > (const char *)max) {
return (ISC_R_INVALIDFILE);
}
isc_crc64_update(crc, (void *)data, sizeof(*data));
data->data = NULL;
if (data->len != 0) {
data->data = (char *)data + sizeof(data_holder_t);
}
if (data->len > 0) {
isc_crc64_update(crc, (const void *)data->data, data->len);
}
return (ISC_R_SUCCESS);
}
/*
* Load test data into the RBT.
*/
static void
add_test_data(isc_mem_t *mctx, dns_rbt_t *rbt) {
char buffer[1024];
isc_buffer_t b;
isc_result_t result;
dns_fixedname_t fname;
dns_name_t *name;
dns_compress_t cctx;
rbt_testdata_t *testdatap = testdata;
dns_compress_init(&cctx, -1, mctx);
while (testdatap->name != NULL && testdatap->data.data != NULL) {
memmove(buffer, testdatap->name, testdatap->name_len);
isc_buffer_init(&b, buffer, testdatap->name_len);
isc_buffer_add(&b, testdatap->name_len);
name = dns_fixedname_initname(&fname);
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
testdatap++;
continue;
}
if (name != NULL) {
result = dns_rbt_addname(rbt, name, &testdatap->data);
assert_int_equal(result, ISC_R_SUCCESS);
}
testdatap++;
}
dns_compress_invalidate(&cctx);
}
/*
* Walk the tree and ensure that all the test nodes are present.
*/
static void
check_test_data(dns_rbt_t *rbt) {
char buffer[1024];
char *arg;
dns_fixedname_t fname;
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t b;
data_holder_t *data;
isc_result_t result;
dns_name_t *foundname;
rbt_testdata_t *testdatap = testdata;
foundname = dns_fixedname_initname(&fixed);
while (testdatap->name != NULL && testdatap->data.data != NULL) {
memmove(buffer, testdatap->name, testdatap->name_len + 1);
arg = buffer;
isc_buffer_init(&b, arg, testdatap->name_len);
isc_buffer_add(&b, testdatap->name_len);
name = dns_fixedname_initname(&fname);
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
if (result != ISC_R_SUCCESS) {
testdatap++;
continue;
}
data = NULL;
result = dns_rbt_findname(rbt, name, 0, foundname,
(void *)&data);
assert_int_equal(result, ISC_R_SUCCESS);
testdatap++;
}
}
static void
data_printer(FILE *out, void *datap) {
data_holder_t *data = (data_holder_t *)datap;
fprintf(out, "%d bytes, %s", data->len, data->data);
}
/* Test writing an rbt to file */
static void
serialize_test(void **state) {
dns_rbt_t *rbt = NULL;
isc_result_t result;
FILE *rbtfile = NULL;
dns_rbt_t *rbt_deserialized = NULL;
off_t offset;
int fd;
off_t filesize = 0;
char *base;
UNUSED(state);
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
result = dns_rbt_create(dt_mctx, delete_data, NULL, &rbt);
assert_int_equal(result, ISC_R_SUCCESS);
add_test_data(dt_mctx, rbt);
if (verbose) {
dns_rbt_printtext(rbt, data_printer, stdout);
}
/*
* Serialize the tree.
*/
rbtfile = fopen("./zone.bin", "w+b");
assert_non_null(rbtfile);
result = dns_rbt_serialize_tree(rbtfile, rbt, write_data, NULL,
&offset);
assert_true(result == ISC_R_SUCCESS);
dns_rbt_destroy(&rbt);
/*
* Deserialize the tree.
* Map in the whole file in one go
*/
fd = open("zone.bin", O_RDWR);
assert_int_not_equal(fd, -1);
isc_file_getsizefd(fd, &filesize);
base = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_PRIVATE, fd, 0);
assert_true(base != NULL && base != MAP_FAILED);
close(fd);
result = dns_rbt_deserialize_tree(base, filesize, 0, dt_mctx,
delete_data, NULL, fix_data, NULL,
NULL, &rbt_deserialized);
/* Test to make sure we have a valid tree */
assert_true(result == ISC_R_SUCCESS);
if (rbt_deserialized == NULL) {
fail_msg("deserialized rbt is null!"); /* Abort execution. */
}
check_test_data(rbt_deserialized);
if (verbose) {
dns_rbt_printtext(rbt_deserialized, data_printer, stdout);
}
dns_rbt_destroy(&rbt_deserialized);
munmap(base, filesize);
unlink("zone.bin");
}
/* Test reading a corrupt map file */
static void
deserialize_corrupt_test(void **state) {
dns_rbt_t *rbt = NULL;
isc_result_t result;
FILE *rbtfile = NULL;
off_t offset;
int fd;
off_t filesize = 0;
char *base, *p, *q;
int i;
UNUSED(state);
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
/* Set up map file */
result = dns_rbt_create(dt_mctx, delete_data, NULL, &rbt);
assert_int_equal(result, ISC_R_SUCCESS);
add_test_data(dt_mctx, rbt);
rbtfile = fopen("./zone.bin", "w+b");
assert_non_null(rbtfile);
result = dns_rbt_serialize_tree(rbtfile, rbt, write_data, NULL,
&offset);
assert_true(result == ISC_R_SUCCESS);
dns_rbt_destroy(&rbt);
/* Read back with random fuzzing */
for (i = 0; i < 256; i++) {
dns_rbt_t *rbt_deserialized = NULL;
fd = open("zone.bin", O_RDWR);
assert_int_not_equal(fd, -1);
isc_file_getsizefd(fd, &filesize);
base = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_PRIVATE, fd, 0);
assert_true(base != NULL && base != MAP_FAILED);
close(fd);
/* Randomly fuzz a portion of the memory */
/* cppcheck-suppress nullPointerArithmeticRedundantCheck */
p = base + (isc_random_uniform(filesize));
/* cppcheck-suppress nullPointerArithmeticRedundantCheck */
q = base + filesize;
q -= (isc_random_uniform(q - p));
while (p++ < q) {
*p = isc_random8();
}
result = dns_rbt_deserialize_tree(
base, filesize, 0, dt_mctx, delete_data, NULL, fix_data,
NULL, NULL, &rbt_deserialized);
/* Test to make sure we have a valid tree */
assert_true(result == ISC_R_SUCCESS ||
result == ISC_R_INVALIDFILE);
if (result != ISC_R_SUCCESS) {
assert_null(rbt_deserialized);
}
if (rbt_deserialized != NULL) {
dns_rbt_destroy(&rbt_deserialized);
}
munmap(base, filesize);
}
unlink("zone.bin");
}
/* Test the dns_rbt_serialize_align() function */
static void
serialize_align_test(void **state) {
UNUSED(state);
assert_true(dns_rbt_serialize_align(0) == 0);
assert_true(dns_rbt_serialize_align(1) == 8);
assert_true(dns_rbt_serialize_align(2) == 8);
assert_true(dns_rbt_serialize_align(3) == 8);
assert_true(dns_rbt_serialize_align(4) == 8);
assert_true(dns_rbt_serialize_align(5) == 8);
assert_true(dns_rbt_serialize_align(6) == 8);
assert_true(dns_rbt_serialize_align(7) == 8);
assert_true(dns_rbt_serialize_align(8) == 8);
assert_true(dns_rbt_serialize_align(9) == 16);
assert_true(dns_rbt_serialize_align(0xff) == 0x100);
assert_true(dns_rbt_serialize_align(0x301) == 0x308);
}
int
main(int argc, char **argv) {
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(serialize_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(deserialize_corrupt_test,
_setup, _teardown),
cmocka_unit_test(serialize_align_test),
};
int c;
while ((c = isc_commandline_parse(argc, argv, "v")) != -1) {
switch (c) {
case 'v':
verbose = true;
break;
default:
break;
}
}
return (cmocka_run_group_tests(tests, NULL, NULL));
}
#else /* HAVE_CMOCKA */
#include <stdio.h>
int
main(void) {
printf("1..0 # Skipped: cmocka not available\n");
return (SKIPPED_TEST_EXIT_CODE);
}
#endif /* if HAVE_CMOCKA */

View file

@ -1909,9 +1909,6 @@ dns_zone_rpz_enable(dns_zone_t *zone, dns_rpz_zones_t *rpzs,
{
return (ISC_R_NOTIMPLEMENTED);
}
if (zone->masterformat == dns_masterformat_map) {
return (ISC_R_NOTIMPLEMENTED);
}
/*
* This must happen only once or be redundant.

View file

@ -685,53 +685,6 @@ isc_file_splitpath(isc_mem_t *mctx, const char *path, char **dirname,
return (ISC_R_SUCCESS);
}
void *
isc_file_mmap(void *addr, size_t len, int prot, int flags, int fd,
off_t offset) {
#ifdef HAVE_MMAP
return (mmap(addr, len, prot, flags, fd, offset));
#else /* ifdef HAVE_MMAP */
void *buf;
ssize_t ret;
off_t end;
UNUSED(addr);
UNUSED(prot);
UNUSED(flags);
end = lseek(fd, 0, SEEK_END);
lseek(fd, offset, SEEK_SET);
if (end - offset < (off_t)len) {
len = end - offset;
}
buf = malloc(len);
if (buf == NULL) {
return (NULL);
}
ret = read(fd, buf, len);
if (ret != (ssize_t)len) {
free(buf);
buf = NULL;
}
return (buf);
#endif /* ifdef HAVE_MMAP */
}
int
isc_file_munmap(void *addr, size_t len) {
#ifdef HAVE_MMAP
return (munmap(addr, len));
#else /* ifdef HAVE_MMAP */
UNUSED(len);
free(addr);
return (0);
#endif /* ifdef HAVE_MMAP */
}
#define DISALLOW "\\/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
static isc_result_t

View file

@ -342,22 +342,6 @@ isc_file_getsizefd(int fd, off_t *size);
* - ISC_R_SUCCESS on success
*/
void *
isc_file_mmap(void *addr, size_t len, int prot, int flags, int fd,
off_t offset);
/*%<
* Portable front-end to mmap(). If mmap() is not defined on this
* platform, then we simulate it by calling malloc() and read().
* (In this event, the addr, prot, and flags parameters are ignored).
*/
int
isc_file_munmap(void *addr, size_t len);
/*%<
* Portable front-end to munmap(). If munmap() is not defined on
* this platform, then we simply free the memory.
*/
isc_result_t
isc_file_sanitize(const char *dir, const char *base, const char *ext,
char *path, size_t length);

View file

@ -1400,7 +1400,7 @@ static cfg_type_t cfg_type_mustbesecure = {
cfg_doc_tuple, &cfg_rep_tuple, mustbesecure_fields
};
static const char *masterformat_enums[] = { "map", "raw", "text", NULL };
static const char *masterformat_enums[] = { "raw", "text", NULL };
static cfg_type_t cfg_type_masterformat = {
"masterformat", cfg_parse_enum, cfg_print_ustring,
cfg_doc_enum, &cfg_rep_string, &masterformat_enums

View file

@ -1536,7 +1536,6 @@
./lib/dns/tests/nsec3param_test.c C 2020,2021
./lib/dns/tests/peer_test.c C 2014,2016,2018,2019,2020,2021
./lib/dns/tests/private_test.c C 2011,2012,2016,2018,2019,2020,2021
./lib/dns/tests/rbt_serialize_test.c C 2014,2015,2016,2018,2019,2020,2021
./lib/dns/tests/rbt_test.c C 2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/dns/tests/rbtdb_test.c C 2021
./lib/dns/tests/rdata_test.c C 2012,2013,2015,2016,2017,2018,2019,2020,2021