Remove DNS64 detection code from clatd.
This has been unused since Q, when the NAT64 prefix started being
detected and passed in by netd instead. Many things depend on the
prefix being correct, including clat BPF offload and DNS64
synthesis, and doing DNS64 detection in clatd provides no way to
make these work. Additionally, R now supports getting the NAT64
prefix via the RA, which makes DNS64 detection in clatd even less
useful.
This CL removes all the DNS64 detection code. The new code parses
the prefix in main.c, and if the prefix is not valid, refuses to
start.
This also lets us remove the -n <netid> parameter which was only
used for DNS64 detection.
It also removes a dependency on dnsproxyd_protocol_headers, which
should be depended on by as few parts of the system as possible.
Test: m
Bug: 144730808
Bug: 151895202
Test: IPv6-only wifi continues to work
Change-Id: I892f364d6cbfe76277686387e35c04d3d6eb5ecc
diff --git a/clatd.c b/clatd.c
index 54fc2f7..3f9dc71 100644
--- a/clatd.c
+++ b/clatd.c
@@ -39,14 +39,14 @@
#include <sys/capability.h>
#include <sys/uio.h>
-#include <private/android_filesystem_config.h>
+#include <netid_client.h> // For MARK_UNSET.
+#include <private/android_filesystem_config.h> // For AID_CLAT.
#include "clatd.h"
#include "config.h"
#include "dump.h"
#include "getaddr.h"
#include "logging.h"
-#include "resolv_netid.h"
#include "ring.h"
#include "setif.h"
#include "translate.h"
@@ -388,18 +388,23 @@
* reads the configuration and applies it to the interface
* uplink_interface - network interface to use to reach the ipv6 internet
* plat_prefix - PLAT prefix to use
+ * v4_addr - the v4 address to use on the tunnel interface
+ * v6_addr - the v6 address to use on the native interface
* tunnel - tun device data
- * net_id - NetID to use, NETID_UNSET indicates use of default network
* mark - the socket mark to use for the sending raw socket
*/
void configure_interface(const char *uplink_interface, const char *plat_prefix, const char *v4_addr,
- const char *v6_addr, struct tun_data *tunnel, unsigned net_id,
- uint32_t mark) {
- if (!read_config("/system/etc/clatd.conf", uplink_interface, plat_prefix, net_id)) {
+ const char *v6_addr, struct tun_data *tunnel, uint32_t mark) {
+ if (!read_config("/system/etc/clatd.conf", uplink_interface)) {
logmsg(ANDROID_LOG_FATAL, "read_config failed");
exit(1);
}
+ if (!plat_prefix || inet_pton(AF_INET6, plat_prefix, &Global_Clatd_Config.plat_subnet) <= 0) {
+ logmsg(ANDROID_LOG_FATAL, "invalid IPv6 address specified for plat prefix: %s", plat_prefix);
+ exit(1);
+ }
+
int mtu = detect_mtu(&Global_Clatd_Config.plat_subnet, htonl(0x08080808), mark);
// clamp to minimum ipv6 mtu - this probably cannot ever trigger
if (mtu < 1280) mtu = 1280;