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:17:47 +0000 (11:17 +0100)
commit422e38bd828d1cddf55fe923ec7ebd269583d8ec
tree227dd65e0cf622f65efbbdc480721558adc80d1e
parentcda631a79580841b7daaca209eb904e9a254dbd6
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>
src/stick_table.c