]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
include/encoding: Fix encode/decode of float types on big-endian systems 37032/head
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 4 Sep 2020 13:42:41 +0000 (15:42 +0200)
committerNathan Cutler <ncutler@suse.com>
Mon, 7 Sep 2020 20:21:41 +0000 (22:21 +0200)
commit178be2a87345ccf395c8256f8c4946b12d32ec7b
treee47191ee2992679cb0881bb0eae30e81889e0951
parent65d8836383deeacfc8343f8d6563548a4c44c835
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>
(cherry picked from commit f1f8b9f93b8c64a17c430a66e73e1e47a58781c7)
src/include/encoding.h