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/main.c b/main.c
index e973bf3..c4834d9 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,7 @@
* main.c - main function
*/
+#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdint.h>
@@ -24,7 +25,7 @@
#include <sys/capability.h>
#include <unistd.h>
-#include "resolv_netid.h"
+#include <netid_client.h> // For MARK_UNSET.
#include "clatd.h"
#include "common.h"
@@ -44,7 +45,6 @@
printf("-p [plat prefix]\n");
printf("-4 [IPv4 address]\n");
printf("-6 [IPv6 address]\n");
- printf("-n [NetId]\n");
printf("-m [socket mark]\n");
printf("-t [tun file descriptor number]\n");
}
@@ -55,13 +55,12 @@
int main(int argc, char **argv) {
struct tun_data tunnel;
int opt;
- char *uplink_interface = NULL, *plat_prefix = NULL, *net_id_str = NULL, *mark_str = NULL;
+ char *uplink_interface = NULL, *plat_prefix = NULL, *mark_str = NULL;
char *v4_addr = NULL, *v6_addr = NULL, *tunfd_str = NULL;
- unsigned net_id = NETID_UNSET;
uint32_t mark = MARK_UNSET;
unsigned len;
- while ((opt = getopt(argc, argv, "i:p:4:6:n:m:t:h")) != -1) {
+ while ((opt = getopt(argc, argv, "i:p:4:6:m:t:h")) != -1) {
switch (opt) {
case 'i':
uplink_interface = optarg;
@@ -75,9 +74,6 @@
case '6':
v6_addr = optarg;
break;
- case 'n':
- net_id_str = optarg;
- break;
case 'm':
mark_str = optarg;
break;
@@ -98,11 +94,6 @@
exit(1);
}
- if (net_id_str != NULL && !parse_unsigned(net_id_str, &net_id)) {
- logmsg(ANDROID_LOG_FATAL, "invalid NetID %s", net_id_str);
- exit(1);
- }
-
if (mark_str != NULL && !parse_unsigned(mark_str, &mark)) {
logmsg(ANDROID_LOG_FATAL, "invalid mark %s", mark_str);
exit(1);
@@ -123,10 +114,10 @@
exit(1);
}
- logmsg(ANDROID_LOG_INFO, "Starting clat version %s on %s netid=%s mark=%s plat=%s v4=%s v6=%s",
- CLATD_VERSION, uplink_interface, net_id_str ? net_id_str : "(none)",
- mark_str ? mark_str : "(none)", plat_prefix ? plat_prefix : "(none)",
- v4_addr ? v4_addr : "(none)", v6_addr ? v6_addr : "(none)");
+ logmsg(ANDROID_LOG_INFO, "Starting clat version %s on %s mark=%s plat=%s v4=%s v6=%s",
+ CLATD_VERSION, uplink_interface, mark_str ? mark_str : "(none)",
+ plat_prefix ? plat_prefix : "(none)", v4_addr ? v4_addr : "(none)",
+ v6_addr ? v6_addr : "(none)");
// run under a regular user but keep needed capabilities
drop_root_but_keep_caps();
@@ -137,12 +128,7 @@
// keeps only admin capability
set_capability(1 << CAP_NET_ADMIN);
- // When run from netd, the environment variable ANDROID_DNS_MODE is set to
- // "local", but that only works for the netd process itself. Removing the
- // following line causes XLAT failure in permissive mode.
- unsetenv("ANDROID_DNS_MODE");
-
- configure_interface(uplink_interface, plat_prefix, v4_addr, v6_addr, &tunnel, net_id, mark);
+ configure_interface(uplink_interface, plat_prefix, v4_addr, v6_addr, &tunnel, mark);
// Drop all remaining capabilities.
set_capability(0);