From: Frédéric Lécaille Date: Thu, 28 Jan 2021 15:22:52 +0000 (+0100) Subject: MINOR: quic: Move transport parmaters to anynomous struct. X-Git-Tag: v2.5-dev8~155 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5aa4143d6c97c059d61c76b47648bb6f24910b5e;p=thirdparty%2Fhaproxy.git 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). --- diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h index 2b89e4a8a7..ed994659fe 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 423419e289..c2471cc881 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 6c1f2d04c5..f349932f5f 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 1c8e9de851..851d2f467b 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;