DivestOS/Patches/LineageOS-14.1/android_system_netd/264479.patch

130 lines
4.8 KiB
Diff

From 73e902f57aae15f4d79ed57f46326fb5a0136c94 Mon Sep 17 00:00:00 2001
From: Erik Kline <ek@google.com>
Date: Thu, 24 Nov 2016 08:30:34 +0900
Subject: [PATCH] Cache flushing no longer occurs updating DNS for a single
netid
Test: runtest netd_integration_test.cpp
Bug: 32517984
Change-Id: I6a82824ab423a07797291e7b4701350c88809117
---
tests/netd_test.cpp | 102 ++++++++++++++++++++++----------------------
1 file changed, 51 insertions(+), 51 deletions(-)
diff --git a/tests/netd_test.cpp b/tests/netd_test.cpp
index a958cd90..97a96b9a 100644
--- a/tests/netd_test.cpp
+++ b/tests/netd_test.cpp
@@ -386,60 +386,60 @@ TEST_F(ResolverTest, GetAddrInfo) {
dns2.addMapping(host_name, ns_type::ns_t_aaaa, "::1.2.3.4");
ASSERT_TRUE(dns2.startServer());
- for (size_t i = 0 ; i < 1000 ; ++i) {
- std::vector<std::string> servers = { listen_addr };
- ASSERT_TRUE(SetResolversForNetwork(mDefaultSearchDomains, servers, mDefaultParams));
- dns.clearQueries();
- dns2.clearQueries();
-
- EXPECT_EQ(0, getaddrinfo("howdy", nullptr, nullptr, &result));
- size_t found = GetNumQueries(dns, host_name);
- EXPECT_LE(1U, found);
- // Could be A or AAAA
- std::string result_str = ToString(result);
- EXPECT_TRUE(result_str == "1.2.3.4" || result_str == "::1.2.3.4")
- << ", result_str='" << result_str << "'";
- // TODO: Use ScopedAddrinfo or similar once it is available in a common header file.
- if (result) {
- freeaddrinfo(result);
- result = nullptr;
- }
- // Verify that the name is cached.
- size_t old_found = found;
- EXPECT_EQ(0, getaddrinfo("howdy", nullptr, nullptr, &result));
- found = GetNumQueries(dns, host_name);
- EXPECT_LE(1U, found);
- EXPECT_EQ(old_found, found);
- result_str = ToString(result);
- EXPECT_TRUE(result_str == "1.2.3.4" || result_str == "::1.2.3.4")
- << result_str;
- if (result) {
- freeaddrinfo(result);
- result = nullptr;
- }
+ std::vector<std::string> servers = { listen_addr };
+ ASSERT_TRUE(SetResolversForNetwork(mDefaultSearchDomains, servers, mDefaultParams));
+ dns.clearQueries();
+ dns2.clearQueries();
+
+ EXPECT_EQ(0, getaddrinfo("howdy", nullptr, nullptr, &result));
+ size_t found = GetNumQueries(dns, host_name);
+ EXPECT_LE(1U, found);
+ // Could be A or AAAA
+ std::string result_str = ToString(result);
+ EXPECT_TRUE(result_str == "1.2.3.4" || result_str == "::1.2.3.4")
+ << ", result_str='" << result_str << "'";
+ // TODO: Use ScopedAddrinfo or similar once it is available in a common header file.
+ if (result) {
+ freeaddrinfo(result);
+ result = nullptr;
+ }
- // Change the DNS resolver, ensure that queries are no longer cached.
- servers = { listen_addr2 };
- ASSERT_TRUE(SetResolversForNetwork(mDefaultSearchDomains, servers, mDefaultParams));
- dns.clearQueries();
- dns2.clearQueries();
-
- EXPECT_EQ(0, getaddrinfo("howdy", nullptr, nullptr, &result));
- found = GetNumQueries(dns, host_name);
- size_t found2 = GetNumQueries(dns2, host_name);
- EXPECT_EQ(0U, found);
- EXPECT_LE(1U, found2);
-
- // Could be A or AAAA
- result_str = ToString(result);
- EXPECT_TRUE(result_str == "1.2.3.4" || result_str == "::1.2.3.4")
- << ", result_str='" << result_str << "'";
- if (result) {
- freeaddrinfo(result);
- result = nullptr;
- }
+ // Verify that the name is cached.
+ size_t old_found = found;
+ EXPECT_EQ(0, getaddrinfo("howdy", nullptr, nullptr, &result));
+ found = GetNumQueries(dns, host_name);
+ EXPECT_LE(1U, found);
+ EXPECT_EQ(old_found, found);
+ result_str = ToString(result);
+ EXPECT_TRUE(result_str == "1.2.3.4" || result_str == "::1.2.3.4")
+ << result_str;
+ if (result) {
+ freeaddrinfo(result);
+ result = nullptr;
}
+
+ // Change the DNS resolver, ensure that queries are still cached.
+ servers = { listen_addr2 };
+ ASSERT_TRUE(SetResolversForNetwork(mDefaultSearchDomains, servers, mDefaultParams));
+ dns.clearQueries();
+ dns2.clearQueries();
+
+ EXPECT_EQ(0, getaddrinfo("howdy", nullptr, nullptr, &result));
+ found = GetNumQueries(dns, host_name);
+ size_t found2 = GetNumQueries(dns2, host_name);
+ EXPECT_EQ(0U, found);
+ EXPECT_LE(0U, found2);
+
+ // Could be A or AAAA
+ result_str = ToString(result);
+ EXPECT_TRUE(result_str == "1.2.3.4" || result_str == "::1.2.3.4")
+ << ", result_str='" << result_str << "'";
+ if (result) {
+ freeaddrinfo(result);
+ result = nullptr;
+ }
+
dns.stopServer();
dns2.stopServer();
}