Patchwork Check for TUNSETOFFLOAD support before trying to enable offload features

login
register
mail settings
Submitter Pierre Riteau
Date Nov. 25, 2009, 10:04 a.m.
Message ID <1259143482-17735-1-git-send-email-Pierre.Riteau@irisa.fr>
Download mbox | patch
Permalink /patch/39296/
State New
Headers show

Comments

Pierre Riteau - Nov. 25, 2009, 10:04 a.m.
This avoids the "TUNSETOFFLOAD ioctl() failed: Invalid argument" message
on kernels without TUNSETOFFLOAD support.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
---
 net/tap-linux.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Mark McLoughlin - Nov. 25, 2009, 10:08 a.m.
On Wed, 2009-11-25 at 11:04 +0100, Pierre Riteau wrote:
> This avoids the "TUNSETOFFLOAD ioctl() failed: Invalid argument" message
> on kernels without TUNSETOFFLOAD support.
> 
> Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>

Acked-by: Mark McLoughlin <markmc@redhat.com>

Thanks,
Mark.

> ---
>  net/tap-linux.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index 0f621a2..e038e1a 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -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)

Patch

diff --git a/net/tap-linux.c b/net/tap-linux.c
index 0f621a2..e038e1a 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -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)