diff options
author | Klement Sekera <ksekera@cisco.com> | 2018-05-16 10:52:45 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2018-06-21 14:50:10 +0000 |
commit | a98346f664aae148d26a8e158008b773d73db96f (patch) | |
tree | 2a850b1925f3dd70817fb0e41324baef71fd7a05 /test/framework.py | |
parent | 56ba844d6a8b8f58b18fe51bf22707b0c37d3a87 (diff) |
ipsec: VPP-1316 calculate IP/TCP/UDP inner checksums
Calculate IP/TCP/UDP checksums in software before adding authentication.
Change-Id: I3e121cb00aeba667764f39ade8d62170f18f8b6b
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/framework.py')
-rw-r--r-- | test/framework.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/framework.py b/test/framework.py index f90197b9b6f..be8c209f4ea 100644 --- a/test/framework.py +++ b/test/framework.py @@ -25,6 +25,7 @@ from vpp_papi_provider import VppPapiProvider from log import RED, GREEN, YELLOW, double_line_delim, single_line_delim, \ getLogger, colorize from vpp_object import VppObjectRegistry +from util import ppp from scapy.layers.inet import IPerror, TCPerror, UDPerror, ICMPerror from scapy.layers.inet6 import ICMPv6DestUnreach, ICMPv6EchoRequest from scapy.layers.inet6 import ICMPv6EchoReply @@ -735,11 +736,14 @@ class VppTestCase(unittest.TestCase): def assert_packet_checksums_valid(self, packet, ignore_zero_udp_checksums=True): + received = packet.__class__(str(packet)) + self.logger.debug( + ppp("Verifying packet checksums for packet:", received)) udp_layers = ['UDP', 'UDPerror'] checksum_fields = ['cksum', 'chksum'] checksums = [] counter = 0 - temp = packet.__class__(str(packet)) + temp = received.__class__(str(received)) while True: layer = temp.getlayer(counter) if layer: @@ -754,12 +758,17 @@ class VppTestCase(unittest.TestCase): else: break counter = counter + 1 + if 0 == len(checksums): + return temp = temp.__class__(str(temp)) for layer, cf in checksums: - self.assert_equal(getattr(packet[layer], cf), - getattr(temp[layer], cf), - "packet checksum on layer #%d: %s" % ( - layer, temp[layer].name)) + calc_sum = getattr(temp[layer], cf) + self.assert_equal( + getattr(received[layer], cf), calc_sum, + "packet checksum on layer #%d: %s" % (layer, temp[layer].name)) + self.logger.debug( + "Checksum field `%s` on `%s` layer has correct value `%s`" % + (cf, temp[layer].name, calc_sum)) def assert_checksum_valid(self, received_packet, layer, field_name='chksum', |