msgr->set_policy_throttlers(entity_name_t::TYPE_MDS, daemon_throttler,
NULL);
+ entity_addr_t bind_addr = ipaddr;
+ entity_addr_t public_addr = ipaddr;
+
+ // check if the public_bind_addr option is set
+ if (!g_conf->public_bind_addr.is_blank_ip()) {
+ bind_addr = g_conf->public_bind_addr;
+
+ // set the default port if not already set
+ if (bind_addr.get_port() == 0) {
+ bind_addr.set_port(CEPH_MON_PORT);
+ }
+ }
+
dout(0) << "starting " << g_conf->name << " rank " << rank
- << " at " << ipaddr
+ << " at public addr " << public_addr
+ << " at bind addr " << bind_addr
<< " mon_data " << g_conf->mon_data
<< " fsid " << monmap.get_fsid()
<< dendl;
- err = msgr->bind(ipaddr);
+ err = msgr->bind(bind_addr);
if (err < 0) {
- derr << "unable to bind monitor to " << ipaddr << dendl;
+ derr << "unable to bind monitor to " << bind_addr << dendl;
prefork.exit(1);
}
+ // if the public and bind addr are different set the msgr addr
+ // to the public one, now that the bind is complete.
+ if (public_addr != bind_addr) {
+ msgr->set_addr(public_addr);
+ }
+
Messenger *mgr_msgr = Messenger::create(g_ceph_context, public_msgr_type,
entity_name_t::MON(rank), "mon-mgrc",
getpid(), 0);
prefork.signal_exit(0);
return 0;
}
-
OPTION(host, OPT_STR, "") // "" means that ceph will use short hostname
OPTION(fsid, OPT_UUID, uuid_d())
OPTION(public_addr, OPT_ADDR, entity_addr_t())
+OPTION(public_bind_addr, OPT_ADDR, entity_addr_t())
OPTION(cluster_addr, OPT_ADDR, entity_addr_t())
OPTION(public_network, OPT_STR, "")
OPTION(cluster_network, OPT_STR, "")
* @param addr The address to use as a template.
*/
virtual void set_addr_unknowns(const entity_addr_t &addr) = 0;
+ /**
+ * Set the address for this Messenger. This is useful if the Messenger
+ * binds to a specific address but advertises a different address on the
+ * the network.
+ *
+ * @param addr The address to use.
+ */
+ virtual void set_addr(const entity_addr_t &addr) = 0;
/// Get the default send priority.
int get_default_send_priority() { return default_send_priority; }
/**
<< " not " << peer_addr
<< " - presumably this is the same node!" << dendl;
} else {
- ldout(async_msgr->cct, 0) << __func__ << " connect claims to be "
- << paddr << " not " << peer_addr << " - wrong node!" << dendl;
- goto fail;
+ ldout(async_msgr->cct, 10) << __func__ << " connect claims to be "
+ << paddr << " not " << peer_addr
+ << " (peer is possibly using public_bind_addr?) " << dendl;
}
}
}
}
+void AsyncMessenger::set_addr(const entity_addr_t &addr)
+{
+ Mutex::Locker l(lock);
+ entity_addr_t t = addr;
+ t.set_nonce(nonce);
+ set_myaddr(t);
+ _init_local_connection();
+}
+
void AsyncMessenger::shutdown_connections(bool queue_reset)
{
ldout(cct,1) << __func__ << " " << dendl;
* @{
*/
void set_addr_unknowns(const entity_addr_t &addr) override;
+ void set_addr(const entity_addr_t &addr) override;
int get_dispatch_queue_len() override {
return dispatch_queue.get_queue_len();
ldout(msgr->cct,0) << "connect claims to be "
<< paddr << " not " << peer_addr << " - presumably this is the same node!" << dendl;
} else {
- ldout(msgr->cct,0) << "connect claims to be "
- << paddr << " not " << peer_addr << " - wrong node!" << dendl;
- goto fail;
+ ldout(msgr->cct,10) << "connect claims to be "
+ << paddr << " not " << peer_addr
+ << " (peer is possibly using public_bind_addr?) " << dendl;
}
}
}
}
+void SimpleMessenger::set_addr(const entity_addr_t &addr)
+{
+ entity_addr_t t = addr;
+ t.set_nonce(nonce);
+ set_myaddr(t);
+ init_local_connection();
+}
+
int SimpleMessenger::get_proto_version(int peer_type, bool connect)
{
int my_type = my_inst.name.type();
* @{
*/
void set_addr_unknowns(const entity_addr_t& addr) override;
+ void set_addr(const entity_addr_t &addr) override;
int get_dispatch_queue_len() override {
return dispatch_queue.get_queue_len();
/* Messenger interface */
virtual void set_addr_unknowns(const entity_addr_t &addr) override
{ } /* XXX applicable? */
+ virtual void set_addr(const entity_addr_t &addr) override
+ { } /* XXX applicable? */
virtual int get_dispatch_queue_len()
{ return 0; } /* XXX bogus? */
// unimplemented Messenger interface
void set_addr_unknowns(const entity_addr_t &addr) override {}
+ void set_addr(const entity_addr_t &addr) override {}
int get_dispatch_queue_len() override { return 0; }
double get_dispatch_queue_max_age(utime_t now) override { return 0; }
void set_cluster_protocol(int p) override {}