From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C5604A04FF for ; Thu, 5 May 2022 12:27:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C014742829; Thu, 5 May 2022 12:27:41 +0200 (CEST) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.133.74]) by mails.dpdk.org (Postfix) with ESMTP id 3F2FE42828 for ; Thu, 5 May 2022 12:27:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651746460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m5j5dHl6TxdzjKKNwasf/xt1TQlTYT6Hhiso+7Q5xck=; b=YStujCKcfTqmYLL2G13Mps/Lpyx3sXHH+LLunbneG1JnZ/dqrqryRU21Q1EC3GAoq2WksY DeZ6Hpu4NjFtSsoe1ONS/WKE6npdDW7IrEI8EqokZ8qT1YUUyDW6aBhjCxiMc8xqiFnVir xXKXukm4vxwM7JinQDSWyPPO7TeOVQ4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-5W8OLU0hMiOf_S0qkGlwmg-1; Thu, 05 May 2022 06:27:37 -0400 X-MC-Unique: 5W8OLU0hMiOf_S0qkGlwmg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88A323C0D186; Thu, 5 May 2022 10:27:37 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 463F9416157; Thu, 5 May 2022 10:27:36 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, jasowang@redhat.com, chenbo.xia@intel.com, david.marchand@redhat.com, olivier.matz@6wind.com Cc: stable@dpdk.org, Maxime Coquelin Subject: [PATCH 2/6] vhost: fix missing enqueue pseudo-header calculation Date: Thu, 5 May 2022 12:27:25 +0200 Message-Id: <20220505102729.821075-3-maxime.coquelin@redhat.com> In-Reply-To: <20220505102729.821075-1-maxime.coquelin@redhat.com> References: <20220505102729.821075-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 --- 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 5f432b0d77..c0ff3357a8 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -548,6 +548,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.1