[RFCLAT#3] Move the tun interface setup from clatd to netd
This is a preparation for reducing the clatd required capability.
Function change:
- configure_tun_ip(), detect_mtu() are moved to netd/ClatdController
- move Clatd_Config.ipv4_local_subnet setup from configure_tun_ip() to
main() because configure_tun_ip() is removed. translate.c needs
the clat IPv4 address for 4->6, 6>->4 address translation.
Bug: 212345928
Test: manual test
1. Connect to ipv6-only wifi.
2. Try IPv4 traffic.
$ ping 8.8.8.8
Change-Id: Ibf80b17865f414f329ab7c50836595f3b99360e2
diff --git a/main.c b/main.c
index 96fbd0d..fe88dfd 100644
--- a/main.c
+++ b/main.c
@@ -145,12 +145,17 @@
exit(1);
}
+ if (!v4_addr || !inet_pton(AF_INET, v4_addr, &Global_Clatd_Config.ipv4_local_subnet.s_addr)) {
+ logmsg(ANDROID_LOG_FATAL, "Invalid IPv4 address %s", v4_addr);
+ exit(1);
+ }
+
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)");
- configure_interface(uplink_interface, plat_prefix, v4_addr, v6_addr, &tunnel, mark);
+ configure_interface(uplink_interface, plat_prefix, v6_addr, &tunnel);
// run under a regular user with no capabilities
drop_root_and_caps();