MINOR: quic: Do not consume the RX buffer on QUIC sock i/o handler side
Rename quic_lstnr_dgram_read() to quic_lstnr_dgram_dispatch() to reflect its new role.
After calling this latter, the sock i/o handler must consume the buffer only if
the datagram it received is detected as wrong by quic_lstnr_dgram_dispatch().
The datagram handler task mark the datagram as consumed atomically setting ->buf
to NULL value. The sock i/o handler is responsible of flushing its RX buffer
before using it. It also keeps a datagram among the consumed ones so that
to pass it to quic_lstnr_dgram_dispatch() and prevent it from allocating a new one.
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index 95c1458..90a1916 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -5403,6 +5403,8 @@
/* If the packet length could not be found, we cannot continue. */
break;
} while (pos < end);
+ /* Mark this datagram as consumed */
+ HA_ATOMIC_STORE(&dgram->buf, NULL);
/* Increasing the received bytes counter by the UDP datagram length
* if this datagram could be associated to a connection.
@@ -5449,8 +5451,13 @@
return 0;
}
-int quic_lstnr_dgram_read(unsigned char *buf, size_t len, void *owner,
- struct sockaddr_storage *saddr, struct list *dgrams)
+/* Retrieve the DCID from the datagram found in <buf> and deliver it to the
+ * correct datagram handler.
+ * Return 1 if a correct datagram could be found, 0 if not.
+ */
+int quic_lstnr_dgram_dispatch(unsigned char *buf, size_t len, void *owner,
+ struct sockaddr_storage *saddr,
+ struct quic_dgram *new_dgram, struct list *dgrams)
{
struct quic_dgram *dgram;
unsigned char *dcid;
@@ -5461,7 +5468,7 @@
if (!len || !quic_get_dgram_dcid(buf, buf + len, &dcid, &dcid_len))
goto err;
- dgram = pool_alloc(pool_head_quic_dgram);
+ dgram = new_dgram ? new_dgram : pool_alloc(pool_head_quic_dgram);
if (!dgram)
goto err;