1. 21 Jul, 2020 1 commit
    • Ondřej Surý's avatar
      Fix the rbt hashtable and grow it when setting max-cache-size · e24bc324
      Ondřej Surý authored
      There were several problems with rbt hashtable implementation:
      1. Our internal hashing function returns uint64_t value, but it was
         silently truncated to unsigned int in dns_name_hash() and
         dns_name_fullhash() functions.  As the SipHash 2-4 higher bits are
         more random, we need to use the upper half of the return value.
      2. The hashtable implementation in rbt.c was using modulo to pick the
         slot number for the hash table.  This has several problems because
         modulo is: a) slow, b) oblivious to patterns in the input data.  This
         could lead to very uneven distribution of the hashed data in the
         hashtable.  Combined with the single-linked lists we use, it could
         really hog-down the lookup and removal of the nodes from the rbt
         tree[a].  The Fibonacci Hashing is much better fit for the hashtable
         function here.  For longer description, read "Fibonacci Hashing: The
         Optimization that the World Forgot"[b] or just look at the Linux
         kernel.  Also this will make Diego very happy :).
      3. The hashtable would rehash every time the number of nodes in the rbt
         tree would exceed 3 * (hashtable size).  The overcommit will make the
         uneven distribution in the hashtable even worse, but the main problem
         lies in the rehashing - every time the database grows beyond the
         limit, each subsequent rehashing will be much slower.  The mitigation
         here is letting the rbt know how big the cache can grown and
         pre-allocate the hashtable to be big enough to actually never need to
         rehash.  This will consume more memory at the start, but since the
         size of the hashtable is capped to `1 << 32` (e.g. 4 mio entries), it
         will only consume maximum of 32GB of memory for hashtable in the
         worst case (and max-cache-size would need to be set to more than
         4TB).  Calling the dns_db_adjusthashsize() will also cap the maximum
         size of the hashtable to the pre-computed number of bits, so it won't
         try to consume more gigabytes of memory than available for the
         FIXME: What is the average size of the rbt node that gets hashed?  I
         chose the pagesize (4k) as initial value to precompute the size of
         the hashtable, but the value is based on feeling and not any real
      For future work, there are more places where we use result of the hash
      value modulo some small number and that would benefit from Fibonacci
      Hashing to get better distribution.
      a. A doubly linked list should be used here to speedup the removal of
         the entries from the hashtable.
      b. https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/
  2. 21 Feb, 2020 1 commit
  3. 13 Feb, 2020 2 commits
    • Evan Hunt's avatar
      apply the modified style · e851ed0b
      Evan Hunt authored
    • Ondřej Surý's avatar
      Use clang-tidy to add curly braces around one-line statements · 056e133c
      Ondřej Surý authored
      The command used to reformat the files in this commit was:
      ./util/run-clang-tidy \
      	-clang-tidy-binary clang-tidy-11
      	-clang-apply-replacements-binary clang-apply-replacements-11 \
      	-checks=-*,readability-braces-around-statements \
      	-j 9 \
      	-fix \
      	-format \
      	-style=file \
      clang-format -i --style=format $(git ls-files '*.c' '*.h')
      uncrustify -c .uncrustify.cfg --replace --no-backup $(git ls-files '*.c' '*.h')
      clang-format -i --style=format $(git ls-files '*.c' '*.h')
  4. 12 Feb, 2020 1 commit
  5. 10 Feb, 2020 1 commit
  6. 01 Oct, 2019 4 commits
    • Ondřej Surý's avatar
      Various little fixes found by coccinelle · 288f5a4b
      Ondřej Surý authored
      The coccinellery repository provides many little semantic patches to fix common
      problems in the code.  The number of semantic patches in the coccinellery
      repository is high and most of the semantic patches apply only for Linux, so it
      doesn't make sense to run them on regular basis as the processing takes a lot of
      The list of issue found in BIND 9, by no means complete, includes:
      - double assignment to a variable
      - `continue` at the end of the loop
      - double checks for `NULL`
      - useless checks for `NULL` (cannot be `NULL`, because of earlier return)
      - using `0` instead of `NULL`
      - useless extra condition (`if (foo) return; if (!foo) { ...; }`)
      - removing & in front of static functions passed as arguments
    • Mark Andrews's avatar
      remove unused variable · dfcc9e18
      Mark Andrews authored
    • Ondřej Surý's avatar
      Replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf() · c2dad0dc
      Ondřej Surý authored
      Use the semantic patch from the previous commit to replace all the calls to
      dns_name_copy() with NULL as third argument with dns_name_copynf().
    • Ondřej Surý's avatar
      Add RUNTIME_CHECK() around result = dns_name_copy(..., NULL) calls · 89b269b0
      Ondřej Surý authored
      This second commit uses second semantic patch to replace the calls to
      dns_name_copy() with NULL as third argument where the result was stored in a
      isc_result_t variable.  As the dns_name_copy(..., NULL) cannot fail gracefully
      when the third argument is NULL, it was just a bunch of dead code.
      Couple of manual tweaks (removing dead labels and unused variables) were
      manually applied on top of the semantic patch.
  7. 23 Jul, 2019 1 commit
  8. 26 Jun, 2019 1 commit
    • Michał Kępień's avatar
      Include <stdlib.h> in lib/dns/dnsrps.c · 6cfcc6e8
      Michał Kępień authored
      Since commit 0771dd3b, <isc/mem.h> no
      longer includes <isc/xml.h>.  On some systems (e.g. FreeBSD), this means
      that no header included by lib/dns/dnsrps.c (and no header included by
      those headers) contains a definition of free() any more, which triggers
      a compiler warning as lib/dns/dnsrps.c calls that function.  Add the
      missing #include directive to prevent that warning from being triggered.
  9. 08 Mar, 2019 1 commit
  10. 28 Nov, 2018 1 commit
  11. 22 Nov, 2018 2 commits
  12. 08 Nov, 2018 1 commit
  13. 28 Aug, 2018 1 commit
  14. 08 Aug, 2018 2 commits
  15. 23 Feb, 2018 1 commit
  16. 18 Nov, 2017 1 commit
  17. 06 Oct, 2017 1 commit
  18. 13 Sep, 2017 1 commit
    • Evan Hunt's avatar
      [master] cleanup strcat/strcpy · 114f9508
      Evan Hunt authored
      4722.	[cleanup]	Clean up uses of strcpy() and strcat() in favor of
      			strlcpy() and strlcat() for safety. [RT #45981]
  19. 12 Sep, 2017 1 commit
  20. 11 Sep, 2017 1 commit
    • Evan Hunt's avatar
      [master] DNS Response Policy Service API · 3363f314
      Evan Hunt authored
      4713.	[func]		Added support for the DNS Response Policy Service
      			(DNSRPS) API, which allows named to use an external
      			response policy daemon when built with
      			"configure --enable-dnsrps".  Thanks to Vernon
      			Schryver and Farsight Security. [RT #43376]