Loading res_send.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -542,7 +542,7 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int // SERVFAIL or times out) do not unduly affect the stats. if (shouldRecordStats) { res_sample sample; _res_stats_set_sample(&sample, now, *rcode, delay); res_stats_set_sample(&sample, now, *rcode, delay); resolv_cache_add_resolver_stats_sample(statp->netid, revision_id, serverSockAddr, sample, params.max_samples); resolv_stats_add(statp->netid, serverSockAddr, dnsQueryEvent); Loading Loading @@ -803,7 +803,7 @@ read_len: */ if (resplen > 0) { struct timespec done = evNowTime(); *delay = _res_stats_calculate_rtt(&done, &now); *delay = res_stats_calculate_rtt(&done, &now); *rcode = anhp->rcode; } return (resplen); Loading Loading @@ -1012,7 +1012,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int } timespec done = evNowTime(); *delay = _res_stats_calculate_rtt(&done, &now); *delay = res_stats_calculate_rtt(&done, &now); if (anhp->rcode == SERVFAIL || anhp->rcode == NOTIMP || anhp->rcode == REFUSED) { LOG(DEBUG) << __func__ << ": server rejected query:"; res_pquery(ans, (resplen > anssiz) ? anssiz : resplen); Loading res_stats.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ #include "stats.h" // Calculate the round-trip-time from start time t0 and end time t1. int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0) { int res_stats_calculate_rtt(const timespec* t1, const timespec* t0) { // Divide ns by one million to get ms, multiply s by thousand to get ms (obvious) long ms0 = t0->tv_sec * 1000 + t0->tv_nsec / 1000000; long ms1 = t1->tv_sec * 1000 + t1->tv_nsec / 1000000; Loading @@ -32,7 +32,7 @@ int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0) { } // Create a sample for calculating server reachability statistics. void _res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt) { void res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt) { LOG(INFO) << __func__ << ": rcode = " << rcode << ", sec = " << rtt; sample->at = now; sample->rcode = rcode; Loading resolv_cache.h +15 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include "ResolverStats.h" #include "params.h" #include "stats.h" // Sets the name server addresses to the provided ResState. // The name servers are retrieved from the cache which is associated Loading Loading @@ -115,3 +116,17 @@ void resolv_stats_dump(android::netdutils::DumpWriter& dw, unsigned netid); void resolv_oem_options_dump(android::netdutils::DumpWriter& dw, unsigned netid); const char* tc_mode_to_str(const int mode); /* Retrieve a local copy of the stats for the given netid. The buffer must have space for * MAXNS __resolver_stats. Returns the revision id of the resolvers used. */ int resolv_cache_get_resolver_stats( unsigned netid, res_params* params, res_stats stats[MAXNS], const std::vector<android::netdutils::IPSockAddr>& serverSockAddrs); /* Add a sample to the shared struct for the given netid and server, provided that the * revision_id of the stored servers has not changed. */ void resolv_cache_add_resolver_stats_sample(unsigned netid, int revision_id, const android::netdutils::IPSockAddr& serverSockAddr, const res_sample& sample, int max_samples); resolv_private.h +0 −23 Original line number Diff line number Diff line Loading @@ -55,12 +55,9 @@ #include <string> #include <vector> #include <netdutils/InternetAddresses.h> #include "DnsResolver.h" #include "netd_resolv/resolv.h" #include "params.h" #include "stats.h" #include "stats.pb.h" // Linux defines MAXHOSTNAMELEN as 64, while the domain name limit in Loading Loading @@ -119,26 +116,6 @@ struct ResState { // TODO: remove these legacy aliases typedef ResState* res_state; /* Retrieve a local copy of the stats for the given netid. The buffer must have space for * MAXNS res_stats. Returns the revision id of the resolvers used or -1 on failure. */ int resolv_cache_get_resolver_stats( unsigned netid, res_params* params, res_stats stats[MAXNS], const std::vector<android::netdutils::IPSockAddr>& serverSockAddrs); /* Add a sample to the shared struct for the given netid and server, provided that the * revision_id of the stored servers has not changed. */ void resolv_cache_add_resolver_stats_sample(unsigned netid, int revision_id, const android::netdutils::IPSockAddr& serverSockAddr, const res_sample& sample, int max_samples); // Calculate the round-trip-time from start time t0 and end time t1. int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0); // Create a sample for calculating server reachability statistics. void _res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt); /* End of stats related definitions */ /* Loading stats.h +6 −0 Original line number Diff line number Diff line Loading @@ -55,3 +55,9 @@ int android_net_res_stats_get_info_for_net(unsigned netid, int* nscount, // Returns an array of bools indicating which servers are considered good int android_net_res_stats_get_usable_servers(const res_params* params, res_stats stats[], int nscount, bool valid_servers[]); // Calculate the round-trip-time from start time t0 and end time t1. int res_stats_calculate_rtt(const timespec* t1, const timespec* t0); // Create a sample for calculating server reachability statistics. void res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt); Loading
res_send.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -542,7 +542,7 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int // SERVFAIL or times out) do not unduly affect the stats. if (shouldRecordStats) { res_sample sample; _res_stats_set_sample(&sample, now, *rcode, delay); res_stats_set_sample(&sample, now, *rcode, delay); resolv_cache_add_resolver_stats_sample(statp->netid, revision_id, serverSockAddr, sample, params.max_samples); resolv_stats_add(statp->netid, serverSockAddr, dnsQueryEvent); Loading Loading @@ -803,7 +803,7 @@ read_len: */ if (resplen > 0) { struct timespec done = evNowTime(); *delay = _res_stats_calculate_rtt(&done, &now); *delay = res_stats_calculate_rtt(&done, &now); *rcode = anhp->rcode; } return (resplen); Loading Loading @@ -1012,7 +1012,7 @@ static int send_dg(res_state statp, res_params* params, const uint8_t* buf, int } timespec done = evNowTime(); *delay = _res_stats_calculate_rtt(&done, &now); *delay = res_stats_calculate_rtt(&done, &now); if (anhp->rcode == SERVFAIL || anhp->rcode == NOTIMP || anhp->rcode == REFUSED) { LOG(DEBUG) << __func__ << ": server rejected query:"; res_pquery(ans, (resplen > anssiz) ? anssiz : resplen); Loading
res_stats.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ #include "stats.h" // Calculate the round-trip-time from start time t0 and end time t1. int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0) { int res_stats_calculate_rtt(const timespec* t1, const timespec* t0) { // Divide ns by one million to get ms, multiply s by thousand to get ms (obvious) long ms0 = t0->tv_sec * 1000 + t0->tv_nsec / 1000000; long ms1 = t1->tv_sec * 1000 + t1->tv_nsec / 1000000; Loading @@ -32,7 +32,7 @@ int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0) { } // Create a sample for calculating server reachability statistics. void _res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt) { void res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt) { LOG(INFO) << __func__ << ": rcode = " << rcode << ", sec = " << rtt; sample->at = now; sample->rcode = rcode; Loading
resolv_cache.h +15 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include "ResolverStats.h" #include "params.h" #include "stats.h" // Sets the name server addresses to the provided ResState. // The name servers are retrieved from the cache which is associated Loading Loading @@ -115,3 +116,17 @@ void resolv_stats_dump(android::netdutils::DumpWriter& dw, unsigned netid); void resolv_oem_options_dump(android::netdutils::DumpWriter& dw, unsigned netid); const char* tc_mode_to_str(const int mode); /* Retrieve a local copy of the stats for the given netid. The buffer must have space for * MAXNS __resolver_stats. Returns the revision id of the resolvers used. */ int resolv_cache_get_resolver_stats( unsigned netid, res_params* params, res_stats stats[MAXNS], const std::vector<android::netdutils::IPSockAddr>& serverSockAddrs); /* Add a sample to the shared struct for the given netid and server, provided that the * revision_id of the stored servers has not changed. */ void resolv_cache_add_resolver_stats_sample(unsigned netid, int revision_id, const android::netdutils::IPSockAddr& serverSockAddr, const res_sample& sample, int max_samples);
resolv_private.h +0 −23 Original line number Diff line number Diff line Loading @@ -55,12 +55,9 @@ #include <string> #include <vector> #include <netdutils/InternetAddresses.h> #include "DnsResolver.h" #include "netd_resolv/resolv.h" #include "params.h" #include "stats.h" #include "stats.pb.h" // Linux defines MAXHOSTNAMELEN as 64, while the domain name limit in Loading Loading @@ -119,26 +116,6 @@ struct ResState { // TODO: remove these legacy aliases typedef ResState* res_state; /* Retrieve a local copy of the stats for the given netid. The buffer must have space for * MAXNS res_stats. Returns the revision id of the resolvers used or -1 on failure. */ int resolv_cache_get_resolver_stats( unsigned netid, res_params* params, res_stats stats[MAXNS], const std::vector<android::netdutils::IPSockAddr>& serverSockAddrs); /* Add a sample to the shared struct for the given netid and server, provided that the * revision_id of the stored servers has not changed. */ void resolv_cache_add_resolver_stats_sample(unsigned netid, int revision_id, const android::netdutils::IPSockAddr& serverSockAddr, const res_sample& sample, int max_samples); // Calculate the round-trip-time from start time t0 and end time t1. int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0); // Create a sample for calculating server reachability statistics. void _res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt); /* End of stats related definitions */ /* Loading
stats.h +6 −0 Original line number Diff line number Diff line Loading @@ -55,3 +55,9 @@ int android_net_res_stats_get_info_for_net(unsigned netid, int* nscount, // Returns an array of bools indicating which servers are considered good int android_net_res_stats_get_usable_servers(const res_params* params, res_stats stats[], int nscount, bool valid_servers[]); // Calculate the round-trip-time from start time t0 and end time t1. int res_stats_calculate_rtt(const timespec* t1, const timespec* t0); // Create a sample for calculating server reachability statistics. void res_stats_set_sample(res_sample* sample, time_t now, int rcode, int rtt);