Only set type ANY if we are a pure client; otherwise, preserve the
type. Also, only populate the addr if we have a blank ip (sometimes
we already know it from learn_addr_unknowns).
Signed-off-by: Sage Weil <sage@redhat.com>
// fix all addrs of the same family, regardless of type (msgr2 vs legacy)
entity_addrvec_t newaddrs = *my_addrs;
for (auto& a : newaddrs.v) {
- if (a.get_family() == peer_addr_for_me.get_family()) {
+ if (a.is_blank_ip() &&
+ a.get_family() == peer_addr_for_me.get_family()) {
entity_addr_t t = peer_addr_for_me;
- t.set_type(a.get_type());
if (!did_bind) {
+ t.set_type(entity_addr_t::TYPE_ANY);
t.set_port(0);
} else {
+ t.set_type(a.get_type());
t.set_port(a.get_port());
}
t.set_nonce(a.get_nonce());
return;
lock.Lock();
- if (need_addr) {
+ if (need_addr && my_addr.is_blank_ip()) {
entity_addr_t t = peer_addr_for_me;
- t.set_type(entity_addr_t::TYPE_ANY);
- t.set_port(my_addr.get_port());
+ if (!did_bind) {
+ t.set_type(entity_addr_t::TYPE_ANY);
+ t.set_port(0);
+ } else {
+ t.set_type(entity_addr_t::TYPE_LEGACY);
+ t.set_port(my_addr.get_port());
+ }
t.set_nonce(my_addr.get_nonce());
ANNOTATE_BENIGN_RACE_SIZED(&my_addr, sizeof(my_addr),
"SimpleMessenger learned addr");