Add binder calls to start and stop NAT64 prefix discovery.
Currently NAT64 prefix discovery, which runs in netd, is started
by netd itself when a network is programmed with all-IPv6 DNS
servers. Unfortunately this is not correct because in many cases
we program DNS servers before the network is connected and it's
actually possible to send packets to them.
In general netd does not have enough visibility into network
lifecycle management to decide when to start and stop prefix
discovery. So move it into the framework with the rest of the
464xlat control plane.
This CL removes the automatic start/stop of DNS64 prefix
discovery and adds binder IPCs for the framework to start and
stop it.
Bug: 65674744
Test: system/netd/tests/runtests.sh
Change-Id: I399c236505590690efa5ece3b75b5161a41fcb7d
diff --git a/server/ResolverController.cpp b/server/ResolverController.cpp
index c8bf967..ae990d1 100644
--- a/server/ResolverController.cpp
+++ b/server/ResolverController.cpp
@@ -109,13 +109,6 @@
return checkCallingPermission(String16(permission));
}
-bool allIPv6Only(const std::vector<std::string>& servers) {
- for (const auto& server : servers) {
- if (server.find(':') == std::string::npos) return false;
- }
- return !servers.empty();
-}
-
} // namespace
int ResolverController::setDnsServers(unsigned netId, const char* searchDomains,
@@ -287,30 +280,8 @@
res_params.retry_count = params[INetd::RESOLVER_PARAMS_RETRY_COUNT];
}
- const auto rval = setDnsServers(netId, domains_str.c_str(), server_ptrs.data(),
- server_ptrs.size(), &res_params);
-
- if (rval == 0) {
- // Start DNS64 discovery after successfully setting any new DNS servers
- // as the cache may have been cleared (if the nameservers differ), and
- // we might discover a different DNS64 prefix. If the cache has not been
- // cleared, we may quickly rediscover the same prefix.
- //
- // Operators may choose to use a longer TTL in order to reduce repeated
- // resolution (see also https://tools.ietf.org/html/rfc7050#section-5).
- if (allIPv6Only(servers)) {
- // TODO: Keep any existing discovered prefix around for use while
- // re-discovery is in progress. Otherwise, whenever DNS servers are
- // pushed to netd there can be gaps where it would appear there was
- // no prefix64 when in fact we had previously discovered one (and
- // are highly likely to rediscover the same one).
- mDns64Configuration.startPrefixDiscovery(netId);
- } else {
- mDns64Configuration.stopPrefixDiscovery(netId);
- }
- }
-
- return rval;
+ return setDnsServers(netId, domains_str.c_str(), server_ptrs.data(), server_ptrs.size(),
+ &res_params);
}
int ResolverController::getResolverInfo(int32_t netId, std::vector<std::string>* servers,
@@ -348,6 +319,14 @@
return 0;
}
+void ResolverController::startPrefix64Discovery(int32_t netId) {
+ mDns64Configuration.startPrefixDiscovery(netId);
+}
+
+void ResolverController::stopPrefix64Discovery(int32_t netId) {
+ return mDns64Configuration.stopPrefixDiscovery(netId);
+}
+
// TODO: use StatusOr<T> to wrap the result.
int ResolverController::getPrefix64(unsigned netId, netdutils::IPPrefix* prefix) {
netdutils::IPPrefix p = mDns64Configuration.getPrefix64(netId);