]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: use qc_send_hdshk_pkts() in handshake IO cb
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 8 Apr 2024 07:46:46 +0000 (09:46 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 10 Apr 2024 09:07:19 +0000 (11:07 +0200)
quic_conn_io_cb() manually implements emission by using lower level
functions qc_prep_pkts() and qc_send_ppkts(). Replace this by using the
higher level function qc_send_hdshk_pkts() which notably handle buffer
allocation and purging.

This allows to clean up send API by flagging qc_prep_pkts() and
qc_send_ppkts() as static. They are now used in a single location inside
qc_send_hdshk_pkts().

include/haproxy/quic_tx.h
src/quic_conn.c
src/quic_tx.c

index 7dc83dbfd307e2fa840b76a07e364a5dec6eb003..fe12874a066b986d141ba67cd162bc9f0db344c2 100644 (file)
@@ -35,9 +35,9 @@ struct buffer *qc_get_txb(struct quic_conn *qc);
 
 void qel_register_send(struct list *send_list, struct quic_enc_level *qel,
                        struct list *frms);
-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_hdshk_pkts(struct quic_conn *qc, int old_data, struct list *send_list);
 int qc_send_app_pkts(struct quic_conn *qc, struct list *frms);
+
 int qc_dgrams_retransmit(struct quic_conn *qc);
 void qc_prep_hdshk_fast_retrans(struct quic_conn *qc,
                                 struct list *ifrms, struct list *hfrms);
index f3ff1633827277492c33205b49d9632c7a869025..f3e3111a3af83236791d5501ee806574579c9259 100644 (file)
@@ -741,11 +741,9 @@ static struct quic_conn_closed *qc_new_cc_conn(struct quic_conn *qc)
 /* QUIC connection packet handler task. */
 struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
 {
-       int ret;
        struct quic_conn *qc = context;
-       struct buffer *buf = NULL;
        struct list send_list = LIST_HEAD_INIT(send_list);
-       struct quic_enc_level *qel, *tmp_qel;
+       struct quic_enc_level *qel;
        int st;
        struct tasklet *tl = (struct tasklet *)t;
 
@@ -798,41 +796,11 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
        list_for_each_entry(qel, &qc->qel_list, list)
                qel_register_send(&send_list, qel, &qel->pktns->tx.frms);
 
-       buf = qc_get_txb(qc);
-       if (!buf)
-               goto out;
-
-       if (b_data(buf) && !qc_purge_txbuf(qc, buf))
+       if (!qc_send_hdshk_pkts(qc, 0, &send_list)) {
+               TRACE_DEVEL("qc_send_hdshk_pkts() failed", QUIC_EV_CONN_IO_CB, qc);
                goto out;
-
-       /* Currently buf cannot be non-empty at this stage. Even if a previous
-        * sendto() has failed it is emptied to simulate packet emission and
-        * rely on QUIC lost detection to try to emit it.
-        */
-       BUG_ON_HOT(b_data(buf));
-       b_reset(buf);
-
-       ret = qc_prep_hpkts(qc, buf, &send_list);
-
-       /* Always reset QEL sending list. */
-       list_for_each_entry_safe(qel, tmp_qel, &send_list, el_send) {
-               LIST_DEL_INIT(&qel->el_send);
-               qel->send_frms = NULL;
        }
 
-       if (ret == -1) {
-               qc_txb_release(qc);
-               goto out;
-       }
-
-       if (ret && !qc_send_ppkts(buf, qc->xprt_ctx)) {
-               if (qc->flags & QUIC_FL_CONN_TO_KILL)
-                       qc_txb_release(qc);
-               goto out;
-       }
-
-       qc_txb_release(qc);
-
  out:
        /* Release the Handshake encryption level and packet number space if
         * the Handshake is confirmed and if there is no need to send
index ee587aca0e5b5d6f1c257644811a6560cde4f9bb..eca3799fd66104b2e1b0a946cd09483e5f57d58d 100644 (file)
@@ -362,7 +362,7 @@ static void qc_purge_tx_buf(struct quic_conn *qc, struct buffer *buf)
  *   Remaining data are purged from the buffer and will eventually be detected
  *   as lost which gives the opportunity to retry sending.
  */
-int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
+static int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
 {
        int ret = 0;
        struct quic_conn *qc;
@@ -659,7 +659,8 @@ static inline void qc_select_tls_ver(struct quic_conn *qc,
  * Returns the number of bytes prepared in datragrams/packets if succeeded
  * (may be 0), or -1 if something wrong happened.
  */
-int qc_prep_hpkts(struct quic_conn *qc, struct buffer *buf, struct list *qels)
+static int qc_prep_hpkts(struct quic_conn *qc, struct buffer *buf,
+                         struct list *qels)
 {
        int ret, cc, padding;
        struct quic_tx_packet *first_pkt, *prv_pkt;