]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
virtio-net: disable guest csum during XDP set
authorJason Wang <jasowang@redhat.com>
Thu, 22 Nov 2018 06:36:30 +0000 (14:36 +0800)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:44:57 +0000 (09:44 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836968
[ Upstream commit e59ff2c49ae16e1d179de679aca81405829aee6c ]

We don't disable VIRTIO_NET_F_GUEST_CSUM if XDP was set. This means we
can receive partial csumed packets with metadata kept in the
vnet_hdr. This may have several side effects:

- It could be overridden by header adjustment, thus is might be not
  correct after XDP processing.
- There's no way to pass such metadata information through
  XDP_REDIRECT to another driver.
- XDP does not support checksum offload right now.

So simply disable guest csum if possible in this the case of XDP.

Fixes: 3f93522ffab2d ("virtio-net: switch off offloads on demand if possible on XDP set")
Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Pavel Popa <pashinho1990@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/virtio_net.c

index ee7a441e01ec3369d17c6969111ede461c4e17c5..3065d1858658c5bc27152978aa8bbc49afea99ba 100644 (file)
@@ -62,7 +62,8 @@ static const unsigned long guest_offloads[] = {
        VIRTIO_NET_F_GUEST_TSO4,
        VIRTIO_NET_F_GUEST_TSO6,
        VIRTIO_NET_F_GUEST_ECN,
-       VIRTIO_NET_F_GUEST_UFO
+       VIRTIO_NET_F_GUEST_UFO,
+       VIRTIO_NET_F_GUEST_CSUM
 };
 
 struct virtnet_stats {
@@ -1998,9 +1999,6 @@ static int virtnet_clear_guest_offloads(struct virtnet_info *vi)
        if (!vi->guest_offloads)
                return 0;
 
-       if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))
-               offloads = 1ULL << VIRTIO_NET_F_GUEST_CSUM;
-
        return virtnet_set_guest_offloads(vi, offloads);
 }
 
@@ -2010,8 +2008,6 @@ static int virtnet_restore_guest_offloads(struct virtnet_info *vi)
 
        if (!vi->guest_offloads)
                return 0;
-       if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))
-               offloads |= 1ULL << VIRTIO_NET_F_GUEST_CSUM;
 
        return virtnet_set_guest_offloads(vi, offloads);
 }