diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-15 02:00:02 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-15 02:00:02 +0000 |
commit | cf6f3ed1b766c4d11a1d7d33da605f87215c19fc (patch) | |
tree | 4ce3e86e3851116f8acda0333bd44bbfd6436b4a | |
parent | 07f75c13b8c43e216469bf2332aa0e29846fa510 (diff) | |
parent | 3b827f1c1920f878fdcd678fed6af4a3fad06c24 (diff) | |
download | android-clat-android12-mainline-captiveportallogin-release.tar.gz |
Snap for 7550930 from 3b827f1c1920f878fdcd678fed6af4a3fad06c24 to mainline-captiveportallogin-releaseandroid-mainline-12.0.0_r6android-mainline-12.0.0_r23android12-mainline-captiveportallogin-release
Change-Id: I09376591728ecb051270770bd7296e209374dd45
-rw-r--r-- | Android.bp | 36 | ||||
-rw-r--r-- | METADATA | 3 | ||||
-rw-r--r-- | clatd.c | 5 | ||||
-rw-r--r-- | clatd.conf | 0 | ||||
-rw-r--r-- | clatd.h | 4 | ||||
-rw-r--r-- | dump.c | 2 | ||||
-rw-r--r-- | dump.h | 4 | ||||
-rw-r--r-- | main.c | 16 | ||||
-rw-r--r-- | vendor-464xlat.rc | 15 |
9 files changed, 71 insertions, 14 deletions
@@ -1,3 +1,26 @@ +package { + default_applicable_licenses: ["external_android-clat_license"], +} + +// Added automatically by a large-scale-change +// +// large-scale-change included anything that looked like it might be a license +// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc. +// +// Please consider removing redundant or irrelevant files from 'license_text:'. +// See: http://go/android-license-faq +license { + name: "external_android-clat_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-Apache-2.0", + ], + license_text: [ + "LICENSE", + "NOTICE", + ], +} + cc_defaults { name: "clatd_defaults", @@ -63,12 +86,13 @@ cc_binary { tidy_flags: [ "-warnings-as-errors=clang-analyzer-security*,cert-*,android-*", ], -} - -// The configuration file. -prebuilt_etc { - name: "clatd.conf", - src: "clatd.conf", + // Actually not required for clatd itself. See comments in the rc file. + init_rc: [ + "vendor-464xlat.rc", + ], + sanitize: { + memtag_heap: true, + }, } // Unit tests. diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..d97975c --- /dev/null +++ b/METADATA @@ -0,0 +1,3 @@ +third_party { + license_type: NOTICE +} @@ -58,11 +58,6 @@ struct clat_config Global_Clatd_Config; volatile sig_atomic_t running = 1; -/* function: stop_loop - * signal handler: stop the event loop - */ -void stop_loop() { running = 0; } - /* function: configure_packet_socket * Binds the packet socket and attaches the receive filter to it. * sock - the socket to configure diff --git a/clatd.conf b/clatd.conf deleted file mode 100644 index e69de29..0000000 --- a/clatd.conf +++ /dev/null @@ -18,6 +18,7 @@ #ifndef __CLATD_H__ #define __CLATD_H__ +#include <signal.h> #include <stdlib.h> #include <sys/uio.h> @@ -35,7 +36,8 @@ struct tun_data; // how frequently (in seconds) to poll for an address change while there is no traffic #define NO_TRAFFIC_INTERFACE_POLL_FREQUENCY 90 -void stop_loop(); +extern volatile sig_atomic_t running; + void configure_tun_ip(const struct tun_data *tunnel, const char *v4_addr, int mtu); void set_capability(uint64_t target_cap); void drop_root_but_keep_caps(); @@ -21,6 +21,7 @@ #include <arpa/inet.h> #include <linux/icmp.h> +#include <linux/if_tun.h> #include <netinet/icmp6.h> #include <netinet/in.h> #include <netinet/ip.h> @@ -33,6 +34,7 @@ #include "clatd.h" #include "debug.h" +#include "dump.h" #include "logging.h" #if CLAT_DEBUG @@ -31,14 +31,14 @@ void dump_icmp(struct icmphdr *icmp); void dump_udp(const struct udphdr *udp, const struct iphdr *ip, const uint8_t *payload, size_t payload_size); void dump_tcp(const struct tcphdr *tcp, const struct iphdr *ip, const uint8_t *payload, - size_t payload_size, const char *options, size_t options_size); + size_t payload_size, const uint8_t *options, size_t options_size); void dump_ip6(struct ip6_hdr *header); void dump_icmp6(struct icmp6_hdr *icmp6); void dump_udp6(const struct udphdr *udp, const struct ip6_hdr *ip6, const uint8_t *payload, size_t payload_size); void dump_tcp6(const struct tcphdr *tcp, const struct ip6_hdr *ip6, const uint8_t *payload, - size_t payload_size, const char *options, size_t options_size); + size_t payload_size, const uint8_t *options, size_t options_size); void logcat_hexdump(const char *info, const uint8_t *data, size_t len); void dump_iovec(const struct iovec *iov, int iov_len); @@ -35,6 +35,11 @@ #define DEVICEPREFIX "v4-" +/* function: stop_loop + * signal handler: stop the event loop + */ +static void stop_loop() { running = 0; }; + /* function: print_help * in case the user is running this on the command line */ @@ -143,5 +148,16 @@ int main(int argc, char **argv) { logmsg(ANDROID_LOG_INFO, "Shutting down clat on %s", uplink_interface); del_anycast_address(tunnel.write_fd6, &Global_Clatd_Config.ipv6_local_subnet); + close(tunnel.write_fd6); + close(tunnel.read_fd6); + close(tunnel.fd4); + + if (running) { + logmsg(ANDROID_LOG_INFO, "Clatd on %s waiting for SIGTERM", uplink_interface); + while (running) sleep(60); + logmsg(ANDROID_LOG_INFO, "Clatd on %s received SIGTERM", uplink_interface); + } else { + logmsg(ANDROID_LOG_INFO, "Clatd on %s already received SIGTERM", uplink_interface); + } return 0; } diff --git a/vendor-464xlat.rc b/vendor-464xlat.rc new file mode 100644 index 0000000..609531d --- /dev/null +++ b/vendor-464xlat.rc @@ -0,0 +1,15 @@ +# Certain vendors disable 464xlat by setting a vendor property. +# The connectivity code in the Tethering APEX needs to disable +# 464xlat when the property is set, but it is only allowed to +# access non-vendor system properties. So copy the property to +# a property available to system APIs in android.sysprop. +# +# Arguably this script should live close to the code that uses +# it, but scrips in APEXes are not allowed to use "on property". +# So put it here close to clatd, which is at least related to +# 464xlat. +on property:persist.vendor.net.doxlat=true + setprop net.464xlat.cellular.enabled true + +on property:persist.vendor.net.doxlat=false + setprop net.464xlat.cellular.enabled false |