From: deanliang06 <[email protected]>
With thread group specific FD tables, a datagram can be received on a
certain thread group and then handled by another. In that case, the
handler's fdtable cannot reference the fd of the attached listener. What
we tried to do is to scan the bind for listeners with the same bind as
original listener and with thread group being the same as the handler
thread. This way we can reference the listener. However, if this lookup misses
(with certain configs) we end up using the listener with reciever and thus fd
num on other thread group. When we reference this stale fd, we may refer to
another descriptor or just an invalid descriptor (depending on the handler's
fdtable).
The solution for this is to add error handling after the scan to see if
the listener is valid (bind is assigned to current thread group), and if it
isn't, we drop the datagram and emit the QUIC trace.
---
src/quic_rx.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/quic_rx.c b/src/quic_rx.c
index 42ab47b74..8ea1b8adc 100644
--- a/src/quic_rx.c
+++ b/src/quic_rx.c
@@ -2567,8 +2567,9 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct
quic_conn *from_qc,
/*
* Make sure we have a usable file descriptor. When each thread
* group has its own file descriptor tables, we can't just assume
- * we can use the current listener, so find a more fitting one if
- * needed.
+ * we can use the current listener, so find one which can be
+ * assigned to handler thread group. If no such listener exists,
+ * drop the datagram.
*/
if (li && (global.tune.options & GTUNE_NO_TG_FD_SHARING) &&
li->rx.bind_tgroup != tgid) {
@@ -2580,6 +2581,11 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct
quic_conn *from_qc,
break;
}
}
+
+ if (li->rx.bind_tgroup != tgid) {
+ TRACE_ERROR("No listener with same bind in current
thread group", QUIC_EV_CONN_LPKT);
+ goto err;
+ }
}
pos = dgram->buf;
--
2.54.0.windows.1