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>
@@ -422,33 +423,53 @@ int qc_handle_frms_of_lost_pkt(struct quic_conn *qc,
422423 * Always succeeds.
423424 */
424425static void qc_notify_cc_of_newly_acked_pkts (struct quic_conn * qc ,
425- struct list * newly_acked_pkts )
426+ struct list * newly_acked_pkts ,
427+ unsigned int bytes_lost ,
428+ unsigned int rtt ,
429+ unsigned int largest_pkt_sent_ts )
426430{
427431 struct quic_tx_packet * pkt , * tmp ;
428432 struct quic_cc_event ev = { .type = QUIC_CC_EVT_ACK , };
433+ struct quic_cc_path * p = qc -> path ;
434+ struct quic_cc_drs * drs =
435+ p -> cc .algo -> get_drs ? p -> cc .algo -> get_drs (& p -> cc ) : NULL ;
436+ unsigned int bytes_delivered = 0 , pkt_delivered = 0 ;
429437
430438 TRACE_ENTER (QUIC_EV_CONN_PRSAFRM , qc );
431439
432440 list_for_each_entry_safe (pkt , tmp , newly_acked_pkts , list ) {
433441 pkt -> pktns -> tx .in_flight -= pkt -> in_flight_len ;
434- qc -> path -> prep_in_flight -= pkt -> in_flight_len ;
435- qc -> path -> in_flight -= pkt -> in_flight_len ;
442+ p -> prep_in_flight -= pkt -> in_flight_len ;
443+ p -> in_flight -= pkt -> in_flight_len ;
436444 if (pkt -> flags & QUIC_FL_TX_PACKET_ACK_ELICITING )
437- qc -> path -> ifae_pkts -- ;
445+ p -> ifae_pkts -- ;
438446 /* If this packet contained an ACK frame, proceed to the
439447 * acknowledging of range of acks from the largest acknowledged
440448 * packet number which was sent in an ACK frame by this packet.
441449 */
442450 if (pkt -> largest_acked_pn != -1 )
443451 qc_treat_ack_of_ack (qc , & pkt -> pktns -> rx .arngs , pkt -> largest_acked_pn );
452+ bytes_delivered += pkt -> len ;
453+ pkt_delivered = pkt -> rs .delivered ;
444454 ev .ack .acked = pkt -> in_flight_len ;
445455 ev .ack .time_sent = pkt -> time_sent ;
446456 ev .ack .pn = pkt -> pn_node .key ;
447- quic_cc_event (& qc -> path -> cc , & ev );
457+ /* Note that this event is not emitted for BBR. */
458+ quic_cc_event (& p -> cc , & ev );
459+ if (drs && (pkt -> flags & QUIC_FL_TX_PACKET_ACK_ELICITING ))
460+ quic_cc_drs_update_rate_sample (drs , pkt );
448461 LIST_DEL_INIT (& pkt -> list );
449462 quic_tx_packet_refdec (pkt );
450463 }
451464
465+ if (drs ) {
466+ quic_cc_drs_on_ack_recv (drs , p , pkt_delivered );
467+ drs -> lost += bytes_lost ;
468+ }
469+ if (p -> cc .algo -> on_ack_rcvd )
470+ p -> cc .algo -> on_ack_rcvd (& p -> cc , bytes_delivered , pkt_delivered ,
471+ rtt , bytes_lost , now_ms );
472+
452473 TRACE_LEAVE (QUIC_EV_CONN_PRSAFRM , qc );
453474
454475}
@@ -552,6 +573,9 @@ static int qc_parse_ack_frm(struct quic_conn *qc,
552573 } while (1 );
553574
554575 if (!LIST_ISEMPTY (& newly_acked_pkts )) {
576+ unsigned int bytes_lost = 0 ;
577+ uint32_t largest_pkt_sent_ts = TICK_ETERNITY ;
578+
555579 if (!qc_handle_newly_acked_pkts (qc , & pkt_flags , & newly_acked_pkts ))
556580 goto leave ;
557581
@@ -561,11 +585,14 @@ static int qc_parse_ack_frm(struct quic_conn *qc,
561585 }
562586
563587 if (!eb_is_empty (& qel -> pktns -> tx .pkts )) {
564- qc_packet_loss_lookup (qel -> pktns , qc , & lost_pkts );
565- if (!qc_release_lost_pkts (qc , qel -> pktns , & lost_pkts , now_ms ))
588+ qc_packet_loss_lookup (qel -> pktns , qc , & lost_pkts , & bytes_lost );
589+ if (!qc_release_lost_pkts (qc , qel -> pktns , & lost_pkts ,
590+ now_ms , & largest_pkt_sent_ts ))
566591 goto leave ;
567592 }
568- qc_notify_cc_of_newly_acked_pkts (qc , & newly_acked_pkts );
593+
594+ qc_notify_cc_of_newly_acked_pkts (qc , & newly_acked_pkts ,
595+ bytes_lost , * rtt_sample , largest_pkt_sent_ts );
569596 if (quic_peer_validated_addr (qc ))
570597 qc -> path -> loss .pto_count = 0 ;
571598 qc_set_timer (qc );
0 commit comments