diff options
| author | Maciej Żenczykowski <maze@google.com> | 2020-06-03 02:31:51 +0000 |
|---|---|---|
| committer | Maciej Zenczykowski <maze@google.com> | 2020-06-04 09:52:08 +0000 |
| commit | 8452f3f65229a25fb99da23019e732f4b169b566 (patch) | |
| tree | 04b595394e39ae6bcae22ac69242e906e5425161 | |
| parent | 36f4665ab429bcb2a698cb49acf541f202747730 (diff) | |
| download | platform_external_android-clat-8452f3f65229a25fb99da23019e732f4b169b566.tar.gz platform_external_android-clat-8452f3f65229a25fb99da23019e732f4b169b566.tar.bz2 platform_external_android-clat-8452f3f65229a25fb99da23019e732f4b169b566.zip | |
cleanup - read_config() and ipv4_local_prefixlen
Test:
git grep 'read_config|ipv4_local_prefixlen|default_pdp_interface'
comes up empty
Bug: 144730808
Test: atest clatd_test netd_integration_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Original-Change: https://android-review.googlesource.com/1322226
Merged-In: I67b70fe298f69ac51dfbc5daf4078b842fb62808
Change-Id: I67b70fe298f69ac51dfbc5daf4078b842fb62808
| -rw-r--r-- | clatd.c | 10 | ||||
| -rw-r--r-- | clatd.conf | 1 | ||||
| -rw-r--r-- | clatd_test.cpp | 4 | ||||
| -rw-r--r-- | config.c | 34 | ||||
| -rw-r--r-- | config.h | 4 |
5 files changed, 5 insertions, 48 deletions
@@ -98,7 +98,7 @@ int configure_packet_socket(int sock) { struct sockaddr_ll sll = { .sll_family = AF_PACKET, .sll_protocol = htons(ETH_P_IPV6), - .sll_ifindex = if_nametoindex(Global_Clatd_Config.default_pdp_interface), + .sll_ifindex = if_nametoindex(Global_Clatd_Config.native_ipv6_interface), .sll_pkttype = PACKET_OTHERHOST, // The 464xlat IPv6 address is not assigned to the kernel. }; if (bind(sock, (struct sockaddr *)&sll, sizeof(sll))) { @@ -318,11 +318,7 @@ int detect_mtu(const struct in6_addr *plat_subnet, uint32_t plat_suffix, uint32_ */ void configure_interface(const char *uplink_interface, const char *plat_prefix, const char *v4_addr, 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); - } - + Global_Clatd_Config.native_ipv6_interface = uplink_interface; 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); @@ -430,7 +426,7 @@ void event_loop(struct tun_data *tunnel) { time_t now = time(NULL); if (last_interface_poll < (now - INTERFACE_POLL_FREQUENCY)) { - if (ipv6_address_changed(Global_Clatd_Config.default_pdp_interface)) { + if (ipv6_address_changed(Global_Clatd_Config.native_ipv6_interface)) { break; } } @@ -1 +0,0 @@ -temporary_placeholder 0 diff --git a/clatd_test.cpp b/clatd_test.cpp index e24b036..514aaa8 100644 --- a/clatd_test.cpp +++ b/clatd_test.cpp @@ -585,7 +585,7 @@ class ClatdTest : public ::testing::Test { inet_pton(AF_INET, kIPv4LocalAddr, &Global_Clatd_Config.ipv4_local_subnet); inet_pton(AF_INET6, kIPv6PlatSubnet, &Global_Clatd_Config.plat_subnet); memset(&Global_Clatd_Config.ipv6_local_subnet, 0, sizeof(in6_addr)); - Global_Clatd_Config.default_pdp_interface = const_cast<char *>(sTun.name().c_str()); + Global_Clatd_Config.native_ipv6_interface = const_cast<char *>(sTun.name().c_str()); } // Static because setting up the tun interface takes about 40ms. @@ -631,8 +631,6 @@ TEST_F(ClatdTest, DetectMtu) { } TEST_F(ClatdTest, ConfigureTunIpManual) { - Global_Clatd_Config.ipv4_local_prefixlen = 29; - // Create an interface for configure_tun_ip to configure and bring up. TunInterface v4Iface; ASSERT_EQ(0, v4Iface.init()); @@ -42,37 +42,3 @@ struct clat_config Global_Clatd_Config; * returns: 0 if the subnets are different, 1 if they are the same. */ int ipv6_prefix_equal(struct in6_addr *a1, struct in6_addr *a2) { return !memcmp(a1, a2, 8); } - -/* function: read_config - * reads the config file and parses it into the global variable Global_Clatd_Config. returns 0 on - * failure, 1 on success - * file - filename to parse - * uplink_interface - interface to use to reach the internet and supplier of address space - */ -int read_config(const char *file, const char *uplink_interface) { - cnode *root = config_node("", ""); - - if (!root) { - logmsg(ANDROID_LOG_FATAL, "out of memory"); - return 0; - } - - memset(&Global_Clatd_Config, '\0', sizeof(Global_Clatd_Config)); - - config_load_file(root, file); - if (root->first_child == NULL) { - logmsg(ANDROID_LOG_FATAL, "Could not read config file %s", file); - goto failed; - } - - Global_Clatd_Config.default_pdp_interface = strdup(uplink_interface); - if (!Global_Clatd_Config.default_pdp_interface) goto failed; - - Global_Clatd_Config.ipv4_local_prefixlen = 29; - - return 1; - -failed: - free(root); - return 0; -} @@ -24,14 +24,12 @@ struct clat_config { struct in6_addr ipv6_local_subnet; struct in_addr ipv4_local_subnet; - int16_t ipv4_local_prefixlen; struct in6_addr plat_subnet; - char *default_pdp_interface; + const char *native_ipv6_interface; }; extern struct clat_config Global_Clatd_Config; -int read_config(const char *file, const char *uplink_interface); int ipv6_prefix_equal(struct in6_addr *a1, struct in6_addr *a2); #endif /* __CONFIG_H__ */ |
