From: Frédéric Lécaille Date: Tue, 28 Nov 2023 08:09:36 +0000 (+0100) Subject: REORG: quic: Move ncbuf related function from quic_rx to quic_conn X-Git-Tag: v2.9-dev12~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43fbea0f3847a1aab6e3a498fc3e9e7598e2c369;p=thirdparty%2Fhaproxy.git REORG: quic: Move ncbuf related function from quic_rx to quic_conn Move quic_get_ncbuf() and quic_free_ncbuf() from quic_rx.c to quic_conn.h as static inlined functions. --- diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h index 2f2d446591..1cd17d7665 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -30,9 +30,9 @@ #include #include -#include #include -#include +#include +#include #include #include #include @@ -130,6 +130,38 @@ static inline void quic_conn_mv_cids_to_cc_conn(struct quic_conn_closed *cc_conn } +/* Allocate the underlying required memory for non-contiguous buffer */ +static inline struct ncbuf *quic_get_ncbuf(struct ncbuf *ncbuf) +{ + struct buffer buf = BUF_NULL; + + if (!ncb_is_null(ncbuf)) + return ncbuf; + + b_alloc(&buf); + BUG_ON(b_is_null(&buf)); + + *ncbuf = ncb_make(buf.area, buf.size, 0); + ncb_init(ncbuf, 0); + + return ncbuf; +} + +/* Release the underlying memory use by non-contiguous buffer */ +static inline void quic_free_ncbuf(struct ncbuf *ncbuf) +{ + struct buffer buf; + + if (ncb_is_null(ncbuf)) + return; + + buf = b_make(ncbuf->area, ncbuf->size, 0, 0); + b_free(&buf); + offer_buffers(NULL, 1); + + *ncbuf = NCBUF_NULL; +} + void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm); void quic_set_connection_close(struct quic_conn *qc, const struct quic_err err); void quic_set_tls_alert(struct quic_conn *qc, int alert); diff --git a/include/haproxy/quic_rx.h b/include/haproxy/quic_rx.h index dd2d6289c7..494bc4a2d5 100644 --- a/include/haproxy/quic_rx.h +++ b/include/haproxy/quic_rx.h @@ -30,7 +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); -void quic_free_ncbuf(struct ncbuf *ncbuf); 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, diff --git a/src/quic_rx.c b/src/quic_rx.c index e49e6dc952..0c313446c3 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -674,38 +674,6 @@ static int qc_handle_strm_frm(struct quic_rx_packet *pkt, return !ret; } -/* Release the underlying memory use by non-contiguous buffer */ -void quic_free_ncbuf(struct ncbuf *ncbuf) -{ - struct buffer buf; - - if (ncb_is_null(ncbuf)) - return; - - buf = b_make(ncbuf->area, ncbuf->size, 0, 0); - b_free(&buf); - offer_buffers(NULL, 1); - - *ncbuf = NCBUF_NULL; -} - -/* Allocate the underlying required memory for non-contiguous buffer */ -static struct ncbuf *quic_get_ncbuf(struct ncbuf *ncbuf) -{ - struct buffer buf = BUF_NULL; - - if (!ncb_is_null(ncbuf)) - return ncbuf; - - b_alloc(&buf); - BUG_ON(b_is_null(&buf)); - - *ncbuf = ncb_make(buf.area, buf.size, 0); - ncb_init(ncbuf, 0); - - return ncbuf; -} - /* Parse CRYPTO frame coming with packet at connectionn. * Returns 1 if succeeded, 0 if not. Also set <*fast_retrans> to 1 if the * speed up handshake completion may be run after having received duplicated