summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2020-06-03 02:18:53 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-03 02:18:53 +0000
commit63f08abe0e8f2b0b20b33076929977083ef6a4fc (patch)
tree78403ff0b4e610944bcedce389485e4e759d58c2
parent60118314b724ce80dd30720b2127c8ab7bd42cc5 (diff)
parentba667df1c1f52c77c8bfefa55957c7e270b6e842 (diff)
downloadplatform_external_android-clat-63f08abe0e8f2b0b20b33076929977083ef6a4fc.tar.gz
platform_external_android-clat-63f08abe0e8f2b0b20b33076929977083ef6a4fc.tar.bz2
platform_external_android-clat-63f08abe0e8f2b0b20b33076929977083ef6a4fc.zip
cleanup - read_config() and ipv4_local_prefixlen am: ba667df1c1
Original change: https://android-review.googlesource.com/c/platform/external/android-clat/+/1322226 Change-Id: I6a3d6a123c6e01a9034e0701bfedac2667db25b0
-rw-r--r--clatd.c10
-rw-r--r--clatd.conf1
-rw-r--r--clatd_test.cpp4
-rw-r--r--config.c34
-rw-r--r--config.h4
5 files changed, 5 insertions, 48 deletions
diff --git a/clatd.c b/clatd.c
index 50693f5..edae761 100644
--- a/clatd.c
+++ b/clatd.c
@@ -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;
}
}
diff --git a/clatd.conf b/clatd.conf
index 36fcafd..e69de29 100644
--- a/clatd.conf
+++ b/clatd.conf
@@ -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());
diff --git a/config.c b/config.c
index f7c9724..d83b958 100644
--- a/config.c
+++ b/config.c
@@ -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;
-}
diff --git a/config.h b/config.h
index 32558ca..0152df0 100644
--- a/config.h
+++ b/config.h
@@ -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__ */