summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>2015-10-27 18:13:17 -0600
committerSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>2015-11-15 12:59:53 -0700
commitb38ac868d20bb9c1cae087ab18691d242aad0c5c (patch)
tree0cbcf17e3fef6deaf6c1e04ab432e516b7be268d
parent7efed4e30259da5348c4a7c2c77a0d0d4b13834d (diff)
downloadandroid_external_android-clat-b38ac868d20bb9c1cae087ab18691d242aad0c5c.tar.gz
android_external_android-clat-b38ac868d20bb9c1cae087ab18691d242aad0c5c.tar.bz2
android_external_android-clat-b38ac868d20bb9c1cae087ab18691d242aad0c5c.zip
Revert "clatd: Use the TUN_NOCHECKSUM flag for the tun device"
This reverts commit 7efed4e30259da5348c4a7c2c77a0d0d4b13834d. This change may bypass checksum validation for all packets even if they have not been validated earlier. Hardware supports checksum offload for IPv4 / IPv6 UDP and TCP packets only. ICMPv4 / ICMPv6 / fragmented packet checksum offload is not supported and as a result the checksum will not be validated even once before these packet are delivered to the application. Change-Id: I28152b63bb432c3dc37fe7a713c3b225a662f678
-rw-r--r--clatd.c3
-rw-r--r--config.h2
-rw-r--r--tun.c71
-rw-r--r--tun.h1
4 files changed, 0 insertions, 77 deletions
diff --git a/clatd.c b/clatd.c
index ca21984..faeb679 100644
--- a/clatd.c
+++ b/clatd.c
@@ -496,9 +496,6 @@ int main(int argc, char **argv) {
// run under a regular user
drop_root();
- //check HW features and disable checksum validation if already handled by hardware
- rx_checksum_offloaded = check_csum_offload(uplink_interface);
-
// we can create tun devices as non-root because we're in the VPN group.
tunnel.fd4 = tun_open();
if(tunnel.fd4 < 0) {
diff --git a/config.h b/config.h
index 82a91be..e31a81d 100644
--- a/config.h
+++ b/config.h
@@ -39,8 +39,6 @@ struct clat_config {
extern struct clat_config Global_Clatd_Config;
-extern int rx_checksum_offloaded;
-
int read_config(const char *file, const char *uplink_interface, const char *plat_prefix,
unsigned net_id);
void config_generate_local_ipv6_subnet(struct in6_addr *interface_ip);
diff --git a/tun.c b/tun.c
index 8068b2f..49f0ea7 100644
--- a/tun.c
+++ b/tun.c
@@ -22,14 +22,10 @@
#include <linux/if.h>
#include <linux/if_tun.h>
#include <sys/ioctl.h>
-#include <linux/ethtool.h>
#include <sys/uio.h>
-#include "config.h"
#include "clatd.h"
-int rx_checksum_offloaded = 0;
-
/* function: tun_open
* tries to open the tunnel device
*/
@@ -65,11 +61,6 @@ int tun_alloc(char *dev, int fd) {
return err;
}
strcpy(dev, ifr.ifr_name);
-
- if (rx_checksum_offloaded) {
- ioctl(fd, TUNSETNOCSUM, 1);
- }
-
return 0;
}
@@ -96,65 +87,3 @@ int set_nonblocking(int fd) {
int send_tun(int fd, clat_packet out, int iov_len) {
return writev(fd, out, iov_len);
}
-
-/* function: get_ethtool_feature_val
- * gets if a particular ethtool feature is enabled
- * dev - the device name to query the feature on
- * cmd - the feature to query
- * returns: 1 if feature is enabled, 0 if disabled
- */
-int get_ethtool_feature_val(char *dev, int cmd) {
- int fd;
- struct ifreq ifr;
- struct ethtool_value eval;
-
- if (!dev){
- return 0;
- }
-
- if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
- return 0;
- }
-
- memset(&ifr, 0, sizeof(ifr));
- memset(&eval, 0, sizeof(eval));
- strlcpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
- eval.cmd = cmd;
- eval.data = 0;
- ifr.ifr_data = (caddr_t)&eval;
- if (ioctl(fd, SIOCETHTOOL, &ifr) == -1) {
- close(fd);
- return 0;
- }
-
- close(fd);
-
- if (!eval.data) {
- return 0;
- }
-
- return 1;
-}
-
-/* function: check_csum_offload
- * checks if GRO and RXCSUM are enabled on the device
- * dev - the device name to query on
- * returns: 1 if checksum is offloaded, 0 if checksum needs
- * to be validated in network stack.
- */
-int check_csum_offload(char *dev) {
- int fd;
- struct ifreq ifr;
- struct ethtool_value eval;
-
- if (!dev){
- return 0;
- }
-
- if(get_ethtool_feature_val(dev, ETHTOOL_GGRO) &&
- get_ethtool_feature_val(dev, ETHTOOL_GRXCSUM)) {
- return 1;
- }
-
- return 0;
-}
diff --git a/tun.h b/tun.h
index f1c41bf..bcdd10e 100644
--- a/tun.h
+++ b/tun.h
@@ -33,6 +33,5 @@ int tun_open();
int tun_alloc(char *dev, int fd);
int send_tun(int fd, clat_packet out, int iov_len);
int set_nonblocking(int fd);
-int check_csum_offload(char *dev);
#endif