]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: remove qc_treat_rx_crypto_frms()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 8 Mar 2024 16:47:03 +0000 (17:47 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Mar 2024 13:27:51 +0000 (14:27 +0100)
This commit removes qc_treat_rx_crypto_frms(). This function was used in
a single place inside qc_ssl_provide_all_quic_data(). Besides, its
naming was confusing as conceptually it is directly linked to quic_ssl
module instead of quic_rx.

Thus, body of qc_treat_rx_crypto_frms() is inlined directly inside
qc_ssl_provide_all_quic_data(). Also, qc_ssl_provide_quic_data() is now
only used inside quic_ssl to its scope is set to static. Overall, API
for CRYPTO frame handling is now cleaner.

include/haproxy/quic_rx.h
include/haproxy/quic_ssl.h
src/quic_rx.c
src/quic_ssl.c

index 494bc4a2d59d8a2e390921958266081bdd9a1e64..3e65acb0867efe900ad76f707db062e16e45a6e7 100644 (file)
@@ -30,8 +30,6 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
 int qc_treat_rx_pkts(struct quic_conn *qc);
 int qc_parse_hd_form(struct quic_rx_packet *pkt,
                      unsigned char **pos, const unsigned char *end);
-int qc_treat_rx_crypto_frms(struct quic_conn *qc, struct quic_enc_level *el,
-                            struct ssl_sock_ctx *ctx);
 int qc_handle_frms_of_lost_pkt(struct quic_conn *qc,
                                struct quic_tx_packet *pkt,
                                struct list *pktns_frm_list);
index 8f7df47795d12c9bb155fe926fa790626ee5b6a9..a84f5fffcc2c934d008e67fae930936c30265824 100644 (file)
 
 int ssl_quic_initial_ctx(struct bind_conf *bind_conf);
 int qc_alloc_ssl_sock_ctx(struct quic_conn *qc);
-int qc_ssl_provide_quic_data(struct ncbuf *ncbuf,
-                             enum ssl_encryption_level_t level,
-                             struct ssl_sock_ctx *ctx,
-                             const unsigned char *data, size_t len);
 int qc_ssl_provide_all_quic_data(struct quic_conn *qc, struct ssl_sock_ctx *ctx);
 
 static inline void qc_free_ssl_sock_ctx(struct ssl_sock_ctx **ctx)
index 433e6ae5c85e0353f2412e2eca9357c5db7f3f29..c6a23f3ce6e846f0257420351dd4b6cc9ba85c1a 100644 (file)
@@ -1155,50 +1155,6 @@ static void qc_rm_hp_pkts(struct quic_conn *qc, struct quic_enc_level *el)
        TRACE_LEAVE(QUIC_EV_CONN_ELRMHP, qc);
 }
 
