vhost: disable host TSO for linear buffers without extbuf
authorIlya Maximets <i.maximets@ovn.org>
Thu, 17 Oct 2019 15:00:19 +0000 (17:00 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 25 Oct 2019 17:23:06 +0000 (19:23 +0200)
If linear buffers requested and external buffers are not, vhost
will not be able to receive any buffer that doesn't fit in a
single mbuf.  Moreover, if such a buffer will appear in a vring
it will never be dequeued and the whole vring will become dead
breaking the network connection.

Disable segmentation offloading from the host side to avoid
having such a big buffers.

Fixes: c3ff0ac70acb ("vhost: improve performance by supporting large buffer")

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/socket.c

index 2d3d208..a34bc7f 100644 (file)
@@ -933,6 +933,24 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
                        ~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT);
        }
 
+       /*
+        * We'll not be able to receive a buffer from guest in linear mode
+        * without external buffer if it will not fit in a single mbuf, which is
+        * likely if segmentation offloading enabled.
+        */
+       if (vsocket->linearbuf && !vsocket->extbuf) {
+               uint64_t seg_offload_features =
+                               (1ULL << VIRTIO_NET_F_HOST_TSO4) |
+                               (1ULL << VIRTIO_NET_F_HOST_TSO6) |
+                               (1ULL << VIRTIO_NET_F_HOST_UFO);
+
+               RTE_LOG(INFO, VHOST_CONFIG,
+                       "Linear buffers requested without external buffers, "
+                       "disabling host segmentation offloading support\n");
+               vsocket->supported_features &= ~seg_offload_features;
+               vsocket->features &= ~seg_offload_features;
+       }
+
        if (!(flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {
                vsocket->supported_features &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);
                vsocket->features &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);