Skip to contentSkip to conversation

Check for TUNSETOFFLOAD support before trying to enable offload features

PATCH In review Pierre Riteau 2 participants 2 messages Nov 25, 2009 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check for TUNSETOFFLOAD support before trying to enable offload features

This avoids the "TUNSETOFFLOAD ioctl() failed: Invalid argument" message on kernels without TUNSETOFFLOAD support.

---
 net/tap-linux.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
net/tap-linux.c +5 -0
index 0f621a2..e038e1a 100644
@@ -129,6 +129,11 @@ void tap_fd_set_offload(int fd, int csum, int tso4,
 {
     unsigned int offload = 0;
 
+    /* Check if our kernel supports TUNSETOFFLOAD */
+    if (ioctl(fd, TUNSETOFFLOAD, 0) != 0 && errno == EINVAL) {
+        return;
+    }
+
     if (csum) {
         offload |= TUN_F_CSUM;
         if (tso4)
Signature · 1 line
1.6.5
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Pierre Riteau

This avoids the "TUNSETOFFLOAD ioctl() failed: Invalid argument" message on kernels without TUNSETOFFLOAD support.

Thanks,
Mark.

Quoted 20 lines
---
 net/tap-linux.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
net/tap-linux.c +5 -0
index 0f621a2..e038e1a 100644
@@ -129,6 +129,11 @@ void tap_fd_set_offload(int fd, int csum, int tso4,
 {
     unsigned int offload = 0;
 
+    /* Check if our kernel supports TUNSETOFFLOAD */
+    if (ioctl(fd, TUNSETOFFLOAD, 0) != 0 && errno == EINVAL) {
+        return;
+    }
+
     if (csum) {
         offload |= TUN_F_CSUM;
         if (tso4)