Skip to content

Commit 2fb47f9

Browse files
committed
MINOR: quic: RX part modifications to support BBR
qc_notify_cc_of_newly_acked_pkts() aim is to notify the congestion algorithm of all the packet acknowledgements. It must call quic_cc_drs_update_rate_sample() to update the delivery rate sampling information. It must also call quic_cc_drs_on_ack_recv() to update the state of the delivery rate sampling part used by BBR. Finally, ->on_ack_rcvd() is called with the total number of bytes delivered by the sender from the newly acknowledged packets with <bytes_delivered> as parameter to do so. <pkt_delivered> store the per-packet number of bytes delivered by the newly sent acknowledged packet (the packet with the highest packet number). <bytes_lost> is also used and has been set by qc_packet_loss_lookup() before calling qc_notify_cc_of_newly_acked_pkts().
1 parent 5466fd7 commit 2fb47f9

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/quic_rx.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <haproxy/ncbuf.h>
2020
#include <haproxy/proto_quic.h>
2121
#include <haproxy/quic_ack.h>
22+
#include <haproxy/quic_cc_drs.h>
2223
#include <haproxy/quic_cid.h>
2324
#include <haproxy/quic_retransmit.h>
2425
#include <haproxy/quic_retry.h>
@@ -421,33 +422,52 @@ int qc_handle_frms_of_lost_pkt(struct quic_conn *qc,
421422
* Always succeeds.
422423
*/
423424
static void qc_notify_cc_of_newly_acked_pkts(struct quic_conn *qc,
424-
struct list *newly_acked_pkts)
425+
struct list *newly_acked_pkts,
426+
unsigned int bytes_lost,
427+
unsigned int rtt)
425428
{
426429
struct quic_tx_packet *pkt, *tmp;
427430
struct quic_cc_event ev = { .type = QUIC_CC_EVT_ACK, };
431+
struct quic_cc_path *p = qc->path;
432+
struct quic_cc_drs *drs =
433+
p->cc.algo->get_drs ? p->cc.algo->get_drs(&p->cc) : NULL;
434+
unsigned int bytes_delivered = 0, pkt_delivered = 0;
428435

429436
TRACE_ENTER(QUIC_EV_CONN_PRSAFRM, qc);
430437

431438
list_for_each_entry_safe(pkt, tmp, newly_acked_pkts, list) {
432439
pkt->pktns->tx.in_flight -= pkt->in_flight_len;
433-
qc->path->prep_in_flight -= pkt->in_flight_len;
434-
qc->path->in_flight -= pkt->in_flight_len;
440+
p->prep_in_flight -= pkt->in_flight_len;
441+
p->in_flight -= pkt->in_flight_len;
435442
if (pkt->flags & QUIC_FL_TX_PACKET_ACK_ELICITING)
436-
qc->path->ifae_pkts--;
443+
p->ifae_pkts--;
437444
/* If this packet contained an ACK frame, proceed to the
438445
* acknowledging of range of acks from the largest acknowledged
439446
* packet number which was sent in an ACK frame by this packet.
440447
*/
441448
if (pkt->largest_acked_pn != -1)
442449
qc_treat_ack_of_ack(qc, &pkt->pktns->rx.arngs, pkt->largest_acked_pn);
450+
bytes_delivered += pkt->len;
451+
pkt_delivered = pkt->rs.delivered;
443452
ev.ack.acked = pkt->in_flight_len;
444453
ev.ack.time_sent = pkt->time_sent;
445454
ev.ack.pn = pkt->pn_node.key;
446-
quic_cc_event(&qc->path->cc, &ev);
455+
/* Note that this event is not emitted for BBR. */
456+
quic_cc_event(&p->cc, &ev);
457+
if (drs && (pkt->flags & QUIC_FL_TX_PACKET_ACK_ELICITING))
458+
quic_cc_drs_update_rate_sample(drs, pkt);
447459
LIST_DEL_INIT(&pkt->list);
448460
quic_tx_packet_refdec(pkt);
449461
}
450462

463+
if (drs) {
464+
quic_cc_drs_on_ack_recv(drs, p, pkt_delivered);
465+
drs->lost += bytes_lost;
466+
}
467+
if (p->cc.algo->on_ack_rcvd)
468+
p->cc.algo->on_ack_rcvd(&p->cc, bytes_delivered, pkt_delivered,
469+
rtt, bytes_lost, now_ms);
470+
451471
TRACE_LEAVE(QUIC_EV_CONN_PRSAFRM, qc);
452472

453473
}
@@ -551,6 +571,8 @@ static int qc_parse_ack_frm(struct quic_conn *qc,
551571
} while (1);
552572

553573
if (!LIST_ISEMPTY(&newly_acked_pkts)) {
574+
unsigned int bytes_lost = 0;
575+
554576
if (!qc_handle_newly_acked_pkts(qc, &pkt_flags, &newly_acked_pkts))
555577
goto leave;
556578

@@ -560,11 +582,13 @@ static int qc_parse_ack_frm(struct quic_conn *qc,
560582
}
561583

562584
if (!eb_is_empty(&qel->pktns->tx.pkts)) {
563-
qc_packet_loss_lookup(qel->pktns, qc, &lost_pkts);
585+
qc_packet_loss_lookup(qel->pktns, qc, &lost_pkts, &bytes_lost);
564586
if (!qc_release_lost_pkts(qc, qel->pktns, &lost_pkts, now_ms))
565587
goto leave;
566588
}
567-
qc_notify_cc_of_newly_acked_pkts(qc, &newly_acked_pkts);
589+
590+
qc_notify_cc_of_newly_acked_pkts(qc, &newly_acked_pkts,
591+
bytes_lost, *rtt_sample);
568592
if (quic_peer_validated_addr(qc))
569593
qc->path->loss.pto_count = 0;
570594
qc_set_timer(qc);

0 commit comments

Comments
 (0)