]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: increase dns buffer size 59565/head
authorNuckal777 <erik.schubert@sap.com>
Mon, 2 Sep 2024 12:49:38 +0000 (14:49 +0200)
committerNuckal777 <erik.schubert@sap.com>
Wed, 7 May 2025 13:21:43 +0000 (15:21 +0200)
Increases the buffers used for dns reponses from 512 to NS_MAXMSG bytes.
Otherwise service discovery fails, if DNS reponses are larger than 512 bytes.

Fixes: https://tracker.ceph.com/issues/68064
Signed-off-by: Nuckal777 <erik.schubert@sap.com>
src/common/dns_resolve.cc

index 6acfa3a5a9b8f43b3ef6a14eeb143e07d3353846..f726f111032c7ccd0e06124653c771557857b4d7 100644 (file)
@@ -212,19 +212,19 @@ int DNSResolver::resolve_ip_addr(CephContext *cct, const string& hostname,
 int DNSResolver::resolve_ip_addr(CephContext *cct, res_state *res, const string& hostname, 
     entity_addr_t *addr) {
 
-  u_char nsbuf[NS_PACKETSZ];
+  auto nsbuf = std::make_unique<std::array<u_char, NS_MAXMSG>>();
   int len;
   int family = cct->_conf->ms_bind_ipv6 ? AF_INET6 : AF_INET;
   int type = cct->_conf->ms_bind_ipv6 ? ns_t_aaaa : ns_t_a;
 
 #ifdef HAVE_RES_NQUERY
-  len = resolv_h->res_nquery(*res, hostname.c_str(), ns_c_in, type, nsbuf, sizeof(nsbuf));
+  len = resolv_h->res_nquery(*res, hostname.c_str(), ns_c_in, type, nsbuf->data(), nsbuf->size());
 #else
   {
 # ifndef HAVE_THREAD_SAFE_RES_QUERY
     std::lock_guard l(lock);
 # endif
-    len = resolv_h->res_query(hostname.c_str(), ns_c_in, type, nsbuf, sizeof(nsbuf));
+    len = resolv_h->res_query(hostname.c_str(), ns_c_in, type, nsbuf->data(), nsbuf->size());
   }
 #endif
   if (len < 0) {
@@ -237,7 +237,7 @@ int DNSResolver::resolve_ip_addr(CephContext *cct, res_state *res, const string&
   }
 
   ns_msg handle;
-  ns_initparse(nsbuf, len, &handle);
+  ns_initparse(nsbuf->data(), len, &handle);
 
   if (ns_msg_count(handle, ns_s_an) == 0) {
     ldout(cct, 20) << "no address found for hostname " << hostname << dendl;
@@ -285,7 +285,7 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
     });
 #endif
 
-  u_char nsbuf[NS_PACKETSZ];
+  auto nsbuf = std::make_unique<std::array<u_char, NS_MAXMSG>>();
   int num_hosts;
 
   string proto_str = srv_protocol_to_str(trans_protocol);
@@ -294,15 +294,15 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
   int len;
 
 #ifdef HAVE_RES_NQUERY
-  len = resolv_h->res_nsearch(res, query_str.c_str(), ns_c_in, ns_t_srv, nsbuf,
-      sizeof(nsbuf));
+  len = resolv_h->res_nsearch(res, query_str.c_str(), ns_c_in, ns_t_srv, nsbuf->data(),
+      nsbuf->size());
 #else
   {
 # ifndef HAVE_THREAD_SAFE_RES_QUERY
     std::lock_guard l(lock);
 # endif
-    len = resolv_h->res_search(query_str.c_str(), ns_c_in, ns_t_srv, nsbuf,
-        sizeof(nsbuf));
+    len = resolv_h->res_search(query_str.c_str(), ns_c_in, ns_t_srv, nsbuf->data(),
+        nsbuf->size());
   }
 #endif
   if (len < 0) {
@@ -316,7 +316,7 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
 
   ns_msg handle;
 
-  ns_initparse(nsbuf, len, &handle);
+  ns_initparse(nsbuf->data(), len, &handle);
 
   num_hosts = ns_msg_count (handle, ns_s_an);
   if (num_hosts == 0) {