From 714d1096bc5ab09ac0ab30c7371e2c8c594afda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Tue, 28 Nov 2023 14:02:17 +0100 Subject: [PATCH] REORG: quic: Move qc_notify_send() to quic_conn Move qc_notify_send() from quic_tx.c to quic_conn.c. Note that it was already exported from both quic_conn.h and quic_tx.h. Modify this latter header to fix the duplication. --- include/haproxy/quic_tx.h | 1 - src/quic_conn.c | 29 +++++++++++++++++++++++++++++ src/quic_tx.c | 30 ------------------------------ 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/include/haproxy/quic_tx.h b/include/haproxy/quic_tx.h index e556cce83..0659c14e3 100644 --- a/include/haproxy/quic_tx.h +++ b/include/haproxy/quic_tx.h @@ -37,7 +37,6 @@ int qc_prep_hpkts(struct quic_conn *qc, struct buffer *buf, struct list *qels); int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx); int qc_send_app_pkts(struct quic_conn *qc, struct list *frms); int qc_dgrams_retransmit(struct quic_conn *qc); -int qc_notify_send(struct quic_conn *qc); void qc_prep_hdshk_fast_retrans(struct quic_conn *qc, struct list *ifrms, struct list *hfrms); int send_retry(int fd, struct sockaddr_storage *addr, diff --git a/src/quic_conn.c b/src/quic_conn.c index 9559eb462..b5545976a 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -1725,6 +1725,35 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len) return 0; } +/* Wake-up upper layer for sending if all conditions are met : + * - room in congestion window or probe packet to sent + * - socket FD ready to sent or listener socket used + * + * Returns 1 if upper layer has been woken up else 0. + */ +int qc_notify_send(struct quic_conn *qc) +{ + const struct quic_pktns *pktns = qc->apktns; + + if (qc->subs && qc->subs->events & SUB_RETRY_SEND) { + /* RFC 9002 7.5. Probe Timeout + * + * Probe packets MUST NOT be blocked by the congestion controller. + */ + if ((quic_cc_path_prep_data(qc->path) || pktns->tx.pto_probe) && + (!qc_test_fd(qc) || !fd_send_active(qc->fd))) { + tasklet_wakeup(qc->subs->tasklet); + qc->subs->events &= ~SUB_RETRY_SEND; + if (!qc->subs->events) + qc->subs = NULL; + + return 1; + } + } + + return 0; +} + /* Notify upper layer of a fatal error which forces to close the connection. */ void qc_notify_err(struct quic_conn *qc) { diff --git a/src/quic_tx.c b/src/quic_tx.c index 4af91b2a8..5ff9764a1 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -2581,36 +2581,6 @@ static struct quic_tx_packet *qc_build_pkt(unsigned char **pos, free_quic_tx_packet(qc, pkt); goto leave; } - -/* Wake-up upper layer for sending if all conditions are met : - * - room in congestion window or probe packet to sent - * - socket FD ready to sent or listener socket used - * - * Returns 1 if upper layer has been woken up else 0. - */ -int qc_notify_send(struct quic_conn *qc) -{ - const struct quic_pktns *pktns = qc->apktns; - - if (qc->subs && qc->subs->events & SUB_RETRY_SEND) { - /* RFC 9002 7.5. Probe Timeout - * - * Probe packets MUST NOT be blocked by the congestion controller. - */ - if ((quic_cc_path_prep_data(qc->path) || pktns->tx.pto_probe) && - (!qc_test_fd(qc) || !fd_send_active(qc->fd))) { - tasklet_wakeup(qc->subs->tasklet); - qc->subs->events &= ~SUB_RETRY_SEND; - if (!qc->subs->events) - qc->subs = NULL; - - return 1; - } - } - - return 0; -} - /* * Local variables: * c-indent-level: 8