]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: quic: Wrong connection ID to thread ID association
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 7 Sep 2022 13:06:52 +0000 (15:06 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Wed, 7 Sep 2022 13:59:43 +0000 (15:59 +0200)
commit3122c75fd1f9a73a13ec533a4f313be0af1c5348
tree84070d2ddbdc4a4d891a775b99d5b271d0d70d5e
parent614742b79c63626cf477b4a85779db41223adbf9
BUG/MINOR: quic: Wrong connection ID to thread ID association

To work, quic_pin_cid_to_tid() must set cid[0] to a value with <target_id>
as <global.nbthread> modulo. For each integer n, (n - (n % m)) + d has always
d as modulo m (with d < m).

So, this statement seemed correct:

     cid[0] = cid[0] - (cid[0] % global.nbthread) + target_tid;

except when n wraps or when another modulo is applied to the addition result.
Here, for 8bit modulo arithmetic, if m does not divides 256, this cannot
works for values which wraps when we increment them by d.
For instance n=255 m=3 and d=1 the formula result is 0 (should be d).

To fix this, we first limit c[0] to 255 - <target_id> to prevent c[0] from wrapping.

Thank you to @esb for having reported this issue in GH #1855.

Must be backported to 2.6
include/haproxy/xprt_quic.h