From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 150601B53 for ; Wed, 19 Sep 2018 16:42:31 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id q8-v6so7298227wmq.4 for ; Wed, 19 Sep 2018 07:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=K92hwt4uK6szi6ZRlIUxBr+M9JNRbALGThdZANMlflI=; b=aRoEvtSs4670cqkIUHiJNhCSU3kOVAtmQfP8TvnBTeUhj1cSEnCy2JIDUZjbdAxOPI g+A6SH36rMNztv7vwIK5cJe3RVjCjhRPDkO7QOyJp+F4E27X6J1nIISi+oebh9z/dQCE IHA+lHkWnq81UY6e+uvKY78GbmIEnV0E7XkPEk8JaOy/uiHuukjjSDh2XcYCr76KgFjm cvDk84ZiIW7+uMkqXAUlniJeQJ+dnVVJ5kHCj6xUqO4e69DMcR8iqlm5CTsFAx5uzEmH ziL5BEuuUJbjTU4sYklAui9EhNo0lg2tgdOEXp+SYl8dxTaDe1RS7MJITTAobxxD3M/M UvDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K92hwt4uK6szi6ZRlIUxBr+M9JNRbALGThdZANMlflI=; b=a72TwY6vGmjZ4YB2gPh1XuSpeUN5YHGVX0xnSPcbRWA5Vb+yGDdntb2Bnl5sSWiEGc ki8ZF6AMc01U6C3SlTpuMsj9puVi+ZJTAUXPYJztPA6ZknueXr35Zc0NuafQGgePuVOt tTfY/L1M4ofryhH1dh5pY4rucupP1S/B0VUxrg7T8UALholBqL14hVNoT41puvuDtq2D ypsp3x+9aA+Gx8BMFTVwYJ35zRSfd2rpexoyHlNLoi/Cv/6Gd0aFe0vhaaVc0LUVehFy XylsBZrmz68Ek6p93zpAHL8iPiRrde0zT0MKlRcZEgMVlVnVu9I1SRtX7a6vZODG6Yke BpGQ== X-Gm-Message-State: APzg51DwNzqznB6N98c2Kma4OooiN3QMoC9+3o7OFAGtdSNhsSgroakz 3X+wy6LHzkITwgK63Wxsi6g8fJGgiovPaw== X-Google-Smtp-Source: ANB0Vdb5+RP/2dX5VyrjDm3lpKItil5kpLq1CbJ1IqEDvNdvR/r3TlkzmwV9TsdkM3kZssBC6kYZqQ== X-Received: by 2002:a1c:3d07:: with SMTP id k7-v6mr21414774wma.146.1537368150740; Wed, 19 Sep 2018 07:42:30 -0700 (PDT) Received: from pala.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c3-v6sm25716246wrm.56.2018.09.19.07.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 07:42:29 -0700 (PDT) From: Didier Pallard To: dev@dpdk.org Cc: stable@dpdk.org Date: Wed, 19 Sep 2018 16:42:08 +0200 Message-Id: <20180919144208.17064-1-didier.pallard@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net: fix Intel prepare function for IP checksum offload 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: , X-List-Received-Date: Wed, 19 Sep 2018 14:42:32 -0000 Current Intel tx prepare function does not properly handle the case where only IP checksum is requested, without requesting any L4 checksum or TSO: IP checksum is not properly reset to 0 and output packet may contain invalid IP checksum. Fixes: 4fb7e803eb1a ("ethdev: add Tx preparation") Cc: stable@dpdk.org Signed-off-by: Didier Pallard --- lib/librte_net/rte_net.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index b6ab6e1d57b2..e59760a0a108 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -122,14 +122,16 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) (ol_flags & PKT_TX_OUTER_IPV6)) inner_l3_offset += m->outer_l2_len + m->outer_l3_len; - if ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) { - if (ol_flags & PKT_TX_IPV4) { - ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, - inner_l3_offset); + if (ol_flags & PKT_TX_IPV4) { + ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, + inner_l3_offset); - if (ol_flags & PKT_TX_IP_CKSUM) - ipv4_hdr->hdr_checksum = 0; + if (ol_flags & PKT_TX_IP_CKSUM) + ipv4_hdr->hdr_checksum = 0; + } + if ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) { + if (ol_flags & PKT_TX_IPV4) { udp_hdr = (struct udp_hdr *)((char *)ipv4_hdr + m->l3_len); udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, @@ -146,12 +148,6 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) } else if ((ol_flags & PKT_TX_TCP_CKSUM) || (ol_flags & PKT_TX_TCP_SEG)) { if (ol_flags & PKT_TX_IPV4) { - ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, - inner_l3_offset); - - if (ol_flags & PKT_TX_IP_CKSUM) - ipv4_hdr->hdr_checksum = 0; - /* non-TSO tcp or TSO */ tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + m->l3_len); -- 2.11.0