MINOR: quic: define quic_cc_algo as const

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.
This commit is contained in:
Amaury Denoyelle 2025-12-01 13:53:59 +01:00
parent acbb378136
commit 979588227f
10 changed files with 17 additions and 17 deletions

View 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

View file

@ -35,13 +35,13 @@
#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];
};

View 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;

View 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;

View file

@ -27,14 +27,14 @@
#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;

View 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,

View 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,

View 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,

View 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,

View 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);