BUG/MINOR: stktable: fix big-endian compatiblity in smp_to_stkey()
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 9 Jan 2025 08:05:43 +0000 (09:05 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Jan 2025 10:30:44 +0000 (11:30 +0100)
commit8eaf5b681ccd3f11ff2651a5b92671444b55cde2
tree6b851780f9433f18d0ca602d42e9ba1ce000f4e6
parent8abed46c7d7be29bce71b3db8dbc28a0d64c900b
BUG/MINOR: stktable: fix big-endian compatiblity in smp_to_stkey()

When smp_to_stkey() deals with SINT samples, since stick-tables deals with
32 bits integers while SINT sample is 64 bit integer, inplace conversion
was done in smp_to_stkey. For that the 64 bit integer was truncated before
the key would point to it. Unfortunately this only works on little endian
architectures because with big endian ones, the key would point to the
wrong 32bit range.

To fix the issue and make the conversion endian-proof, let's re-assign
the sample as 32bit integer before the key points to it.

Thanks to Willy for having spotted the bug and suggesting the above fix.

It should be backported to all stable versions.

(cherry picked from commit b59d1fd911045c37b3fc88795a1f2c1947e6e59d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 422e38bd828d1cddf55fe923ec7ebd269583d8ec)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/stick_table.c