From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [dpdk-users] Invalid TCP/UDP checksum for IPV4 packets Date: Wed, 07 Jun 2017 16:39:49 +0200 Message-ID: <2411222.g8kaCR81iN@xps> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: users@dpdk.org, dev@dpdk.org To: Julien Castets Return-path: In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, 31/05/2017 10:16, Julien Castets: > I had a running application on DPDK 2.2.0 which offloads IP/TCP/UDP > checksums to the NIC. A few days ago, I started the migration to 17.02 > and started to see invalid TCP/UDP checksum. > > I called the new API rte_eth_tx_prepare() but checksums were still invalid. > > After digging for a few hours in DPDK source code, I discovered the > flag PKT_TX_IPV4 needs to be set in ol_flags. > > Basically, the function rte_net_intel_cksum_flags_prepare of rte_net.h > (http://dpdk.org/doc/api/rte__net_8h_source.html) does the following: > > if (offload TCP checksum flag is set) { > if (PKT_TX_IPV4 in ol_flags) { > // compute ipv4 checksum > } > else { > // compute ipv6 checksum > } > } > > Because I didn't set PKT_TX_IPV4 in ol_flags, I was going into the > "else" clause and the checksum was computed as if my packet was an > IPV6 packet. > > Don't you think it would be preferable to assert instead of > considering a non-explicitely-declared-IPV4-packet as being an IPV6 > packet? Yes, you're right. I think we were avoiding wasting 1 cycle here. Usability was the cost for best performance. A good trade-off may be to use RTE_ASSERT which will be triggered only in debug mode.