Re: [PATCH v2] netfilter: nfnetlink_queue: optimize verdict lookup with hash table
From: David Laight
Date: Thu Nov 13 2025 - 14:40:34 EST
On Thu, 13 Nov 2025 02:25:24 -0800
Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
> On Thu, Nov 13, 2025 at 1:26 AM Scott Mitchell <scott.k.mitch1@xxxxxxxxx> wrote:
....
> I do not think this is an efficient hash function.
>
> queue->id_sequence is monotonically increasing (controlled by the
> kernel : __nfqnl_enqueue_packet(), not user space).
If id_sequence is allocated by the kernel, is there any requirement
that the values be sequential rather than just unique?
If they don't need to be sequential then the kernel can pick an 'id' value
such that 'id & mask' is unique for all 'live' id values.
Then the hash becomes 'perfect' and degenerates into a simple array lookup.
Just needs a bit of housekeeping...
David