]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: quic: Remove two useless pools a low QUIC connection level
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 22 Jun 2023 13:02:38 +0000 (15:02 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 30 Jun 2023 14:20:55 +0000 (16:20 +0200)
Both "quic_tx_ring" and "quic_rx_crypto_frm" pool are no more used.

Should be backported as far as 2.6.

include/haproxy/quic_conn-t.h
include/haproxy/quic_tls.h
src/quic_conn.c

index eb05fd5376c3a407e24f4fa7b24eaa9fbfa525d5..d05a7b96f7cbd9f306c4b17f8c49703476f662e4 100644 (file)
@@ -252,7 +252,6 @@ enum quic_pkt_type {
 #define QUIC_CONN_RX_BUFSZ (1UL << 16)
 
 extern struct trace_source trace_quic;
-extern struct pool_head *pool_head_quic_tx_ring;
 extern struct pool_head *pool_head_quic_rx_packet;
 extern struct pool_head *pool_head_quic_tx_packet;
 extern struct pool_head *pool_head_quic_crypto_buf;
index 0c6aff9bed950c7c9e7b2c71ff1a9d49d6af18a7..9927044b479f573f1babdb7c9c5aa0088e9d35c0 100644 (file)
@@ -184,6 +184,24 @@ static inline struct quic_pktns **ssl_to_quic_pktns(struct quic_conn *qc,
        }
 }
 
+/* These following functions map TLS implementation encryption level to ours */
+static inline struct quic_pktns **qel_to_quic_pktns(struct quic_conn *qc,
+                                                    enum quic_tls_enc_level level)
+{
+       switch (level) {
+       case QUIC_TLS_ENC_LEVEL_INITIAL:
+               return &qc->ipktns;
+       case QUIC_TLS_ENC_LEVEL_EARLY_DATA:
+               return &qc->apktns;
+       case QUIC_TLS_ENC_LEVEL_HANDSHAKE:
+               return &qc->hpktns;
+       case QUIC_TLS_ENC_LEVEL_APP:
+               return &qc->apktns;
+       default:
+               return NULL;
+       }
+}
+
 /* Map <level> TLS stack encryption level to our internal QUIC TLS encryption level
  * if succeded, or -1 if failed.
  */
@@ -224,6 +242,27 @@ static inline struct quic_enc_level **ssl_to_qel_addr(struct quic_conn *qc,
        }
 }
 
+/* Return the address of the QUIC TLS encryption level associated to <level> internal
+ * encryption level and attached to <qc> QUIC connection if succeeded, or
+ * NULL if failed.
+ */
+static inline struct quic_enc_level **qel_to_qel_addr(struct quic_conn *qc,
+                                                      enum quic_tls_enc_level level)
+{
+       switch (level) {
+       case QUIC_TLS_ENC_LEVEL_INITIAL:
+               return &qc->iel;
+       case QUIC_TLS_ENC_LEVEL_EARLY_DATA:
+               return &qc->eel;
+       case QUIC_TLS_ENC_LEVEL_HANDSHAKE:
+               return &qc->hel;
+       case QUIC_TLS_ENC_LEVEL_APP:
+               return &qc->ael;
+       default:
+               return NULL;
+       }
+}
+
 /* Return the QUIC TLS encryption level associated to <level> internal encryption
  * level attached to <qc> QUIC connection if succeeded, or NULL if failed.
  */
index f44945af21280e1396d6df234a69b8597c4939ee..40454f1122bb5177a8aa51d5e2334515f07e9bbb 100644 (file)
@@ -211,7 +211,6 @@ INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE);
 
 static BIO_METHOD *ha_quic_meth;
 
-DECLARE_POOL(pool_head_quic_tx_ring, "quic_tx_ring", QUIC_TX_RING_BUFSZ);
 DECLARE_POOL(pool_head_quic_conn_rxbuf, "quic_conn_rxbuf", QUIC_CONN_RX_BUFSZ);
 DECLARE_STATIC_POOL(pool_head_quic_conn_ctx,
                     "quic_conn_ctx", sizeof(struct ssl_sock_ctx));
@@ -221,7 +220,6 @@ DECLARE_POOL(pool_head_quic_connection_id,
 DECLARE_POOL(pool_head_quic_dgram, "quic_dgram", sizeof(struct quic_dgram));
 DECLARE_POOL(pool_head_quic_rx_packet, "quic_rx_packet", sizeof(struct quic_rx_packet));
 DECLARE_POOL(pool_head_quic_tx_packet, "quic_tx_packet", sizeof(struct quic_tx_packet));
-DECLARE_STATIC_POOL(pool_head_quic_rx_crypto_frm, "quic_rx_crypto_frm", sizeof(struct quic_rx_crypto_frm));
 DECLARE_POOL(pool_head_quic_crypto_buf, "quic_crypto_buf", sizeof(struct quic_crypto_buf));
 DECLARE_STATIC_POOL(pool_head_quic_cstream, "quic_cstream", sizeof(struct quic_cstream));
 DECLARE_POOL(pool_head_quic_frame, "quic_frame", sizeof(struct quic_frame));
@@ -6051,6 +6049,17 @@ static inline int qc_try_rm_hp(struct quic_conn *qc,
 
        tel = quic_packet_type_enc_level(pkt->type);
        qel = qc_quic_enc_level(qc, tel);
+       if (!qel) {
+               struct quic_enc_level **qc_qel = qel_to_qel_addr(qc, tel);
+               struct quic_pktns **qc_pktns = qel_to_quic_pktns(qc, tel);
+
+               if (!qc_enc_level_alloc(qc, qc_pktns, qc_qel, quic_to_ssl_enc_level(tel))) {
+                       TRACE_PROTO("Could not allocated an encryption level", QUIC_EV_CONN_ADDDATA, qc);
+                       goto out;
+               }
+
+               qel = *qc_qel;
+       }
 
        if (qc_qel_may_rm_hp(qc, qel)) {
                struct quic_tls_ctx *tls_ctx = qc_select_tls_ctx(qc, qel, pkt);