Skip to content

Commit

Permalink
osd/OSDMap: OSDMap CRC inconsistence with incremental CRC
Browse files Browse the repository at this point in the history
OSDMap incremental update in OSD::handle_osd_map can trigger
CRC inconsistence given a cluster with big and little endian
nodes. The OSDMap CRC (o->get_crc()) is incorrect comparing
to the OSDMap::Incremental (inc.full_crc).
Fixed by using ceph_le16/32/64 instead of __u16/32/64.

Fixes: https://tracker.ceph.com/issues/54320

Signed-off-by: Aliaksei Makarau <aliaksei.makarau@ibm.com>
  • Loading branch information
aliakseimakarau committed Feb 20, 2022
1 parent bdf3eeb commit 8915317
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/msg/msg_types.h
Expand Up @@ -248,18 +248,22 @@ struct entity_addr_t {
}
};

__u32 type;
__u32 nonce;
ceph_le32 type;
ceph_le32 nonce;
union {
sockaddr sa;
sockaddr_in sin;
sockaddr_in6 sin6;
} u;

entity_addr_t() : type(0), nonce(0) {
entity_addr_t() {
type = 0;
nonce = 0;
memset(&u, 0, sizeof(u));
}
entity_addr_t(__u32 _type, __u32 _nonce) : type(_type), nonce(_nonce) {
entity_addr_t(__u32 _type, __u32 _nonce) {
type = init_le32(_type);
nonce = init_le32(_nonce);
memset(&u, 0, sizeof(u));
}
explicit entity_addr_t(const ceph_entity_addr &o) {
Expand All @@ -272,13 +276,13 @@ struct entity_addr_t {
}

uint32_t get_type() const { return type; }
void set_type(uint32_t t) { type = t; }
void set_type(uint32_t t) { type = init_le32(t); }
bool is_legacy() const { return type == TYPE_LEGACY; }
bool is_msgr2() const { return type == TYPE_MSGR2; }
bool is_any() const { return type == TYPE_ANY; }

__u32 get_nonce() const { return nonce; }
void set_nonce(__u32 n) { nonce = n; }
void set_nonce(__u32 n) { nonce = init_le32(n); }

int get_family() const {
return u.sa.sa_family;
Expand Down

0 comments on commit 8915317

Please sign in to comment.