]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Add max_idle_timeout advertisement handling
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 8 Mar 2022 13:08:16 +0000 (14:08 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 11 Mar 2022 10:37:30 +0000 (11:37 +0100)
When we store the remote transport parameters, we compute the maximum idle
timeout for the connection which is the minimum of the two advertised
max_idle_timeout transport parameter values if both have non-null values, or the
maximum if one of the value is set and non-null.

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

index 277143d9207ed34e56c0af22839f2272bde2a08d..37bfad4e85f140bb4ce26aa3ad39c900c91c059c 100644 (file)
@@ -742,6 +742,7 @@ struct quic_conn {
                struct quic_tls_kp nxt_tx;
        } ku;
        unsigned int max_ack_delay;
+       unsigned int max_idle_timeout;
        struct quic_path paths[1];
        struct quic_path *path;
 
index 48568e9a69f066e05e6182e8aabb9fb14a3bbd9a..1156912871f49fc564b4f8f0cbf1eff8bde7c139 100644 (file)
@@ -942,17 +942,30 @@ static inline int quic_transport_params_decode(struct quic_transport_params *p,
 /* Store transport parameters found in <buf> buffer into <conn> QUIC connection
  * depending on <server> value which must be 1 for a server (haproxy listener)
  * or 0 for a client (connection to a haproxy server).
+ * Note that peer transport parameters are stored in the TX part of the connection:
+ * they are used to send packets to the peer with its transport parameters as
+ * limitations.
  * Returns 1 if succeeded, 0 if not.
  */
 static inline int quic_transport_params_store(struct quic_conn *conn, int server,
                                               const unsigned char *buf,
                                               const unsigned char *end)
 {
-       if (!quic_transport_params_decode(&conn->tx.params, server, buf, end))
+       struct quic_transport_params *tx_params = &conn->tx.params;
+       struct quic_transport_params *rx_params = &conn->rx.params;
+
+       if (!quic_transport_params_decode(tx_params, server, buf, end))
                return 0;
 
-       if (conn->tx.params.max_ack_delay)
-               conn->max_ack_delay = conn->tx.params.max_ack_delay;
+       if (tx_params->max_ack_delay)
+               conn->max_ack_delay = tx_params->max_ack_delay;
+
+       if (tx_params->max_idle_timeout && rx_params->max_idle_timeout)
+               conn->max_idle_timeout =
+                       QUIC_MIN(tx_params->max_idle_timeout, rx_params->max_idle_timeout);
+       else
+               conn->max_idle_timeout =
+                       QUIC_MAX(tx_params->max_idle_timeout, rx_params->max_idle_timeout);
 
        return 1;
 }