]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: underflow issue for bbr_inflight_hi_from_lost_packet()
authorFrederic Lecaille <flecaille@haproxy.com>
Thu, 12 Dec 2024 11:04:14 +0000 (12:04 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 13 Dec 2024 13:42:43 +0000 (14:42 +0100)
Add a test to ensure that values of a local variable used by
bbr_inflight_hi_from_lost_packet() is not be impacted by underflow issues
when subtracting too big numbers and make this function return a correct value.

Must be backported to 3.1.

src/quic_cc_bbr.c

index b08c4b5397a698e58d54ac3df0fb97f311b96807..fb5c23e757e319397dde38d3eaef66c58261b8a9 100644 (file)
@@ -1334,9 +1334,13 @@ static uint64_t bbr_inflight_hi_from_lost_packet(struct quic_cc_rs *rs,
        BUG_ON(rs->lost < size);
        /* What was lost before this packet? */
        lost_prev = rs->lost - size;
+       if (BBR_LOSS_THRESH_MULT * inflight_prev < lost_prev * BBR_LOSS_THRESH_DIVI)
+               return inflight_prev;
+
        lost_prefix =
                (BBR_LOSS_THRESH_MULT * inflight_prev - lost_prev * BBR_LOSS_THRESH_DIVI) /
                (BBR_LOSS_THRESH_DIVI - BBR_LOSS_THRESH_MULT);
+       /* At what inflight value did losses cross BBRLossThresh? */
        return inflight_prev + lost_prefix;
 }