Loading DnsProxyListener.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -300,7 +300,14 @@ bool parseQuery(const uint8_t* msg, size_t msgLen, uint16_t* query_id, int* rr_t } void initDnsEvent(NetworkDnsEventReported* event) { // The value 0 has the special meaning of unset/unknown in Westworld atoms. // The value 0 has the special meaning of unset/unknown in Westworld atoms. So, we set both // flags to -1 as default value. // 1. The hints flag is only used in resolv_getaddrinfo. When user set it to -1 in // resolv_getaddrinfo, the flag will cause validation (validateHints) failure in // getaddrinfo, so it will not do DNS query and will upload DNS stats log with // return_code = RC_EAI_BADFLAGS. // 2. The res_nsend flags are only used in resolv_res_nsend. When user set it to -1 in // resolv_res_nsend,res_nsend will do nothing special by the setting. event->set_hints_ai_flags(-1); event->set_res_nsend_flags(-1); } Loading DnsTlsDispatcher.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -97,11 +97,10 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const std::list<DnsTlsServer>& for (const auto& server : orderedServers) { DnsQueryEvent* dnsQueryEvent = statp->event->mutable_dns_query_events()->add_dns_query_event(); dnsQueryEvent->set_rcode(NS_R_INTERNAL_ERROR); Stopwatch query_stopwatch; Stopwatch queryStopwatch; code = this->query(server, statp->_mark, query, ans, resplen); dnsQueryEvent->set_latency_micros(saturate_cast<int32_t>(query_stopwatch.timeTakenUs())); dnsQueryEvent->set_latency_micros(saturate_cast<int32_t>(queryStopwatch.timeTakenUs())); dnsQueryEvent->set_dns_server_index(serverCount++); dnsQueryEvent->set_ip_version(ipFamilyToIPVersion(server.ss.ss_family)); dnsQueryEvent->set_protocol(PROTO_DOT); Loading @@ -113,16 +112,18 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const std::list<DnsTlsServer>& case DnsTlsTransport::Response::success: dnsQueryEvent->set_rcode( static_cast<NsRcode>(reinterpret_cast<HEADER*>(ans.base())->rcode)); [[fallthrough]]; return code; case DnsTlsTransport::Response::limit_error: dnsQueryEvent->set_rcode(NS_R_INTERNAL_ERROR); return code; // These response codes might differ when trying other servers, so // keep iterating to see if we can get a different (better) result. case DnsTlsTransport::Response::network_error: // Sync from res_tls_send in res_send.cpp dnsQueryEvent->set_rcode(NS_R_TIMEOUT); [[fallthrough]]; continue; case DnsTlsTransport::Response::internal_error: dnsQueryEvent->set_rcode(NS_R_INTERNAL_ERROR); continue; // No "default" statement. } Loading res_send.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -416,9 +416,9 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a terrno = ETIMEDOUT; int anslen = 0; Stopwatch cache_stopwatch; Stopwatch cacheStopwatch; cache_status = resolv_cache_lookup(statp->netid, buf, buflen, ans, anssiz, &anslen, flags); const int32_t cacheLatencyUs = saturate_cast<int32_t>(cache_stopwatch.timeTakenUs()); const int32_t cacheLatencyUs = saturate_cast<int32_t>(cacheStopwatch.timeTakenUs()); if (cache_status == RESOLV_CACHE_FOUND) { HEADER* hp = (HEADER*)(void*)ans; *rcode = hp->rcode; Loading Loading @@ -560,7 +560,7 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a LOG(DEBUG) << __func__ << ": Querying server (# " << ns + 1 << ") address = " << abuf; Stopwatch query_stopwatch; Stopwatch queryStopwatch; if (v_circuit) { /* Use VC; at most one attempt per server. */ bool shouldRecordStats = (attempt == 0); Loading @@ -570,7 +570,7 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a &delay); dnsQueryEvent->set_latency_micros( saturate_cast<int32_t>(query_stopwatch.timeTakenUs())); saturate_cast<int32_t>(queryStopwatch.timeTakenUs())); dnsQueryEvent->set_dns_server_index(ns); dnsQueryEvent->set_ip_version(ipFamilyToIPVersion(nsap->sa_family)); dnsQueryEvent->set_retry_times(attempt); Loading Loading @@ -607,7 +607,7 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a &gotsomewhere, &now, rcode, &delay); dnsQueryEvent->set_latency_micros( saturate_cast<int32_t>(query_stopwatch.timeTakenUs())); saturate_cast<int32_t>(queryStopwatch.timeTakenUs())); dnsQueryEvent->set_dns_server_index(ns); dnsQueryEvent->set_ip_version(ipFamilyToIPVersion(nsap->sa_family)); dnsQueryEvent->set_retry_times(attempt); Loading Loading
DnsProxyListener.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -300,7 +300,14 @@ bool parseQuery(const uint8_t* msg, size_t msgLen, uint16_t* query_id, int* rr_t } void initDnsEvent(NetworkDnsEventReported* event) { // The value 0 has the special meaning of unset/unknown in Westworld atoms. // The value 0 has the special meaning of unset/unknown in Westworld atoms. So, we set both // flags to -1 as default value. // 1. The hints flag is only used in resolv_getaddrinfo. When user set it to -1 in // resolv_getaddrinfo, the flag will cause validation (validateHints) failure in // getaddrinfo, so it will not do DNS query and will upload DNS stats log with // return_code = RC_EAI_BADFLAGS. // 2. The res_nsend flags are only used in resolv_res_nsend. When user set it to -1 in // resolv_res_nsend,res_nsend will do nothing special by the setting. event->set_hints_ai_flags(-1); event->set_res_nsend_flags(-1); } Loading
DnsTlsDispatcher.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -97,11 +97,10 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const std::list<DnsTlsServer>& for (const auto& server : orderedServers) { DnsQueryEvent* dnsQueryEvent = statp->event->mutable_dns_query_events()->add_dns_query_event(); dnsQueryEvent->set_rcode(NS_R_INTERNAL_ERROR); Stopwatch query_stopwatch; Stopwatch queryStopwatch; code = this->query(server, statp->_mark, query, ans, resplen); dnsQueryEvent->set_latency_micros(saturate_cast<int32_t>(query_stopwatch.timeTakenUs())); dnsQueryEvent->set_latency_micros(saturate_cast<int32_t>(queryStopwatch.timeTakenUs())); dnsQueryEvent->set_dns_server_index(serverCount++); dnsQueryEvent->set_ip_version(ipFamilyToIPVersion(server.ss.ss_family)); dnsQueryEvent->set_protocol(PROTO_DOT); Loading @@ -113,16 +112,18 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const std::list<DnsTlsServer>& case DnsTlsTransport::Response::success: dnsQueryEvent->set_rcode( static_cast<NsRcode>(reinterpret_cast<HEADER*>(ans.base())->rcode)); [[fallthrough]]; return code; case DnsTlsTransport::Response::limit_error: dnsQueryEvent->set_rcode(NS_R_INTERNAL_ERROR); return code; // These response codes might differ when trying other servers, so // keep iterating to see if we can get a different (better) result. case DnsTlsTransport::Response::network_error: // Sync from res_tls_send in res_send.cpp dnsQueryEvent->set_rcode(NS_R_TIMEOUT); [[fallthrough]]; continue; case DnsTlsTransport::Response::internal_error: dnsQueryEvent->set_rcode(NS_R_INTERNAL_ERROR); continue; // No "default" statement. } Loading
res_send.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -416,9 +416,9 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a terrno = ETIMEDOUT; int anslen = 0; Stopwatch cache_stopwatch; Stopwatch cacheStopwatch; cache_status = resolv_cache_lookup(statp->netid, buf, buflen, ans, anssiz, &anslen, flags); const int32_t cacheLatencyUs = saturate_cast<int32_t>(cache_stopwatch.timeTakenUs()); const int32_t cacheLatencyUs = saturate_cast<int32_t>(cacheStopwatch.timeTakenUs()); if (cache_status == RESOLV_CACHE_FOUND) { HEADER* hp = (HEADER*)(void*)ans; *rcode = hp->rcode; Loading Loading @@ -560,7 +560,7 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a LOG(DEBUG) << __func__ << ": Querying server (# " << ns + 1 << ") address = " << abuf; Stopwatch query_stopwatch; Stopwatch queryStopwatch; if (v_circuit) { /* Use VC; at most one attempt per server. */ bool shouldRecordStats = (attempt == 0); Loading @@ -570,7 +570,7 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a &delay); dnsQueryEvent->set_latency_micros( saturate_cast<int32_t>(query_stopwatch.timeTakenUs())); saturate_cast<int32_t>(queryStopwatch.timeTakenUs())); dnsQueryEvent->set_dns_server_index(ns); dnsQueryEvent->set_ip_version(ipFamilyToIPVersion(nsap->sa_family)); dnsQueryEvent->set_retry_times(attempt); Loading Loading @@ -607,7 +607,7 @@ int res_nsend(res_state statp, const u_char* buf, int buflen, u_char* ans, int a &gotsomewhere, &now, rcode, &delay); dnsQueryEvent->set_latency_micros( saturate_cast<int32_t>(query_stopwatch.timeTakenUs())); saturate_cast<int32_t>(queryStopwatch.timeTakenUs())); dnsQueryEvent->set_dns_server_index(ns); dnsQueryEvent->set_ip_version(ipFamilyToIPVersion(nsap->sa_family)); dnsQueryEvent->set_retry_times(attempt); Loading