#include "common/pick_address.h"
+#include <bitset>
#include <netdb.h>
#include <netinet/in.h>
#include <string>
addrs->v.clear();
unsigned addrt = (flags & (CEPH_PICK_ADDRESS_PUBLIC |
+ CEPH_PICK_ADDRESS_PUBLIC_BIND |
CEPH_PICK_ADDRESS_CLUSTER));
- if (addrt == 0 ||
- addrt == (CEPH_PICK_ADDRESS_PUBLIC |
- CEPH_PICK_ADDRESS_CLUSTER)) {
+ // TODO: move to std::popcount when it's available for all release lines
+ // we are interested in (quincy was a blocker at the time of writing)
+ if (std::bitset<sizeof(addrt)*CHAR_BIT>(addrt).count() != 1) {
+ // these flags are mutually exclusive and one of them must be
+ // always set (in other words: it's mode selection).
return -EINVAL;
}
unsigned msgrv = flags & (CEPH_PICK_ADDRESS_MSGR1 |
networks = cct->_conf.get_val<std::string>("public_network");
interfaces =
cct->_conf.get_val<std::string>("public_network_interface");
+ } else if (addrt & CEPH_PICK_ADDRESS_PUBLIC_BIND) {
+ addr = cct->_conf.get_val<entity_addr_t>("public_bind_addr");
+ // XXX: we don't support _network nor _network_interface for
+ // the public_bind addrs yet.
+ if (addr.is_blank_ip()) {
+ return -ENOENT;
+ }
} else {
addr = cct->_conf.get_val<entity_addr_t>("cluster_addr");
networks = cct->_conf.get_val<std::string>("cluster_network");
#define CEPH_PICK_ADDRESS_IPV6 0x20
#define CEPH_PICK_ADDRESS_PREFER_IPV4 0x40
#define CEPH_PICK_ADDRESS_DEFAULT_MON_PORTS 0x80
+#define CEPH_PICK_ADDRESS_PUBLIC_BIND 0x100
#ifndef WITH_SEASTAR
/*