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>
Change-Id: I67b70fe298f69ac51dfbc5daf4078b842fb62808
diff --git a/clatd.c b/clatd.c
index 50693f5..edae761 100644
--- a/clatd.c
+++ b/clatd.c
@@ -98,7 +98,7 @@
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 @@
*/
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 @@
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 @@
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, 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 @@
* 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__ */