]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/{async,simple}: make learned_addr a bit smarter
authorSage Weil <sage@redhat.com>
Wed, 6 Feb 2019 12:23:16 +0000 (06:23 -0600)
committerSage Weil <sage@redhat.com>
Thu, 7 Feb 2019 12:13:09 +0000 (06:13 -0600)
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>
src/msg/async/AsyncMessenger.cc
src/msg/simple/SimpleMessenger.cc

index 72423f8087c7db8be461735798a91407704b9353..f6bcaa9b794eac33d001b89b96152b948471d98b 100644 (file)
@@ -899,12 +899,14 @@ bool AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
       // 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());
index 39f159df9df7fc256c4a5f5d5179ddda6ce466ff..09d1ab7b2a249e5130fd10fd3160f4b1b030c513 100644 (file)
@@ -740,10 +740,15 @@ void SimpleMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
     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");