]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Switch the locknum generation for qpznode to random
authorOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2025 20:15:22 +0000 (21:15 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 4 Feb 2025 22:28:53 +0000 (23:28 +0100)
Instead of using on hash of the name modulo number of the buckets,
assign the locknum randomly with isc_random_uniform().  This makes
the locknum assignment aligned with qpcache and allows the bucket
number to be non-prime in the future.

(cherry picked from commit 732fc338a94d58f78a15e17225a94e1a5f868d6a)

lib/dns/qpzone.c

index a78192c81b71be31750ba91663f130f068486a37..d35598bc2a7c16d3c234a4c0ec5d715fc32179f2 100644 (file)
@@ -527,10 +527,11 @@ new_qpznode(qpzonedb_t *qpdb, const dns_name_t *name) {
        *newdata = (qpznode_t){
                .name = DNS_NAME_INITEMPTY,
                .references = ISC_REFCOUNT_INITIALIZER(1),
+               .locknum = isc_random_uniform(qpdb->buckets_count),
        };
-       newdata->locknum = dns_name_hash(name) % qpdb->buckets_count;
-       dns_name_dupwithoffsets(name, qpdb->common.mctx, &newdata->name);
+
        isc_mem_attach(qpdb->common.mctx, &newdata->mctx);
+       dns_name_dupwithoffsets(name, qpdb->common.mctx, &newdata->name);
 
 #if DNS_DB_NODETRACE
        fprintf(stderr, "new_qpznode:%s:%s:%d:%p->references = 1\n", __func__,