From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, jasowang@redhat.com, chenbo.xia@intel.com,
david.marchand@redhat.com, olivier.matz@6wind.com,
wenwux.ma@intel.com, yuying.zhang@intel.com,
aman.deep.singh@intel.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>, stable@dpdk.org
Subject: [PATCH v2 2/6] vhost: fix missing enqueue pseudo-header calculation
Date: Wed, 8 Jun 2022 14:49:42 +0200 [thread overview]
Message-ID: <20220608124946.102623-3-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20220608124946.102623-1-maxime.coquelin@redhat.com>
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 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 68a26eb17d..ce22e3ac79 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -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;
--
2.35.3
prev parent reply other threads:[~2022-06-08 12:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220608124946.102623-1-maxime.coquelin@redhat.com>
2022-06-08 12:49 ` [PATCH v2 1/6] Revert "app/testpmd: modify mac in csum forwarding" Maxime Coquelin
2022-06-13 12:24 ` Singh, Aman Deep
2022-06-17 12:42 ` Maxime Coquelin
2022-06-08 12:49 ` Maxime Coquelin [this message]
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=20220608124946.102623-3-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=aman.deep.singh@intel.com \
--cc=chenbo.xia@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=jasowang@redhat.com \
--cc=olivier.matz@6wind.com \
--cc=stable@dpdk.org \
--cc=wenwux.ma@intel.com \
--cc=yuying.zhang@intel.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).