Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/common/network/apple_dns_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,6 @@ void AppleDnsResolverImpl::PendingResolution::onDNSServiceGetAddrInfoReply(
"error_code={}, hostname={}",
dns_name_, flags, flags & kDNSServiceFlagsMoreComing ? "yes" : "no",
flags & kDNSServiceFlagsAdd ? "yes" : "no", interface_index, error_code, hostname);
RELEASE_ASSERT(interface_index == 0,
fmt::format("unexpected interface_index={}", interface_index));

if (!pending_cb_) {
pending_cb_ = {ResolutionStatus::Success, {}};
Expand All @@ -326,6 +324,9 @@ void AppleDnsResolverImpl::PendingResolution::onDNSServiceGetAddrInfoReply(
return;
}

RELEASE_ASSERT(interface_index == 0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ENVOY_BUG? I.e. it's fully recoverable.

fmt::format("unexpected interface_index={}", interface_index));

// Only add this address to the list if kDNSServiceFlagsAdd is set. Callback targets are only
// additive.
if (flags & kDNSServiceFlagsAdd) {
Expand Down
15 changes: 15 additions & 0 deletions test/common/network/apple_dns_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ TEST_F(AppleDnsImplTest, DnsIpAddressVersion) {
dispatcher_->run(Event::Dispatcher::RunType::Block);
}

TEST_F(AppleDnsImplTest, DnsIpAddressVersionInvalid) {
EXPECT_NE(nullptr, resolveWithExpectations("invalidDnsName", DnsLookupFamily::Auto,
DnsResolver::ResolutionStatus::Failure, false));
dispatcher_->run(Event::Dispatcher::RunType::Block);

EXPECT_NE(nullptr, resolveWithExpectations("invalidDnsName", DnsLookupFamily::V4Only,
DnsResolver::ResolutionStatus::Failure, false));
dispatcher_->run(Event::Dispatcher::RunType::Block);

EXPECT_NE(nullptr, resolveWithExpectations("invalidDnsName", DnsLookupFamily::V6Only,
DnsResolver::ResolutionStatus::Failure, false));
dispatcher_->run(Event::Dispatcher::RunType::Block);
}

TEST_F(AppleDnsImplTest, CallbackException) {
EXPECT_NE(nullptr, resolveWithException("google.com", DnsLookupFamily::V4Only));
EXPECT_THROW_WITH_MESSAGE(dispatcher_->run(Event::Dispatcher::RunType::Block), EnvoyException,
Expand Down Expand Up @@ -356,6 +370,7 @@ TEST_F(AppleDnsImplFakeApiTest, SynchronousErrorInGetAddrInfo) {
// This callback should never be executed.
FAIL();
}));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}

TEST_F(AppleDnsImplFakeApiTest, QuerySynchronousCompletion) {
Expand Down