<< " went away" << dendl;
// can't find the mon we were talking to (above)
_reopen_session();
- } else if (monmap.get_addrs(new_rank) != con_addrs) {
- // FIXME: we might make this a more sophisticated check later if we do
- // multiprotocol IPV4/IPV6 and have a strict preference
- ldout(cct,10) << " mon." << new_rank << " has addrs "
- << monmap.get_addrs(new_rank) << " but i'm connected to "
- << con_addrs << dendl;
+ } else if (messenger->should_use_msgr2() &&
+ monmap.get_addrs(new_rank).has_msgr2() &&
+ !con_addrs.has_msgr2()) {
+ ldout(cct,1) << " mon." << new_rank << " has (v2) addrs "
+ << monmap.get_addrs(new_rank) << " but i'm connected to "
+ << con_addrs << ", reconnecting" << dendl;
_reopen_session();
}
}
return local_connection;
}
+bool AsyncMessenger::should_use_msgr2()
+{
+ // if we are bound to v1 only, and we are connecting to a v2 peer,
+ // we cannot use the peer's v2 address. otherwise the connection
+ // is assymetrical, because they would have to use v1 to connect
+ // to us, and we would use v2, and connection race detection etc
+ // would totally break down (among other things). or, the other
+ // end will be confused that we advertise ourselve with a v1
+ // address only (that we bound to) but connected with protocol v2.
+ return !did_bind || get_myaddrs().has_msgr2();
+}
+
entity_addrvec_t AsyncMessenger::_filter_addrs(int type,
const entity_addrvec_t& addrs)
{
- if (did_bind &&
- !get_myaddrs().has_msgr2() &&
- get_mytype() == type) {
- // if we are bound to v1 only, and we are connecting to a peer, we cannot
- // use the peer's v2 address (yet). otherwise the connection is assymetrical,
- // because they would have to use v1 to connect to us, and we would use v2,
- // and connection race detection etc would totally break down (among other
- // things).
+ if (!should_use_msgr2()) {
ldout(cct, 10) << __func__ << " " << addrs << " type " << type
<< " limiting to v1 ()" << dendl;
entity_addrvec_t r;