summaryrefslogtreecommitdiff
path: root/net/tap-linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tap-linux.c')
-rw-r--r--net/tap-linux.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 0059404069..b6f1fad5e4 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -111,3 +111,29 @@ int tap_probe_vnet_hdr(int fd)
return ifr.ifr_flags & IFF_VNET_HDR;
}
+
+void tap_fd_set_offload(int fd, int csum, int tso4,
+ int tso6, int ecn, int ufo)
+{
+ unsigned int offload = 0;
+
+ if (csum) {
+ offload |= TUN_F_CSUM;
+ if (tso4)
+ offload |= TUN_F_TSO4;
+ if (tso6)
+ offload |= TUN_F_TSO6;
+ if ((tso4 || tso6) && ecn)
+ offload |= TUN_F_TSO_ECN;
+ if (ufo)
+ offload |= TUN_F_UFO;
+ }
+
+ if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
+ offload &= ~TUN_F_UFO;
+ if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
+ fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
+ strerror(errno));
+ }
+ }
+}