2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +00:00

improve calculation of database transfer size

- change name of 'bytes' to 'xfrsize' in dns_db_getsize() parameter list
  and related variables; this is a more accurate representation of what
  the function is doing
- change the size calculations in dns_db_getsize() to more accurately
  represent the space needed for a *XFR message or journal file to contain
  the data in the database. previously we returned the sizes of all
  rdataslabs, including header overhead and offset tables, which
  resulted in the database size being reported as much larger than the
  equivalent *XFR or journal.
- map files caused a particular problem here: the fullname can't be
  determined from the node while a file is being deserialized, because
  the uppernode pointers aren't set yet. so we store "full name length"
  in the dns_rbtnode structure while serializing, and clear it after
  deserialization is complete.
This commit is contained in:
Evan Hunt
2020-02-22 00:37:05 -08:00
parent 52a31a9883
commit 98b55eb442
9 changed files with 180 additions and 58 deletions

View File

@@ -361,6 +361,34 @@ dns_rdataslab_size(unsigned char *slab, unsigned int reservelen) {
return ((unsigned int)(current - slab));
}
unsigned int
dns_rdataslab_rdatasize(unsigned char *slab, unsigned int reservelen) {
unsigned int count, length, rdatalen = 0;
unsigned char *current;
REQUIRE(slab != NULL);
current = slab + reservelen;
count = *current++ * 256;
count += *current++;
#if DNS_RDATASET_FIXED
current += (4 * count);
#endif /* if DNS_RDATASET_FIXED */
while (count > 0) {
count--;
length = *current++ * 256;
length += *current++;
rdatalen += length;
#if DNS_RDATASET_FIXED
current += length + 2;
#else /* if DNS_RDATASET_FIXED */
current += length;
#endif /* if DNS_RDATASET_FIXED */
}
return (rdatalen);
}
unsigned int
dns_rdataslab_count(unsigned char *slab, unsigned int reservelen) {
unsigned int count;