From 16102c6927000c37b09b6189311ad5625c9cb801 Mon Sep 17 00:00:00 2001 From: Nuckal777 Date: Mon, 2 Sep 2024 14:49:38 +0200 Subject: [PATCH] mon: increase dns buffer size 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 --- src/common/dns_resolve.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common/dns_resolve.cc b/src/common/dns_resolve.cc index 6acfa3a5a9b8f..f726f111032c7 100644 --- a/src/common/dns_resolve.cc +++ b/src/common/dns_resolve.cc @@ -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>(); 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>(); 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) { -- 2.47.3