]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
include/encoding: Fix encode/decode of float types on big-endian systems 36992/head
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 4 Sep 2020 13:42:41 +0000 (15:42 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Sun, 6 Sep 2020 11:28:07 +0000 (13:28 +0200)
commitf1f8b9f93b8c64a17c430a66e73e1e47a58781c7
tree15ddf611f59a6fea60444abeab0bc5aa78f7cd76
parente7f960f2d5e5b7f47ce753021130023e7293275a
include/encoding: Fix encode/decode of float types on big-endian systems

Currently, floating-point types use "raw" encoding, which means they're
simply copied as byte stream.

This means that if the decoding happens on a machine that differs in
byte order from the source machine, the returned value will be
incorrect. As one effect of this problem, a big-endian OSD node cannot
join a cluster where the MON node is little-endian (or vice versa),
because the OSDMap (incremental) structure contains floating-point
values, and as a result of this conversion problem, the OSD node will
crash with an assertion failure as soon as it receives any OSDMap update
from the MON.

This should be fixed by always encoding floating-point values in
little-endian byte order just as is done for integers. (Note that this
still assumes source and target machines used the same floating-point
format except for byte order. But given that nearly all platforms these
days use IEEE binary32/binary64 for float/double, that seems a
reasonable assumption.)

Fixes: https://tracker.ceph.com/issues/47302
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/include/encoding.h