MINOR: quic: Add max_idle_timeout advertisement handling
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.
diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h
index 277143d..37bfad4 100644
--- a/include/haproxy/xprt_quic-t.h
+++ b/include/haproxy/xprt_quic-t.h
@@ -742,6 +742,7 @@
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;
diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h
index 48568e9..1156912 100644
--- a/include/haproxy/xprt_quic.h
+++ b/include/haproxy/xprt_quic.h
@@ -942,17 +942,30 @@
/* 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;
}