]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Improve qc_prep_pkts() flexibility
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 3 Jan 2022 10:14:30 +0000 (11:14 +0100)
committerFrédéric Lécaille <flecaille@haproxy.com>
Tue, 4 Jan 2022 16:30:00 +0000 (17:30 +0100)
We want to be able to choose the encryption levels to be used
by qc_prep_pkts() outside of it.

src/xprt_quic.c

index 3ba009fa5c51360bf83519e657caa043cbab51ea..98718ce1dd41b9729473d02290d204d754ee0f61 100644 (file)
@@ -2405,9 +2405,10 @@ static inline void qc_set_dg(struct cbuf *cbuf,
  * packet in this datagram.
  * Returns 1 if succeeded, or 0 if something wrong happened.
  */
-static int qc_prep_pkts(struct quic_conn *qc, struct qring *qr)
+static int qc_prep_pkts(struct quic_conn *qc, struct qring *qr,
+                        enum quic_tls_enc_level tel,
+                        enum quic_tls_enc_level next_tel)
 {
-       enum quic_tls_enc_level tel, next_tel;
        struct quic_enc_level *qel;
        struct cbuf *cbuf;
        unsigned char *end_buf, *end, *pos, *spos;
@@ -2423,11 +2424,6 @@ static int qc_prep_pkts(struct quic_conn *qc, struct qring *qr)
 
        TRACE_ENTER(QUIC_EV_CONN_PHPKTS, qc);
 
-       if (!quic_get_tls_enc_levels(&tel, &next_tel, HA_ATOMIC_LOAD(&qc->state), 0)) {
-               TRACE_DEVEL("unknown enc. levels", QUIC_EV_CONN_PHPKTS, qc);
-               goto err;
-       }
-
  start:
        dglen = 0;
        total = 0;
@@ -3142,7 +3138,9 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
 
        if (!qr)
                qr = MT_LIST_POP(qc->tx.qring_list, typeof(qr), mt_list);
-       ret = qc_prep_pkts(qc, qr);
+       if (!quic_get_tls_enc_levels(&tel, &next_tel, st, zero_rtt))
+               goto err;
+       ret = qc_prep_pkts(qc, qr, tel, next_tel);
        if (ret == -1)
                goto err;
        else if (ret == 0)