]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: define quic_cc_algo as const
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 1 Dec 2025 12:53:59 +0000 (13:53 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 1 Dec 2025 14:05:41 +0000 (15:05 +0100)
Each QUIC congestion algorithm is defined as a structure with callbacks
in it. Every quic_conn has a member pointing to the configured
algorithm, inherited from the bind-conf keyword or to the default CUBIC
value.

Convert all these definitions to const. This ensures that there never
will be an accidental modification of a globally shared structure. This
also requires to mark quic_cc_algo field in bind_conf and quic_cc as
const.

include/haproxy/listener-t.h
include/haproxy/quic_cc-t.h
include/haproxy/quic_cc.h
src/cfgparse-quic.c
src/quic_cc.c
src/quic_cc_bbr.c
src/quic_cc_cubic.c
src/quic_cc_newreno.c
src/quic_cc_nocc.c
src/quic_conn.c

index ce189736d8fdc2e23155f81aca89720b3cfb6779..c8f1e214b3a72619a7ea2d68364f3aee3bff1e0b 100644 (file)
@@ -186,7 +186,7 @@ struct bind_conf {
 #endif
 #ifdef USE_QUIC
        struct quic_transport_params quic_params; /* QUIC transport parameters. */
-       struct quic_cc_algo *quic_cc_algo; /* QUIC control congestion algorithm */
+       const struct quic_cc_algo *quic_cc_algo; /* QUIC control congestion algorithm */
        size_t max_cwnd;                   /* QUIC maximumu congestion control window size (kB) */
        enum quic_sock_mode quic_mode;     /* QUIC socket allocation strategy */
 #endif
index c3a7e0bc025d468177196f2025fb425db72d758c..90c693a48d2f49de8ff54e6494e4a024d9d080ef 100644 (file)
 
 #define QUIC_CC_INFINITE_SSTHESH ((uint32_t)-1)
 
-extern struct quic_cc_algo quic_cc_algo_nr;
-extern struct quic_cc_algo quic_cc_algo_cubic;
-extern struct quic_cc_algo quic_cc_algo_bbr;
-extern struct quic_cc_algo *default_quic_cc_algo;
+extern const struct quic_cc_algo quic_cc_algo_nr;
+extern const struct quic_cc_algo quic_cc_algo_cubic;
+extern const struct quic_cc_algo quic_cc_algo_bbr;
+extern const struct quic_cc_algo *default_quic_cc_algo;
 
 /* Fake algorithm with its fixed window */
-extern struct quic_cc_algo quic_cc_algo_nocc;
+extern const struct quic_cc_algo quic_cc_algo_nocc;
 
 extern unsigned long long last_ts;
 
@@ -90,7 +90,7 @@ enum quic_cc_algo_type {
 struct quic_cc {
        /* <conn> is there only for debugging purpose. */
        struct quic_conn *qc;
-       struct quic_cc_algo *algo;
+       const struct quic_cc_algo *algo;
        uint32_t priv[144];
 };
 
index 4360a5af0038e0a2748f507aacb4a3f0422864b0..661d12f4cbe4a1608777b1ae10880ee3f8c5f6ad 100644 (file)
@@ -35,7 +35,7 @@
 #include <haproxy/quic_loss.h>
 #include <haproxy/thread.h>
 
-void quic_cc_init(struct quic_cc *cc, struct quic_cc_algo *algo, struct quic_conn *qc);
+void quic_cc_init(struct quic_cc *cc, const struct quic_cc_algo *algo, struct quic_conn *qc);
 void quic_cc_event(struct quic_cc *cc, struct quic_cc_event *ev);
 void quic_cc_state_trace(struct buffer *buf, const struct quic_cc *cc);
 
@@ -83,7 +83,7 @@ static inline void *quic_cc_priv(const struct quic_cc *cc)
  * which is true for an IPv4 path, if not false for an IPv6 path.
  */
 static inline void quic_cc_path_init(struct quic_cc_path *path, int ipv4, unsigned long max_cwnd,
-                                     struct quic_cc_algo *algo,
+                                     const struct quic_cc_algo *algo,
                                      struct quic_conn *qc)
 {
        unsigned int max_dgram_sz;
index 334d71eb70bd126eed7ad98f689b9d7ef4efbd58..7d097ab753a3a006e20d5d7dca7faf03ac52e82c 100644 (file)
@@ -101,7 +101,7 @@ static unsigned long parse_window_size(const char *kw, char *value,
 static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
                                    struct bind_conf *conf, char **err)
 {
-       struct quic_cc_algo *cc_algo;
+       const struct quic_cc_algo *cc_algo;
        const char *algo = NULL;
        struct ist algo_ist, arg_ist;
        char *arg;
index 98ef0a7549b5b37abccd96ec0b275b685760ae38..c866af16451ba05fe0511e4da4dd4488897f08c1 100644 (file)
 #include <haproxy/quic_tune.h>
 #include <haproxy/thread.h>
 
-struct quic_cc_algo *default_quic_cc_algo = &quic_cc_algo_cubic;
+const struct quic_cc_algo *default_quic_cc_algo = &quic_cc_algo_cubic;
 
 /*
  * Initialize <cc> congestion control with <algo> as algorithm depending on <ipv4>
  * a boolean which is true for an IPv4 path.
  */
 void quic_cc_init(struct quic_cc *cc,
-                  struct quic_cc_algo *algo, struct quic_conn *qc)
+                  const struct quic_cc_algo *algo, struct quic_conn *qc)
 {
        cc->qc = qc;
        cc->algo = algo;
index e36b61c97d771171f5325d02e80f398cbadb2c8c..bb8a5f06d5e4241d772b1b8edc58c03aed0edcbb 100644 (file)
@@ -1531,7 +1531,7 @@ static void bbr_state_cli(struct buffer *buf, const struct quic_cc_path *p)
                      (ull)bbr->bw, (ull)p->send_quantum, (ull)bbr->pacing_rate);
 }
 
-struct quic_cc_algo quic_cc_algo_bbr = {
+const struct quic_cc_algo quic_cc_algo_bbr = {
        .type        = QUIC_CC_ALGO_TP_BBR,
        .init        = bbr_init,
        .pacing_inter = bbr_pacing_inter,
index bae7605c6fd893af2100580b4d174afb9cb3afe2..a1cc4800257e23eaef0617acd60956eb6f7cc6a4 100644 (file)
@@ -667,7 +667,7 @@ static void quic_cc_cubic_state_cli(struct buffer *buf, const struct quic_cc_pat
                      (long long)(path->cwnd - c->last_w_max));
 }
 
-struct quic_cc_algo quic_cc_algo_cubic = {
+const struct quic_cc_algo quic_cc_algo_cubic = {
        .type        = QUIC_CC_ALGO_TP_CUBIC,
        .flags       = QUIC_CC_ALGO_FL_OPT_PACING,
        .init        = quic_cc_cubic_init,
index c6a5a360a56e224c7855da1e8f6e165efdb8d5c3..e0a5e3790defd67b54847556952795b2751c4083 100644 (file)
@@ -210,7 +210,7 @@ static void quic_cc_nr_event(struct quic_cc *cc, struct quic_cc_event *ev)
        return quic_cc_nr_state_cbs[nr->state](cc, ev);
 }
 
-struct quic_cc_algo quic_cc_algo_nr = {
+const struct quic_cc_algo quic_cc_algo_nr = {
        .type        = QUIC_CC_ALGO_TP_NEWRENO,
        .flags       = QUIC_CC_ALGO_FL_OPT_PACING,
        .init        = quic_cc_nr_init,
index 81f0a5ef0f06b4584a068a0dc60ec72df8337eef..83bbdfc2e28892880df0bf97638e088784b688be 100644 (file)
@@ -67,7 +67,7 @@ static void quic_cc_nocc_event(struct quic_cc *cc, struct quic_cc_event *ev)
        return quic_cc_nocc_state_cbs[QUIC_CC_ST_SS](cc, ev);
 }
 
-struct quic_cc_algo quic_cc_algo_nocc = {
+const struct quic_cc_algo quic_cc_algo_nocc = {
        .type        = QUIC_CC_ALGO_TP_NOCC,
        .flags       = QUIC_CC_ALGO_FL_OPT_PACING,
        .init        = quic_cc_nocc_init,
index f13f474d06fd52b51a58c423b01e635c8f358d75..08fde6795db22ac3e762a6f8e1b4f12687c6b7f3 100644 (file)
@@ -1132,7 +1132,7 @@ struct quic_conn *qc_new_conn(void *target,
        struct listener *l = objt_listener(target);
        struct server *srv = objt_server(target);
        struct proxy *prx = l ? l->bind_conf->frontend : __objt_server(target)->proxy;
-       struct quic_cc_algo *cc_algo = NULL;
+       const struct quic_cc_algo *cc_algo = NULL;
        unsigned int next_actconn = 0, next_sslconn = 0, next_handshake = 0;
 
        TRACE_ENTER(QUIC_EV_CONN_INIT);