diff options
author | JP Abgrall <jpa@google.com> | 2013-12-20 14:51:26 -0800 |
---|---|---|
committer | JP Abgrall <jpa@google.com> | 2013-12-26 12:29:11 -0800 |
commit | 4e0dd83686869c292e162dc76992863d3f3a3c38 (patch) | |
tree | a63ff9ab95c72bc736064bbc46bd0255df7d8c61 | |
parent | c9f4c89da6c76ebc59a0ec1047853a13ce5f5d96 (diff) | |
download | platform_external_android-clat-4e0dd83686869c292e162dc76992863d3f3a3c38.tar.gz platform_external_android-clat-4e0dd83686869c292e162dc76992863d3f3a3c38.tar.bz2 platform_external_android-clat-4e0dd83686869c292e162dc76992863d3f3a3c38.zip |
Add ip6 dummy address to keep data usage stats consistent.
Because of the way the tunnel pumps packets into the networking
stack, the netfilter xt_qtaguid module can't track stats
accurately: the totals don't add up.
With "clat" having an ip address, qtaguid will track stats
against it, which then can be deducted from the external iface.
Bug: 11687690
Change-Id: I22ebf26dd9249e821da87665d2bfb0e54d3cdf64
-rw-r--r-- | clatd.c | 9 | ||||
-rw-r--r-- | clatd.conf | 3 | ||||
-rw-r--r-- | config.c | 4 | ||||
-rw-r--r-- | config.h | 3 |
4 files changed, 18 insertions, 1 deletions
@@ -203,6 +203,13 @@ void configure_tun_ip(const struct tun_data *tunnel) { exit(1); } + status = add_address(tunnel->device6, AF_INET6, &Global_Clatd_Config.ipv6_local_address, + 64, NULL); + if(status < 0) { + logmsg(ANDROID_LOG_FATAL,"configure_tun_ip/if_address(6) failed: %s",strerror(-status)); + exit(1); + } + if((status = if_up(tunnel->device6, Global_Clatd_Config.mtu)) < 0) { logmsg(ANDROID_LOG_FATAL,"configure_tun_ip/if_up(6) failed: %s",strerror(-status)); exit(1); @@ -468,7 +475,7 @@ int main(int argc, char **argv) { // open the tunnel device before dropping privs tunnel.fd6 = tun_open(); if(tunnel.fd6 < 0) { - logmsg(ANDROID_LOG_FATAL, "tun_open failed: %s", strerror(errno)); + logmsg(ANDROID_LOG_FATAL, "tun_open6 failed: %s", strerror(errno)); exit(1); } @@ -5,6 +5,9 @@ ipv6_host_id ::464 # ipv4 subnet for the local traffic to use. This is a /32 host address ipv4_local_subnet 192.0.0.4 +# ipv6 extra link local address for the ip6 iface. +ipv6_local_address fe80::c000:0004 + # get the plat_subnet from dns lookups (requires DNS64) plat_from_dns64 yes # hostname to use to lookup plat subnet. must contain only A records @@ -255,6 +255,9 @@ int read_config(const char *file, const char *uplink_interface, const char *plat if(!config_item_ip(root, "ipv4_local_subnet", DEFAULT_IPV4_LOCAL_SUBNET, &Global_Clatd_Config.ipv4_local_subnet)) goto failed; + if(!config_item_ip6(root, "ipv6_local_address", DEFAULT_IPV6_LOCAL_ADDRESS, &Global_Clatd_Config.ipv6_local_address)) + goto failed; + if(plat_prefix) { // plat subnet is coming from the command line if(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); @@ -295,6 +298,7 @@ void dump_config() { logmsg(ANDROID_LOG_DEBUG,"mtu = %d",Global_Clatd_Config.mtu); logmsg(ANDROID_LOG_DEBUG,"ipv4mtu = %d",Global_Clatd_Config.ipv4mtu); + logmsg(ANDROID_LOG_DEBUG,"ipv6_local_address = %s",inet_ntop(AF_INET6, &Global_Clatd_Config.ipv6_local_address, charbuffer, sizeof(charbuffer))); logmsg(ANDROID_LOG_DEBUG,"ipv6_local_subnet = %s",inet_ntop(AF_INET6, &Global_Clatd_Config.ipv6_local_subnet, charbuffer, sizeof(charbuffer))); logmsg(ANDROID_LOG_DEBUG,"ipv4_local_subnet = %s",inet_ntop(AF_INET, &Global_Clatd_Config.ipv4_local_subnet, charbuffer, sizeof(charbuffer))); logmsg(ANDROID_LOG_DEBUG,"plat_subnet = %s",inet_ntop(AF_INET6, &Global_Clatd_Config.plat_subnet, charbuffer, sizeof(charbuffer))); @@ -22,10 +22,13 @@ #include <sys/system_properties.h> #define DEFAULT_IPV4_LOCAL_SUBNET "192.168.255.1" +#define DEFAULT_IPV6_LOCAL_ADDRESS "fe80::c000:0004" + #define DEFAULT_DNS64_DETECTION_HOSTNAME "ipv4.google.com" struct clat_config { int16_t mtu, ipv4mtu; + struct in6_addr ipv6_local_address; struct in6_addr ipv6_local_subnet; struct in6_addr ipv6_host_id; struct in_addr ipv4_local_subnet; |