From: LihongX Ma <lihongx.ma@intel.com>
To: dts@dpdk.org
Cc: LihongX Ma <lihongx.ma@intel.com>
Subject: [dts] [PATCH V1 3/4] tests: use scapy modules vxlan instead of local modules
Date: Tue, 20 Oct 2020 02:31:54 +0800 [thread overview]
Message-ID: <1603132315-19498-4-git-send-email-lihongx.ma@intel.com> (raw)
In-Reply-To: <1603132315-19498-1-git-send-email-lihongx.ma@intel.com>
- modify the import path of vxlan layers
Signed-off-by: LihongX Ma <lihongx.ma@intel.com>
---
tests/TestSuite_cloud_filter.py | 5 ++---
tests/TestSuite_generic_flow_api.py | 27 ---------------------------
tests/TestSuite_vxlan.py | 2 +-
tests/TestSuite_vxlan_sample.py | 2 +-
4 files changed, 4 insertions(+), 32 deletions(-)
diff --git a/tests/TestSuite_cloud_filter.py b/tests/TestSuite_cloud_filter.py
index 3723e57..abc474f 100644
--- a/tests/TestSuite_cloud_filter.py
+++ b/tests/TestSuite_cloud_filter.py
@@ -46,11 +46,10 @@ from settings import HEADER_SIZE
from packet import Packet
from scapy.layers.inet import UDP, IP
+from scapy.layers.vxlan import VXLAN
from scapy.packet import split_layers, bind_layers
-from vxlan import VXLAN
-from vxlan import VXLAN_PORT
-
+VXLAN_PORT = 4789
CLOUD_PORT = 8472
split_layers(UDP, VXLAN, dport=VXLAN_PORT)
bind_layers(UDP, VXLAN, dport=CLOUD_PORT)
diff --git a/tests/TestSuite_generic_flow_api.py b/tests/TestSuite_generic_flow_api.py
index da061fe..1660669 100644
--- a/tests/TestSuite_generic_flow_api.py
+++ b/tests/TestSuite_generic_flow_api.py
@@ -148,19 +148,6 @@ class TestGeneric_flow_api(TestCase):
time.sleep(2)
self.vf_flag = 0
- def load_module(self, module=""):
- """
- Load vxlan or nvgre module to scapy.
- """
- # load vxlan module to scapy
- cwd = os.getcwd()
- dir_module = cwd + r'/' + 'dep'
- self.tester.scapy_append('sys.path.append("%s")' % dir_module)
- if module == "vxlan":
- self.tester.scapy_append("from vxlan import VXLAN")
- elif module == "nvgre":
- self.tester.scapy_append('from nvgre import NVGRE')
-
def verify_result(self, pf_vf, expect_rxpkts, expect_queue, verify_mac):
"""
verify the packet to the expected queue or be dropped
@@ -322,12 +309,6 @@ class TestGeneric_flow_api(TestCase):
self.dut.send_expect(flow_cmd, "created")
rule_created = 1
- # Enable vxlan packet sending
- if "VXLAN" in flow_pkt:
- self.load_module("vxlan")
- elif "NVGRE" in flow_pkt:
- self.load_module("nvgre")
-
# The rule is created successfully, so send the consistent packet.
self.sendpkt(pktstr=flow_pkt)
cur_mac = re.search("dst='(\S\S:\S\S:\S\S:\S\S:\S\S:\S\S)'", flow_pkt)
@@ -2290,21 +2271,17 @@ class TestGeneric_flow_api(TestCase):
extrapkt_rulenum = self.all_flows_process(basic_flow_actions)
extra_packet = extrapkt_rulenum['extrapacket']
- self.load_module("vxlan")
self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN()/Ether(dst="%s")/Dot1Q(vlan=11)/IP()/TCP()/Raw("x" * 20)' % (self.outer_mac, self.inner_mac))
self.verify_result("pf", expect_rxpkts="1", expect_queue=extrapkt_rulenum['queue'][0],
verify_mac=self.outer_mac)
- self.load_module("vxlan")
self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN(vni=5)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (self.outer_mac, self.wrong_mac))
self.verify_result("pf", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
- self.load_module("vxlan")
self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN(vni=%s)/Ether(dst="%s")/Dot1Q(vlan=%s)/IP()/TCP()/Raw("x" * 20)' % (
self.outer_mac, extra_packet[5]['vni'], self.wrong_mac, extra_packet[5]['invlan']))
self.verify_result("vf0", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
- self.load_module("vxlan")
self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN(vni=%s)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (
self.wrong_mac, extra_packet[6]['vni'], self.inner_mac))
self.verify_result("vf1", expect_rxpkts="0", expect_queue="NULL", verify_mac=self.wrong_mac)
@@ -2356,22 +2333,18 @@ class TestGeneric_flow_api(TestCase):
extrapkt_rulenum = self.all_flows_process(basic_flow_actions)
extra_packet = extrapkt_rulenum['extrapacket']
- self.load_module("nvgre")
self.sendpkt('Ether(dst="%s")/IP()/NVGRE()/Ether(dst="%s")/Dot1Q(vlan=1)/IP()/TCP()/Raw("x" * 20)' % (self.outer_mac, self.inner_mac))
self.verify_result("pf", expect_rxpkts="1", expect_queue=extrapkt_rulenum['queue'][0],
verify_mac=self.outer_mac)
- self.load_module("nvgre")
self.sendpkt('Ether(dst="%s")/IP()/NVGRE(TNI=%s)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (
self.outer_mac, extra_packet[4]['tni'], self.wrong_mac))
self.verify_result("pf", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
- self.load_module("nvgre")
self.sendpkt('Ether(dst="%s")/IP()/NVGRE(TNI=%s)/Ether(dst="%s")/Dot1Q(vlan=%s)/IP()/TCP()/Raw("x" * 20)' % (
self.outer_mac, extra_packet[5]['tni'], self.wrong_mac, extra_packet[5]['invlan']))
self.verify_result("vf0", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
- self.load_module("nvgre")
self.sendpkt('Ether(dst="%s")/IP()/NVGRE(TNI=%s)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (
self.wrong_mac, extra_packet[6]['tni'], self.inner_mac))
self.verify_result("vf1", expect_rxpkts="0", expect_queue="NULL", verify_mac=self.wrong_mac)
diff --git a/tests/TestSuite_vxlan.py b/tests/TestSuite_vxlan.py
index 2db3549..eb324fb 100644
--- a/tests/TestSuite_vxlan.py
+++ b/tests/TestSuite_vxlan.py
@@ -48,7 +48,7 @@ from scapy.utils import wrpcap, rdpcap
from scapy.layers.inet import Ether, IP, TCP, UDP
from scapy.layers.inet6 import IPv6
from scapy.layers.l2 import Dot1Q
-from vxlan import VXLAN
+from scapy.layers.vxlan import VXLAN
from scapy.layers.sctp import SCTP, SCTPChunkData
from scapy.sendrecv import sniff
from scapy.config import conf
diff --git a/tests/TestSuite_vxlan_sample.py b/tests/TestSuite_vxlan_sample.py
index feaad14..92253bb 100644
--- a/tests/TestSuite_vxlan_sample.py
+++ b/tests/TestSuite_vxlan_sample.py
@@ -54,7 +54,7 @@ from scapy.utils import wrpcap, rdpcap
from scapy.layers.inet import Ether, IP, TCP, UDP
from scapy.layers.inet6 import IPv6
from scapy.layers.l2 import Dot1Q
-from vxlan import VXLAN
+from scapy.layers.vxlan import VXLAN
from scapy.layers.sctp import SCTP, SCTPChunkData
from scapy.sendrecv import sniff
from scapy.config import conf
--
2.7.4
next prev parent reply other threads:[~2020-10-20 2:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules " LihongX Ma
2020-10-19 18:31 ` [dts] [PATCH V1 1/4] dep: remove the scapy modules in dep LihongX Ma
2020-10-19 18:31 ` [dts] [PATCH V1 2/4] framework/packet: use scapy modules instead of local modules LihongX Ma
2020-10-19 18:31 ` LihongX Ma [this message]
2020-10-19 18:31 ` [dts] [PATCH V1 4/4] tests: use scapy modules gre instead of local modules nvgre LihongX Ma
2020-10-28 6:35 ` [dts] [PATCH V1 0/4] use scapy modules instead of local modules Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1603132315-19498-4-git-send-email-lihongx.ma@intel.com \
--to=lihongx.ma@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).