From patchwork Thu Oct 24 14:28:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Leitner X-Patchwork-Id: 61912 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 929EF1EA7A; Thu, 24 Oct 2019 16:28:30 +0200 (CEST) Received: from sysclose.org (smtp.sysclose.org [69.164.214.230]) by dpdk.org (Postfix) with ESMTP id B51001EA79 for ; Thu, 24 Oct 2019 16:28:28 +0200 (CEST) Received: by sysclose.org (Postfix, from userid 5001) id 075922EF9; Thu, 24 Oct 2019 14:28:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 sysclose.org 075922EF9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sysclose.org; s=201903; t=1571927308; bh=o4Q3DoPZEUJFB5aZ5YihPCOlktlSz+mndPGnDzMinrk=; h=From:To:Cc:Subject:Date:From; b=byowdIukiJFPsGLtyjGFO9idefNek8S20k9lioaG4ulfFj0BcEFwUFVsUwtFKGBFs +WYFQQQY7gD3BakwnfENMbs/Z8HSvgrlu38n6nXPt29TxxntGazRuFlTK4Qh3RGiVK j0DYEOehOK7u03KxeyKp1qT9DC6XettvSem7cW+4gmZr1+9AUA8nxrXgTeGj6P2eS0 ZHo8ox+pWeeNBbs91yG/ruS+96wN0mUdFq1cGc8mCaPdT0J+zUK82W2ox1qB6EZ9Pn AOuKYSLLsIdL4mccDOAHdEyFMQIMarRM4IYSFt/yq6rH5YpJ11WVmN9vuVnelCl/79 5ghHcM5sTXINg== X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.sysclose.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (unknown [177.183.215.210]) by sysclose.org (Postfix) with ESMTPSA id 301A3181; Thu, 24 Oct 2019 14:28:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 sysclose.org 301A3181 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sysclose.org; s=201903; t=1571927307; bh=o4Q3DoPZEUJFB5aZ5YihPCOlktlSz+mndPGnDzMinrk=; h=From:To:Cc:Subject:Date:From; b=YO0x4t5VFCoyWa0i8lHoTA8jvzAhN9iwl9OcT2jr+A01wj4Q3kCpaGY9mMsBDO5YO 4dFn0MqRLvHg8cUkVAx2T9mNZiVz+O/7sNNxfcQ2D5AhRzKASs8MmpZc+oT3EOW5ob oAx/aBio41DyX857AStlmmquK7RLCjPHbewEJDT/bHrdjFe5LfTY6AiG2Ci/xICehe NmtkKL6e+ycbaXOKWiA+sw2/E30IZ/zpwPyfYM1ZXmu/37Vbw0W4F8VIPT5tpgdURh kapG76HXcLArb5a2saSiGRP9B3ecxV/UZ4sY08mZ/PO/5ErIxKeb3npRfOD6fUHgFX fMl14dYD9HypA== From: Flavio Leitner To: dev@dpdk.org Cc: Maxime Coquelin , Tiwei Bie , Obrembski MichalX Date: Thu, 24 Oct 2019 11:28:14 -0300 Message-Id: <20191024142814.10979-1-fbl@sysclose.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] vhost: fix IPv4 csum calculation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently the IPv4 header checksum is calculated including its current value, which can be a valid checksum or just garbage. In any case, if the original value is not zero, then the result is always wrong. The IPv4 checksum is defined in RFC791, page 14 says: Header Checksum: 16 bits The checksum algorithm is: The checksum field is the 16 bit one's complement of the one's complement sum of all 16 bit words in the header. For purposes of computing the checksum, the value of the checksum field is zero. Thus force the csum field to always be zero. Signed-off-by: Flavio Leitner Reviewed-by: Maxime Coquelin --- lib/librte_vhost/virtio_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index eae7825f04..cde7498c76 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -445,6 +445,7 @@ virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr) ipv4_hdr = rte_pktmbuf_mtod_offset(m_buf, struct rte_ipv4_hdr *, m_buf->l2_len); + ipv4_hdr->hdr_checksum = 0; ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); }