net: calculate checksum of packet with IPv4 options
authorMichael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>
Tue, 1 Sep 2020 09:47:55 +0000 (11:47 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 6 Oct 2020 15:10:02 +0000 (17:10 +0200)
commitac0ad5eff81d50170261845b3b805885011ef929
treef56bd6007f93a85a12f8c5d76698e7ecf039d31e
parent56bb5841fd0608989101d933f091852a3126b4fe
net: calculate checksum of packet with IPv4 options

Currently, rte_ipv4_cksum() and rte_ipv4_udptcp_cksum() assume all IPv4
headers have sizeof(struct rte_ipv4_hdr) bytes. This is not true for
those (rare) packets with IPv4 options. Thus, both IPv4 and TCP/UDP
checksums are calculated wrong.

This patch fixes the issue by using the actual IPv4 header length from
the packet's IHL field.

Signed-off-by: Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_net/rte_ip.h