All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vlad Yasevich <vyasevic@redhat.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v2] macvtap: Correctly set tap features when IFF_VNET_HDR is disabled.
Date: Wed, 14 Aug 2013 22:24:37 +0300	[thread overview]
Message-ID: <20130814192437.GA20226@redhat.com> (raw)
In-Reply-To: <1376499820-27764-1-git-send-email-vyasevic@redhat.com>

On Wed, Aug 14, 2013 at 01:03:40PM -0400, Vlad Yasevich wrote:
> When the user turns off IFF_VNET_HDR flag, attempts to change
> offload features via TUNSETOFFLOAD do not work.  This could cause
> GSO packets to be delivered to the user when the user is
> not prepared to handle them.

Just to clarify - is there some userspace that actually
triggers this?


> To solve, allow processing of TUNSETOFFLOAD when IFF_VNET_HDR is
> disabled.  Treat any attempt to enable offloads as an error in
> this case.
> We also need to update the TUN_FEATURES mask to include all checksum
> options as the underlying device may have something other then
> HW_CSUM set.
> 
> Change since v1:
>   - Removed the call to update offloads when IFF_VNET_HDR is turned off.
>   - Changed the macvtap version of TUN_OFFLOADS to include all checksum
>     offloads since the physical nic may have them set.
>   - Treat enabling of offloads without vnet_hdr support as error.
> 
> Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
> ---
>  drivers/net/macvtap.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index a98fb0e..3acfc37 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -65,7 +65,7 @@ static struct cdev macvtap_cdev;
>  
>  static const struct proto_ops macvtap_socket_ops;
>  
> -#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
> +#define TUN_OFFLOADS (NETIF_F_ALL_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
>  		      NETIF_F_TSO6 | NETIF_F_UFO)
>  #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
>  /*
> @@ -1024,6 +1024,12 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
>  	if (!vlan)
>  		return -ENOLINK;
>  
> +	/* If the user is trying to set offloads while IFF_VNET_HDR is
> +	 * off, report it as an error.
> +	 */
> +	if (!(q->flags & IFF_VNET_HDR) && arg)
> +		return -EINVAL;
> +
>  	features = vlan->dev->features;
>  
>  	if (arg & TUN_F_CSUM) {
> @@ -1155,10 +1161,6 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
>  			    TUN_F_TSO_ECN | TUN_F_UFO))
>  			return -EINVAL;
>  
> -		/* TODO: only accept frames with the features that
> -			 got enabled for forwarded frames */
> -		if (!(q->flags & IFF_VNET_HDR))
> -			return  -EINVAL;
>  		rtnl_lock();
>  		ret = set_offload(q, arg);
>  		rtnl_unlock();
> -- 
> 1.8.1.4

  parent reply	other threads:[~2013-08-14 19:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 17:03 [PATCH v2] macvtap: Correctly set tap features when IFF_VNET_HDR is disabled Vlad Yasevich
2013-08-14 17:50 ` Michael S. Tsirkin
2013-08-14 19:14   ` Vlad Yasevich
2013-08-14 19:23     ` Michael S. Tsirkin
2013-08-14 19:24 ` Michael S. Tsirkin [this message]
2013-08-14 20:22   ` Vlad Yasevich
2013-08-14 20:52     ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130814192437.GA20226@redhat.com \
    --to=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=vyasevic@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.