From f79809641282c9372817c4d5079c5b82c2c0b432 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Thu, 19 Aug 2021 17:35:21 +0200 Subject: [PATCH] MINOR: quic: Post handshake packet building improvements Make qc_prep_hdshk_pkts() and qui_conn_io_cb() handle the case where we enter them with QUIC_HS_ST_COMPLETE or QUIC_HS_ST_CONFIRMED as connection state with QUIC_TLS_ENC_LEVEL_APP and QUIC_TLS_ENC_LEVEL_NONE to consider to prepare packets. quic_get_tls_enc_levels() is modified to return QUIC_TLS_ENC_LEVEL_APP and QUIC_TLS_ENC_LEVEL_NONE as levels to consider when coalescing packets in the same datagram. --- include/haproxy/quic_tls.h | 7 +++++-- src/xprt_quic.c | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/haproxy/quic_tls.h b/include/haproxy/quic_tls.h index d6d0e86..288cc16 100644 --- a/include/haproxy/quic_tls.h +++ b/include/haproxy/quic_tls.h @@ -361,11 +361,14 @@ static inline int quic_get_tls_enc_levels(enum quic_tls_enc_level *level, break; case QUIC_HS_ST_SERVER_HANDSHAKE: case QUIC_HS_ST_CLIENT_HANDSHAKE: - case QUIC_HS_ST_COMPLETE: - case QUIC_HS_ST_CONFIRMED: *level = QUIC_TLS_ENC_LEVEL_HANDSHAKE; *next_level = QUIC_TLS_ENC_LEVEL_APP; break; + case QUIC_HS_ST_COMPLETE: + case QUIC_HS_ST_CONFIRMED: + *level = QUIC_TLS_ENC_LEVEL_APP; + *next_level = QUIC_TLS_ENC_LEVEL_NONE; + break; default: return 0; } diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 11afae7..634c553 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -2114,7 +2114,8 @@ static int qc_prep_hdshk_pkts(struct qring *qr, struct ssl_sock_ctx *ctx) * been sent, select the next level. */ if ((tel == QUIC_TLS_ENC_LEVEL_INITIAL || tel == QUIC_TLS_ENC_LEVEL_HANDSHAKE) && - (MT_LIST_ISEMPTY(&qel->pktns->tx.frms) || qc->els[next_tel].pktns->tx.in_flight)) { + (MT_LIST_ISEMPTY(&qel->pktns->tx.frms) || + (next_tel != QUIC_TLS_ENC_LEVEL_NONE && qc->els[next_tel].pktns->tx.in_flight))) { tel = next_tel; qel = &qc->els[tel]; if (!MT_LIST_ISEMPTY(&qel->pktns->tx.frms)) { @@ -2644,7 +2645,7 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state) goto err; qel = &qc->els[tel]; - next_qel = &qc->els[next_tel]; + next_qel = next_tel == QUIC_TLS_ENC_LEVEL_NONE ? NULL : &qc->els[next_tel]; next_level: tls_ctx = &qel->tls_ctx; @@ -2685,7 +2686,7 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state) skip_send: /* Check if there is something to do for the next level. */ - if ((next_qel->tls_ctx.rx.flags & QUIC_FL_TLS_SECRETS_SET) && + if (next_qel && (next_qel->tls_ctx.rx.flags & QUIC_FL_TLS_SECRETS_SET) && (!MT_LIST_ISEMPTY(&next_qel->rx.pqpkts) || !eb_is_empty(&next_qel->rx.pkts))) { qel = next_qel; goto next_level; -- 1.7.10.4