From b27c6bcce894786a8e082eafd59eccbf6f2731cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 17 Jun 2024 11:40:40 +0200 Subject: [PATCH] Expand the list of the priority types and move it to db_p.h Add HTTPS, SVCB, SRV, PTR, NAPTR, DNSKEY and TXT records to the list of the priority types that are put at the beginning of the slabheader list for faster access and to avoid eviction when there are more types than the max-types-per-name limit. --- lib/dns/db_p.h | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/dns/qpcache.c | 24 ------------------------ lib/dns/qpzone.c | 25 ------------------------- lib/dns/rbtdb.c | 24 ------------------------ lib/dns/rbtdb_p.h | 2 ++ 5 files changed, 44 insertions(+), 73 deletions(-) diff --git a/lib/dns/db_p.h b/lib/dns/db_p.h index f12d9b4a33..fa6fa5485a 100644 --- a/lib/dns/db_p.h +++ b/lib/dns/db_p.h @@ -145,4 +145,46 @@ typedef struct { bool exiting; } db_nodelock_t; +static inline bool +prio_type(dns_typepair_t type) { + switch (type) { + case dns_rdatatype_soa: + case DNS_SIGTYPE(dns_rdatatype_soa): + case dns_rdatatype_a: + case DNS_SIGTYPE(dns_rdatatype_a): + case dns_rdatatype_mx: + case DNS_SIGTYPE(dns_rdatatype_mx): + case dns_rdatatype_aaaa: + case DNS_SIGTYPE(dns_rdatatype_aaaa): + case dns_rdatatype_nsec: + case DNS_SIGTYPE(dns_rdatatype_nsec): + case dns_rdatatype_nsec3: + case DNS_SIGTYPE(dns_rdatatype_nsec3): + case dns_rdatatype_ns: + case DNS_SIGTYPE(dns_rdatatype_ns): + case dns_rdatatype_ds: + case DNS_SIGTYPE(dns_rdatatype_ds): + case dns_rdatatype_cname: + case DNS_SIGTYPE(dns_rdatatype_cname): + case dns_rdatatype_dname: + case DNS_SIGTYPE(dns_rdatatype_dname): + case dns_rdatatype_svcb: + case DNS_SIGTYPE(dns_rdatatype_svcb): + case dns_rdatatype_https: + case DNS_SIGTYPE(dns_rdatatype_https): + case dns_rdatatype_dnskey: + case DNS_SIGTYPE(dns_rdatatype_dnskey): + case dns_rdatatype_srv: + case DNS_SIGTYPE(dns_rdatatype_srv): + case dns_rdatatype_txt: + case DNS_SIGTYPE(dns_rdatatype_txt): + case dns_rdatatype_ptr: + case DNS_SIGTYPE(dns_rdatatype_ptr): + case dns_rdatatype_naptr: + case DNS_SIGTYPE(dns_rdatatype_naptr): + return (true); + } + return (false); +} + ISC_LANG_ENDDECLS diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index c56bc2abe7..2aa4b67aa3 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -2438,30 +2438,6 @@ again: } } -static bool -prio_type(dns_typepair_t type) { - switch (type) { - case dns_rdatatype_soa: - case DNS_SIGTYPE(dns_rdatatype_soa): - case dns_rdatatype_a: - case DNS_SIGTYPE(dns_rdatatype_a): - case dns_rdatatype_aaaa: - case DNS_SIGTYPE(dns_rdatatype_aaaa): - case dns_rdatatype_nsec: - case DNS_SIGTYPE(dns_rdatatype_nsec): - case dns_rdatatype_nsec3: - case DNS_SIGTYPE(dns_rdatatype_nsec3): - case dns_rdatatype_ns: - case DNS_SIGTYPE(dns_rdatatype_ns): - case dns_rdatatype_ds: - case DNS_SIGTYPE(dns_rdatatype_ds): - case dns_rdatatype_cname: - case DNS_SIGTYPE(dns_rdatatype_cname): - return (true); - } - return (false); -} - /*% * These functions allow the heap code to rank the priority of each * element. It returns true if v1 happens "sooner" than v2. diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 4bcd5e2890..5a2b487ce1 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -330,31 +330,6 @@ typedef struct qpdb_dbiterator { */ static atomic_uint_fast16_t init_count = 0; -static bool -prio_type(dns_typepair_t type) { - switch (type) { - case dns_rdatatype_soa: - case DNS_SIGTYPE(dns_rdatatype_soa): - case dns_rdatatype_a: - case DNS_SIGTYPE(dns_rdatatype_a): - case dns_rdatatype_aaaa: - case DNS_SIGTYPE(dns_rdatatype_aaaa): - case dns_rdatatype_nsec: - case DNS_SIGTYPE(dns_rdatatype_nsec): - case dns_rdatatype_ns: - case DNS_SIGTYPE(dns_rdatatype_ns): - case dns_rdatatype_ds: - case DNS_SIGTYPE(dns_rdatatype_ds): - case dns_rdatatype_nsec3: - case DNS_SIGTYPE(dns_rdatatype_nsec3): - case dns_rdatatype_cname: - case DNS_SIGTYPE(dns_rdatatype_cname): - return (true); - } - - return (false); -} - /* * Locking * diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index deadde73c7..6319e21c24 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -351,30 +351,6 @@ dns__rbtdb_setttl(dns_slabheader_t *header, dns_ttl_t newttl) { } } -static bool -prio_type(dns_typepair_t type) { - switch (type) { - case dns_rdatatype_soa: - case DNS_SIGTYPE(dns_rdatatype_soa): - case dns_rdatatype_a: - case DNS_SIGTYPE(dns_rdatatype_a): - case dns_rdatatype_aaaa: - case DNS_SIGTYPE(dns_rdatatype_aaaa): - case dns_rdatatype_nsec: - case DNS_SIGTYPE(dns_rdatatype_nsec): - case dns_rdatatype_nsec3: - case DNS_SIGTYPE(dns_rdatatype_nsec3): - case dns_rdatatype_ns: - case DNS_SIGTYPE(dns_rdatatype_ns): - case dns_rdatatype_ds: - case DNS_SIGTYPE(dns_rdatatype_ds): - case dns_rdatatype_cname: - case DNS_SIGTYPE(dns_rdatatype_cname): - return (true); - } - return (false); -} - /*% * These functions allow the heap code to rank the priority of each * element. It returns true if v1 happens "sooner" than v2. diff --git a/lib/dns/rbtdb_p.h b/lib/dns/rbtdb_p.h index cee0499a51..b28863eac7 100644 --- a/lib/dns/rbtdb_p.h +++ b/lib/dns/rbtdb_p.h @@ -21,6 +21,8 @@ #include #include +#include "db_p.h" /* for db_nodelock_t */ + /*% * Note that "impmagic" is not the first four bytes of the struct, so * ISC_MAGIC_VALID cannot be used.