-/* Process all the CRYPTO frame at <el> encryption level. This is the
- * responsibility of the called to ensure there exists a CRYPTO data
- * stream for this level.
- * Return 1 if succeeded, 0 if not.
- */
-int qc_treat_rx_crypto_frms(struct quic_conn *qc, struct quic_enc_level *el,
-                            struct ssl_sock_ctx *ctx)
-{
-       int ret = 0;
-       struct ncbuf *ncbuf;
-       struct quic_cstream *cstream = el->cstream;
-       ncb_sz_t data;
-
-       TRACE_ENTER(QUIC_EV_CONN_PHPKTS, qc);
-
-       BUG_ON(!cstream);
-       ncbuf = &cstream->rx.ncbuf;
-       if (ncb_is_null(ncbuf))
-               goto done;
-
-       /* TODO not working if buffer is wrapping */
-       while ((data = ncb_data(ncbuf, 0))) {
-               const unsigned char *cdata = (const unsigned char *)ncb_head(ncbuf);
-
-               if (!qc_ssl_provide_quic_data(&el->cstream->rx.ncbuf, el->level,
-                                             ctx, cdata, data))
-                       goto leave;
-
-               cstream->rx.offset += data;
-               TRACE_DEVEL("buffered crypto data were provided to TLS stack",
-                           QUIC_EV_CONN_PHPKTS, qc, el);
-       }
-
- done:
-       ret = 1;
- leave:
-       if (!ncb_is_null(ncbuf) && ncb_is_empty(ncbuf)) {
-               TRACE_DEVEL("freeing crypto buf", QUIC_EV_CONN_PHPKTS, qc, el);
-               quic_free_ncbuf(ncbuf);
-       }
-       TRACE_LEAVE(QUIC_EV_CONN_PHPKTS, qc);
-       return ret;
-}
-
 /* Check if it's possible to remove header protection for packets related to
  * encryption level <qel>. If <qel> is NULL, assume it's false.
  *
index 5af2417d64f825e53fe3135f2e3dfdd54ace2025..d7f112d992d62f50621716b3467c7a63d8601180 100644 (file)
@@ -2,7 +2,6 @@
 #include <haproxy/ncbuf.h>
 #include <haproxy/proxy.h>
 #include <haproxy/quic_conn.h>
-#include <haproxy/quic_rx.h>
 #include <haproxy/quic_sock.h>
 #include <haproxy/quic_ssl.h>
 #include <haproxy/quic_tls.h>
@@ -501,10 +500,10 @@ static forceinline void qc_ssl_dump_errors(struct connection *conn)
  * Remaining parameter are there for debugging purposes.
  * Return 1 if succeeded, 0 if not.
  */
-int qc_ssl_provide_quic_data(struct ncbuf *ncbuf,
-                             enum ssl_encryption_level_t level,
-                             struct ssl_sock_ctx *ctx,
-                             const unsigned char *data, size_t len)
+static int qc_ssl_provide_quic_data(struct ncbuf *ncbuf,
+                                    enum ssl_encryption_level_t level,
+                                    struct ssl_sock_ctx *ctx,
+                                    const unsigned char *data, size_t len)
 {
 #ifdef DEBUG_STRICT
        enum ncb_ret ncb_ret;
@@ -666,6 +665,8 @@ int qc_ssl_provide_all_quic_data(struct quic_conn *qc, struct ssl_sock_ctx *ctx)
 {
        int ret = 0;
        struct quic_enc_level *qel;
+       struct ncbuf *ncbuf;
+       ncb_sz_t data;
 
        TRACE_ENTER(QUIC_EV_CONN_PHPKTS, qc);
        list_for_each_entry(qel, &qc->qel_list, list) {
@@ -674,8 +675,27 @@ int qc_ssl_provide_all_quic_data(struct quic_conn *qc, struct ssl_sock_ctx *ctx)
                if (!cstream)
                        continue;
 
-               if (!qc_treat_rx_crypto_frms(qc, qel, ctx))
-                       goto leave;
+               ncbuf = &cstream->rx.ncbuf;
+               if (ncb_is_null(ncbuf))
+                       continue;
+
+               /* TODO not working if buffer is wrapping */
+               while ((data = ncb_data(ncbuf, 0))) {
+                       const unsigned char *cdata = (const unsigned char *)ncb_head(ncbuf);
+
+                       if (!qc_ssl_provide_quic_data(&qel->cstream->rx.ncbuf, qel->level,
+                                                     ctx, cdata, data))
+                               goto leave;
+
+                       cstream->rx.offset += data;
+                       TRACE_DEVEL("buffered crypto data were provided to TLS stack",
+                                   QUIC_EV_CONN_PHPKTS, qc, qel);
+               }
+
+               if (!ncb_is_null(ncbuf) && ncb_is_empty(ncbuf)) {
+                       TRACE_DEVEL("freeing crypto buf", QUIC_EV_CONN_PHPKTS, qc, qel);
+                       quic_free_ncbuf(ncbuf);
+               }
        }
 
        ret = 1;