Skip to content

Commit

Permalink
DNS filter: set default resolver timeout (#12293)
Browse files Browse the repository at this point in the history
Fix an ASAN failure in certain env. 

Risk Level: low
Testing: n/a
Docs Changes: n/a
Release Notes: n/a
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
  • Loading branch information
lambdai authored Aug 17, 2020
1 parent 51551ae commit 49aedfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion source/extensions/filters/udp/dns_filter/dns_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ DnsFilterEnvoyConfig::DnsFilterEnvoyConfig(
Server::Configuration::ListenerFactoryContext& context,
const envoy::extensions::filters::udp::dns_filter::v3alpha::DnsFilterConfig& config)
: root_scope_(context.scope()), cluster_manager_(context.clusterManager()), api_(context.api()),
stats_(generateStats(config.stat_prefix(), root_scope_)), random_(context.random()) {
stats_(generateStats(config.stat_prefix(), root_scope_)),
resolver_timeout_(DEFAULT_RESOLVER_TIMEOUT), random_(context.random()) {
using envoy::extensions::filters::udp::dns_filter::v3alpha::DnsFilterConfig;

const auto& server_config = config.server_config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class DnsFilterResolver : Logger::Loggable<Logger::Id::filter> {
DnsFilterResolver(DnsFilterResolverCallback& callback, AddressConstPtrVec resolvers,
std::chrono::milliseconds timeout, Event::Dispatcher& dispatcher,
uint64_t max_pending_lookups)
: dispatcher_(dispatcher),
: timeout_(timeout), dispatcher_(dispatcher),
resolver_(dispatcher.createDnsResolver(resolvers, false /* use_tcp_for_dns_lookups */)),
callback_(callback), timeout_(timeout), max_pending_lookups_(max_pending_lookups) {}
callback_(callback), max_pending_lookups_(max_pending_lookups) {}
/**
* @brief entry point to resolve the name in a DnsQueryRecord
*
Expand Down Expand Up @@ -61,10 +61,10 @@ class DnsFilterResolver : Logger::Loggable<Logger::Id::filter> {
*/
void onResolveTimeout();

std::chrono::milliseconds timeout_;
Event::Dispatcher& dispatcher_;
const Network::DnsResolverSharedPtr resolver_;
DnsFilterResolverCallback& callback_;
std::chrono::milliseconds timeout_;
absl::flat_hash_map<const DnsQueryRecord*, LookupContext> lookups_;
uint64_t max_pending_lookups_;
};
Expand Down

0 comments on commit 49aedfd

Please sign in to comment.