Re: [PATCH v4 net-next 3/3] ipv4/udp: Add 4-tuple hash for connected socket
From: Paolo Abeni
Date: Mon Oct 14 2024 - 06:20:03 EST
On 10/12/24 03:29, Philo Lu wrote:
Currently, the udp_table has two hash table, the port hash and portaddr
hash. Usually for UDP servers, all sockets have the same local port and
addr, so they are all on the same hash slot within a reuseport group.
In some applications, UDP servers use connect() to manage clients. In
particular, when firstly receiving from an unseen 4 tuple, a new socket
is created and connect()ed to the remote addr:port, and then the fd is
used exclusively by the client.
How do you handle the following somewhat racing scenario? a 2nd packet
beloning to the same 4-tulpe lands into the unconnected socket receive
queue just after the 1st one, before the connected socket is created.
The server process such packet after the connected socket creation.
How many connected sockets is your system serving concurrently? Possibly
it would make sense to allocate a larger hash table for the connected
UDP sockets, using separate/different min/max/scale values WRT to the
unconnected tables.
Cheers,
Paolo