]> git.droids-corp.org - dpdk.git/commitdiff
vhost: fix missing enqueue pseudo-header calculation
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Wed, 8 Jun 2022 12:49:42 +0000 (14:49 +0200)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Fri, 17 Jun 2022 12:41:04 +0000 (14:41 +0200)
The Virtio specification requires that in case of checksum
offloading, the pseudo-header checksum must be set in the
L4 header.

When received from another Vhost-user port, the packet
checksum might already contain the pseudo-header checksum
but we have no way to know it. So we have no other choice
than doing the pseudo-header checksum systematically.

This patch handles this using the rte_net_intel_cksum_prepare()
helper.

Fixes: 859b480d5afd ("vhost: add guest offload setting")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
lib/vhost/virtio_net.c

index 68a26eb17da236c93e8a39d3d885daa63d513104..ce22e3ac79176d342c624af4b0308b97ccaad80b 100644 (file)
@@ -596,6 +596,16 @@ virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)
                csum_l4 |= RTE_MBUF_F_TX_TCP_CKSUM;
 
        if (csum_l4) {
+               /*
+                * Pseudo-header checksum must be set as per Virtio spec.
+                *
+                * Note: We don't propagate rte_net_intel_cksum_prepare()
+                * errors, as it would have an impact on performance, and an
+                * error would mean the packet is dropped by the guest instead
+                * of being dropped here.
+                */
+               rte_net_intel_cksum_prepare(m_buf);
+
                net_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
                net_hdr->csum_start = m_buf->l2_len + m_buf->l3_len;