]> 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 21:50:49 +0000 (22:50 +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.

lib/dns/qpzone.c

index a1b7b97a207cff2312f52eee471b00d61fb8ef1f..e0ddab3bfbfc35bf19cfe6e51e0f928473256d34 100644 (file)
@@ -595,10 +595,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__,