[dpdk-dev] [PATCH] lib/librte_net: fix bug for ipv4 checksum calculating

Thomas Monjalon thomas at monjalon.net
Sun May 24 17:22:46 CEST 2020


14/05/2020 03:27, guohongzhi:
> The function of rte_ipv4_cksum for calculating the
> checksum of IPv4 header is incorrect.
> This function will return checksum value like 0xffff.
> This value, however, is considered an illegal checksum on some switches(like Trident3).
> 
> RFC 1624 specifies the IPv4 checksum as follows:
> https://tools.ietf.org/rfc/rfc1624
> Since there is guaranteed to be at least one
>    non-zero field in the IP header, and the checksum field in the
>    protocol header is the complement of the sum, the checksum field can
>    never contain ~(+0), which is -0 (0xFFFF).  It can, however, contain
>    ~(-0), which is +0 (0x0000).
> 
> ---
>  lib/librte_net/rte_ip.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Suggested title:
	net: fix IPv4 checksum

Please send a v2 with your full name and add a Signed-off-by line.
You can check the contributing guidelines:
	http://core.dpdk.org/contribute/#send

You need to add these lines from previous reviews:

Fixes: 6006818cfb26 ("net: new checksum functions")
Cc: stable at dpdk.org

Reviewed-By: Morten Brørup <mb at smartsharesystems.com>
Acked-by: Olivier Matz <olivier.matz at 6wind.com>





More information about the dev mailing list