]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: implement MAX_DATA emission
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 16 May 2022 14:19:59 +0000 (16:19 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 May 2022 14:25:07 +0000 (16:25 +0200)
This commit is similar to the previous one but deals with MAX_DATA for
connection-level data flow control. It uses the same function
qcc_consume_qcs() to update flow control level and generate a MAX_DATA
frame if needed.

include/haproxy/mux_quic-t.h
src/mux_quic.c

index 7a9d09a01a018acfeb389993a81bfa03eabe09b4..12b66eb237e6301d866bb958ef0ddc2650dd660d 100644 (file)
@@ -56,6 +56,10 @@ struct qcc {
                uint64_t msd_bidi_l; /* initial max-stream-data on local streams */
                uint64_t msd_bidi_r; /* initial max-stream-data on remote streams */
                uint64_t cl_bidi_r; /* total count of closed remote bidi stream since last MAX_STREAMS emission */
+
+               uint64_t md; /* current max-data allowed for the peer */
+               uint64_t md_init; /* initial max-data */
+               uint64_t sent_offsets; /* sum of all offsets received */
        } lfctl;
 
        /* flow-control fields set by the peer which we must respect. */
index 2d34a7adf82604677d934078c1760fba668f8f16..68b2bd8a587ca1190ebd78226312dce1ddb0ffa7 100644 (file)
@@ -314,6 +314,21 @@ void qcs_consume(struct qcs *qcs, uint64_t bytes)
                LIST_APPEND(&qcc->lfctl.frms, &frm->list);
                tasklet_wakeup(qcc->wait_event.tasklet);
        }
+
+       qcc->lfctl.sent_offsets += bytes;
+       if (qcc->lfctl.md - qcc->lfctl.sent_offsets < qcc->lfctl.md_init / 2) {
+               frm = pool_zalloc(pool_head_quic_frame);
+               BUG_ON(!frm); /* TODO handle this properly */
+
+               qcc->lfctl.md = qcc->lfctl.sent_offsets + qcc->lfctl.md_init;
+
+               LIST_INIT(&frm->reflist);
+               frm->type = QUIC_FT_MAX_DATA;
+               frm->max_data.max_data = qcc->lfctl.md;
+
+               LIST_APPEND(&qcs->qcc->lfctl.frms, &frm->list);
+               tasklet_wakeup(qcs->qcc->wait_event.tasklet);
+       }
 }
 
 /* Retrieve as an ebtree node the stream with <id> as ID, possibly allocates
@@ -1249,6 +1264,9 @@ static int qc_init(struct connection *conn, struct proxy *prx,
        qcc->lfctl.msd_bidi_r = lparams->initial_max_stream_data_bidi_remote;
        qcc->lfctl.cl_bidi_r = 0;
 
+       qcc->lfctl.md = qcc->lfctl.md_init = lparams->initial_max_data;
+       qcc->lfctl.sent_offsets = 0;
+
        rparams = &conn->handle.qc->tx.params;
        qcc->rfctl.md = rparams->initial_max_data;
        qcc->rfctl.msd_bidi_l = rparams->initial_max_stream_data_bidi_local;