MINOR: quic: Move some counters from [rt]x quic_conn anonymous struct

Move rx.bytes, tx.bytes and tx.prep_bytes quic_conn struct member to
bytes anonymous struct (bytes.rx, bytes.tx and bytes.prep member respectively).
They are moved before being defined into a bytes anonoymous struct common to
a future struct to be defined.

Consequently adapt the code.
This commit is contained in:
Frédéric Lécaille 2023-08-04 17:02:25 +02:00
parent a45f90dd4e
commit f7ab5918d1
6 changed files with 18 additions and 16 deletions

View File

@ -510,18 +510,20 @@ struct quic_conn {
struct connection *conn;
struct {
/* Number of sent bytes. */
uint64_t bytes;
/* Number of bytes for prepared packets */
uint64_t prep_bytes;
uint64_t prep;
/* Number of sent bytes. */
uint64_t tx;
/* Number of received bytes. */
uint64_t rx;
} bytes;
struct {
/* Transport parameters sent by the peer */
struct quic_transport_params params;
/* Send buffer used to write datagrams. */
struct buffer buf;
} tx;
struct {
/* Number of received bytes. */
uint64_t bytes;
/* Transport parameters the peer will receive */
struct quic_transport_params params;
/* RX buffer */

View File

@ -474,7 +474,7 @@ static inline size_t quic_path_prep_data(struct quic_path *path)
*/
static inline size_t quic_may_send_bytes(struct quic_conn *qc)
{
return 3 * qc->rx.bytes - qc->tx.prep_bytes;
return 3 * qc->bytes.rx - qc->bytes.prep;
}
/* CRYPTO data buffer handling functions. */

View File

@ -149,7 +149,7 @@ int quic_peer_validated_addr(struct quic_conn *qc)
qc->state >= QUIC_HS_ST_COMPLETE)
return 1;
BUG_ON(qc->tx.prep_bytes > 3 * qc->rx.bytes);
BUG_ON(qc->bytes.prep > 3 * qc->bytes.rx);
return 0;
}
@ -1133,11 +1133,11 @@ struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4,
TLS_EXTENSION_QUIC_TRANSPORT_PARAMETERS_DRAFT:
TLS_EXTENSION_QUIC_TRANSPORT_PARAMETERS;
/* TX part. */
qc->tx.bytes = qc->tx.prep_bytes = 0;
qc->bytes.tx = qc->bytes.prep = 0;
memset(&qc->tx.params, 0, sizeof(qc->tx.params));
qc->tx.buf = BUF_NULL;
/* RX part. */
qc->rx.bytes = 0;
qc->bytes.rx = 0;
memset(&qc->rx.params, 0, sizeof(qc->rx.params));
qc->rx.buf = b_make(qc->rx.buf.area, QUIC_CONN_RX_BUFSZ, 0, 0);
for (i = 0; i < QCS_MAX_TYPES; i++)

View File

@ -2559,7 +2559,7 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
* if this datagram could be associated to a connection.
*/
if (dgram->qc)
dgram->qc->rx.bytes += dgram->len;
dgram->qc->bytes.rx += dgram->len;
/* This must never happen. */
BUG_ON(pos > end);

View File

@ -500,9 +500,9 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
(unsigned long)pkt->pn_node.key,
quic_pktns_char(qc, pkt->pktns),
(unsigned long long)pkt->in_flight_len);
chunk_appendf(&trace_buf, " rx.bytes=%llu tx.bytes=%llu",
(unsigned long long)qc->rx.bytes,
(unsigned long long)qc->tx.bytes);
chunk_appendf(&trace_buf, " bytes.rx=%llu bytes.tx=%llu",
(unsigned long long)qc->bytes.rx,
(unsigned long long)qc->bytes.tx);
list_for_each_entry(frm, &pkt->frms, list) {
chunk_appendf(&trace_buf, " frm@%p", frm);
chunk_frm_appendf(&trace_buf, frm);

View File

@ -626,7 +626,7 @@ int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
}
b_del(buf, dglen + headlen);
qc->tx.bytes += tmpbuf.data;
qc->bytes.tx += tmpbuf.data;
time_sent = now_ms;
for (pkt = first_pkt; pkt; pkt = next_pkt) {
@ -2477,8 +2477,8 @@ static struct quic_tx_packet *qc_build_pkt(unsigned char **pos,
/* Consume a packet number */
qel->pktns->tx.next_pn++;
qc->tx.prep_bytes += pkt->len;
if (qc->tx.prep_bytes >= 3 * qc->rx.bytes && !quic_peer_validated_addr(qc)) {
qc->bytes.prep += pkt->len;
if (qc->bytes.prep >= 3 * qc->bytes.rx && !quic_peer_validated_addr(qc)) {
qc->flags |= QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED;
TRACE_PROTO("anti-amplification limit reached", QUIC_EV_CONN_TXPKT, qc);
}