From: Amaury Denoyelle Date: Wed, 21 May 2025 10:03:47 +0000 (+0200) Subject: CLEANUP: quic: remove unused cbuf module X-Git-Tag: v3.2-dev17~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf45bf1ad87687b6f6eb47c7e36e3d2779abfc0f;p=thirdparty%2Fhaproxy.git CLEANUP: quic: remove unused cbuf module Cbuf are not used anymore. Remove the related source and header files, as well as include statements in the rest of QUIC source files. --- diff --git a/Makefile b/Makefile index d1893e54d..1959ac479 100644 --- a/Makefile +++ b/Makefile @@ -660,7 +660,7 @@ OPTIONS_OBJS += src/mux_quic.o src/h3.o src/quic_rx.o src/quic_tx.o \ src/quic_cc_nocc.o src/quic_cc.o src/quic_pacing.o \ src/h3_stats.o src/quic_stats.o src/qpack-enc.o \ src/qpack-tbl.o src/quic_cc_drs.o src/quic_fctl.o \ - src/cbuf.o src/quic_enc.o + src/quic_enc.o endif ifneq ($(USE_QUIC_OPENSSL_COMPAT:0=),) diff --git a/include/haproxy/cbuf-t.h b/include/haproxy/cbuf-t.h deleted file mode 100644 index fee97c380..000000000 --- a/include/haproxy/cbuf-t.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * include/haprox/cbuf-t.h - * This file contains definition for circular buffers. - * - * Copyright 2021 HAProxy Technologies, Frederic Lecaille - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, version 2.1 - * exclusively. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _HAPROXY_CBUF_T_H -#define _HAPROXY_CBUF_T_H -#ifdef USE_QUIC -#ifndef USE_OPENSSL -#error "Must define USE_OPENSSL" -#endif -#endif - -#include -#include - -extern struct pool_head *pool_head_cbuf; - -struct cbuf { - /* buffer */ - unsigned char *buf; - /* buffer size */ - size_t sz; - /* Writer index */ - size_t wr; - /* Reader index */ - size_t rd; -}; - -#endif /* _HAPROXY_CBUF_T_H */ diff --git a/include/haproxy/cbuf.h b/include/haproxy/cbuf.h deleted file mode 100644 index b217a5c2d..000000000 --- a/include/haproxy/cbuf.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * include/haprox/cbuf.h - * This file contains definitions and prototypes for circular buffers. - * Inspired from Linux circular buffers (include/linux/circ_buf.h). - * - * Copyright 2021 HAProxy Technologies, Frederic Lecaille - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, version 2.1 - * exclusively. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _HAPROXY_CBUF_H -#define _HAPROXY_CBUF_H -#ifdef USE_QUIC -#ifndef USE_OPENSSL -#error "Must define USE_OPENSSL" -#endif -#endif - -#include -#include -#include - -struct cbuf *cbuf_new(unsigned char *buf, size_t sz); -void cbuf_free(struct cbuf *cbuf); - -/* Amount of data between and */ -#define CBUF_DATA(wr, rd, size) (((wr) - (rd)) & ((size) - 1)) - -/* Return the writer position in . - * To be used only by the writer! - */ -static inline unsigned char *cb_wr(struct cbuf *cbuf) -{ - return cbuf->buf + cbuf->wr; -} - -/* Reset the reader index. - * To be used by a reader! - */ -static inline void cb_rd_reset(struct cbuf *cbuf) -{ - cbuf->rd = 0; -} - -/* Reset the writer index. - * To be used by a writer! - */ -static inline void cb_wr_reset(struct cbuf *cbuf) -{ - cbuf->wr = 0; -} - -/* Increase circular buffer data by . - * To be used by a writer! - */ -static inline void cb_add(struct cbuf *cbuf, size_t count) -{ - cbuf->wr = (cbuf->wr + count) & (cbuf->sz - 1); -} - -/* Return the reader position in . - * To be used only by the reader! - */ -static inline unsigned char *cb_rd(struct cbuf *cbuf) -{ - return cbuf->buf + cbuf->rd; -} - -/* Skip byte in circular buffer. - * To be used by a reader! - */ -static inline void cb_del(struct cbuf *cbuf, size_t count) -{ - cbuf->rd = (cbuf->rd + count) & (cbuf->sz - 1); -} - -/* Return the amount of data left in . - * To be used only by the writer! - */ -static inline size_t cb_data(struct cbuf *cbuf) -{ - size_t rd; - - rd = HA_ATOMIC_LOAD(&cbuf->rd); - return CBUF_DATA(cbuf->wr, rd, cbuf->sz); -} - -/* Return the amount of room left in minus 1 to distinguish - * the case where the buffer is full from the case where is is empty - * To be used only by the write! - */ -static inline size_t cb_room(struct cbuf *cbuf) -{ - size_t rd; - - rd = HA_ATOMIC_LOAD(&cbuf->rd); - return CBUF_DATA(rd, cbuf->wr + 1, cbuf->sz); -} - -/* Return the amount of contiguous data left in . - * To be used only by the reader! - */ -static inline size_t cb_contig_data(struct cbuf *cbuf) -{ - size_t end, n; - - end = cbuf->sz - cbuf->rd; - n = (HA_ATOMIC_LOAD(&cbuf->wr) + end) & (cbuf->sz - 1); - return n < end ? n : end; -} - -/* Return the amount of contiguous space left in . - * To be used only by the writer! - */ -static inline size_t cb_contig_space(struct cbuf *cbuf) -{ - size_t end, n; - - end = cbuf->sz - 1 - cbuf->wr; - n = (HA_ATOMIC_LOAD(&cbuf->rd) + end) & (cbuf->sz - 1); - return n <= end ? n : end + 1; -} - -#endif /* _HAPROXY_CBUF_H */ diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index a3737c8ef..a060eca60 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -28,7 +28,6 @@ #include -#include #include #include diff --git a/src/cbuf.c b/src/cbuf.c deleted file mode 100644 index b36bbebd6..000000000 --- a/src/cbuf.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Circular buffer management - * - * Copyright 2021 HAProxy Technologies, Frederic Lecaille - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, version 2.1 - * exclusively. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include - -DECLARE_POOL(pool_head_cbuf, "cbuf", sizeof(struct cbuf)); - -/* Allocate and return a new circular buffer with as byte internal buffer - * if succeeded, NULL if not. - */ -struct cbuf *cbuf_new(unsigned char *buf, size_t sz) -{ - struct cbuf *cbuf; - - cbuf = pool_alloc(pool_head_cbuf); - if (cbuf) { - cbuf->sz = sz; - cbuf->buf = buf; - cbuf->wr = 0; - cbuf->rd = 0; - } - - return cbuf; -} - -/* Free QUIC ring */ -void cbuf_free(struct cbuf *cbuf) -{ - if (!cbuf) - return; - - pool_free(pool_head_cbuf, cbuf); -} - -/* - * Local variables: - * c-indent-level: 8 - * c-basic-offset: 8 - * End: - */ diff --git a/src/proto_quic.c b/src/proto_quic.c index 7dfe5fd32..c68cf33c2 100644 --- a/src/proto_quic.c +++ b/src/proto_quic.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include diff --git a/src/quic_conn.c b/src/quic_conn.c index bed8ac102..79fe36c76 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include