Remove all non-public resolver APIs
These functions were effectively dead code since when we started hiding
all symbols in libnetd_resolv except the few that are part of the public
interface. Removing them brings us a bit closer to removing h_errno.
However, netd also calls getaddrinfo() from various places, and
currently it's taking a longer trip through bionic before landing into
android_getaddrinfofornetcontext(). This will break as soon as we change
the signature of android_getaddrinfofornetcontext(), so we should decide
what to do about this. One option would be renaming our copy of
getaddrinfo() and switch netd to it.
Test: atest netd_integration_test
Change-Id: Iacfde97203365ce4d09d8e1c1d67930d729f46b1
diff --git a/resolv/res_cache.cpp b/resolv/res_cache.cpp
index 8eb20e2..a6bc6bf 100644
--- a/resolv/res_cache.cpp
+++ b/resolv/res_cache.cpp
@@ -1757,7 +1757,6 @@
int resolv_set_nameservers_for_net(unsigned netid, const char** servers, unsigned numservers,
const char* domains, const __res_params* params) {
- char sbuf[NI_MAXSERV];
char* cp;
int* offset;
struct addrinfo* nsaddrinfo[MAXNS];
@@ -1769,18 +1768,20 @@
// Parse the addresses before actually locking or changing any state, in case there is an error.
// As a side effect this also reduces the time the lock is kept.
- struct addrinfo hints = {
- .ai_family = AF_UNSPEC, .ai_socktype = SOCK_DGRAM, .ai_flags = AI_NUMERICHOST};
+ char sbuf[NI_MAXSERV];
snprintf(sbuf, sizeof(sbuf), "%u", NAMESERVER_PORT);
for (unsigned i = 0; i < numservers; i++) {
// The addrinfo structures allocated here are freed in free_nameservers_locked().
- int rt = getaddrinfo(servers[i], sbuf, &hints, &nsaddrinfo[i]);
+ const addrinfo hints = {
+ .ai_family = AF_UNSPEC, .ai_socktype = SOCK_DGRAM, .ai_flags = AI_NUMERICHOST};
+ int rt = getaddrinfo_numeric(servers[i], sbuf, hints, &nsaddrinfo[i]);
if (rt != 0) {
for (unsigned j = 0; j < i; j++) {
freeaddrinfo(nsaddrinfo[j]);
nsaddrinfo[j] = NULL;
}
- VLOG << __func__ << ": getaddrinfo(" << servers[i] << ") = " << gai_strerror(rt);
+ VLOG << __func__ << ": getaddrinfo_numeric(" << servers[i]
+ << ") = " << gai_strerror(rt);
return EINVAL;
}
}