BUILD: quic: fix overflow in global tune
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 30 Jan 2025 17:01:53 +0000 (18:01 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 16 Apr 2025 08:47:51 +0000 (10:47 +0200)
A new global option was recently introduced to disable pacing. However,
the value used (1<<31) caused issue with some compiler as options field
used for storage is declared as int. Move pacing deactivation flag
outside into the newly defined quic_tune to fix this.

This should be backported up to 3.1 after a period of observation. Note
that it relied on the previous patch which defined new quic_tune type.

(cherry picked from commit b849ee5fa35b7a909869db1dfd19f450f3172034)
[ada: patch was manually adapted since a19d9b0486 ("MAJOR: quic: mark
 pacing as stable and enable it by default") was not backported]
Signed-off-by: Aurelien DARRAGON <adarragon@haproxy.com>

include/haproxy/global-t.h
include/haproxy/quic_tune-t.h
src/cfgparse-quic.c
src/cfgparse.c
src/haproxy.c
src/mux_quic.c

index be4fcc9..6d4a398 100644 (file)
@@ -87,7 +87,6 @@
 #define GTUNE_LISTENER_MQ_ANY    (GTUNE_LISTENER_MQ_FAIR | GTUNE_LISTENER_MQ_OPT)
 #define GTUNE_QUIC_CC_HYSTART    (1<<29)
 #define GTUNE_QUIC_NO_UDP_GSO    (1<<30)
-#define GTUNE_QUIC_NO_PACING     (1<<31)
 
 #define NO_ZERO_COPY_FWD             0x0001 /* Globally disable zero-copy FF */
 #define NO_ZERO_COPY_FWD_PT          0x0002 /* disable zero-copy FF for PT (recv & send are disabled automatically) */
index 37cd741..7d083c5 100644 (file)
@@ -6,6 +6,8 @@
 #error "Must define USE_OPENSSL"
 #endif
 
+#define QUIC_TUNE_NO_PACING     0x00000001
+
 struct quic_tune {
        uint options;
 };
index 92861cd..c74f242 100644 (file)
@@ -411,10 +411,10 @@ static int cfg_parse_quic_tune_on_off(char **args, int section_type, struct prox
                                          "'expose-experimental-directives'\n", args[0]);
                                return -1;
                        }
-                       global.tune.options &= ~GTUNE_QUIC_NO_PACING;
+                       quic_tune.options &= ~QUIC_TUNE_NO_PACING;
                }
                else
-                       global.tune.options |= GTUNE_QUIC_NO_PACING;
+                       quic_tune.options |= QUIC_TUNE_NO_PACING;
        }
 
        return 0;
index 47e5716..974634a 100644 (file)
@@ -72,6 +72,7 @@
 #include <haproxy/namespace.h>
 #include <haproxy/quic_cc-t.h>
 #include <haproxy/quic_sock.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/obj_type-t.h>
 #include <haproxy/openssl-compat.h>
 #include <haproxy/peers-t.h>
@@ -3096,7 +3097,7 @@ init_proxies_list_stage1:
                                  bind_conf->quic_cc_algo : default_quic_cc_algo;
 
                                if (!(cc_algo->flags & QUIC_CC_ALGO_FL_OPT_PACING) &&
-                                   global.tune.options & GTUNE_QUIC_NO_PACING) {
+                                   quic_tune.options & QUIC_TUNE_NO_PACING) {
                                        ha_warning("Binding [%s:%d] for %s %s: using the selected congestion algorithm without pacing may cause slowdowns or high loss rates during transfers.\n",
                                                   bind_conf->file, bind_conf->line,
                                                   proxy_type_str(curproxy), curproxy->id);
index e0aca47..1e08bb2 100644 (file)
 #include <haproxy/proto_sockpair.h>
 #include <haproxy/proto_tcp.h>
 #include <haproxy/proxy.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/regex.h>
 #include <haproxy/sample.h>
 #include <haproxy/server.h>
@@ -1395,7 +1396,7 @@ static void init_args(int argc, char **argv)
 #endif
 #ifdef USE_QUIC
        global.tune.options |= GTUNE_QUIC_SOCK_PER_CONN;
-       global.tune.options |= GTUNE_QUIC_NO_PACING;
+       quic_tune.options |= QUIC_TUNE_NO_PACING;
 #endif
        global.tune.options |= GTUNE_STRICT_LIMITS;
 
index e40c5c1..458da36 100644 (file)
@@ -23,6 +23,7 @@
 #include <haproxy/quic_sock.h>
 #include <haproxy/quic_stream.h>
 #include <haproxy/quic_tp-t.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/quic_tx.h>
 #include <haproxy/session.h>
 #include <haproxy/ssl_sock-t.h>
@@ -40,7 +41,7 @@ static void qmux_ctrl_room(struct qc_stream_desc *, uint64_t room);
 /* Returns true if pacing should be used for <conn> connection. */
 static int qcc_is_pacing_active(const struct connection *conn)
 {
-       return !(global.tune.options & GTUNE_QUIC_NO_PACING);
+       return !(quic_tune.options & QUIC_TUNE_NO_PACING);
 }
 
 static void qcs_free_ncbuf(struct qcs *qcs, struct ncbuf *ncbuf)