If we are a client and didn't bind, then we should not fill in the port for our
address. The one the peer sent us is just the random port our outgoing connection
happened to land on!
Signed-off-by: Sage Weil <sage@redhat.com>
if (my_addrs->empty()) {
auto a = peer_addr_for_me;
a.set_nonce(nonce);
+ if (!did_bind) {
+ a.set_port(0);
+ }
set_myaddrs(entity_addrvec_t(a));
ldout(cct,10) << __func__ << " had no addrs" << dendl;
} else {
if (a.get_family() == peer_addr_for_me.get_family()) {
entity_addr_t t = peer_addr_for_me;
t.set_type(a.get_type());
- t.set_port(a.get_port());
+ if (!did_bind) {
+ t.set_port(0);
+ } else {
+ t.set_port(a.get_port());
+ }
t.set_nonce(a.get_nonce());
ldout(cct,10) << __func__ << " " << a << " -> " << t << dendl;
a = t;