Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/dns_resolv.cc: Query for AAAA-record if ms_bind_ipv6 is True #20530

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/common/dns_resolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,17 @@ int DNSResolver::resolve_ip_addr(CephContext *cct, res_state *res, const string&

u_char nsbuf[NS_PACKETSZ];
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, ns_t_a, nsbuf, sizeof(nsbuf));
len = resolv_h->res_nquery(*res, hostname.c_str(), ns_c_in, type, nsbuf, sizeof(nsbuf));
#else
{
# ifndef HAVE_THREAD_SAFE_RES_QUERY
Mutex::Locker l(lock);
# endif
len = resolv_h->res_query(hostname.c_str(), ns_c_in, ns_t_a, nsbuf, sizeof(nsbuf));
len = resolv_h->res_query(hostname.c_str(), ns_c_in, type, nsbuf, sizeof(nsbuf));
}
#endif
if (len < 0) {
Expand Down Expand Up @@ -249,7 +250,7 @@ int DNSResolver::resolve_ip_addr(CephContext *cct, res_state *res, const string&

char addr_buf[64];
memset(addr_buf, 0, sizeof(addr_buf));
inet_ntop(AF_INET, ns_rr_rdata(rr), addr_buf, sizeof(addr_buf));
inet_ntop(family, ns_rr_rdata(rr), addr_buf, sizeof(addr_buf));
if (!addr->parse(addr_buf)) {
lderr(cct) << "failed to parse address '" << (const char *)ns_rr_rdata(rr)
<< "'" << dendl;
Expand Down