Loading Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ cc_library { "res_mkquery.cpp", "res_query.cpp", "res_send.cpp", "res_state.cpp", "res_stats.cpp", "Dns64Configuration.cpp", "DnsProxyListener.cpp", Loading PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line [Builtin Hooks] clang_format = true commit_msg_test_field = false [Builtin Hooks Options] clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp getaddrinfo.cpp +6 −11 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ #include <android-base/logging.h> #include "netd_resolv/resolv.h" #include "res_init.h" #include "resolv_cache.h" #include "resolv_private.h" Loading Loading @@ -1445,18 +1446,11 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai, return EAI_FAMILY; } res_state res = res_get_state(); if (!res) return EAI_MEMORY; /* this just sets our netid val in the thread private data so we don't have to * modify the api's all the way down to res_send.c's res_nsend. We could * fully populate the thread private data here, but if we get down there * and have a cache hit that would be wasted, so we do the rest there on miss */ res_setnetcontext(res, netcontext, event); ResState res; res_init(&res, netcontext, event); int he; if (res_searchN(name, &q, res, &he) < 0) { if (res_searchN(name, &q, &res, &he) < 0) { // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA. // Note that res_searchN() doesn't set the pair NETDB_INTERNAL and errno. // See also herrnoToAiErrno(). Loading Loading @@ -1612,7 +1606,8 @@ static int res_queryN(const char* name, res_target* target, res_state res, int* LOG(DEBUG) << __func__ << ": (" << cl << ", " << type << ")"; n = res_nmkquery(res, QUERY, name, cl, type, NULL, 0, NULL, buf, sizeof(buf)); n = res_nmkquery(QUERY, name, cl, type, /*data=*/nullptr, /*datalen=*/0, buf, sizeof(buf), res->netcontext_flags); if (n > 0 && (res->netcontext_flags & (NET_CONTEXT_FLAG_USE_DNS_OVER_TLS | NET_CONTEXT_FLAG_USE_EDNS)) && Loading gethnamaddr.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ #include "hostent.h" #include "netd_resolv/resolv.h" #include "res_init.h" #include "resolv_cache.h" #include "resolv_private.h" #include "stats.pb.h" Loading Loading @@ -116,7 +117,7 @@ static void pad_v4v6_hostent(struct hostent* hp, char** bpp, char* ep); static int dns_gethtbyaddr(const unsigned char* uaddr, int len, int af, const android_net_context* netcontext, getnamaddr* info, NetworkDnsEventReported* event); static int dns_gethtbyname(const char* name, int af, getnamaddr* info); static int dns_gethtbyname(ResState* res, const char* name, int af, getnamaddr* info); #define BOUNDED_INCR(x) \ do { \ Loading Loading @@ -393,9 +394,8 @@ int resolv_gethostbyname(const char* name, int af, hostent* hp, char* buf, size_ NetworkDnsEventReported* event) { getnamaddr info; res_state res = res_get_state(); if (res == nullptr) return EAI_MEMORY; res_setnetcontext(res, netcontext, event); ResState res; res_init(&res, netcontext, event); size_t size; switch (af) { Loading Loading @@ -450,7 +450,7 @@ int resolv_gethostbyname(const char* name, int af, hostent* hp, char* buf, size_ info.buf = buf; info.buflen = buflen; if (_hf_gethtbyname2(name, af, &info)) { int error = dns_gethtbyname(name, af, &info); int error = dns_gethtbyname(&res, name, af, &info); if (error != 0) return error; } *result = hp; Loading Loading @@ -652,7 +652,7 @@ static void pad_v4v6_hostent(struct hostent* hp, char** bpp, char* ep) { }); } static int dns_gethtbyname(const char* name, int addr_type, getnamaddr* info) { static int dns_gethtbyname(ResState* res, const char* name, int addr_type, getnamaddr* info) { int n, type; info->hp->h_addrtype = addr_type; Loading @@ -670,9 +670,6 @@ static int dns_gethtbyname(const char* name, int addr_type, getnamaddr* info) { } auto buf = std::make_unique<querybuf>(); res_state res = res_get_state(); if (!res) return EAI_MEMORY; int he; n = res_nsearch(res, name, C_IN, type, buf->buf, (int)sizeof(buf->buf), &he); if (n < 0) { Loading Loading @@ -734,12 +731,10 @@ static int dns_gethtbyaddr(const unsigned char* uaddr, int len, int af, auto buf = std::make_unique<querybuf>(); res_state res = res_get_state(); if (!res) return EAI_MEMORY; res_setnetcontext(res, netcontext, event); ResState res; res_init(&res, netcontext, event); int he; n = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, (int)sizeof(buf->buf), &he); n = res_nquery(&res, qbuf, C_IN, T_PTR, buf->buf, (int)sizeof(buf->buf), &he); if (n < 0) { LOG(DEBUG) << __func__ << ": res_nquery failed (" << n << ")"; // Note that res_nquery() doesn't set the pair NETDB_INTERNAL and errno. Loading res_cache.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -140,6 +140,7 @@ using android::base::StringAppendF; * ***************************************** */ const int CONFIG_MAX_ENTRIES = 64 * 2 * 5; constexpr int DNSEVENT_SUBSAMPLING_MAP_DEFAULT_KEY = -1; static time_t _time_now(void) { struct timeval tv; Loading Loading
Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ cc_library { "res_mkquery.cpp", "res_query.cpp", "res_send.cpp", "res_state.cpp", "res_stats.cpp", "Dns64Configuration.cpp", "DnsProxyListener.cpp", Loading
PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line [Builtin Hooks] clang_format = true commit_msg_test_field = false [Builtin Hooks Options] clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
getaddrinfo.cpp +6 −11 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ #include <android-base/logging.h> #include "netd_resolv/resolv.h" #include "res_init.h" #include "resolv_cache.h" #include "resolv_private.h" Loading Loading @@ -1445,18 +1446,11 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai, return EAI_FAMILY; } res_state res = res_get_state(); if (!res) return EAI_MEMORY; /* this just sets our netid val in the thread private data so we don't have to * modify the api's all the way down to res_send.c's res_nsend. We could * fully populate the thread private data here, but if we get down there * and have a cache hit that would be wasted, so we do the rest there on miss */ res_setnetcontext(res, netcontext, event); ResState res; res_init(&res, netcontext, event); int he; if (res_searchN(name, &q, res, &he) < 0) { if (res_searchN(name, &q, &res, &he) < 0) { // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA. // Note that res_searchN() doesn't set the pair NETDB_INTERNAL and errno. // See also herrnoToAiErrno(). Loading Loading @@ -1612,7 +1606,8 @@ static int res_queryN(const char* name, res_target* target, res_state res, int* LOG(DEBUG) << __func__ << ": (" << cl << ", " << type << ")"; n = res_nmkquery(res, QUERY, name, cl, type, NULL, 0, NULL, buf, sizeof(buf)); n = res_nmkquery(QUERY, name, cl, type, /*data=*/nullptr, /*datalen=*/0, buf, sizeof(buf), res->netcontext_flags); if (n > 0 && (res->netcontext_flags & (NET_CONTEXT_FLAG_USE_DNS_OVER_TLS | NET_CONTEXT_FLAG_USE_EDNS)) && Loading
gethnamaddr.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ #include "hostent.h" #include "netd_resolv/resolv.h" #include "res_init.h" #include "resolv_cache.h" #include "resolv_private.h" #include "stats.pb.h" Loading Loading @@ -116,7 +117,7 @@ static void pad_v4v6_hostent(struct hostent* hp, char** bpp, char* ep); static int dns_gethtbyaddr(const unsigned char* uaddr, int len, int af, const android_net_context* netcontext, getnamaddr* info, NetworkDnsEventReported* event); static int dns_gethtbyname(const char* name, int af, getnamaddr* info); static int dns_gethtbyname(ResState* res, const char* name, int af, getnamaddr* info); #define BOUNDED_INCR(x) \ do { \ Loading Loading @@ -393,9 +394,8 @@ int resolv_gethostbyname(const char* name, int af, hostent* hp, char* buf, size_ NetworkDnsEventReported* event) { getnamaddr info; res_state res = res_get_state(); if (res == nullptr) return EAI_MEMORY; res_setnetcontext(res, netcontext, event); ResState res; res_init(&res, netcontext, event); size_t size; switch (af) { Loading Loading @@ -450,7 +450,7 @@ int resolv_gethostbyname(const char* name, int af, hostent* hp, char* buf, size_ info.buf = buf; info.buflen = buflen; if (_hf_gethtbyname2(name, af, &info)) { int error = dns_gethtbyname(name, af, &info); int error = dns_gethtbyname(&res, name, af, &info); if (error != 0) return error; } *result = hp; Loading Loading @@ -652,7 +652,7 @@ static void pad_v4v6_hostent(struct hostent* hp, char** bpp, char* ep) { }); } static int dns_gethtbyname(const char* name, int addr_type, getnamaddr* info) { static int dns_gethtbyname(ResState* res, const char* name, int addr_type, getnamaddr* info) { int n, type; info->hp->h_addrtype = addr_type; Loading @@ -670,9 +670,6 @@ static int dns_gethtbyname(const char* name, int addr_type, getnamaddr* info) { } auto buf = std::make_unique<querybuf>(); res_state res = res_get_state(); if (!res) return EAI_MEMORY; int he; n = res_nsearch(res, name, C_IN, type, buf->buf, (int)sizeof(buf->buf), &he); if (n < 0) { Loading Loading @@ -734,12 +731,10 @@ static int dns_gethtbyaddr(const unsigned char* uaddr, int len, int af, auto buf = std::make_unique<querybuf>(); res_state res = res_get_state(); if (!res) return EAI_MEMORY; res_setnetcontext(res, netcontext, event); ResState res; res_init(&res, netcontext, event); int he; n = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, (int)sizeof(buf->buf), &he); n = res_nquery(&res, qbuf, C_IN, T_PTR, buf->buf, (int)sizeof(buf->buf), &he); if (n < 0) { LOG(DEBUG) << __func__ << ": res_nquery failed (" << n << ")"; // Note that res_nquery() doesn't set the pair NETDB_INTERNAL and errno. Loading
res_cache.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -140,6 +140,7 @@ using android::base::StringAppendF; * ***************************************** */ const int CONFIG_MAX_ENTRIES = 64 * 2 * 5; constexpr int DNSEVENT_SUBSAMPLING_MAP_DEFAULT_KEY = -1; static time_t _time_now(void) { struct timeval tv; Loading