]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Missing active_connection_id_limit default value
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 3 Sep 2021 14:42:19 +0000 (16:42 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Sep 2021 13:27:25 +0000 (15:27 +0200)
The peer transport parameter values were not initialized with
the default ones (when absent), especially the
"active_connection_id_limit" parameter with 2 as default value
when absent from received remote transport parameters. This
had as side effect to send too much NEW_CONNECTION_ID frames.
This was the case for curl which does not announce any
"active_connection_id_limit" parameter.
Also rename ->idle_timeout to ->max_idle_timeout to reflect the RFC9000.

include/haproxy/xprt_quic-t.h
include/haproxy/xprt_quic.h
src/xprt_quic.c

index b06245554d3bdb83820d8fd9e5e0a6844c8e40e2..df0125e908ce2d270819d177821fe31ce496be21 100644 (file)
@@ -263,14 +263,15 @@ struct preferred_address {
        uint8_t stateless_reset_token[QUIC_STATELESS_RESET_TOKEN_LEN];
 };
 
-/* Default values for some of transport parameters */
+/* Default values for the absent transport parameters */
 #define QUIC_DFLT_MAX_UDP_PAYLOAD_SIZE   65527 /* bytes */
 #define QUIC_DFLT_ACK_DELAY_COMPONENT        3 /* milliseconds */
 #define QUIC_DFLT_MAX_ACK_DELAY             25 /* milliseconds */
+#define QUIC_ACTIVE_CONNECTION_ID_LIMIT      2 /* number of connections */
 
 /* Types of QUIC transport parameters */
 #define QUIC_TP_ORIGINAL_DESTINATION_CONNECTION_ID   0
-#define QUIC_TP_IDLE_TIMEOUT                         1
+#define QUIC_TP_MAX_IDLE_TIMEOUT                     1
 #define QUIC_TP_STATELESS_RESET_TOKEN                2
 #define QUIC_TP_MAX_UDP_PAYLOAD_SIZE                 3
 #define QUIC_TP_INITIAL_MAX_DATA                     4
@@ -300,7 +301,7 @@ struct preferred_address {
  * Note that forbidden parameters sent by clients MUST generate TRANSPORT_PARAMETER_ERROR errors.
  */
 struct quic_transport_params {
-       uint64_t idle_timeout;
+       uint64_t max_idle_timeout;
        uint64_t max_udp_payload_size;                 /* Default: 65527 bytes (max of UDP payload for IPv6) */
        uint64_t initial_max_data;
        uint64_t initial_max_stream_data_bidi_local;
index 1158d0de55c0e684f130fa65910511a05fb8f1aa..bcb1d9553ae882eb868084326e474530f9e2c249 100644 (file)
@@ -423,7 +423,8 @@ static inline unsigned int quic_ack_delay_ms(struct quic_ack *ack_frm,
        return ack_frm->ack_delay << conn->tx.params.ack_delay_exponent;
 }
 
-/* Initialize <dst> transport parameters from <quic_dflt_trasports_parame>.
+/* Initialize <dst> transport parameters with default values (when absent)
+ * from <quic_dflt_trasports_params>.
  * Never fails.
  */
 static inline void quic_dflt_transport_params_cpy(struct quic_transport_params *dst)
@@ -431,6 +432,7 @@ static inline void quic_dflt_transport_params_cpy(struct quic_transport_params *
        dst->max_udp_payload_size = quic_dflt_transport_params.max_udp_payload_size;
        dst->ack_delay_exponent   = quic_dflt_transport_params.ack_delay_exponent;
        dst->max_ack_delay        = quic_dflt_transport_params.max_ack_delay;
+       dst->active_connection_id_limit = quic_dflt_transport_params.active_connection_id_limit;
 }
 
 /* Initialize <p> transport parameters depending <server> boolean value which
@@ -441,9 +443,10 @@ static inline void quic_dflt_transport_params_cpy(struct quic_transport_params *
 static inline void quic_transport_params_init(struct quic_transport_params *p,
                                               int server)
 {
+       /* Default values (when absent) */
        quic_dflt_transport_params_cpy(p);
 
-       p->idle_timeout                        = 30000;
+       p->max_idle_timeout                    = 30000;
 
        p->initial_max_data                    = 1 * 1024 * 1024;
        p->initial_max_stream_data_bidi_local  = 256 * 1024;
@@ -549,6 +552,7 @@ static inline int quic_transport_param_decode(struct quic_transport_params *p,
 {
        const unsigned char *end = *buf + len;
 
+       quic_dflt_transport_params_cpy(p);
        switch (type) {
        case QUIC_TP_ORIGINAL_DESTINATION_CONNECTION_ID:
                if (!server || len >= sizeof p->original_destination_connection_id.data)
@@ -584,8 +588,8 @@ static inline int quic_transport_param_decode(struct quic_transport_params *p,
                        return 0;
                p->with_preferred_address = 1;
                break;
-       case QUIC_TP_IDLE_TIMEOUT:
-               if (!quic_dec_int(&p->idle_timeout, buf, end))
+       case QUIC_TP_MAX_IDLE_TIMEOUT:
+               if (!quic_dec_int(&p->max_idle_timeout, buf, end))
                        return 0;
                break;
        case QUIC_TP_MAX_UDP_PAYLOAD_SIZE:
@@ -762,8 +766,8 @@ static inline int quic_transport_params_encode(unsigned char *buf,
                                          p->initial_source_connection_id.len))
                return 0;
 
-       if (p->idle_timeout &&
-           !quic_transport_param_enc_int(&pos, end, QUIC_TP_IDLE_TIMEOUT, p->idle_timeout))
+       if (p->max_idle_timeout &&
+           !quic_transport_param_enc_int(&pos, end, QUIC_TP_MAX_IDLE_TIMEOUT, p->max_idle_timeout))
                return 0;
 
        /*
@@ -825,6 +829,7 @@ static inline int quic_transport_params_encode(unsigned char *buf,
                return 0;
 
        if (p->active_connection_id_limit &&
+           p->active_connection_id_limit != QUIC_ACTIVE_CONNECTION_ID_LIMIT &&
            !quic_transport_param_enc_int(&pos, end, QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT,
                                          p->active_connection_id_limit))
            return 0;
index cfe43b1a538fe2561014b27539dc938afe7743a6..0fdd45d9ccdb00a6c98b21e44ab77afea1e88dbb 100644 (file)
 #include <haproxy/trace.h>
 #include <haproxy/xprt_quic.h>
 
+/* This is the values of some QUIC transport parameters when absent.
+ * Should be used to initialize any transport parameters (local or remote)
+ * before updating them with customized values.
+ */
 struct quic_transport_params quic_dflt_transport_params = {
        .max_udp_payload_size = QUIC_DFLT_MAX_UDP_PAYLOAD_SIZE,
        .ack_delay_exponent   = QUIC_DFLT_ACK_DELAY_COMPONENT,
        .max_ack_delay        = QUIC_DFLT_MAX_ACK_DELAY,
+       .active_connection_id_limit = QUIC_ACTIVE_CONNECTION_ID_LIMIT,
 };
 
 /* trace source and events */