Loading Experiments.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -69,7 +69,6 @@ class Experiments { "parallel_lookup_sleep_time", "parallel_lookup_sleep_time", "retransmission_time_interval", "retransmission_time_interval", "retry_count", "retry_count", "skip_4a_query_on_v6_linklocal_addr", "sort_nameservers", "sort_nameservers", }; }; // This value is used in updateInternal as the default value if any flags can't be found. // This value is used in updateInternal as the default value if any flags can't be found. Loading getaddrinfo.cpp +1 −2 Original line number Original line Diff line number Diff line Loading @@ -1310,8 +1310,7 @@ static int _find_src_addr(const struct sockaddr* addr, struct sockaddr* src_addr return -1; return -1; } } if (Experiments::getInstance()->getFlag("skip_4a_query_on_v6_linklocal_addr", 1) && if (src_addr->sa_family == AF_INET6) { src_addr->sa_family == AF_INET6) { sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(src_addr); sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(src_addr); if (!allow_v6_linklocal && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { if (!allow_v6_linklocal && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { // There is no point in sending an AAAA query because the device does not have a global // There is no point in sending an AAAA query because the device does not have a global Loading tests/resolv_integration_test.cpp +0 −49 Original line number Original line Diff line number Diff line Loading @@ -7813,55 +7813,6 @@ TEST_F(ResolverMultinetworkTest, IPv6LinkLocalWithDefaultRoute) { EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_aaaa, host_name), 1U); 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) { // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a // network. Skip it because v6 link-local address is a prerequisite for this test. SKIP_IF_KERNEL_VERSION_LOWER_THAN(4, 9, 0); 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()); // Ensuring that routing is applied. This is required for mainline test (b/257404586). usleep(1000 * 1000); 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. // v6 mdns is expected to be sent when the IPv6 address is a link-local with a default route. TEST_F(ResolverMultinetworkTest, MdnsIPv6LinkLocalWithDefaultRoute) { TEST_F(ResolverMultinetworkTest, MdnsIPv6LinkLocalWithDefaultRoute) { // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a Loading tests/resolv_test_utils.h +0 −2 Original line number Original line Diff line number Diff line Loading @@ -188,8 +188,6 @@ const std::string kKeepListeningUdpFlag(kFlagPrefix + "keep_listening_udp"); const std::string kParallelLookupSleepTimeFlag(kFlagPrefix + "parallel_lookup_sleep_time"); const std::string kParallelLookupSleepTimeFlag(kFlagPrefix + "parallel_lookup_sleep_time"); const std::string kRetransIntervalFlag(kFlagPrefix + "retransmission_time_interval"); const std::string kRetransIntervalFlag(kFlagPrefix + "retransmission_time_interval"); const std::string kRetryCountFlag(kFlagPrefix + "retry_count"); const std::string kRetryCountFlag(kFlagPrefix + "retry_count"); const std::string kSkip4aQueryOnV6LinklocalAddrFlag(kFlagPrefix + "skip_4a_query_on_v6_linklocal_addr"); const std::string kSortNameserversFlag(kFlagPrefix + "sort_nameservers"); const std::string kSortNameserversFlag(kFlagPrefix + "sort_nameservers"); const std::string kPersistNetPrefix("persist.net."); const std::string kPersistNetPrefix("persist.net."); Loading Loading
Experiments.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -69,7 +69,6 @@ class Experiments { "parallel_lookup_sleep_time", "parallel_lookup_sleep_time", "retransmission_time_interval", "retransmission_time_interval", "retry_count", "retry_count", "skip_4a_query_on_v6_linklocal_addr", "sort_nameservers", "sort_nameservers", }; }; // This value is used in updateInternal as the default value if any flags can't be found. // This value is used in updateInternal as the default value if any flags can't be found. Loading
getaddrinfo.cpp +1 −2 Original line number Original line Diff line number Diff line Loading @@ -1310,8 +1310,7 @@ static int _find_src_addr(const struct sockaddr* addr, struct sockaddr* src_addr return -1; return -1; } } if (Experiments::getInstance()->getFlag("skip_4a_query_on_v6_linklocal_addr", 1) && if (src_addr->sa_family == AF_INET6) { src_addr->sa_family == AF_INET6) { sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(src_addr); sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(src_addr); if (!allow_v6_linklocal && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { if (!allow_v6_linklocal && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { // There is no point in sending an AAAA query because the device does not have a global // There is no point in sending an AAAA query because the device does not have a global Loading
tests/resolv_integration_test.cpp +0 −49 Original line number Original line Diff line number Diff line Loading @@ -7813,55 +7813,6 @@ TEST_F(ResolverMultinetworkTest, IPv6LinkLocalWithDefaultRoute) { EXPECT_EQ(GetNumQueriesForType(*dnsPair->dnsServer, ns_type::ns_t_aaaa, host_name), 1U); 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) { // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a // network. Skip it because v6 link-local address is a prerequisite for this test. SKIP_IF_KERNEL_VERSION_LOWER_THAN(4, 9, 0); 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()); // Ensuring that routing is applied. This is required for mainline test (b/257404586). usleep(1000 * 1000); 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. // v6 mdns is expected to be sent when the IPv6 address is a link-local with a default route. TEST_F(ResolverMultinetworkTest, MdnsIPv6LinkLocalWithDefaultRoute) { TEST_F(ResolverMultinetworkTest, MdnsIPv6LinkLocalWithDefaultRoute) { // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a // Kernel 4.4 does not provide an IPv6 link-local address when an interface is added to a Loading
tests/resolv_test_utils.h +0 −2 Original line number Original line Diff line number Diff line Loading @@ -188,8 +188,6 @@ const std::string kKeepListeningUdpFlag(kFlagPrefix + "keep_listening_udp"); const std::string kParallelLookupSleepTimeFlag(kFlagPrefix + "parallel_lookup_sleep_time"); const std::string kParallelLookupSleepTimeFlag(kFlagPrefix + "parallel_lookup_sleep_time"); const std::string kRetransIntervalFlag(kFlagPrefix + "retransmission_time_interval"); const std::string kRetransIntervalFlag(kFlagPrefix + "retransmission_time_interval"); const std::string kRetryCountFlag(kFlagPrefix + "retry_count"); const std::string kRetryCountFlag(kFlagPrefix + "retry_count"); const std::string kSkip4aQueryOnV6LinklocalAddrFlag(kFlagPrefix + "skip_4a_query_on_v6_linklocal_addr"); const std::string kSortNameserversFlag(kFlagPrefix + "sort_nameservers"); const std::string kSortNameserversFlag(kFlagPrefix + "sort_nameservers"); const std::string kPersistNetPrefix("persist.net."); const std::string kPersistNetPrefix("persist.net."); Loading