From 5aa4143d6c97c059d61c76b47648bb6f24910b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Thu, 28 Jan 2021 16:22:52 +0100 Subject: [PATCH] MINOR: quic: Move transport parmaters to anynomous struct. We move ->params transport parameters to ->rx.params. They are the transport parameters which will be sent to the peer, and used for the endpoint flow control. So, they will be used to received packets from the peer (RX part). Also move ->rx_tps transport parameters to ->tx.params. They are the transport parameter which are sent by the peer, and used to respect its flow control limits. So, they will be used when sending packets to the peer (TX part). --- include/haproxy/xprt_quic-t.h | 9 ++++----- include/haproxy/xprt_quic.h | 8 ++++---- src/quic_sock.c | 8 ++++---- src/xprt_quic.c | 8 ++++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h index 2b89e4a8a..ed994659f 100644 --- a/include/haproxy/xprt_quic-t.h +++ b/include/haproxy/xprt_quic-t.h @@ -571,8 +571,6 @@ struct quic_path { struct quic_conn { uint32_t version; - /* Transport parameters. */ - struct quic_transport_params params; unsigned char enc_params[QUIC_TP_MAX_ENCLEN]; /* encoded QUIC transport parameters */ size_t enc_params_len; @@ -589,9 +587,6 @@ struct quic_conn { struct eb_root cids; struct quic_enc_level els[QUIC_TLS_ENC_LEVEL_MAX]; - - struct quic_transport_params rx_tps; - struct quic_pktns pktns[QUIC_TLS_PKTNS_MAX]; /* Used only to reach the tasklet for the I/O handler from this quic_conn object. */ @@ -620,10 +615,14 @@ struct quic_conn { * when sending probe packets. */ int nb_pto_dgrams; + /* Transport parameters sent by the peer */ + struct quic_transport_params params; } tx; struct { /* Number of received bytes. */ uint64_t bytes; + /* Transport parameters the peer will receive */ + struct quic_transport_params params; } rx; unsigned int max_ack_delay; struct quic_path paths[1]; diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index 423419e28..c2471cc88 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -499,7 +499,7 @@ static inline void quic_packet_number_encode(unsigned char **buf, static inline unsigned int quic_ack_delay_ms(struct quic_ack *ack_frm, struct quic_conn *conn) { - return ack_frm->ack_delay << conn->rx_tps.ack_delay_exponent; + return ack_frm->ack_delay << conn->tx.params.ack_delay_exponent; } /* Initialize transport parameters from . @@ -958,11 +958,11 @@ 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->rx_tps, server, buf, end)) + if (!quic_transport_params_decode(&conn->tx.params, server, buf, end)) return 0; - if (conn->rx_tps.max_ack_delay) - conn->max_ack_delay = conn->rx_tps.max_ack_delay; + if (conn->tx.params.max_ack_delay) + conn->max_ack_delay = conn->tx.params.max_ack_delay; return 1; } diff --git a/src/quic_sock.c b/src/quic_sock.c index 6c1f2d04c..f349932f5 100644 --- a/src/quic_sock.c +++ b/src/quic_sock.c @@ -161,18 +161,18 @@ struct connection *quic_sock_accept_conn(struct listener *l, int *status) pkt->scid.data, pkt->scid.len)) goto err; - odcid = &qc->params.original_destination_connection_id; + odcid = &qc->rx.params.original_destination_connection_id; /* Copy the transport parameters. */ - qc->params = l->bind_conf->quic_params; + qc->rx.params = l->bind_conf->quic_params; /* Copy original_destination_connection_id transport parameter. */ memcpy(odcid->data, &pkt->dcid, pkt->odcid_len); odcid->len = pkt->odcid_len; /* Copy the initial source connection ID. */ - quic_cid_cpy(&qc->params.initial_source_connection_id, &qc->scid); + quic_cid_cpy(&qc->rx.params.initial_source_connection_id, &qc->scid); qc->enc_params_len = quic_transport_params_encode(qc->enc_params, qc->enc_params + sizeof qc->enc_params, - &qc->params, 1); + &qc->rx.params, 1); if (!qc->enc_params_len) goto err; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 1c8e9de85..851d2f467 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -1881,7 +1881,7 @@ static int quic_build_post_handshake_frames(struct quic_conn *conn) LIST_APPEND(&conn->tx.frms_to_send, &frm->list); } - for (i = 1; i < conn->rx_tps.active_connection_id_limit; i++) { + for (i = 1; i < conn->tx.params.active_connection_id_limit; i++) { struct quic_connection_id *cid; frm = pool_alloc(pool_head_quic_frame); @@ -4115,13 +4115,13 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx) &ctx->ssl, &ctx->bio, ha_quic_meth, ctx) == -1) goto err; - quic_conn->params = srv->quic_params; + quic_conn->rx.params = srv->quic_params; /* Copy the initial source connection ID. */ - quic_cid_cpy(&quic_conn->params.initial_source_connection_id, &quic_conn->scid); + quic_cid_cpy(&quic_conn->rx.params.initial_source_connection_id, &quic_conn->scid); quic_conn->enc_params_len = quic_transport_params_encode(quic_conn->enc_params, quic_conn->enc_params + sizeof quic_conn->enc_params, - &quic_conn->params, 0); + &quic_conn->rx.params, 0); if (!quic_conn->enc_params_len) goto err;