]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: move global tune options into quic_tune
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 17 Mar 2025 14:15:55 +0000 (15:15 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 24 Mar 2025 09:01:46 +0000 (10:01 +0100)
A new structure quic_tune has recently been defined. Its purpose is to
store global options related to QUIC. Previously, only the tunable to
toggle pacing was stored in it.

This commit moves several QUIC related tunable from global to quic_tune
structure. This better centralizes QUIC configuration option and gives
room for future generic options.

include/haproxy/global-t.h
include/haproxy/quic_tune-t.h
src/cfgparse-quic.c
src/haproxy.c
src/proto_quic.c
src/quic_cc_cubic.c
src/quic_conn.c
src/quic_tx.c

index 40b5a65b798a49d5a6fdb3138da002e5900eb70c..922277695cb93925bf81c90bf643725991345880 100644 (file)
 #define GTUNE_DISABLE_H2_WEBSOCKET (1<<21)
 #define GTUNE_DISABLE_ACTIVE_CLOSE (1<<22)
 #define GTUNE_QUICK_EXIT         (1<<23)
-#define GTUNE_QUIC_SOCK_PER_CONN (1<<24)
+/* (1<<24) unused */
 #define GTUNE_NO_QUIC            (1<<25)
 #define GTUNE_USE_FAST_FWD       (1<<26)
 #define GTUNE_LISTENER_MQ_FAIR   (1<<27)
 #define GTUNE_LISTENER_MQ_OPT    (1<<28)
 #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)
 
 /* subsystem-specific debugging options for tune.debug */
 #define GDBG_CPU_AFFINITY           (1U<< 0)
index 7d083c5899d791747037a0a6a8385aaaa4a9f88b..04bd38b660c50f31829e932363a5d8264a6703a3 100644 (file)
@@ -7,6 +7,9 @@
 #endif
 
 #define QUIC_TUNE_NO_PACING     0x00000001
+#define QUIC_TUNE_NO_UDP_GSO    0x00000002
+#define QUIC_TUNE_SOCK_PER_CONN 0x00000004
+#define QUIC_TUNE_CC_HYSTART    0x00000008
 
 struct quic_tune {
        uint options;
index a1621967c96578c64da72f1f56c860622aba5409..b2551d8b6330950478e9d9ffdc8a1ca2b37784e0 100644 (file)
@@ -212,10 +212,10 @@ static int cfg_parse_quic_tune_socket_owner(char **args, int section_type,
                return -1;
 
        if (strcmp(args[1], "connection") == 0) {
-               global.tune.options |= GTUNE_QUIC_SOCK_PER_CONN;
+               quic_tune.options |= QUIC_TUNE_SOCK_PER_CONN;
        }
        else if (strcmp(args[1], "listener") == 0) {
-               global.tune.options &= ~GTUNE_QUIC_SOCK_PER_CONN;
+               quic_tune.options &= ~QUIC_TUNE_SOCK_PER_CONN;
        }
        else {
                memprintf(err, "'%s' expects either 'listener' or 'connection' but got '%s'.", args[0], args[1]);
@@ -357,7 +357,7 @@ static int cfg_parse_quic_tune_setting0(char **args, int section_type,
                quic_tune.options |= QUIC_TUNE_NO_PACING;
        }
        else if (strcmp(suffix, "disable-udp-gso") == 0) {
-               global.tune.options |= GTUNE_QUIC_NO_UDP_GSO;
+               quic_tune.options |= QUIC_TUNE_NO_UDP_GSO;
        }
        else {
                memprintf(err, "'%s' keyword unhandled (please report this bug).", args[0]);
@@ -397,9 +397,9 @@ static int cfg_parse_quic_tune_on_off(char **args, int section_type, struct prox
        }
        else if (strcmp(suffix, "cc-hystart") == 0) {
                if (on)
-                       global.tune.options |= GTUNE_QUIC_CC_HYSTART;
+                       quic_tune.options |= QUIC_TUNE_CC_HYSTART;
                else
-                       global.tune.options &= ~GTUNE_QUIC_CC_HYSTART;
+                       quic_tune.options &= ~QUIC_TUNE_CC_HYSTART;
        }
 
        return 0;
index dd02a096aa8ee3b7718f3c6b5f479b86030c237b..1a718281105aa35d894afe8ead5ecffb4414ac1e 100644 (file)
 #include <haproxy/openssl-compat.h>
 #include <haproxy/quic_conn.h>
 #include <haproxy/quic_tp-t.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/pattern.h>
 #include <haproxy/peers.h>
 #include <haproxy/pool.h>
@@ -1435,9 +1436,6 @@ static void init_args(int argc, char **argv)
 #endif
 #ifdef USE_THREAD
        global.tune.options |= GTUNE_IDLE_POOL_SHARED;
-#endif
-#ifdef USE_QUIC
-       global.tune.options |= GTUNE_QUIC_SOCK_PER_CONN;
 #endif
        global.tune.options |= GTUNE_STRICT_LIMITS;
 
@@ -1446,6 +1444,10 @@ static void init_args(int argc, char **argv)
        /* Use zero-copy forwarding by default */
        global.tune.no_zero_copy_fwd = 0;
 
+#ifdef USE_QUIC
+       quic_tune.options |= QUIC_TUNE_SOCK_PER_CONN;
+#endif
+
        /* keep a copy of original arguments for the master process */
        old_argv = copy_argv(argc, argv);
        if (!old_argv) {
index 7790571de89f46dde8ac8cdd619c13f4a292ee3e..26b2fda99c9d88a97715e5462c622e5b9c5dd422 100644 (file)
@@ -44,6 +44,7 @@
 #include <haproxy/proxy-t.h>
 #include <haproxy/quic_conn.h>
 #include <haproxy/quic_sock.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/sock.h>
 #include <haproxy/sock_inet.h>
 #include <haproxy/task.h>
@@ -802,7 +803,7 @@ static int quic_test_socketopts(void)
        int ret;
 
        /* Check for connection socket-owner mode support. */
-       if (global.tune.options & GTUNE_QUIC_SOCK_PER_CONN) {
+       if (quic_tune.options & QUIC_TUNE_SOCK_PER_CONN) {
                ret = quic_test_conn_socket_owner();
                if (ret < 0) {
                        goto err;
@@ -810,12 +811,12 @@ static int quic_test_socketopts(void)
                else if (!ret) {
                        ha_diag_warning("Your platform does not seem to support UDP source address retrieval through IP_PKTINFO or an alternative flag. "
                                        "QUIC connections will use listener socket.\n");
-                       global.tune.options &= ~GTUNE_QUIC_SOCK_PER_CONN;
+                       quic_tune.options &= ~QUIC_TUNE_SOCK_PER_CONN;
                }
        }
 
        /* Check for UDP GSO support. */
-       if (!(global.tune.options & GTUNE_QUIC_NO_UDP_GSO)) {
+       if (!(quic_tune.options & QUIC_TUNE_NO_UDP_GSO)) {
                ret = quic_test_gso();
                if (ret < 0) {
                        goto err;
@@ -823,7 +824,7 @@ static int quic_test_socketopts(void)
                else if (!ret) {
                        ha_diag_warning("Your platform does not support UDP GSO. "
                                        "This will be automatically disabled for QUIC transfer.\n");
-                       global.tune.options |= GTUNE_QUIC_NO_UDP_GSO;
+                       quic_tune.options |= QUIC_TUNE_NO_UDP_GSO;
                }
        }
 
index 8d7b8543428460d0552e71c8c9562eeba30c679d..96d91efa77c426990ad909b7417a59a79e6873cf 100644 (file)
@@ -2,6 +2,7 @@
 #include <haproxy/quic_cc.h>
 #include <haproxy/quic_cc_hystart.h>
 #include <haproxy/quic_trace.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/ticks.h>
 #include <haproxy/trace.h>
 
@@ -102,7 +103,7 @@ static void quic_cc_cubic_reset(struct quic_cc *cc)
        c->last_w_max = 0;
        c->W_est = 0;
        c->recovery_start_time = 0;
-       if (global.tune.options & GTUNE_QUIC_CC_HYSTART)
+       if (quic_tune.options & QUIC_TUNE_CC_HYSTART)
                quic_cc_hystart_reset(&c->hystart);
        TRACE_LEAVE(QUIC_EV_CONN_CC, cc->qc);
 }
@@ -448,7 +449,7 @@ static void quic_cc_cubic_ss_cb(struct quic_cc *cc, struct quic_cc_event *ev)
        TRACE_PROTO("CC cubic", QUIC_EV_CONN_CC, cc->qc, ev);
        switch (ev->type) {
        case QUIC_CC_EVT_ACK:
-               if (global.tune.options & GTUNE_QUIC_CC_HYSTART) {
+               if (quic_tune.options & QUIC_TUNE_CC_HYSTART) {
                        struct quic_hystart *h = &c->hystart;
                        unsigned int acked = QUIC_MIN(ev->ack.acked, (uint64_t)HYSTART_LIMIT * path->mtu);
 
index d135afc60dfe33762b564b1c1b27155672f99559..77f28a4f284cbfead0644a83616666d24eadcd64 100644 (file)
@@ -60,6 +60,7 @@
 #include <haproxy/quic_token.h>
 #include <haproxy/quic_tp.h>
 #include <haproxy/quic_trace.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/quic_tx.h>
 #include <haproxy/cbuf.h>
 #include <haproxy/proto_quic.h>
@@ -1174,7 +1175,7 @@ struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4,
        conn_id->qc = qc;
 
        if (HA_ATOMIC_LOAD(&l->rx.quic_mode) == QUIC_SOCK_MODE_CONN &&
-           (global.tune.options & GTUNE_QUIC_SOCK_PER_CONN) &&
+           (quic_tune.options & QUIC_TUNE_SOCK_PER_CONN) &&
            is_addr(local_addr)) {
                TRACE_USER("Allocate a socket for QUIC connection", QUIC_EV_CONN_INIT, qc);
                qc_alloc_fd(qc, local_addr, peer_addr);
index 1ac8b0d92ecabe74204066c4b7840bd81956ee44..06f851b4d60e8ef336ae66eb5c50730e844b0639 100644 (file)
@@ -28,6 +28,7 @@
 #include <haproxy/quic_stream.h>
 #include <haproxy/quic_tls.h>
 #include <haproxy/quic_trace.h>
+#include <haproxy/quic_tune.h>
 #include <haproxy/ssl_sock-t.h>
 
 DECLARE_POOL(pool_head_quic_tx_packet, "quic_tx_packet", sizeof(struct quic_tx_packet));
@@ -427,7 +428,7 @@ static int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
                        }
                        qc->path->in_flight += pkt->in_flight_len;
                        pkt->pktns->tx.in_flight += pkt->in_flight_len;
-                       if ((global.tune.options & GTUNE_QUIC_CC_HYSTART) && pkt->pktns == qc->apktns)
+                       if ((quic_tune.options & QUIC_TUNE_CC_HYSTART) && pkt->pktns == qc->apktns)
                                cc->algo->hystart_start_round(cc, pkt->pn_node.key);
                        if (pkt->in_flight_len)
                                qc_set_timer(qc);
@@ -763,7 +764,7 @@ static int qc_prep_pkts(struct quic_conn *qc, struct buffer *buf,
                                /* Everything sent. Continue within the same datagram. */
                                prv_pkt = cur_pkt;
                        }
-                       else if (!(global.tune.options & GTUNE_QUIC_NO_UDP_GSO) &&
+                       else if (!(quic_tune.options & QUIC_TUNE_NO_UDP_GSO) &&
                                 !(HA_ATOMIC_LOAD(&qc->li->flags) & LI_F_UDP_GSO_NOTSUPP) &&
                                 dglen == qc->path->mtu &&
                                 (char *)end < b_wrap(buf) &&