]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: quic: fix zero value of tune.quic.sec.stateless-reset-rate
authorFrederic Lecaille <flecaille@haproxy.com>
Thu, 27 Aug 2026 13:59:41 +0000 (15:59 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 28 Aug 2026 15:41:46 +0000 (17:41 +0200)
quic_stateless_reset_rate_init() split <quic_tune.sec_stateless_reset_rate>
across threads as (rate + tid) / nbthread, which can round down to 0 when
<rate> is lower than <nbthread>. send_stateless_reset() reads a 0 value as
"no limit", so a low <rate> silently disabled rate limiting on some
threads instead of restricting it further.

Fix it by giving every thread the same value, rounded up so it can never
reach 0: (rate + nbthread - 1) / nbthread. Updated the doc accordingly.

This bug was introduced by commit 297321e3e ("MINOR: quic: add
tune.quic.sec.stateless-reset-rate"), only present in this dev branch,
so no backport is needed.

doc/configuration.txt
src/quic_tx.c

index ae5f44ccc93e8cc9c7a3599d43d39c537aa3565a..fa9b418f42a88665954c819ba0a65c8b0be77479 100644 (file)
@@ -5367,10 +5367,10 @@ tune.quic.mem.tx-max <size>
 
 tune.quic.sec.stateless-reset-rate <number>
   Sets the maximum total number of QUIC Stateless Reset packets emitted per
-  second, across all threads. Each thread gets its own even share of this
-  total, so the actual number sent per second may be slightly under or over
-  <number> depending on how evenly it divides by the thread count, but the
-  total across all threads never drifts from it over time.
+  second, across all threads. Each thread is given the same share of this
+  total, rounded up so that share always stays strictly positive. As a
+  result, when <number> does not divide evenly among the threads, the real
+  total emitted per second across all threads can be higher than <number>.
 
   The default value is 1000.
 
index 00193fd9b058a9333404ff2fa5b886b257d65786..43ce8fc57e861f6f1ee5a431c96721a5b8c68917 100644 (file)
@@ -2379,12 +2379,11 @@ REGISTER_UNITTEST("quic_tx", quic_tx_unittest);
 
 static int quic_stateless_reset_rate_init(void)
 {
-       /* split N across threads so the totals add up to exactly N: this
-        * thread gets (N + tid) / nbthread. No flat ceil() here, since that
-        * could push the total above N.
+       /* every thread gets the same share: (rate + nbthread - 1) / nbthread,
+        * which stays strictly positive for any rate >= 1.
         */
        quic_stateless_reset_rate =
-               (quic_tune.sec_stateless_reset_rate + tid) / global.nbthread;
+               (quic_tune.sec_stateless_reset_rate + global.nbthread - 1) / global.nbthread;
        return 1;
 }
 REGISTER_PER_THREAD_INIT(quic_stateless_reset_rate_init);