]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mount/conf: Fix IPv6 parsing 46112/head
authorMatan Breizman <mbreizma@redhat.com>
Wed, 27 Apr 2022 10:06:13 +0000 (10:06 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 2 May 2022 13:02:58 +0000 (13:02 +0000)
Fixes: https://tracker.ceph.com/issues/47300
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
(cherry picked from commit 5be921f334324c04344d26c024cf4a9ba403fbdd)

src/mount/conf.cc
src/msg/msg_types.cc
src/msg/msg_types.h

index 104969eefbf39830c7c58f379b44cafd2ef71e10..05dc09c04804b35e9a59da4824f5a2ab1f453d33 100644 (file)
@@ -67,9 +67,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 330cfba5bc35a997aad4129473ef90198b418c63..ba088e84f3204bdc6cb6eda2686b963253409a31 100644 (file)
@@ -380,3 +380,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 77c9fcaab8fda6321ceee3602f00ce35c9960b3f..31d19a946d97a2556d6516648e94e80e1eefd85b 100644 (file)
@@ -431,6 +431,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;