Re: [PATCH] rhashtable: specialize default comparison for constant parameters

From: Herbert Xu

Date: Fri Sep 25 2026 - 20:14:29 EST


On Fri, Sep 25, 2026 at 10:37:55AM +0100, Usama Arif wrote:
>
> That holds for the params given to rhashtable_init(), but not for the
> params passed to the fast-path helpers. The BPF resizable hashmap
> passes a constant template with no key_len and no obj_cmpfn
> (rhtab_params in kernel/bpf/hashtab.c), and sets key_len only in the
> copy it gives to rhashtable_init(). Without the "?: ht->p.key_len",
> its lookups would memcmp() zero bytes and return the first object in
> the bucket. rht_key_get_hash() has the same fallback for this user,
> see c9429bf56405a. (I added Mykyta the author of that patch in CC.)

That's quite an eyesore but I guess we're stuck with it for now.

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt