From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vlad Yasevich <vyasevic@redhat.com>
Cc: netdev@vger.kernel.org, Vladislav Yasevich <vyasevich@gmail.com>,
ben@decadent.org.uk, stefanha@redhat.com,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 09/10] macvtap: Re-enable UFO support
Date: Thu, 18 Dec 2014 09:55:49 +0200 [thread overview]
Message-ID: <20141218075549.GB31702@redhat.com> (raw)
In-Reply-To: <54923F67.3000205@redhat.com>
On Wed, Dec 17, 2014 at 09:43:51PM -0500, Vlad Yasevich wrote:
> On 12/17/2014 05:41 PM, Michael S. Tsirkin wrote:
> > On Wed, Dec 17, 2014 at 01:20:54PM -0500, Vladislav Yasevich wrote:
> >> Now that UFO is split into v4 and v6 parts, we can bring
> >> back v4 support. Continue to handle legacy applications
> >> by selecting the ipv6 fagment id but do not change the
> >> gso type. This allows 2 legacy VMs to continue to communicate.
> >>
> >> Based on original work from Ben Hutchings.
> >>
> >> Fixes: 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
> >> CC: Ben Hutchings <ben@decadent.org.uk>
> >> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> >> ---
> >> drivers/net/macvtap.c | 20 ++++++++++++++------
> >> 1 file changed, 14 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> >> index 880cc09..75febd4 100644
> >> --- a/drivers/net/macvtap.c
> >> +++ b/drivers/net/macvtap.c
> >> @@ -66,7 +66,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 | \
> >> - NETIF_F_TSO6)
> >> + NETIF_F_TSO6 | NETIF_F_UFO)
> >> #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
> >> #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
> >>
> >> @@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
> >> gso_type = SKB_GSO_TCPV6;
> >> break;
> >> case VIRTIO_NET_HDR_GSO_UDP:
> >> - pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
> >> - current->comm);
> >> gso_type = SKB_GSO_UDP;
> >> - if (skb->protocol == htons(ETH_P_IPV6))
> >> + if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
> >> + /* This is to support legacy appliacations.
> >> + * Do not change the gso_type as legacy apps
> >> + * may not know about the new type.
> >> + */
> >> ipv6_proxy_select_ident(skb);
> >> + }
> >> break;
> >> default:
> >> return -EINVAL;
> >> @@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
> >> vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
> >> else if (sinfo->gso_type & SKB_GSO_TCPV6)
> >> vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
> >> + else if (sinfo->gso_type & SKB_GSO_UDP)
> >> + vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
> >> else
> >> BUG();
> >> if (sinfo->gso_type & SKB_GSO_TCP_ECN)
> >> @@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
> >> if (arg & TUN_F_TSO6)
> >> feature_mask |= NETIF_F_TSO6;
> >> }
> >> +
> >> + if (arg & TUN_F_UFO)
> >> + feature_mask |= NETIF_F_UFO;
> >> }
> >>
> >> /* tun/tap driver inverts the usage for TSO offloads, where
> >> @@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
> >> * When user space turns off TSO, we turn off GSO/LRO so that
> >> * user-space will not receive TSO frames.
> >> */
> >> - if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
> >> + if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
> >> features |= RX_OFFLOADS;
> >> else
> >> features &= ~RX_OFFLOADS;
> >
> > By the way this logic is completely broken, even without your patch,
> > isn't it?
> >
> > It says: enable LRO+GRO if any of NETIF_F_TSO | NETIF_F_TSO6 |
> > NETIF_F_UFO set.
> >
> > So what happens if I enable TSO only?
> > LRO gets enabled so I can still get TSO6 packets.
> >
> >
> > This really should be:
> >
> > if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO) ==
> > (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)
> >
> >
> > fixing this probably should be a separate patch before your
> > series, and Cc stable.
>
> Actually, all this LRO/GRO feature manipulation on the macvtap device is
> rather pointless as those features aren't really checked at any point
> on the macvtap receive path. GRO calls are done from napi context on
> the lowest device, so by the time a packet hits macvtap, GRO/LRO has
> already been done.
>
> So it doesn't really matter that we disable them incorrectly. I
> can send a separate patch to clean this up.
Hmm so if userspace says it can't handle TSO packets,
it might get them anyway?
> >
> >
> >> @@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
> >> case TUNSETOFFLOAD:
> >> /* let the user check for future flags */
> >> if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
> >> - TUN_F_TSO_ECN))
> >> + TUN_F_TSO_ECN | TUN_F_UFO))
> >> return -EINVAL;
> >>
> >> rtnl_lock();
> >> --
> >> 1.9.3
next prev parent reply other threads:[~2014-12-18 7:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-17 18:20 [PATCH 00/10] Split UFO into v4 and v6 versions Vladislav Yasevich
2014-12-17 18:20 ` [PATCH 01/10] core: Split out UFO6 support Vladislav Yasevich
2014-12-17 20:10 ` Ben Hutchings
2014-12-17 20:43 ` Vlad Yasevich
2014-12-17 22:45 ` Michael S. Tsirkin
2014-12-17 23:31 ` Vlad Yasevich
2014-12-18 7:54 ` Michael S. Tsirkin
2014-12-18 15:01 ` Vlad Yasevich
2014-12-18 17:35 ` Michael S. Tsirkin
2014-12-18 17:50 ` Michael S. Tsirkin
2014-12-19 20:13 ` Vlad Yasevich
2014-12-20 21:03 ` Michael S. Tsirkin
2014-12-22 4:06 ` Vlad Yasevich
2014-12-19 19:55 ` Vlad Yasevich
2014-12-17 18:20 ` [PATCH 02/10] net: Correctly mark IPv6 UFO offload type Vladislav Yasevich
2014-12-17 18:20 ` [PATCH 03/10] ovs: Enable handling of UFO6 packets Vladislav Yasevich
2014-12-17 20:17 ` Sergei Shtylyov
2014-12-17 20:44 ` Vlad Yasevich
2014-12-17 22:26 ` Michael S. Tsirkin
2014-12-17 18:20 ` [PATCH 04/10] loopback: Turn on UFO6 support Vladislav Yasevich
2014-12-17 18:20 ` [PATCH 05/10] veth: Enable " Vladislav Yasevich
2014-12-17 18:20 ` [PATCH 06/10] macvlan: " Vladislav Yasevich
2014-12-17 18:20 ` [PATCH 07/10] s2io: " Vladislav Yasevich
2014-12-17 18:20 ` [PATCH 08/10] tun: Re-uanble UFO support Vladislav Yasevich
2014-12-17 22:33 ` Michael S. Tsirkin
2014-12-18 5:51 ` Jason Wang
2014-12-18 15:12 ` Vlad Yasevich
2014-12-19 4:37 ` Jason Wang
2014-12-17 18:20 ` [PATCH 09/10] macvtap: Re-enable " Vladislav Yasevich
2014-12-17 22:41 ` Michael S. Tsirkin
2014-12-18 2:43 ` Vlad Yasevich
2014-12-18 7:55 ` Michael S. Tsirkin [this message]
2014-12-18 15:15 ` Vlad Yasevich
2014-12-17 18:20 ` [PATCH 10/10] Revert "drivers/net: Disable UFO through virtio" Vladislav Yasevich
2014-12-17 22:44 ` Michael S. Tsirkin
2014-12-18 5:28 ` [PATCH 00/10] Split UFO into v4 and v6 versions Jason Wang
2014-12-24 18:11 ` Ben Hutchings
2014-12-24 18:59 ` Michael S. Tsirkin
2014-12-25 3:02 ` Jason Wang
2014-12-25 7:14 ` Michael S. Tsirkin
2014-12-25 9:50 ` Jason Wang
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=20141218075549.GB31702@redhat.com \
--to=mst@redhat.com \
--cc=ben@decadent.org.uk \
--cc=netdev@vger.kernel.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=vyasevic@redhat.com \
--cc=vyasevich@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).