[V1,4/4] tests: use scapy modules gre instead of local modules nvgre
diff mbox series

Message ID 1603132315-19498-5-git-send-email-lihongx.ma@intel.com
State Accepted
Headers show
Series
  • use scapy modules instead of local modules
Related show

Commit Message

Ma, LihongX Oct. 19, 2020, 6:31 p.m. UTC
- remove the import of nvgre
 - use GRE instead of nvgre in some suite that send pkt by self

Signed-off-by: LihongX Ma <lihongx.ma@intel.com>
---
 tests/TestSuite_ipgre.py |  7 +------
 tests/TestSuite_nvgre.py |  9 ++++-----
 tests/TestSuite_tso.py   | 14 +-------------
 3 files changed, 6 insertions(+), 24 deletions(-)

Patch
diff mbox series

diff --git a/tests/TestSuite_ipgre.py b/tests/TestSuite_ipgre.py
index 743c7ab..5e7750c 100644
--- a/tests/TestSuite_ipgre.py
+++ b/tests/TestSuite_ipgre.py
@@ -44,7 +44,7 @@  import re
 import time
 import os
 
-from packet import Packet, NVGRE, IPPROTO_NVGRE
+from packet import Packet
 
 from scapy.utils import wrpcap, rdpcap
 from scapy.packet import split_layers,bind_layers
@@ -80,7 +80,6 @@  class TestIpgre(TestCase):
         self.tester_iface = self.tester.get_interface(tester_port)
         self.tester_iface_mac =  self.tester.get_mac(tester_port)
         self.initialize_port_config()
-        self.re_bind_nvgre_to_gre()
 
     def initialize_port_config(self):
         self.outer_mac_src = '00:00:10:00:00:00'
@@ -142,10 +141,6 @@  class TestIpgre(TestCase):
             wrpcap("/tmp/ref_pkt.pcap", pkt.pktgen.pkt)
             time.sleep(1)
 
-    def re_bind_nvgre_to_gre(self):
-        split_layers(IP, NVGRE, frag=0, proto=IPPROTO_NVGRE)
-        bind_layers(IP, GRE, frag=0, proto=IPPROTO_NVGRE)
-
     def get_chksums(self, pcap=None):
         """
         get chksum values of Outer and Inner packet L3&L4
diff --git a/tests/TestSuite_nvgre.py b/tests/TestSuite_nvgre.py
index 306a89d..ce02a85 100644
--- a/tests/TestSuite_nvgre.py
+++ b/tests/TestSuite_nvgre.py
@@ -48,9 +48,8 @@  from socket import AF_INET6
 from scapy.utils import struct, socket, wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP
 from scapy.layers.inet6 import IPv6
-from scapy.layers.l2 import Dot1Q
+from scapy.layers.l2 import Dot1Q, GRE
 from scapy.layers.sctp import SCTP, SCTPChunkData
-from nvgre import NVGRE
 from scapy.sendrecv import sniff
 from scapy.config import conf
 from scapy.route import *
@@ -307,7 +306,7 @@  class NvgreTestConfig(object):
         GRE package: outer/GRE header/inner
         """
         if self.outer_ip_proto == 47:
-            self.pkt = outer / NVGRE() / inner
+            self.pkt = outer / GRE(key_present=1,proto=0x6558,key=0x00000100) / inner
         else:
             self.pkt = outer / ("X" * self.payload_size)
 
@@ -332,8 +331,8 @@  class NvgreTestConfig(object):
         if payload.guess_payload_class(payload).name == "IP":
             chk_sums['outer_ip'] = hex(payload[IP].chksum)
 
-        if pkts[0].haslayer(NVGRE) == 1:
-            inner = pkts[0][NVGRE]
+        if pkts[0].haslayer(GRE) == 1:
+            inner = pkts[0][GRE]
             if inner.haslayer(IP) == 1:
                 chk_sums['inner_ip'] = hex(inner[IP].chksum)
                 if inner[IP].proto == 6:
diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py
index e7b4a8c..d0c67d4 100644
--- a/tests/TestSuite_tso.py
+++ b/tests/TestSuite_tso.py
@@ -101,16 +101,6 @@  class TestTSO(TestCase):
         """
         pass
 
-    def load_module(self):
-        """
-        Load vxlan or nvgre module to scapy.
-        """
-        cwd = os.getcwd()
-        dir_module = cwd + r'/' + 'dep' + '/scapy_modules'
-        self.tester.scapy_append('sys.path.append("%s")' % dir_module)
-        self.tester.scapy_append("from vxlan import VXLAN")
-        self.tester.scapy_append('from nvgre import NVGRE')
-
     def tcpdump_start_sniffing(self, ifaces=[]):
         """
         Starts tcpdump in the background to sniff the tester interface where
@@ -347,7 +337,6 @@  class TestTSO(TestCase):
         for loading_size in self.loading_sizes:
             # Vxlan test
             self.tcpdump_start_sniffing([tx_interface, rx_interface])
-            self.load_module()
             out = self.dut.send_expect("clear port stats all", "testpmd> ", 120)
             self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/UDP(sport=1021,dport=4789)/VXLAN()/Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, mac, loading_size, tx_interface))
             out = self.tester.scapy_execute()
@@ -371,9 +360,8 @@  class TestTSO(TestCase):
         for loading_size in self.loading_sizes:
             # Nvgre test
             self.tcpdump_start_sniffing([tx_interface, rx_interface])
-            self.load_module()
             out = self.dut.send_expect("clear port stats all", "testpmd> ", 120)
-            self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2",proto=47)/NVGRE()/Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, mac, loading_size, tx_interface))
+            self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2",proto=47)/GRE(key_present=1,proto=0x6558,key=0x00001000)/Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, mac, loading_size, tx_interface))
             out = self.tester.scapy_execute()
             out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
             print(out)