If we decode a zeroed sockaddr, we should end up with a TYPE_NONE
entity_addr_t, not v1::/0.
This was obscured by unit test TestAddrvecEncodeAddrDecode3, which
took an addrvec with all v2 addrs, decoded to an addr variable that
previously had v1:1.2.3.4:/0, and asserted the result was not v1::/0.
The test passed before because the set_sockaddr() failed on AF_UNSPEC
and the addr kept v1:1.2.3.4, but with the previous commit it failed
because it equaled v1::/0. In reality, addr should get - (addr TYPE_NONE).
The TestEmptyAddrvecEncodeAddrDecode test case is similarly adjusted.
Signed-off-by: Sage Weil <sage@redhat.com>
__u16 rest;
decode(marker, bl);
decode(rest, bl);
- type = TYPE_LEGACY;
decode(nonce, bl);
sockaddr_storage ss;
decode(ss, bl);
set_sockaddr((sockaddr*)&ss);
+ if (get_family() == AF_UNSPEC) {
+ type = TYPE_NONE;
+ } else {
+ type = TYPE_LEGACY;
+ }
}
// Right now, these only deal with sockaddr_storage that have only family and content.
addrvec.encode(bl, 0);
auto bli = bl.cbegin();
addr.decode(bli);
- ASSERT_EQ(addr, entity_addr_t(1, 0));
+ ASSERT_EQ(addr, entity_addr_t());
}
const char *addrvec_checks[][4] = {
auto bli = bl.cbegin();
addr.decode(bli);
+ //cout << addrvec << " (legacy " << addrvec.legacy_addr()
+ //<< ") -> " << addr << std::endl;
ASSERT_NE(addr, addrvec.v[0]); // it's not the first addr(which is non-legacy)
- ASSERT_NE(addr, entity_addr_t(1, 0)); // it's not a blank addr either
+ ASSERT_EQ(addr, entity_addr_t()); // it's not a blank addr either
}
const char *addrvec_parse_checks[][3] = {