With per-thread-group FD tables, quic_dgram_parse() looks for a listener
of the same bind line in the current thread group, since commit
62d6ed440 ("MEDIUM: quic: Do not use another thread group's listener
FD"). But the CID tree is shared by all bind lines, so a datagram for a
connection may be received on a bind line which has no listener in the
group of the connection's thread, and the listener of the other group
was then kept. If no connection ended up being used, its FD, which
means nothing in the current group, was used to send a Version
Negotiation, Retry or Stateless Reset packet, and a new connection
could be attached to that listener.
Drop the packet in these cases only, ie when the version is not
supported or when no connection is found. Packets for an existing
connection do not need the listener and are still processed. This can
be tested with "tune.fd.tables per-thread-group" and two QUIC bind lines
on different thread groups, by sending to the second one the datagrams
of a connection established on the first one.
This was reported by deanliang06 <dextersquad4@gmail.com>, who proposed
a first fix dropping all such datagrams:
https://www.mail-archive.com/haproxy@formilux.org/msg47862.html
This should be backported to 3.5.
goto leave;
}
+/* Returns non-zero if <l>'s FD cannot be used from the current thread group. */
+static inline int quic_lstnr_is_foreign(const struct listener *l)
+{
+ return (global.tune.options & GTUNE_NO_TG_FD_SHARING) &&
+ l->rx.bind_tgroup != tgid;
+}
+
/* Listener only function.
*
* Find the associated connection to the packet <pkt> or create a new one if
if (!qc && *new_tid != -1 && tid != *new_tid)
goto out;
+ if (!qc && quic_lstnr_is_foreign(l)) {
+ TRACE_PROTO("no connection and listener from another thread group, packet dropped",
+ QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
+ goto err;
+ }
+
if (pkt->type == QUIC_PACKET_TYPE_INITIAL) {
BUG_ON(!pkt->version); /* This must not happen. */
* sent only by servers.
*/
if (l && !pkt->version) {
+ if (quic_lstnr_is_foreign(l)) {
+ TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
+ goto drop;
+ }
+
/* unsupported version, send Negotiation packet */
if (send_version_negotiation(l, (struct sockaddr_storage *)&dgram->daddr,
(struct sockaddr_storage *)&dgram->saddr, pkt)) {