From 6492e66e413f7eb26697b9997dbf6063aefe28ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Tue, 17 May 2022 17:23:16 +0200 Subject: [PATCH] MINOR: quic: Move quic_lstnr_dgram_dispatch() out of xprt_quic.c Remove this function from xprt_quic.c which for now implements only "by thread attached to a connection" code. --- include/haproxy/xprt_quic.h | 5 ++--- src/quic_sock.c | 42 ++++++++++++++++++++++++++++++++++ src/xprt_quic.c | 45 ++----------------------------------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index c8587b42c..9602b3a82 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -1258,9 +1258,8 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm); void quic_set_tls_alert(struct quic_conn *qc, int alert); int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alpn_len); struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state); -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); +int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end, + unsigned char **dcid, size_t *dcid_len); int qc_send_app_pkts(struct quic_conn *qc, int old_data, struct list *frms); void qc_notify_close(struct quic_conn *qc); diff --git a/src/quic_sock.c b/src/quic_sock.c index 164993006..6207af703 100644 --- a/src/quic_sock.c +++ b/src/quic_sock.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -217,6 +218,47 @@ struct connection *quic_sock_accept_conn(struct listener *l, int *status) return NULL; } +/* Retrieve the DCID from the datagram found in and deliver it to the + * correct datagram handler. + * Return 1 if a correct datagram could be found, 0 if not. + */ +static 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; + size_t dcid_len; + int cid_tid; + + if (!len || !quic_get_dgram_dcid(buf, buf + len, &dcid, &dcid_len)) + goto err; + + dgram = new_dgram ? new_dgram : pool_alloc(pool_head_quic_dgram); + if (!dgram) + goto err; + + cid_tid = quic_get_cid_tid(dcid); + + /* All the members must be initialized! */ + dgram->owner = owner; + dgram->buf = buf; + dgram->len = len; + dgram->dcid = dcid; + dgram->dcid_len = dcid_len; + dgram->saddr = *saddr; + dgram->qc = NULL; + LIST_APPEND(dgrams, &dgram->list); + MT_LIST_APPEND(&quic_dghdlrs[cid_tid].dgrams, &dgram->mt_list); + + tasklet_wakeup(quic_dghdlrs[cid_tid].task); + + return 1; + + err: + return 0; +} + /* Function called on a read event from a listening socket. It tries * to handle as many connections as possible. */ diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 1781f32b8..5c9b7f2ce 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -6411,8 +6411,8 @@ struct task *quic_lstnr_dghdlr(struct task *t, void *ctx, unsigned int state) /* Retreive the DCID from a QUIC datagram or packet with as first octet. * Returns 1 if succeeded, 0 if not. */ -static int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end, - unsigned char **dcid, size_t *dcid_len) +int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end, + unsigned char **dcid, size_t *dcid_len) { int long_header; size_t minlen, skip; @@ -6441,47 +6441,6 @@ static int quic_get_dgram_dcid(unsigned char *buf, const unsigned char *end, return 0; } -/* Retrieve the DCID from the datagram found in 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; - size_t dcid_len; - int cid_tid; - - if (!len || !quic_get_dgram_dcid(buf, buf + len, &dcid, &dcid_len)) - goto err; - - dgram = new_dgram ? new_dgram : pool_alloc(pool_head_quic_dgram); - if (!dgram) - goto err; - - cid_tid = quic_get_cid_tid(dcid); - - /* All the members must be initialized! */ - dgram->owner = owner; - dgram->buf = buf; - dgram->len = len; - dgram->dcid = dcid; - dgram->dcid_len = dcid_len; - dgram->saddr = *saddr; - dgram->qc = NULL; - LIST_APPEND(dgrams, &dgram->list); - MT_LIST_APPEND(&quic_dghdlrs[cid_tid].dgrams, &dgram->mt_list); - - tasklet_wakeup(quic_dghdlrs[cid_tid].task); - - return 1; - - err: - return 0; -} - /* Notify the MUX layer if alive about an imminent close of . */ void qc_notify_close(struct quic_conn *qc) {