On 11/20/2023 9:21 AM, Deng, KaiwenX wrote: > > >> -----Original Message----- >> From: Ferruh Yigit <ferruh.yi...@amd.com> >> Sent: Friday, November 17, 2023 8:50 AM >> To: Stephen Hemminger <step...@networkplumber.org> >> Cc: Deng, KaiwenX <kaiwenx.d...@intel.com>; dev@dpdk.org; >> sta...@dpdk.org; Yang, Qiming <qiming.y...@intel.com>; Zhou, YidingX >> <yidingx.z...@intel.com>; Singh, Aman Deep <aman.deep.si...@intel.com>; >> Zhang, Yuying <yuying.zh...@intel.com>; Matz, Olivier >> <olivier.m...@6wind.com>; De Lara Guarch, Pablo >> <pablo.de.lara.gua...@intel.com> >> Subject: Re: [PATCH] app/test-pmd: fix L4 checksum with padding data >> >> On 11/16/2023 10:58 PM, Stephen Hemminger wrote: >>> On Thu, 2 Nov 2023 19:20:07 +0000 >>> Ferruh Yigit <ferruh.yi...@amd.com> wrote: >>> >>>> On 8/4/2023 9:28 AM, Kaiwen Deng wrote: >>>>> IEEE 802 packets may have a minimum size limit. The data fields >>>>> should be padded when necessary. In some cases, the padding data is >>>>> not zero. Testpmd does not trim these IP packets to the true length >>>>> of the frame, so errors will occur when calculating TCP or UDP >>>>> checksum. >>>>> >>>> >>>> Hi Kaiwen, >>>> >>>> I am trying to understand the problem, what is the testcase that has >>>> checksum error? >>>> >>>> Are the received mbuf data_len & pkt_len wrong? Instead of trying to >>>> fix the mbuf during forwarding, can we fix where packet generated? >>> >>> The root cause is that get_udptcp_cksum_mbuf is using m->pkt_len which >>> maybe larger than the actual data. The real issue is there and in >>> rte_ip.h checksum code. The correct fix would be to use l3_len instead. >>> >> >> I see, you are right. >> >> In 'rte_ipv4_udptcp_cksum_mbuf()', >> as payload length "mbuf->pkt_len - l4_off" is used, which includes padding >> and if padding is not zero it will end up producing wrong checksum. >> >> >> I agree using 'l3_len' instead is correct fix. >> >> But this requires ABI/API change, >> plus do we have any reason to keep the padding, discarding it as this patch >> does is also simpler alternative. >> >> >> Other alternative can be to zero the padding bytes. I guess standard doesn't >> enforce them to be zero, but we can do this to remove its impact on checksum >> calculation. > I'm not sure if this is ok, it feels like it would reduce performance. > I can try this alternative if needed. >
Yes impacts performance, so not a good alternative, please scratch it. As discussion with Stephen and Morten, consensus is to fix SW functions that calculates checksum. 'rte_ipv4_udptcp_cksum_mbuf()' & 'rte_ipv6_udptcp_cksum_mbuf()'. Instead of using packet_len, those functions can use packet length, which will make the checksum correct. Can you please send a patch to fix those functions? I think this can be done without changing function fingerprint, so without causing any ABI/API break. >> >> >> @Kaiwen, did you able to test this with HW offload, what is the behavior of >> the HW, does is remove padding bytes? >> > I tested the HW offload case and the same tcp/udp checksum error occurs when > padding is not 0, > But if change pkt_len to the true length of the frame, the checksum is > correct. > I was expecting HW not impacted, since padding is part of the spec, my assumption would be HW only take the actual payload size into account, instead of buffer size. Can you please double check? Which HW you are testing with, can you please add maintainer of that HW to this discussion? If HW requires padding to be removed, we may go with your solution. >> >>> It also looks like test-pmd is not validating the IP header. >>> Both parse_ipv4() and parse_ipv6() should check if packet was truncated. >>> Same for both UDP and TCP lengths. >>> >> >