]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/msg_types: TYPE_V1ORV2 -> TYPE_ANY
authorSage Weil <sage@redhat.com>
Wed, 5 Dec 2018 22:13:47 +0000 (16:13 -0600)
committerSage Weil <sage@redhat.com>
Sat, 22 Dec 2018 21:53:13 +0000 (15:53 -0600)
..and allow us to parse it.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonMap.cc
src/msg/msg_types.cc
src/msg/msg_types.h
src/test/test_ipaddr.cc

index afeb5b843b244701c0fe5305573bc651ba5b058e..7fa26a1705f2882607d2347cec488e6d90e0eae1 100644 (file)
@@ -347,11 +347,11 @@ void MonMap::_add_ambiguous_addr(const string& name,
                                 entity_addr_t addr,
                                 int priority)
 {
-  if (addr.get_type() != entity_addr_t::TYPE_V1ORV2) {
+  if (addr.get_type() != entity_addr_t::TYPE_ANY) {
     // a v1: or v2: prefix was specified
     if (addr.get_port() == 0) {
       // use default port
-      if (addr.get_type() == entity_addr_t::TYPE_MSGR2) {
+      if (addr.get_type() == entity_addr_t::TYPE_ANY) {
        addr.set_port(CEPH_MON_PORT_IANA);
       } else if (addr.get_type() == entity_addr_t::TYPE_LEGACY) {
        addr.set_port(CEPH_MON_PORT_LEGACY);
@@ -401,7 +401,7 @@ int MonMap::init_with_ips(const std::string& ips,
                          const std::string &prefix)
 {
   vector<entity_addr_t> addrs;
-  if (!parse_ip_port_vec(ips.c_str(), addrs, entity_addr_t::TYPE_V1ORV2)) {
+  if (!parse_ip_port_vec(ips.c_str(), addrs, entity_addr_t::TYPE_ANY)) {
     return -EINVAL;
   }
   if (addrs.empty())
@@ -426,7 +426,7 @@ int MonMap::init_with_hosts(const std::string& hostlist,
     return -EINVAL;
 
   vector<entity_addr_t> addrs;
-  bool success = parse_ip_port_vec(hosts, addrs, entity_addr_t::TYPE_V1ORV2);
+  bool success = parse_ip_port_vec(hosts, addrs, entity_addr_t::TYPE_ANY);
   free(hosts);
   if (!success)
     return -EINVAL;
index 9e1ecdbdf62abac291c05d6b09df6742a4d89ab1..bc63047604f42a1486a8e3e4f0e6efa65ca3d37e 100644 (file)
@@ -75,6 +75,9 @@ bool entity_addr_t::parse(const char *s, const char **end, int default_type)
   } else if (strncmp("v2:", s, 3) == 0) {
     start += 3;
     newtype = TYPE_MSGR2;
+  } else if (strncmp("any:", s, 4) == 0) {
+    start += 4;
+    newtype = TYPE_ANY;
   } else if (*s == '-') {
     newtype = TYPE_NONE;
     if (end) {
index 7198c287e3259aa06a7800853da925e18cc9c4f2..1f5137e6c50fd46df2a1332d361421975388af68 100644 (file)
@@ -232,7 +232,7 @@ struct entity_addr_t {
     TYPE_NONE = 0,
     TYPE_LEGACY = 1,  ///< legacy msgr1 protocol (ceph jewel and older)
     TYPE_MSGR2 = 2,   ///< msgr2 protocol (new in ceph kraken)
-    TYPE_V1ORV2 = 3,  ///< ambiguous
+    TYPE_ANY = 3,  ///< ambiguous
   } type_t;
   static const type_t TYPE_DEFAULT = TYPE_MSGR2;
   static const char *get_type_name(int t) {
@@ -240,6 +240,7 @@ struct entity_addr_t {
     case TYPE_NONE: return "none";
     case TYPE_LEGACY: return "v1";
     case TYPE_MSGR2: return "v2";
+    case TYPE_ANY: return "any";
     default: return "???";
     }
   };
index 09838804ffd97f606589428e0acc9ee8c8160404..9701632d313fbabc395b1ebf594b464059bbd80e 100644 (file)
@@ -547,15 +547,19 @@ TEST(CommonIPAddr, ambiguous)
   entity_addr_t a;
   bool ok;
 
-  ok = a.parse("1.2.3.4", nullptr, entity_addr_t::TYPE_V1ORV2);
+  ok = a.parse("1.2.3.4", nullptr, entity_addr_t::TYPE_ANY);
   ASSERT_TRUE(ok);
-  ASSERT_EQ(entity_addr_t::TYPE_V1ORV2, a.get_type());
+  ASSERT_EQ(entity_addr_t::TYPE_ANY, a.get_type());
 
-  ok = a.parse("v1:1.2.3.4", nullptr, entity_addr_t::TYPE_V1ORV2);
+  ok = a.parse("any:1.2.3.4", nullptr, entity_addr_t::TYPE_ANY);
+  ASSERT_TRUE(ok);
+  ASSERT_EQ(entity_addr_t::TYPE_ANY, a.get_type());
+
+  ok = a.parse("v1:1.2.3.4", nullptr, entity_addr_t::TYPE_ANY);
   ASSERT_TRUE(ok);
   ASSERT_EQ(entity_addr_t::TYPE_LEGACY, a.get_type());
 
-  ok = a.parse("v2:1.2.3.4", nullptr, entity_addr_t::TYPE_V1ORV2);
+  ok = a.parse("v2:1.2.3.4", nullptr, entity_addr_t::TYPE_ANY);
   ASSERT_TRUE(ok);
   ASSERT_EQ(entity_addr_t::TYPE_MSGR2, a.get_type());
 }