Loading res_send.cpp +22 −7 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ using android::net::IpVersion; using android::net::IV_IPV4; using android::net::IV_IPV6; using android::net::IV_UNKNOWN; using android::net::LinuxErrno; using android::net::NetworkDnsEventReported; using android::net::NS_T_INVALID; using android::net::NsRcode; Loading Loading @@ -499,7 +500,8 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int int retryTimes = (flags & ANDROID_RESOLV_NO_RETRY) ? 1 : params.retry_count; int useTcp = buflen > PACKETSZ; int gotsomewhere = 0; int terrno = ETIMEDOUT; // Use an impossible error code as default value int terrno = ETIME; for (int attempt = 0; attempt < retryTimes; ++attempt) { for (size_t ns = 0; ns < statp->nsaddrs.size(); ++ns) { Loading @@ -521,6 +523,8 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int Stopwatch queryStopwatch; int retry_count_for_event = 0; size_t actualNs = ns; // Use an impossible error code as default value terrno = ETIME; if (useTcp) { // TCP; at most one attempt per server. attempt = retryTimes; Loading Loading @@ -558,6 +562,7 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int dnsQueryEvent->set_rcode(static_cast<NsRcode>(*rcode)); dnsQueryEvent->set_protocol(query_proto); dnsQueryEvent->set_type(getQueryType(buf, buflen)); dnsQueryEvent->set_linux_errno(static_cast<LinuxErrno>(terrno)); // Only record stats the first time we try a query. This ensures that // queries that deterministically fail (e.g., a name that always returns Loading Loading @@ -643,6 +648,7 @@ static int send_vc(res_state statp, res_params* params, const uint8_t* buf, int // It should never happen, but just in case. if (ns >= statp->nsaddrs.size()) { LOG(ERROR) << __func__ << ": Out-of-bound indexing: " << ns; *terrno = EINVAL; return -1; } Loading Loading @@ -675,15 +681,14 @@ same_ns: statp->tcp_nssock.reset(socket(nsap->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)); if (statp->tcp_nssock < 0) { *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(vc): "; switch (errno) { case EPROTONOSUPPORT: case EPFNOSUPPORT: case EAFNOSUPPORT: PLOG(DEBUG) << __func__ << ": socket(vc): "; return 0; default: *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(vc): "; return -1; } } Loading Loading @@ -831,6 +836,7 @@ read_len: *delay = res_stats_calculate_rtt(&done, &start_time); *rcode = anhp->rcode; } *terrno = 0; return (resplen); } Loading Loading @@ -972,6 +978,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int // It should never happen, but just in case. if (*ns >= statp->nsaddrs.size()) { LOG(ERROR) << __func__ << ": Out-of-bound indexing: " << ns; *terrno = EINVAL; return -1; } Loading @@ -984,15 +991,14 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int if (statp->nssocks[*ns] == -1) { statp->nssocks[*ns].reset(socket(nsap->sa_family, SOCK_DGRAM | SOCK_CLOEXEC, 0)); if (statp->nssocks[*ns] < 0) { *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(dg): "; switch (errno) { case EPROTONOSUPPORT: case EPFNOSUPPORT: case EAFNOSUPPORT: PLOG(DEBUG) << __func__ << ": socket(dg): "; return (0); default: *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(dg): "; return (-1); } } Loading @@ -1001,6 +1007,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int if (statp->_mark != MARK_UNSET) { if (setsockopt(statp->nssocks[*ns], SOL_SOCKET, SO_MARK, &(statp->_mark), sizeof(statp->_mark)) < 0) { *terrno = errno; statp->closeSockets(); return -1; } Loading @@ -1010,11 +1017,13 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int // ICMP port-unreachable error. This way we can detect the absence of // a nameserver without timing out. if (random_bind(statp->nssocks[*ns], nsap->sa_family) < 0) { *terrno = errno; dump_error("bind(dg)", nsap, nsaplen); statp->closeSockets(); return (0); } if (connect(statp->nssocks[*ns], nsap, (socklen_t)nsaplen) < 0) { *terrno = errno; dump_error("connect(dg)", nsap, nsaplen); statp->closeSockets(); return (0); Loading @@ -1022,6 +1031,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int LOG(DEBUG) << __func__ << ": new DG socket"; } if (send(statp->nssocks[*ns], (const char*)buf, (size_t)buflen, 0) != buflen) { *terrno = errno; PLOG(DEBUG) << __func__ << ": send: "; statp->closeSockets(); return 0; Loading @@ -1037,6 +1047,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int if (!result.has_value()) { const bool isTimeout = (result.error().code() == ETIMEDOUT); *rcode = (isTimeout) ? RCODE_TIMEOUT : *rcode; *terrno = (isTimeout) ? ETIMEDOUT : errno; *gotsomewhere = (isTimeout) ? 1 : *gotsomewhere; // Leave the UDP sockets open on timeout so we can keep listening for // a late response from this server while retrying on the next server. Loading @@ -1052,6 +1063,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int int resplen = recvfrom(fd, (char*)ans, (size_t)anssiz, 0, (sockaddr*)(void*)&from, &fromlen); if (resplen <= 0) { *terrno = errno; PLOG(DEBUG) << __func__ << ": recvfrom: "; continue; } Loading Loading @@ -1080,6 +1092,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int res_pquery(ans, (resplen > anssiz) ? anssiz : resplen); // record the error statp->_flags |= RES_F_EDNS0ERR; *terrno = EREMOTEIO; continue; } Loading @@ -1095,6 +1108,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int // To get the rest of answer, // use TCP with same server. LOG(DEBUG) << __func__ << ": truncated answer"; *terrno = E2BIG; *v_circuit = 1; return 1; } Loading @@ -1103,6 +1117,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int *rcode = anhp->rcode; *ns = receivedFromNs; *terrno = 0; return resplen; } if (!needRetry) return 0; Loading resolv_unit_test.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -410,6 +410,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -421,6 +422,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -432,6 +434,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -443,6 +446,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, } ] } Loading Loading @@ -486,6 +490,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -496,6 +501,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading @@ -515,6 +521,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -525,6 +532,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading Loading @@ -660,6 +668,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -670,6 +679,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -680,6 +690,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -690,6 +701,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -700,6 +712,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -710,6 +723,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -720,6 +734,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -730,6 +745,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -740,6 +756,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -750,6 +767,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -760,6 +778,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -770,6 +789,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -780,6 +800,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -790,6 +811,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -800,6 +822,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -810,6 +833,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, ] } Loading Loading @@ -1002,6 +1026,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 7, }, { rcode: 0, Loading @@ -1012,6 +1037,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -1022,6 +1048,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading @@ -1041,6 +1068,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 7, }, { rcode: 0, Loading @@ -1051,6 +1079,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -1061,6 +1090,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading Loading @@ -1128,6 +1158,7 @@ TEST_F(GetHostByNameForNetContextTest, AlphabeticalHostname) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, } ] } Loading @@ -1148,6 +1179,7 @@ TEST_F(GetHostByNameForNetContextTest, AlphabeticalHostname) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, } ] } Loading tests/resolv_stats_test_utils.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,8 @@ NetworkDnsEventReported fromNetworkDnsEventReportedStr(const std::string& str) { dnsQueryEvent->set_connected(static_cast<bool>(value)); } else if (protoField[1] == "latency_micros" && ParseInt(protoField[2], &value)) { dnsQueryEvent->set_latency_micros(value); } else if (protoField[1] == "linux_errno" && ParseInt(protoField[2], &value)) { dnsQueryEvent->set_linux_errno(static_cast<LinuxErrno>(value)); } } } Loading @@ -153,6 +155,7 @@ void PrintTo(const DnsQueryEvent& event, std::ostream* os) { *os << " dns_server_index: " << event.dns_server_index() << "\n"; *os << " connected: " << event.connected() << "\n"; *os << " latency_micros: " << event.latency_micros() << "\n"; *os << " linux_errno: " << event.linux_errno() << "\n"; *os << "}"; } Loading tests/resolv_stats_test_utils.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ MATCHER_P(DnsQueryEventEq, other, "") { // Removing the latency check, because we can't predict the time. /* ::testing::Property("latency_micros", &DnsQueryEvent::latency_micros, ::testing::Eq(other.latency_micros())),*/ ::testing::Property("linux_errno", &DnsQueryEvent::linux_errno, ::testing::Eq(other.linux_errno())), ::testing::Property("connected", &DnsQueryEvent::connected, ::testing::Eq(other.connected()))), arg, result_listener); Loading Loading
res_send.cpp +22 −7 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ using android::net::IpVersion; using android::net::IV_IPV4; using android::net::IV_IPV6; using android::net::IV_UNKNOWN; using android::net::LinuxErrno; using android::net::NetworkDnsEventReported; using android::net::NS_T_INVALID; using android::net::NsRcode; Loading Loading @@ -499,7 +500,8 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int int retryTimes = (flags & ANDROID_RESOLV_NO_RETRY) ? 1 : params.retry_count; int useTcp = buflen > PACKETSZ; int gotsomewhere = 0; int terrno = ETIMEDOUT; // Use an impossible error code as default value int terrno = ETIME; for (int attempt = 0; attempt < retryTimes; ++attempt) { for (size_t ns = 0; ns < statp->nsaddrs.size(); ++ns) { Loading @@ -521,6 +523,8 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int Stopwatch queryStopwatch; int retry_count_for_event = 0; size_t actualNs = ns; // Use an impossible error code as default value terrno = ETIME; if (useTcp) { // TCP; at most one attempt per server. attempt = retryTimes; Loading Loading @@ -558,6 +562,7 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int dnsQueryEvent->set_rcode(static_cast<NsRcode>(*rcode)); dnsQueryEvent->set_protocol(query_proto); dnsQueryEvent->set_type(getQueryType(buf, buflen)); dnsQueryEvent->set_linux_errno(static_cast<LinuxErrno>(terrno)); // Only record stats the first time we try a query. This ensures that // queries that deterministically fail (e.g., a name that always returns Loading Loading @@ -643,6 +648,7 @@ static int send_vc(res_state statp, res_params* params, const uint8_t* buf, int // It should never happen, but just in case. if (ns >= statp->nsaddrs.size()) { LOG(ERROR) << __func__ << ": Out-of-bound indexing: " << ns; *terrno = EINVAL; return -1; } Loading Loading @@ -675,15 +681,14 @@ same_ns: statp->tcp_nssock.reset(socket(nsap->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)); if (statp->tcp_nssock < 0) { *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(vc): "; switch (errno) { case EPROTONOSUPPORT: case EPFNOSUPPORT: case EAFNOSUPPORT: PLOG(DEBUG) << __func__ << ": socket(vc): "; return 0; default: *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(vc): "; return -1; } } Loading Loading @@ -831,6 +836,7 @@ read_len: *delay = res_stats_calculate_rtt(&done, &start_time); *rcode = anhp->rcode; } *terrno = 0; return (resplen); } Loading Loading @@ -972,6 +978,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int // It should never happen, but just in case. if (*ns >= statp->nsaddrs.size()) { LOG(ERROR) << __func__ << ": Out-of-bound indexing: " << ns; *terrno = EINVAL; return -1; } Loading @@ -984,15 +991,14 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int if (statp->nssocks[*ns] == -1) { statp->nssocks[*ns].reset(socket(nsap->sa_family, SOCK_DGRAM | SOCK_CLOEXEC, 0)); if (statp->nssocks[*ns] < 0) { *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(dg): "; switch (errno) { case EPROTONOSUPPORT: case EPFNOSUPPORT: case EAFNOSUPPORT: PLOG(DEBUG) << __func__ << ": socket(dg): "; return (0); default: *terrno = errno; PLOG(DEBUG) << __func__ << ": socket(dg): "; return (-1); } } Loading @@ -1001,6 +1007,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int if (statp->_mark != MARK_UNSET) { if (setsockopt(statp->nssocks[*ns], SOL_SOCKET, SO_MARK, &(statp->_mark), sizeof(statp->_mark)) < 0) { *terrno = errno; statp->closeSockets(); return -1; } Loading @@ -1010,11 +1017,13 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int // ICMP port-unreachable error. This way we can detect the absence of // a nameserver without timing out. if (random_bind(statp->nssocks[*ns], nsap->sa_family) < 0) { *terrno = errno; dump_error("bind(dg)", nsap, nsaplen); statp->closeSockets(); return (0); } if (connect(statp->nssocks[*ns], nsap, (socklen_t)nsaplen) < 0) { *terrno = errno; dump_error("connect(dg)", nsap, nsaplen); statp->closeSockets(); return (0); Loading @@ -1022,6 +1031,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int LOG(DEBUG) << __func__ << ": new DG socket"; } if (send(statp->nssocks[*ns], (const char*)buf, (size_t)buflen, 0) != buflen) { *terrno = errno; PLOG(DEBUG) << __func__ << ": send: "; statp->closeSockets(); return 0; Loading @@ -1037,6 +1047,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int if (!result.has_value()) { const bool isTimeout = (result.error().code() == ETIMEDOUT); *rcode = (isTimeout) ? RCODE_TIMEOUT : *rcode; *terrno = (isTimeout) ? ETIMEDOUT : errno; *gotsomewhere = (isTimeout) ? 1 : *gotsomewhere; // Leave the UDP sockets open on timeout so we can keep listening for // a late response from this server while retrying on the next server. Loading @@ -1052,6 +1063,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int int resplen = recvfrom(fd, (char*)ans, (size_t)anssiz, 0, (sockaddr*)(void*)&from, &fromlen); if (resplen <= 0) { *terrno = errno; PLOG(DEBUG) << __func__ << ": recvfrom: "; continue; } Loading Loading @@ -1080,6 +1092,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int res_pquery(ans, (resplen > anssiz) ? anssiz : resplen); // record the error statp->_flags |= RES_F_EDNS0ERR; *terrno = EREMOTEIO; continue; } Loading @@ -1095,6 +1108,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int // To get the rest of answer, // use TCP with same server. LOG(DEBUG) << __func__ << ": truncated answer"; *terrno = E2BIG; *v_circuit = 1; return 1; } Loading @@ -1103,6 +1117,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int *rcode = anhp->rcode; *ns = receivedFromNs; *terrno = 0; return resplen; } if (!needRetry) return 0; Loading
resolv_unit_test.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -410,6 +410,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -421,6 +422,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -432,6 +434,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -443,6 +446,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname_NoData) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, } ] } Loading Loading @@ -486,6 +490,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -496,6 +501,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading @@ -515,6 +521,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -525,6 +532,7 @@ TEST_F(ResolvGetAddrInfoTest, AlphabeticalHostname) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading Loading @@ -660,6 +668,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -670,6 +679,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -680,6 +690,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -690,6 +701,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -700,6 +712,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -710,6 +723,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -720,6 +734,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -730,6 +745,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -740,6 +756,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -750,6 +767,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -760,6 +778,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -770,6 +789,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -780,6 +800,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -790,6 +811,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, } { rcode: 255, Loading @@ -800,6 +822,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 110, }, { rcode: 255, Loading @@ -810,6 +833,7 @@ TEST_F(ResolvGetAddrInfoTest, ServerTimeout) { retry_times: 1, dns_server_index: 0, connected: 0, linux_errno: 110, }, ] } Loading Loading @@ -1002,6 +1026,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 7, }, { rcode: 0, Loading @@ -1012,6 +1037,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -1022,6 +1048,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading @@ -1041,6 +1068,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 7, }, { rcode: 0, Loading @@ -1051,6 +1079,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, }, { rcode: 0, Loading @@ -1061,6 +1090,7 @@ TEST_F(ResolvGetAddrInfoTest, TruncatedResponse) { retry_times: 0, dns_server_index: 0, connected: 0, linux_errno: 0, } ] } Loading Loading @@ -1128,6 +1158,7 @@ TEST_F(GetHostByNameForNetContextTest, AlphabeticalHostname) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, } ] } Loading @@ -1148,6 +1179,7 @@ TEST_F(GetHostByNameForNetContextTest, AlphabeticalHostname) { dns_server_index: 0, connected: 0, latency_micros: 0, linux_errno: 0, } ] } Loading
tests/resolv_stats_test_utils.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,8 @@ NetworkDnsEventReported fromNetworkDnsEventReportedStr(const std::string& str) { dnsQueryEvent->set_connected(static_cast<bool>(value)); } else if (protoField[1] == "latency_micros" && ParseInt(protoField[2], &value)) { dnsQueryEvent->set_latency_micros(value); } else if (protoField[1] == "linux_errno" && ParseInt(protoField[2], &value)) { dnsQueryEvent->set_linux_errno(static_cast<LinuxErrno>(value)); } } } Loading @@ -153,6 +155,7 @@ void PrintTo(const DnsQueryEvent& event, std::ostream* os) { *os << " dns_server_index: " << event.dns_server_index() << "\n"; *os << " connected: " << event.connected() << "\n"; *os << " latency_micros: " << event.latency_micros() << "\n"; *os << " linux_errno: " << event.linux_errno() << "\n"; *os << "}"; } Loading
tests/resolv_stats_test_utils.h +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ MATCHER_P(DnsQueryEventEq, other, "") { // Removing the latency check, because we can't predict the time. /* ::testing::Property("latency_micros", &DnsQueryEvent::latency_micros, ::testing::Eq(other.latency_micros())),*/ ::testing::Property("linux_errno", &DnsQueryEvent::linux_errno, ::testing::Eq(other.linux_errno())), ::testing::Property("connected", &DnsQueryEvent::connected, ::testing::Eq(other.connected()))), arg, result_listener); Loading