tests: improve packet checksum functions 54/37654/2
authorKlement Sekera <klement.sekera@gmail.com>
Mon, 14 Nov 2022 10:26:18 +0000 (11:26 +0100)
committerDave Wallace <dwallacelf@gmail.com>
Wed, 18 Jan 2023 00:39:57 +0000 (00:39 +0000)
commit738cf73b2c5e396a56b8fab19b64a07b171cb14c
treec2d75be0284135424300ffeddb07f7b633192362
parentcc16e7bad74c18b1a682329af5e760c4cd8381ea
tests: improve packet checksum functions

Fool-proof assert_checksum_valid so that one does not verify checksum on
wrong layer (because of how scapy internally works).

Make assert_packet_checksums_valid start checksum checking at inner
layers and outwards to make it more obvious where the error is. With old
behaviour, if one received an ICMP packet carrying a truncated TCP
packet, an error would be raised for ICMP checksum, as that one would be
the first to be wrong after recalculating all packet checksums, while
the real issue is TCP header being truncated and thus unsuitable for use
with this function.

Type: improvement
Signed-off-by: Klement Sekera <klement.sekera@gmail.com>
Change-Id: I39a2b50ec5610f969cfde9796416ee3a50ae0ba3
test/framework.py