11#include <import/eb64tree.h>
22
3+ #include <haproxy/quic_cc-t.h>
34#include <haproxy/quic_conn-t.h>
45#include <haproxy/quic_loss.h>
56#include <haproxy/quic_tls.h>
@@ -151,7 +152,7 @@ struct quic_pktns *quic_pto_pktns(struct quic_conn *qc,
151152 * Always succeeds.
152153 */
153154void qc_packet_loss_lookup (struct quic_pktns * pktns , struct quic_conn * qc ,
154- struct list * lost_pkts )
155+ struct list * lost_pkts , uint32_t * bytes_lost )
155156{
156157 struct eb_root * pkts ;
157158 struct eb64_node * node ;
@@ -213,8 +214,14 @@ void qc_packet_loss_lookup(struct quic_pktns *pktns, struct quic_conn *qc,
213214 ql -> nb_reordered_pkt ++ ;
214215
215216 if (tick_is_le (loss_time_limit , now_ms ) || reordered ) {
217+ struct quic_cc * cc = & qc -> path -> cc ;
218+
219+ if (cc -> algo -> on_pkt_lost )
220+ cc -> algo -> on_pkt_lost (cc , pkt , pkt -> rs .lost );
216221 eb64_delete (& pkt -> pn_node );
217222 LIST_APPEND (lost_pkts , & pkt -> list );
223+ if (bytes_lost )
224+ * bytes_lost += pkt -> len ;
218225 ql -> nb_lost_pkt ++ ;
219226 }
220227 else {
@@ -239,7 +246,8 @@ void qc_packet_loss_lookup(struct quic_pktns *pktns, struct quic_conn *qc,
239246 * CONNECTION_CLOSE was prepared to close the connection ASAP.
240247 */
241248int qc_release_lost_pkts (struct quic_conn * qc , struct quic_pktns * pktns ,
242- struct list * pkts , uint64_t now_us )
249+ struct list * pkts , uint64_t now_us ,
250+ uint32_t * largest_pkt_sent_ts )
243251{
244252 struct quic_tx_packet * pkt , * tmp , * oldest_lost , * newest_lost ;
245253 uint tot_lost = 0 ;
@@ -276,14 +284,20 @@ int qc_release_lost_pkts(struct quic_conn *qc, struct quic_pktns *pktns,
276284
277285 if (!close ) {
278286 if (newest_lost ) {
287+ struct quic_cc * cc = & qc -> path -> cc ;
279288 /* Sent a congestion event to the controller */
280289 struct quic_cc_event ev = { };
281290
282291 ev .type = QUIC_CC_EVT_LOSS ;
283292 ev .loss .time_sent = newest_lost -> time_sent ;
284293 ev .loss .count = tot_lost ;
285294
286- quic_cc_event (& qc -> path -> cc , & ev );
295+ quic_cc_event (cc , & ev );
296+ if (cc -> algo -> congestion_event ) {
297+ if (largest_pkt_sent_ts )
298+ * largest_pkt_sent_ts = newest_lost -> time_sent ;
299+ cc -> algo -> congestion_event (cc , newest_lost -> time_sent );
300+ }
287301 }
288302
289303 /* If an RTT have been already sampled, <rtt_min> has been set.
@@ -295,7 +309,8 @@ int qc_release_lost_pkts(struct quic_conn *qc, struct quic_pktns *pktns,
295309 unsigned int period = newest_lost -> time_sent - oldest_lost -> time_sent ;
296310
297311 if (quic_loss_persistent_congestion (& qc -> path -> loss , period ,
298- now_ms , qc -> max_ack_delay ))
312+ now_ms , qc -> max_ack_delay ) &&
313+ qc -> path -> cc .algo -> slow_start )
299314 qc -> path -> cc .algo -> slow_start (& qc -> path -> cc );
300315 }
301316 }
0 commit comments