aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-03-15 15:53:26 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-03-15 15:53:26 +0000
commit94cc13aaa9f9d2b3af502204b1e0dc2346c6a473 (patch)
tree7a99326e8cdfcb9c6acbb2252c7a54c996815036
parentb19a4b3e061909602ef8e1288a40f2765a2ffa38 (diff)
parent7df7d7d40b22542b8c3faed85f16a3d8a23d8758 (diff)
downloadqemu-snap-temp-L17000000959340705.tar.gz
Merge "Merge cherrypicks of ['android-review.googlesource.com/2490235'] into emu-32-release." into emu-32-releasesnap-temp-L17000000959340705
-rw-r--r--android/android-emu-base/android/base/network/Dns.cpp59
1 files changed, 39 insertions, 20 deletions
diff --git a/android/android-emu-base/android/base/network/Dns.cpp b/android/android-emu-base/android/base/network/Dns.cpp
index e1f962f571..6cc2c80e76 100644
--- a/android/android-emu-base/android/base/network/Dns.cpp
+++ b/android/android-emu-base/android/base/network/Dns.cpp
@@ -98,15 +98,6 @@ static int is_site_local_dns_broadcast(struct in6_addr* address) {
}
return 0;
}
-
-static void print_dns_v6_address(struct in6_addr address) {
- char address_str[INET6_ADDRSTRLEN] = "";
- if (inet_ntop(AF_INET6, &address, address_str, INET6_ADDRSTRLEN) == NULL) {
- LOG(ERROR) << "Failed to stringify IPv6 address for logging.";
- return;
- }
- LOG(VERBOSE) << "IPv6 DNS server found: " << address_str;
-}
#endif
#if DEBUG
@@ -279,15 +270,27 @@ public:
dns_v6_addr = (struct sockaddr_in6*)
dns_server->Address.lpSockaddr;
- if (is_site_local_dns_broadcast(&dns_v6_addr->sin6_addr) ==
- 0) {
- print_dns_v6_address(dns_v6_addr->sin6_addr);
- IpAddress ip = IpAddress(dns_v6_addr->sin6_addr.s6_addr);
- if (ip.valid()) {
- auto ret = present.insert(ip);
- if (ret.second) {
- out->emplace_back(std::move(ip));
- }
+ char address_str[INET6_ADDRSTRLEN] = "";
+ if (inet_ntop(AF_INET6, &address, address_str,
+ INET6_ADDRSTRLEN) == NULL) {
+ LOG(ERROR) << "Failed to stringify IPv6 address for "
+ "logging.";
+ }
+ // b/267647323
+ // Ignore IPv6 DNS address which is site local DNS broadcast
+ // or link local.
+ if (is_site_local_dns_broadcast(&dns_v6_addr->sin6_addr) ||
+ IN6_IS_ADDR_LINKLOCAL(&dns_v6_addr->sin6_addr)) {
+ dprint("Ignore IPv6 address: %s\n", address_str);
+ continue;
+ }
+
+ dprint("IPv6 DNS server found: %s\n", address_str);
+ IpAddress ip = IpAddress(dns_v6_addr->sin6_addr.s6_addr);
+ if (ip.valid()) {
+ auto ret = present.insert(ip);
+ if (ret.second) {
+ out->emplace_back(std::move(ip));
}
}
}
@@ -327,9 +330,25 @@ public:
if (sscanf(line.c_str(), "nameserver%*[ \t]%256s", nameserver) ==
1) {
IpAddress ip(nameserver);
+
if (ip.valid()) {
- out->emplace_back(std::move(ip));
- count++;
+ // b/267647323, discard IPv6 DNS address which is also link
+ // local
+ bool skip = false;
+ if (ip.isIpv6()) {
+ struct in6_addr sin6_addr;
+ if (!inet_pton(AF_INET6, nameserver, &sin6_addr)) {
+ dprint("Failed to parse IPv6 DNS address %s\n", nameserver);
+ } else {
+ skip = IN6_IS_ADDR_LINKLOCAL(&sin6_addr);
+ }
+ }
+ if (!skip) {
+ out->emplace_back(std::move(ip));
+ count++;
+ } else {
+ dprint("Ignore IPv6 link local address: %s\n", ip.toString().c_str());
+ }
}
}
}