]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mount/conf: Fix IPv6 parsing 46051/head
authorMatan Breizman <mbreizma@redhat.com>
Wed, 27 Apr 2022 10:06:13 +0000 (10:06 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 1 May 2022 09:27:38 +0000 (09:27 +0000)
Fixes: https://tracker.ceph.com/issues/47300
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/mount/conf.cc
src/msg/msg_types.cc
src/msg/msg_types.h

index df95912c1f3b507230c4f6b07dff098fcb725587..9a24aa53c3f1985472fdeccf8d70938cffeacd24 100644 (file)
@@ -71,9 +71,7 @@ extern "C" void mount_ceph_get_config_info(const char *config_file,
     }
 
     std::string addr;
-    addr += eaddr.ip_only_to_str();
-    addr += ":";
-    addr += std::to_string(eaddr.get_port());
+    addr += eaddr.ip_n_port_to_str();
     /* If this will overrun cci_mons, stop here */
     if (monaddrs.length() + 1 + addr.length() + 1 > sizeof(cci->cci_mons))
       break;
index 0c28e915b7b0a85f76eb2842d621bffc28416fa0..1a78cb32680986285d882b15d3d92742eab622e7 100644 (file)
@@ -410,3 +410,16 @@ std::string entity_addr_t::ip_only_to_str() const
   }
   return host_ip ? host_ip : "";
 }
+
+std::string entity_addr_t::ip_n_port_to_str() const
+{
+  std::string addr;
+  addr += ip_only_to_str();
+  if (is_ipv6()) {
+    addr = '[' + addr + ']';
+  }
+  addr += ':';
+  addr += std::to_string(get_port());
+  return addr;
+}
+
index 36aad858b385b89bf5281017501f540456c1c0de..6da064c4f86be9d653d2caf48bbdf28404e949cd 100644 (file)
@@ -420,6 +420,7 @@ struct entity_addr_t {
   }
 
   std::string ip_only_to_str() const;
+  std::string ip_n_port_to_str() const;
 
   std::string get_legacy_str() const {
     std::ostringstream ss;