From dfac9250579768e3dd5280dbe1c098a9e6e7412f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 17 May 2012 17:52:54 -0700 Subject: [PATCH] mon: learn peer addrs when probing If we have a monmap with dummy addrs for initial members, and we probe one of those peers and learn their address, update our monmap appropriately. Signed-off-by: Sage Weil --- src/mon/MonMap.h | 5 +++++ src/mon/Monitor.cc | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/mon/MonMap.h b/src/mon/MonMap.h index 7daf8e79e62c3..e7982f137651b 100644 --- a/src/mon/MonMap.h +++ b/src/mon/MonMap.h @@ -162,6 +162,11 @@ class MonMap { assert(m < rank_addr.size()); return rank_addr[m]; } + void set_addr(const string& n, entity_addr_t a) { + assert(mon_addr.count(n)); + mon_addr[n] = a; + calc_ranks(); + } entity_inst_t get_inst(const string& n) { assert(mon_addr.count(n)); int m = get_rank(n); diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 7a6cb1b267cfc..e64739b2c4bd3 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -703,6 +703,23 @@ void Monitor::handle_probe_reply(MMonProbe *m) monmap->rename(peer_name, m->name); } + // new initial peer? + if (monmap->contains(m->name)) { + entity_addr_t a = monmap->get_addr(m->name); + a.set_port(0); + entity_addr_t b; + b.set_family(AF_INET); + dout(1) << " a " << a <<" b " << b << dendl; + if (a == b) { + dout(1) << " learned initial mon " << m->name << " addr " << m->get_source_addr() << dendl; + monmap->set_addr(m->name, m->get_source_addr()); + m->put(); + + bootstrap(); + return; + } + } + // is there an existing quorum? if (m->quorum.size()) { dout(10) << " existing quorum " << m->quorum << dendl; -- 2.39.5