MEDIUM: quic: handle conn bootstrap/handshake on a random thread
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 13 Apr 2023 15:42:34 +0000 (17:42 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 18 Apr 2023 14:54:44 +0000 (16:54 +0200)
commitf16ec344d5b172af603fb0d44ccdc45c0263b5f6
tree2e4a8d38ef62bee2aa7c517ea073744d3d63214b
parent1e959ad522e3e84a0e1f4e88ca017791a3708a28
MEDIUM: quic: handle conn bootstrap/handshake on a random thread

TID encoding in CID was removed by a recent change. It is now possible
to access to the <tid> member stored in quic_connection_id instance.

For unknown CID, a quick solution was to redispatch to the thread
corresponding to the first CID byte. This ensures that an identical CID
will always be handled by the same thread to avoid creating multiple
same connection. However, this forces an uneven load repartition which
can be critical for QUIC handshake operation.

To improve this, remove the above constraint. An unknown CID is now
handled by its receiving thread. However, this means that if multiple
packets are received with the same unknown CID, several threads will try
to allocate the same connection.

To prevent this race condition, CID insertion in global tree is now
conducted first before creating the connection. This is a thread-safe
operation which can only be executed by a single thread. The thread
which have inserted the CID will then proceed to quic_conn allocation.
Other threads won't be able to insert the same CID : this will stop the
treatment of the current packet which is redispatch to the now owning
thread.

This should be backported up to 2.7 after a period of observation.
src/quic_conn.c
src/quic_sock.c