[V1,1/2] tests/tso: modify get_chksum_value_and_verify to fix a checksum-verify error

Message ID 20220823055939.4186198-2-ke1.xu@intel.com (mailing list archive)
State Accepted
Headers
Series tests/tso: modify get_chksum_value_and_verify to fix a checksum-verify error and improve the performance |

Commit Message

Ke Xu Aug. 23, 2022, 5:59 a.m. UTC
  Function "get_chksum_value_and_verify" in test suite TSO case test_tso_tunneling
 cannot verify checksum error.

This function uses the auto checksum calculation of scapy by reading the pcap
 file, erasing the checksum and writing back to a new pcap file. Duplicated
 call to method "packet.read_pcapfile" at line 149 and line 162 will append
 extra packets to the packet sequence stored in "packet.pktgen.pkts". And
 erasing the checksum at line 153 to line 160 will modify the appended packets.
 This leads to a wrongly organized packet sequence writen to file at line 161,
 causing the checksum verifying wrongly use the raw checksum as the corrected
 checksum. This fails the following checksum verifying.

By removing duplicated method call at line 149 and creating new object for
 temporary use at line 162. This bug is fixed.

Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
 tests/TestSuite_tso.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Patch

diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py
index 778ba3cc..ef63b7cf 100644
--- a/tests/TestSuite_tso.py
+++ b/tests/TestSuite_tso.py
@@ -146,7 +146,6 @@  class TestTSO(TestCase):
         packet = Packet()
         self.pks = packet.read_pcapfile(dump_pcap, self.tester)
         for i in range(len(self.pks)):
-            self.pks = packet.read_pcapfile(dump_pcap, self.tester)
             pks = self.pks[i]
             out = pks.show
             chksum_list = re.findall(r"chksum=(0x\w+)", str(out))
@@ -159,7 +158,7 @@  class TestTSO(TestCase):
                 pks["GRE"]["IP"].chksum = None
                 pks["GRE"]["TCP"].chksum = None
             packet.save_pcapfile(self.tester, filename=save_file)
-            self.pks1 = packet.read_pcapfile(save_file, self.tester)
+            self.pks1 = Packet().read_pcapfile(save_file, self.tester)
             out1 = self.pks1[i].show
             chksum_list1 = re.findall(r"chksum=(0x\w+)", str(out1))
             self.tester.send_expect("rm -rf %s" % save_file, "#")