]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Move some counters from [rt]x quic_conn anonymous struct
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 4 Aug 2023 15:02:25 +0000 (17:02 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Mon, 7 Aug 2023 16:57:45 +0000 (18:57 +0200)
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.

include/haproxy/quic_conn-t.h
include/haproxy/quic_conn.h
src/quic_conn.c
src/quic_rx.c
src/quic_trace.c
src/quic_tx.c

index 491ec8bb5c501f6651082efcd1d2b5aed85f445b..eff1a0d184b6ecaf4197fb9715fd413bf6d6aaa3 100644 (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 */
index 0f4ab0bad3b31739f006bdf50913fc7956bca322..2f7b36982ad926ab1903630711178c0e2403d842 100644 (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. */
index 5a4fcfaf3189726dd47d3b1b42b34c1fad843bed..95f4f79b080446143932e71ec70c433a5e8f81a1 100644 (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++)
index 6d38e57545ed4056a97d5164aa165e2c5e39caf2..d28faa5a8dcde1ebc033de16ccd01f35da18f50a 100644 (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);
index c2b2e307dcb49d2e142c8f5e19e940dd61f6846f..372063ba1391ead0d9b836fbdd8fbe5e458f3598 100644 (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);
index 4f479596e3e27f3ec8743b995e5cfc6104b53215..09264860574211b0ab53a8bd53620ed8aa43f77b 100644 (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);
        }