Re: [PATCH v3 net-next 2/3] net/udp: Add 4-tuple hash list basis

From: Willem de Bruijn
Date: Thu Oct 10 2024 - 09:49:50 EST


Philo Lu wrote:
> Add a new hash list, hash4, in udp table. It will be used to implement
> 4-tuple hash for connected udp sockets. This patch adds the hlist to
> table, and implements helpers and the initialization. 4-tuple hash is
> implemented in the following patch.
>
> Signed-off-by: Philo Lu <lulie@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Cambda Zhu <cambda@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Fred Chen <fred.cc@xxxxxxxxxxxxxxx>
> Signed-off-by: Yubing Qiu <yubing.qiuyubing@xxxxxxxxxxxxxxx>

> @@ -3480,16 +3486,15 @@ static struct udp_table __net_init *udp_pernet_table_alloc(unsigned int hash_ent
> if (!udptable)
> goto out;
>
> - slot_size = sizeof(struct udp_hslot) + sizeof(struct udp_hslot_main);
> + slot_size = 2 * sizeof(struct udp_hslot) + sizeof(struct udp_hslot_main);
> udptable->hash = vmalloc_huge(hash_entries * slot_size,
> GFP_KERNEL_ACCOUNT);
> if (!udptable->hash)
> goto free_table;
>
> udptable->hash2 = UDP_HSLOT_MAIN(udptable->hash + hash_entries);
> - udptable->mask = hash_entries - 1;
> + udptable->hash4 = (struct udp_hslot *)(udptable->hash2 + hash_entries);

Unintentional removal of the mask assignment?

> udptable->log = ilog2(hash_entries);
> -

Unnecessary whitespace line removal

> for (i = 0; i < hash_entries; i++) {
> INIT_HLIST_HEAD(&udptable->hash[i].head);
> udptable->hash[i].count = 0;