From 8b58e0f274b8337da2421a50c2b23665381f7453 Mon Sep 17 00:00:00 2001 From: Michal Zima Date: Sat, 15 Jun 2013 16:35:18 +0200 Subject: [PATCH] Automatic disabling of segmentation offload --- src/wrapper.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/wrapper.c b/src/wrapper.c index 3533343..f735a35 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -17,7 +17,9 @@ */ #include /* inet_pton */ +#include /* struct ethtool_value */ #include /* ETH_P_ALL */ +#include /* SIOCETHTOOL */ #include /* ETHERTYPE_* */ #include /* struct ifreq */ #include /* htons */ @@ -38,7 +40,7 @@ #include "wrapper.h" /* +++ CONFIGURATION +++ */ -#define INTERFACE "eth0" /* be sure to turn off generic-segmentation-offload! */ +#define INTERFACE "eth0" #define PREFIX "64:ff9b::" #define IPV4_ADDR "192.168.0.111" #define HOST_IPV6_ADDR "fd77::1:0:1" @@ -59,6 +61,7 @@ int process(char *packet); int main(int argc, char **argv) { struct packet_mreq pmr; + struct ethtool_value ethtool; int sniff_sock; int length; @@ -88,7 +91,18 @@ int main(int argc, char **argv) memcpy(&mac, &interface.ifr_hwaddr.sa_data, sizeof(struct s_mac_addr)); + /* disable generic segmentation offload */ + ethtool.cmd = ETHTOOL_SGSO; + ethtool.data = 0; + interface.ifr_data = (caddr_t) ðtool; + if (ioctl(sniff_sock, SIOCETHTOOL, &interface) == -1) { + log_error("Unable to disable generic segmentation " + "offload on the interface"); + return 1; + } + /* reinitialize the interface */ + interface.ifr_data = NULL; if (ioctl(sniff_sock, SIOCGIFINDEX, &interface) == -1) { log_error("Unable to reinitialize the interface"); return 1;