Loading Experiments.h +1 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ class Experiments { "parallel_lookup_sleep_time", "retransmission_time_interval", "retry_count", "skip_4a_query_on_v6_linklocal_addr", "sort_nameservers", }; // This value is used in updateInternal as the default value if any flags can't be found. Loading PrivateDnsConfiguration.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -193,6 +193,7 @@ PrivateDnsStatus PrivateDnsConfiguration::getStatusLocked(unsigned netId) const } NetworkDnsServerSupportReported PrivateDnsConfiguration::getStatusForMetrics(unsigned netId) const { const auto networkType = resolv_get_network_types_for_net(netId); std::lock_guard guard(mPrivateDnsLock); if (mPrivateDnsModes.find(netId) == mPrivateDnsModes.end()) { Loading @@ -202,7 +203,7 @@ NetworkDnsServerSupportReported PrivateDnsConfiguration::getStatusForMetrics(uns const PrivateDnsStatus status = getStatusLocked(netId); NetworkDnsServerSupportReported event = {}; event.set_network_type(resolv_get_network_types_for_net(netId)); event.set_network_type(networkType); event.set_private_dns_modes(convertEnumType(status.mode)); if (const auto it = mUnorderedDnsTracker.find(netId); it != mUnorderedDnsTracker.end()) { Loading getaddrinfo.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ #define ANY 0 using android::net::Experiments; using android::net::NetworkDnsEventReported; const char in_addrany[] = {0, 0, 0, 0}; Loading Loading @@ -1312,7 +1313,8 @@ static int _find_src_addr(const struct sockaddr* addr, struct sockaddr* src_addr return -1; } if (src_addr->sa_family == AF_INET6) { if (Experiments::getInstance()->getFlag("skip_4a_query_on_v6_linklocal_addr", 1) && src_addr->sa_family == AF_INET6) { sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(src_addr); if (!allow_v6_linklocal && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { return 0; Loading Loading @@ -1666,8 +1668,8 @@ static int res_queryN_parallel(const char* name, res_target* target, ResState* r // Avoiding gateways drop packets if queries are sent too close together // Only needed if we have multiple queries in a row. if (t->next) { int sleepFlag = android::net::Experiments::getInstance()->getFlag( "parallel_lookup_sleep_time", SLEEP_TIME_MS); int sleepFlag = Experiments::getInstance()->getFlag("parallel_lookup_sleep_time", SLEEP_TIME_MS); if (sleepFlag > 1000) sleepFlag = 1000; sleepTimeMs = std::chrono::milliseconds(sleepFlag); } Loading Loading @@ -1697,8 +1699,7 @@ static int res_queryN_parallel(const char* name, res_target* target, ResState* r } static int res_queryN_wrapper(const char* name, res_target* target, ResState* res, int* herrno) { const bool parallel_lookup = android::net::Experiments::getInstance()->getFlag("parallel_lookup_release", 1); const bool parallel_lookup = Experiments::getInstance()->getFlag("parallel_lookup_release", 1); if (parallel_lookup) return res_queryN_parallel(name, target, res, herrno); return res_queryN(name, target, res, herrno); Loading tests/dns_responder/dns_tls_frontend.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -306,10 +306,12 @@ again: // Poll again because the same DoT probe might be sent again. if (isDotProbe && queryCounts == 1) { int n = poll(&fds, 1, 50); const int timeoutMs = 500; int n = poll(&fds, 1, timeoutMs); if (n > 0 && fds.revents & POLLIN) { goto again; } LOG(WARNING) << "Did not receive the second DoT probe within " << timeoutMs << "ms"; } LOG(DEBUG) << __func__ << " return: " << queryCounts; Loading tests/resolv_integration_test.cpp +43 −1 Original line number Diff line number Diff line Loading @@ -4627,7 +4627,7 @@ TEST_F(ResolverTest, ConnectTlsServerTimeout) { EXPECT_EQ(1U, GetNumQueries(dns, hostname2)); EXPECT_EQ(records.at(1).addr, ToString(result)); EXPECT_LE(timeTakenMs, 200); EXPECT_LE(timeTakenMs, 1000); } // TODO: Remove it after b/254186357 is clarified. Loading Loading @@ -7666,6 +7666,48 @@ TEST_F(ResolverMultinetworkTest, IPv6LinkLocalWithDefaultRoute) { EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_aaaa, host_name), 1U); } // Test if the "do not send AAAA query when IPv6 address is link-local with a default route" feature // can be toggled by flag. TEST_F(ResolverMultinetworkTest, IPv6LinkLocalWithDefaultRouteFlag) { constexpr char host_name[] = "ohayou.example.com."; const struct TestConfig { std::string flagValue; std::vector<std::string> ips; unsigned numOfQuadAQuery; } TestConfigs[]{{"0", {"192.0.2.0", "2001:db8:cafe:d00d::31"}, 1U}, {"1", {"192.0.2.0"}, 0U}}; for (const auto& config : TestConfigs) { SCOPED_TRACE(fmt::format("flagValue = {}, numOfQuadAQuery = {}", config.flagValue, config.numOfQuadAQuery)); ScopedSystemProperties sp1(kSkip4aQueryOnV6LinklocalAddrFlag, config.flagValue); ScopedPhysicalNetwork network = CreateScopedPhysicalNetwork(ConnectivityType::V4); ASSERT_RESULT_OK(network.init()); // Add IPv6 default route ASSERT_TRUE(mDnsClient.netdService() ->networkAddRoute(network.netId(), network.ifname(), "::/0", "") .isOk()); const Result<DnsServerPair> dnsPair = network.addIpv4Dns(); ASSERT_RESULT_OK(dnsPair); StartDns(*dnsPair->dnsServer, {{host_name, ns_type::ns_t_a, "192.0.2.0"}, {host_name, ns_type::ns_t_aaaa, "2001:db8:cafe:d00d::31"}}); ASSERT_TRUE(network.setDnsConfiguration()); ASSERT_TRUE(network.startTunForwarder()); auto result = android_getaddrinfofornet_wrapper(host_name, network.netId()); ASSERT_RESULT_OK(result); ScopedAddrinfo ai_results(std::move(result.value())); std::vector<std::string> result_strs = ToStrings(ai_results); EXPECT_THAT(result_strs, testing::UnorderedElementsAreArray(config.ips)); EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_a, host_name), 1U); EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_aaaa, host_name), config.numOfQuadAQuery); } } // v6 mdns is expected to be sent when the IPv6 address is a link-local with a default route. TEST_F(ResolverMultinetworkTest, MdnsIPv6LinkLocalWithDefaultRoute) { // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a Loading Loading
Experiments.h +1 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ class Experiments { "parallel_lookup_sleep_time", "retransmission_time_interval", "retry_count", "skip_4a_query_on_v6_linklocal_addr", "sort_nameservers", }; // This value is used in updateInternal as the default value if any flags can't be found. Loading
PrivateDnsConfiguration.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -193,6 +193,7 @@ PrivateDnsStatus PrivateDnsConfiguration::getStatusLocked(unsigned netId) const } NetworkDnsServerSupportReported PrivateDnsConfiguration::getStatusForMetrics(unsigned netId) const { const auto networkType = resolv_get_network_types_for_net(netId); std::lock_guard guard(mPrivateDnsLock); if (mPrivateDnsModes.find(netId) == mPrivateDnsModes.end()) { Loading @@ -202,7 +203,7 @@ NetworkDnsServerSupportReported PrivateDnsConfiguration::getStatusForMetrics(uns const PrivateDnsStatus status = getStatusLocked(netId); NetworkDnsServerSupportReported event = {}; event.set_network_type(resolv_get_network_types_for_net(netId)); event.set_network_type(networkType); event.set_private_dns_modes(convertEnumType(status.mode)); if (const auto it = mUnorderedDnsTracker.find(netId); it != mUnorderedDnsTracker.end()) { Loading
getaddrinfo.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ #define ANY 0 using android::net::Experiments; using android::net::NetworkDnsEventReported; const char in_addrany[] = {0, 0, 0, 0}; Loading Loading @@ -1312,7 +1313,8 @@ static int _find_src_addr(const struct sockaddr* addr, struct sockaddr* src_addr return -1; } if (src_addr->sa_family == AF_INET6) { if (Experiments::getInstance()->getFlag("skip_4a_query_on_v6_linklocal_addr", 1) && src_addr->sa_family == AF_INET6) { sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(src_addr); if (!allow_v6_linklocal && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { return 0; Loading Loading @@ -1666,8 +1668,8 @@ static int res_queryN_parallel(const char* name, res_target* target, ResState* r // Avoiding gateways drop packets if queries are sent too close together // Only needed if we have multiple queries in a row. if (t->next) { int sleepFlag = android::net::Experiments::getInstance()->getFlag( "parallel_lookup_sleep_time", SLEEP_TIME_MS); int sleepFlag = Experiments::getInstance()->getFlag("parallel_lookup_sleep_time", SLEEP_TIME_MS); if (sleepFlag > 1000) sleepFlag = 1000; sleepTimeMs = std::chrono::milliseconds(sleepFlag); } Loading Loading @@ -1697,8 +1699,7 @@ static int res_queryN_parallel(const char* name, res_target* target, ResState* r } static int res_queryN_wrapper(const char* name, res_target* target, ResState* res, int* herrno) { const bool parallel_lookup = android::net::Experiments::getInstance()->getFlag("parallel_lookup_release", 1); const bool parallel_lookup = Experiments::getInstance()->getFlag("parallel_lookup_release", 1); if (parallel_lookup) return res_queryN_parallel(name, target, res, herrno); return res_queryN(name, target, res, herrno); Loading
tests/dns_responder/dns_tls_frontend.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -306,10 +306,12 @@ again: // Poll again because the same DoT probe might be sent again. if (isDotProbe && queryCounts == 1) { int n = poll(&fds, 1, 50); const int timeoutMs = 500; int n = poll(&fds, 1, timeoutMs); if (n > 0 && fds.revents & POLLIN) { goto again; } LOG(WARNING) << "Did not receive the second DoT probe within " << timeoutMs << "ms"; } LOG(DEBUG) << __func__ << " return: " << queryCounts; Loading
tests/resolv_integration_test.cpp +43 −1 Original line number Diff line number Diff line Loading @@ -4627,7 +4627,7 @@ TEST_F(ResolverTest, ConnectTlsServerTimeout) { EXPECT_EQ(1U, GetNumQueries(dns, hostname2)); EXPECT_EQ(records.at(1).addr, ToString(result)); EXPECT_LE(timeTakenMs, 200); EXPECT_LE(timeTakenMs, 1000); } // TODO: Remove it after b/254186357 is clarified. Loading Loading @@ -7666,6 +7666,48 @@ TEST_F(ResolverMultinetworkTest, IPv6LinkLocalWithDefaultRoute) { EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_aaaa, host_name), 1U); } // Test if the "do not send AAAA query when IPv6 address is link-local with a default route" feature // can be toggled by flag. TEST_F(ResolverMultinetworkTest, IPv6LinkLocalWithDefaultRouteFlag) { constexpr char host_name[] = "ohayou.example.com."; const struct TestConfig { std::string flagValue; std::vector<std::string> ips; unsigned numOfQuadAQuery; } TestConfigs[]{{"0", {"192.0.2.0", "2001:db8:cafe:d00d::31"}, 1U}, {"1", {"192.0.2.0"}, 0U}}; for (const auto& config : TestConfigs) { SCOPED_TRACE(fmt::format("flagValue = {}, numOfQuadAQuery = {}", config.flagValue, config.numOfQuadAQuery)); ScopedSystemProperties sp1(kSkip4aQueryOnV6LinklocalAddrFlag, config.flagValue); ScopedPhysicalNetwork network = CreateScopedPhysicalNetwork(ConnectivityType::V4); ASSERT_RESULT_OK(network.init()); // Add IPv6 default route ASSERT_TRUE(mDnsClient.netdService() ->networkAddRoute(network.netId(), network.ifname(), "::/0", "") .isOk()); const Result<DnsServerPair> dnsPair = network.addIpv4Dns(); ASSERT_RESULT_OK(dnsPair); StartDns(*dnsPair->dnsServer, {{host_name, ns_type::ns_t_a, "192.0.2.0"}, {host_name, ns_type::ns_t_aaaa, "2001:db8:cafe:d00d::31"}}); ASSERT_TRUE(network.setDnsConfiguration()); ASSERT_TRUE(network.startTunForwarder()); auto result = android_getaddrinfofornet_wrapper(host_name, network.netId()); ASSERT_RESULT_OK(result); ScopedAddrinfo ai_results(std::move(result.value())); std::vector<std::string> result_strs = ToStrings(ai_results); EXPECT_THAT(result_strs, testing::UnorderedElementsAreArray(config.ips)); EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_a, host_name), 1U); EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_aaaa, host_name), config.numOfQuadAQuery); } } // v6 mdns is expected to be sent when the IPv6 address is a link-local with a default route. TEST_F(ResolverMultinetworkTest, MdnsIPv6LinkLocalWithDefaultRoute) { // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a Loading