* [dts] [PATCH V1 0/4] use scapy modules instead of local modules
@ 2020-10-19 18:31 LihongX Ma
2020-10-19 18:31 ` [dts] [PATCH V1 1/4] dep: remove the scapy modules in dep LihongX Ma
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: LihongX Ma @ 2020-10-19 18:31 UTC (permalink / raw)
To: dts; +Cc: LihongX Ma
LihongX Ma (4):
dep: remove the scapy modules in dep
framework/packet: use scapy modules instead of local modules
tests: use scapy modules vxlan instead of local modules
tests: use scapy modules gre instead of local modules nvgre
dep/scapy_modules/igmp.py | 164 ------------------------
dep/scapy_modules/lldp.py | 242 ------------------------------------
dep/scapy_modules/mpls.py | 24 ----
dep/scapy_modules/nsh.py | 67 ----------
dep/scapy_modules/nvgre.py | 37 ------
dep/scapy_modules/vxlan.py | 92 --------------
framework/packet.py | 49 ++++++--
tests/TestSuite_cloud_filter.py | 5 +-
tests/TestSuite_generic_flow_api.py | 27 ----
tests/TestSuite_ipgre.py | 7 +-
tests/TestSuite_nvgre.py | 9 +-
tests/TestSuite_tso.py | 14 +--
tests/TestSuite_vxlan.py | 2 +-
tests/TestSuite_vxlan_sample.py | 2 +-
14 files changed, 51 insertions(+), 690 deletions(-)
delete mode 100644 dep/scapy_modules/igmp.py
delete mode 100644 dep/scapy_modules/lldp.py
delete mode 100644 dep/scapy_modules/mpls.py
delete mode 100644 dep/scapy_modules/nsh.py
delete mode 100644 dep/scapy_modules/nvgre.py
delete mode 100644 dep/scapy_modules/vxlan.py
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dts] [PATCH V1 1/4] dep: remove the scapy modules in dep
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules instead of local modules LihongX Ma
@ 2020-10-19 18:31 ` LihongX Ma
2020-10-19 18:31 ` [dts] [PATCH V1 2/4] framework/packet: use scapy modules instead of local modules LihongX Ma
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: LihongX Ma @ 2020-10-19 18:31 UTC (permalink / raw)
To: dts; +Cc: LihongX Ma
- use scapy module igmp instead of local module igmp
- use scapy module lldp instead of local module lldp
- use scapy module mpls instead of local module mpls
- use scapy module nsh instead of local module nsh
- use scapy module gre instead of local module nvgre
- use scapy module vxlan instead of local module vxlan
Signed-off-by: LihongX Ma <lihongx.ma@intel.com>
---
dep/scapy_modules/igmp.py | 164 ------------------------------
dep/scapy_modules/lldp.py | 242 ---------------------------------------------
dep/scapy_modules/mpls.py | 24 -----
dep/scapy_modules/nsh.py | 67 -------------
dep/scapy_modules/nvgre.py | 37 -------
dep/scapy_modules/vxlan.py | 92 -----------------
6 files changed, 626 deletions(-)
delete mode 100644 dep/scapy_modules/igmp.py
delete mode 100644 dep/scapy_modules/lldp.py
delete mode 100644 dep/scapy_modules/mpls.py
delete mode 100644 dep/scapy_modules/nsh.py
delete mode 100644 dep/scapy_modules/nvgre.py
delete mode 100644 dep/scapy_modules/vxlan.py
diff --git a/dep/scapy_modules/igmp.py b/dep/scapy_modules/igmp.py
deleted file mode 100644
index 5cbf9c0..0000000
--- a/dep/scapy_modules/igmp.py
+++ /dev/null
@@ -1,164 +0,0 @@
-#! /usr/bin/env python
-
-# This file is part of Scapy
-# Scapy is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# any later version.
-#
-# Scapy is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Scapy. If not, see <http://www.gnu.org/licenses/>.
-
-# flake8: noqa: E501
-
-# scapy.contrib.description = Internet Group Management Protocol v1/v2 (IGMP/IGMPv2)
-# scapy.contrib.status = loads
-
-from __future__ import print_function
-from scapy.compat import chb, orb
-from scapy.error import warning
-from scapy.fields import ByteEnumField, ByteField, IPField, XShortField
-from scapy.layers.inet import IP, IPOption_Router_Alert
-from scapy.layers.l2 import Ether, getmacbyip
-from scapy.packet import bind_layers, Packet
-from scapy.utils import atol, checksum
-
-
-def isValidMCAddr(ip):
- """convert dotted quad string to long and check the first octet"""
- FirstOct = atol(ip) >> 24 & 0xFF
- return (FirstOct >= 224) and (FirstOct <= 239)
-
-
-class IGMP(Packet):
- """IGMP Message Class for v1 and v2.
-
-This class is derived from class Packet. You need call "igmpize()"
-so the packet is transformed according the RFC when sent.
-a=Ether(src="00:01:02:03:04:05")
-b=IP(src="1.2.3.4")
-c=IGMP(type=0x12, gaddr="224.2.3.4")
-x = a/b/c
-x[IGMP].igmpize()
-sendp(a/b/c, iface="en0")
-
- Parameters:
- type IGMP type field, 0x11, 0x12, 0x16 or 0x17
- mrcode Maximum Response time (zero for v1)
- gaddr Multicast Group Address 224.x.x.x/4
-
-See RFC2236, Section 2. Introduction for definitions of proper
-IGMPv2 message format http://www.faqs.org/rfcs/rfc2236.html
-
- """
- name = "IGMP"
-
- igmptypes = {0x11: "Group Membership Query",
- 0x12: "Version 1 - Membership Report",
- 0x16: "Version 2 - Membership Report",
- 0x17: "Leave Group"}
-
- fields_desc = [ByteEnumField("type", 0x11, igmptypes),
- ByteField("mrcode", 20),
- XShortField("chksum", None),
- IPField("gaddr", "0.0.0.0")]
-
- def post_build(self, p, pay):
- """Called implicitly before a packet is sent to compute and place IGMP checksum.
-
- Parameters:
- self The instantiation of an IGMP class
- p The IGMP message in hex in network byte order
- pay Additional payload for the IGMP message
- """
- p += pay
- if self.chksum is None:
- ck = checksum(p)
- p = p[:2] + chb(ck >> 8) + chb(ck & 0xff) + p[4:]
- return p
-
- @classmethod
- def dispatch_hook(cls, _pkt=None, *args, **kargs):
- if _pkt and len(_pkt) >= 4:
- from scapy.contrib.igmpv3 import IGMPv3
- if orb(_pkt[0]) in [0x22, 0x30, 0x31, 0x32]:
- return IGMPv3
- if orb(_pkt[0]) == 0x11 and len(_pkt) >= 12:
- return IGMPv3
- return IGMP
-
- def igmpize(self):
- """Called to explicitly fixup the packet according to the IGMP RFC
-
- The rules are:
- General:
- 1. the Max Response time is meaningful only in Membership Queries and should be zero
- IP:
- 1. Send General Group Query to 224.0.0.1 (all systems)
- 2. Send Leave Group to 224.0.0.2 (all routers)
- 3a.Otherwise send the packet to the group address
- 3b.Send reports/joins to the group address
- 4. ttl = 1 (RFC 2236, section 2)
- 5. send the packet with the router alert IP option (RFC 2236, section 2)
- Ether:
- 1. Recalculate destination
-
- Returns:
- True The tuple ether/ip/self passed all check and represents
- a proper IGMP packet.
- False One of more validation checks failed and no fields
- were adjusted.
-
- The function will examine the IGMP message to assure proper format.
- Corrections will be attempted if possible. The IP header is then properly
- adjusted to ensure correct formatting and assignment. The Ethernet header
- is then adjusted to the proper IGMP packet format.
- """
- gaddr = self.gaddr if hasattr(self, "gaddr") and self.gaddr else "0.0.0.0" # noqa: E501
- underlayer = self.underlayer
- if self.type not in [0x11, 0x30]: # General Rule 1 # noqa: E501
- self.mrcode = 0
- if isinstance(underlayer, IP):
- if (self.type == 0x11):
- if (gaddr == "0.0.0.0"):
- underlayer.dst = "224.0.0.1" # IP rule 1 # noqa: E501
- elif isValidMCAddr(gaddr):
- underlayer.dst = gaddr # IP rule 3a # noqa: E501
- else:
- warning("Invalid IGMP Group Address detected !")
- return False
- elif ((self.type == 0x17) and isValidMCAddr(gaddr)):
- underlayer.dst = "224.0.0.2" # IP rule 2 # noqa: E501
- elif ((self.type == 0x12) or (self.type == 0x16)) and (isValidMCAddr(gaddr)): # noqa: E501
- underlayer.dst = gaddr # IP rule 3b # noqa: E501
- else:
- warning("Invalid IGMP Type detected !")
- return False
- if not any(isinstance(x, IPOption_Router_Alert) for x in underlayer.options): # noqa: E501
- underlayer.options.append(IPOption_Router_Alert())
- underlayer.ttl = 1 # IP rule 4
- _root = self.firstlayer()
- if _root.haslayer(Ether):
- # Force recalculate Ether dst
- _root[Ether].dst = getmacbyip(underlayer.dst) # Ether rule 1 # noqa: E501
- from scapy.contrib.igmpv3 import IGMPv3
- if isinstance(self, IGMPv3):
- self.encode_maxrespcode()
- return True
-
- def mysummary(self):
- """Display a summary of the IGMP object."""
- if isinstance(self.underlayer, IP):
- return self.underlayer.sprintf("IGMP: %IP.src% > %IP.dst% %IGMP.type% %IGMP.gaddr%") # noqa: E501
- else:
- return self.sprintf("IGMP %IGMP.type% %IGMP.gaddr%")
-
-
-bind_layers(IP, IGMP, frag=0,
- proto=2,
- ttl=1)
diff --git a/dep/scapy_modules/lldp.py b/dep/scapy_modules/lldp.py
deleted file mode 100644
index 8eb8bea..0000000
--- a/dep/scapy_modules/lldp.py
+++ /dev/null
@@ -1,242 +0,0 @@
-#!/usr/bin/env python
-## This file is part of Scapy
-## See http://www.secdev.org/projects/scapy for more informations
-## Copyright (C) Philippe Biondi <phil@secdev.org>
-## This program is published under a GPLv2 license
-
-## Copyright (c) 2011 Jochen Bartl <jochen.bartl gmail com>
-
-"""
-LLDP (Link Layer Discovery Protocol)
-"""
-
-from scapy.packet import *
-from scapy.fields import *
-from scapy.layers.l2 import Ether
-from scapy.layers.inet6 import IP6Field
-
-_LLDP_tlv_cls = {0: "LLDPDUEnd",
- 1: "LLDPChassisId",
- 2: "LLDPPortId",
- 3: "LLDPTTL",
- 4: "LLDPPortDescription",
- 5: "LLDPSystemName",
- 6: "LLDPSystemDescription",
- 7: "LLDPSystemCapabilities",
- 8: "LLDPManagementAddress",
- 127: "LLDPOrganizationalSpecific"}
-
-_LLDP_tlv_types = {0: "End of LLDPDU",
- 1: "Chassis Id",
- 2: "Port Id",
- 3: "Time to Live",
- 4: "Port Description",
- 5: "System Name",
- 6: "System Description",
- 7: "System Capabilities",
- 8: "Management Address",
- 127: "Organization Specific"}
-
-
-# (oui, subtype)
-# 0x0080c2 - IEEE 802.1
-# 0x00120f - IEEE 802.3
-_LLDPOrgSpec_tlv_cls = {(0x0080c2, 0x01): "LLDPDot1PortVlanId",
- }
-
-
-def _LLDPGuessPacketClass(p=None, **kargs):
- if p is None:
- return LLDPGeneric(**kargs)
-
- cls = Raw
-
- if len(p) >= 2:
- t = struct.unpack("!B", p[0])[0]
- t = (0xfe & t) >> 1
-
- if t != 127:
- clsname = _LLDP_tlv_cls.get(t, "LLDPGeneric")
- else:
- oui = struct.unpack("!I", "\x00" + p[2:5])[0]
- subtype = struct.unpack("!B", p[5])[0]
- clsname = _LLDPOrgSpec_tlv_cls.get((oui, subtype), "LLDPOrgSpecGeneric")
-
- cls = globals()[clsname]
-
- return cls(p, **kargs)
-
-
-class LLDPGeneric(Packet):
- name = "LLDP Generic TLV"
- fields_desc = [BitField("type", 1, 7),
- BitFieldLenField("length", None, 9, length_of="value"),
- StrLenField("value", "", length_from=lambda x: x.length)]
-
- def guess_payload_class(self, p):
- return Padding
-
- def post_build(self, p, pay):
- if self.length is None:
- l = len(p) - 2
- p = chr((self.type << 1) ^ (l >> 8)).encode() + chr(l & 0xff).encode() + p[2:]
-
- return p+pay
-
-
-class LLDPOrgSpecGeneric(LLDPGeneric):
- name = "LLDP Org Spec Generic TLV"
- fields_desc = [BitField("type", 127, 7),
- BitFieldLenField("length", None, 9, length_of="value"),
- X3BytesField("oui", 0),
- ByteField("subtype", 0),
- StrLenField("value", "", length_from=lambda x: x.length - 4)]
-
-
-class LLDPDUEnd(LLDPGeneric):
- name = "End of LLDPDU"
- fields_desc = [BitField("type", 0, 7),
- BitField("length", 0, 9)]
-
-
-_LLDPChassisId_Subtypes = {0: "Reserved",
- 1: "Chassis component",
- 2: "Interface alias",
- 3: "Port component",
- 4: "MAC address",
- 5: "Network address",
- 6: "Interface name",
- 7: "Locally assigned"}
-
-
-class LLDPChassisId(LLDPGeneric):
- name = "LLDP Chassis"
- fields_desc = [BitField("type", 1, 7),
- BitField("length", None, 9),
- ByteEnumField("subtype", 4, _LLDPChassisId_Subtypes),
- ConditionalField(MACField("macaddr", "00:11:22:33:44:55"), lambda pkt: pkt.subtype == 4),
- # TODO Subtype 5, IPv4 / IPv6
- # Catch-all field for undefined subtypes
- ConditionalField(StrLenField("value", "", length_from=lambda x: x.length - 1),
- lambda pkt: pkt.subtype not in [4])]
-
-
-_LLDPPortId_Subtypes = {0: "Reserved",
- 1: "Interface alias",
- 2: "Port component",
- 3: "MAC address",
- 4: "Network address",
- 5: "Interface name",
- 6: "Agent circuit ID",
- 7: "Locally assigned"}
-
-
-class LLDPPortId(LLDPGeneric):
- name = "LLDP PortId"
- fields_desc = [BitField("type", 2, 7),
- BitField("length", None, 9),
- ByteEnumField("subtype", 3, _LLDPPortId_Subtypes),
- ConditionalField(MACField("macaddr", "00:11:22:33:44:55"), lambda pkt: pkt.subtype == 3),
- # TODO Subtype 4, IPv4 / IPv6
- # Catch-all field for undefined subtypes
- ConditionalField(StrLenField("value", "", length_from=lambda x: x.length - 1),
- lambda pkt: pkt.subtype not in [3])]
-
-
-class LLDPTTL(LLDPGeneric):
- name = "LLDP TTL"
- fields_desc = [BitField("type", 3, 7),
- BitField("length", None, 9),
- ShortField("seconds", 120)]
-
-
-class LLDPPortDescription(LLDPGeneric):
- name = "LLDP Port Description"
- type = 4
- value = "FastEthernet0/1"
-
-
-class LLDPSystemName(LLDPGeneric):
- name = "LLDP System Name"
- type = 5
- value = "Scapy"
-
-
-class LLDPSystemDescription(LLDPGeneric):
- name = "LLDP System Description"
- type = 6
- value = "Scapy"
-
-
-_LLDPSystemCapabilities = ["other", "repeater", "bridge", "wlanap", "router", "telephone", "docsiscable", "stationonly"]
-
-
-class LLDPSystemCapabilities(LLDPGeneric):
- name = "LLDP System Capabilities"
- fields_desc = [BitField("type", 7, 7),
- BitField("length", None, 9),
- # Available capabilities
- FlagsField("capabilities", 0, 16, _LLDPSystemCapabilities),
- # Enabled capabilities
- FlagsField("enabled", 0, 16, _LLDPSystemCapabilities)]
-
-
-_LLDPManagementAddress_Subtype = {1: "IPv4",
- 2: "IPv6",
- 6: "802"
- }
-
-_LLDPManagementAddress_IfSubtype = {1: "Unknown",
- 2: "ifIndex",
- 3: "System Port Number"
- }
-
-
-class LLDPManagementAddress(LLDPGeneric):
- name = "LLDP Management Address"
- fields_desc = [BitField("type", 8, 7),
- BitField("length", None, 9),
- ByteField("addrlen", None),
- ByteEnumField("addrsubtype", 1, _LLDPManagementAddress_Subtype),
- ConditionalField(IPField("ipaddr", "192.168.0.1"), lambda pkt: pkt.addrsubtype == 1),
- ConditionalField(IP6Field("ip6addr", "2001:db8::1"), lambda pkt: pkt.addrsubtype == 2),
- ConditionalField(MACField("macaddr", "00:11:22:33:44:55"), lambda pkt: pkt.addrsubtype == 6),
- ConditionalField(StrLenField("addrval", "", length_from=lambda x: x.addrlen - 1),
- lambda pkt: pkt.addrsubtype not in [1, 2, 6]),
- ByteEnumField("ifsubtype", 2, _LLDPManagementAddress_IfSubtype),
- IntField("ifnumber", 0),
- FieldLenField("oidlen", None, length_of="oid", fmt="B"),
- StrLenField("oid", "", length_from=lambda x: x.oidlen)]
-
- def post_build(self, p, pay):
- # TODO Remove redundant code. LLDPGeneric.post_build()
- if self.length is None:
- l = len(p) - 2
- p = chr((self.type << 1) ^ (l >> 8)).encode() + chr(l & 0xff).encode() + p[2:]
-
- if self.addrlen is None:
- addrlen = len(p) - 2 - 8 - len(self.oid) + 1
- p = p[:2] + struct.pack("B", addrlen) + p[3:]
-
- return p+pay
-
-
-_LLDPDot1Subtype = {1: "Port VLAN Id"}
-
-
-class LLDPDot1PortVlanId(LLDPOrgSpecGeneric):
- name = "LLDP IEEE 802.1 Port VLAN Id"
- fields_desc = [BitField("type", 127, 7),
- BitField("length", None, 9),
- # TODO: XThreeBytesEnumField
- X3BytesField("oui", 0x0080c2),
- ByteEnumField("subtype", 0x01, _LLDPDot1Subtype),
- ShortField("vlan", 1)]
-
-
-class LLDP(Packet):
- name ="LLDP"
- fields_desc = [PacketListField("tlvlist", [], _LLDPGuessPacketClass)]
-
-
-bind_layers(Ether, LLDP, type=0x88cc)
diff --git a/dep/scapy_modules/mpls.py b/dep/scapy_modules/mpls.py
deleted file mode 100644
index 0b37bba..0000000
--- a/dep/scapy_modules/mpls.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from scapy.packet import Packet, bind_layers, Padding
-from scapy.fields import BitField,ByteField
-from scapy.layers.inet import IP
-from scapy.layers.inet6 import IPv6
-from scapy.layers.l2 import Ether, GRE
-
-class MPLS(Packet):
- name = "MPLS"
- fields_desc = [ BitField("label", 3, 20),
- BitField("cos", 0, 3),
- BitField("s", 1, 1),
- ByteField("ttl", 0) ]
-
- def guess_payload_class(self, payload):
- if len(payload) >= 1:
- ip_version = (ord(payload[0]) >> 4) & 0xF
- if ip_version == 4:
- return IP
- elif ip_version == 6:
- return IPv6
- return Padding
-
-bind_layers(Ether, MPLS, type=0x8847)
-bind_layers(GRE, MPLS, proto=0x8847)
diff --git a/dep/scapy_modules/nsh.py b/dep/scapy_modules/nsh.py
deleted file mode 100644
index 2e249c9..0000000
--- a/dep/scapy_modules/nsh.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from scapy.packet import *
-from scapy.fields import *
-from scapy.layers.inet import Ether, IP
-from scapy.layers.inet6 import IPv6
-from vxlan import VXLAN
-from mpls import MPLS
-
-
-class Metadata(Packet):
- name = 'NSH metadata'
- fields_desc = [XIntField('value', 0)]
-
-
-class NSHTLV(Packet):
- "NSH MD-type 2 - Variable Length Context Headers"
- name = "NSHTLV"
- fields_desc = [
- ShortField('Class', 0),
- BitField('Critical', 0, 1),
- BitField('Type', 0, 7),
- BitField('Reserved', 0, 3),
- BitField('Len', 0, 5),
- PacketListField('Metadata', None, XIntField, count_from='Len')
- ]
-
-
-class NSH(Packet):
- """Network Service Header.
- NSH MD-type 1 if there is no ContextHeaders"""
- name = "NSH"
-
- fields_desc = [
- BitField('Ver', 0, 2),
- BitField('OAM', 0, 1),
- BitField('Critical', 0, 1),
- BitField('Reserved', 0, 6),
- BitField('Len', 0, 6),
- ByteEnumField('MDType', 1, {1: 'Fixed Length',
- 2: 'Variable Length'}),
- ByteEnumField('NextProto', 3, {1: 'IPv4',
- 2: 'IPv6',
- 3: 'Ethernet',
- 4: 'NSH',
- 5: 'MPLS'}),
- X3BytesField('NSP', 0),
- ByteField('NSI', 1),
- ConditionalField(XIntField('NPC', 0), lambda pkt: pkt.MDType == 1),
- ConditionalField(XIntField('NSC', 0), lambda pkt: pkt.MDType == 1),
- ConditionalField(XIntField('SPC', 0), lambda pkt: pkt.MDType == 1),
- ConditionalField(XIntField('SSC', 0), lambda pkt: pkt.MDType == 1),
- ConditionalField(PacketListField("ContextHeaders", None,
- NSHTLV, count_from="Length"),
- lambda pkt: pkt.MDType == 2)
- ]
-
- def mysummary(self):
- return self.sprintf("NSP: %NSP% - NSI: %NSI%")
-
-
-bind_layers(Ether, NSH, {'type': 0x894F}, type=0x894F)
-bind_layers(VXLAN, NSH, {'flags': 0xC, 'NextProtocol': 4}, NextProtocol=4)
-
-bind_layers(NSH, IP, {'NextProto': 1}, NextProto=1)
-bind_layers(NSH, IPv6, {'NextProto': 2}, NextProto=2)
-bind_layers(NSH, Ether, {'NextProto': 3}, NextProto=3)
-bind_layers(NSH, NSH, {'NextProto': 4}, NextProto=4)
-bind_layers(NSH, MPLS, {'NextProto': 5}, NextProto=5)
diff --git a/dep/scapy_modules/nvgre.py b/dep/scapy_modules/nvgre.py
deleted file mode 100644
index 8cb9a87..0000000
--- a/dep/scapy_modules/nvgre.py
+++ /dev/null
@@ -1,37 +0,0 @@
-## This file is part of Scapy
-##
-## Copyright (C) Min Cao <min.cao@intel.com>
-
-"""
-NVGRE (Network Virtual GRE).
-"""
-
-from scapy.packet import *
-from scapy.fields import *
-from scapy.layers.inet import UDP,IP
-from scapy.layers.inet6 import IPv6
-from scapy.layers.l2 import Ether
-from scapy.layers.l2 import GRE
-
-IPPROTO_NVGRE=47
-
-class NVGRE(Packet):
- name = "Network Virtual GRE"
- fields_desc = [BitField("c", 0, 1),
- BitField("r", 0, 1),
- BitField("k", 1, 1),
- BitField("s", 0, 1),
- BitField("reserved0", 0, 9),
- BitField("ver", 0, 3),
- XShortField("protocoltype", 0x6558),
- X3BytesField("TNI", 1),
- ByteField("reserved1", 0)]
-
- def mysummary(self):
- return self.sprintf("NVGRE (tni=%NVGRE.tni%)")
-
-
-bind_layers(NVGRE, Ether, protocoltype=0x6558)
-# fix conflict of GRE and NVGRE
-bind_layers(IP, NVGRE, frag=0, proto=IPPROTO_NVGRE)
-
diff --git a/dep/scapy_modules/vxlan.py b/dep/scapy_modules/vxlan.py
deleted file mode 100644
index c2661d6..0000000
--- a/dep/scapy_modules/vxlan.py
+++ /dev/null
@@ -1,92 +0,0 @@
-'''
-Created on Jul 29, 2014
-
-@author: yliu86
-'''
-from scapy.packet import *
-from scapy.fields import *
-from scapy.layers.inet import UDP, IP
-from scapy.layers.inet6 import IPv6
-from scapy.layers.dns import DNS
-from scapy.layers.l2 import Ether
-
-XLAN_PORT=4789
-
-VXLAN_PORT=4789
-_GP_FLAGS = ["R", "R", "R", "A", "R", "R", "D", "R"]
-
-class VXLAN(Packet):
- name = "VXLAN"
- fields_desc = [
- FlagsField("flags", 0x8, 8,
- ['OAM', 'R', 'NextProtocol', 'Instance',
- 'V1', 'V2', 'R', 'G']),
- ConditionalField(
- ShortField("reserved0", 0),
- lambda pkt: pkt.flags & 0x04,
- ),
- ConditionalField(
- ByteEnumField('NextProtocol', 0,
- {0: 'NotDefined',
- 1: 'IPv4',
- 2: 'IPv6',
- 3: 'Ethernet',
- 4: 'NSH'}),
- lambda pkt: pkt.flags & 0x04,
- ),
- ConditionalField(
- X3BytesField("reserved1", 0x000000),
- lambda pkt: (not pkt.flags & 0x80) and (not pkt.flags & 0x04),
- ),
- ConditionalField(
- FlagsField("gpflags", 0x0, 8, _GP_FLAGS),
- lambda pkt: pkt.flags & 0x80,
- ),
- ConditionalField(
- ShortField("gpid", 0),
- lambda pkt: pkt.flags & 0x80,
- ),
- X3BytesField("vni", 0),
- XByteField("reserved2", 0x00),
- ]
-
- # Use default linux implementation port
- overload_fields = {
- UDP: {'dport': 8472},
- }
-
- def mysummary(self):
- if self.flags & 0x80:
- return self.sprintf("VXLAN (vni=%VXLAN.vni% gpid=%VXLAN.gpid%)")
- else:
- return self.sprintf("VXLAN (vni=%VXLAN.vni%)")
-
- def guess_payload_class(self, payload):
- if self.flag == vxlanmagic:
- return VXLAN
- else:
- return Packet.guess_payload_class(self, payload)
-
-bind_layers(UDP, VXLAN, dport=4789) # RFC standard vxlan port
-bind_layers(UDP, VXLAN, dport=4790) # RFC standard vxlan-gpe port
-bind_layers(UDP, VXLAN, dport=6633) # New IANA assigned port for use with NSH
-bind_layers(UDP, VXLAN, dport=8472) # Linux implementation port
-bind_layers(UDP, VXLAN, dport=48879) # Cisco ACI
-bind_layers(UDP, VXLAN, sport=4789)
-bind_layers(UDP, VXLAN, sport=4790)
-bind_layers(UDP, VXLAN, sport=6633)
-bind_layers(UDP, VXLAN, sport=8472)
-# By default, set both ports to the RFC standard
-bind_layers(UDP, VXLAN, sport=4789, dport=4789)
-
-# Dissection
-bind_bottom_up(VXLAN, Ether, NextProtocol=0)
-bind_bottom_up(VXLAN, IP, NextProtocol=1)
-bind_bottom_up(VXLAN, IPv6, NextProtocol=2)
-bind_bottom_up(VXLAN, Ether, NextProtocol=3)
-bind_bottom_up(VXLAN, Ether, NextProtocol=None)
-# Build
-bind_top_down(VXLAN, Ether, flags=12, NextProtocol=0)
-bind_top_down(VXLAN, IP, flags=12, NextProtocol=1)
-bind_top_down(VXLAN, IPv6, flags=12, NextProtocol=2)
-bind_top_down(VXLAN, Ether, flags=12, NextProtocol=3)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dts] [PATCH V1 2/4] framework/packet: use scapy modules instead of local modules
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules instead of local 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 ` LihongX Ma
2020-10-19 18:31 ` [dts] [PATCH V1 3/4] tests: use scapy modules vxlan " LihongX Ma
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: LihongX Ma @ 2020-10-19 18:31 UTC (permalink / raw)
To: dts; +Cc: LihongX Ma
- use GRE instead of NVGRE
- use LLDPDU, LLDPDUManagementAddress instead of LLDP and LLDPManagementAddress
- as vxlan is the default supported layers, delete the extra import action
- add api to analysis the scapy string that include NVGRE field, and will use
GRE instead of it
Signed-off-by: LihongX Ma <lihongx.ma@intel.com>
---
framework/packet.py | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/framework/packet.py b/framework/packet.py
index a7cd172..44b8e0e 100644
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -51,10 +51,9 @@ sys.path.append(DEP_FOLDER + '/scapy_modules')
from utils import convert_ip2int
from utils import convert_int2ip
-scapy_modules_required = {'nvgre': ['NVGRE', 'IPPROTO_NVGRE'],
- 'gtp': ['GTP_U_Header', 'GTP_PDUSession_ExtensionHeader'],
- 'lldp': ['LLDP', 'LLDPManagementAddress'], 'Dot1BR': ['Dot1BR'], 'pfcp': ['PFCP'],
- 'nsh': ['NSH'], 'igmp': ['IGMP'], 'mpls': ['MPLS'], 'sctp': ['SCTP', 'SCTPChunkData'], 'vxlan': ['VXLAN']}
+scapy_modules_required = {'gtp': ['GTP_U_Header', 'GTP_PDUSession_ExtensionHeader'],
+ 'lldp': ['LLDPDU', 'LLDPDUManagementAddress'], 'Dot1BR': ['Dot1BR'], 'pfcp': ['PFCP'],
+ 'nsh': ['NSH'], 'igmp': ['IGMP'], 'mpls': ['MPLS'], 'sctp': ['SCTP', 'SCTPChunkData']}
local_modules = [m[:-3] for m in os.listdir(DEP_FOLDER + '/scapy_modules') if (m.endswith('.py') and not m.startswith('__'))]
for m in scapy_modules_required:
@@ -91,6 +90,14 @@ LayersTypes = {
# ipv4_ext_unknown, ipv6_ext_unknown
"L3": ['ipv4', 'ipv4ihl', 'ipv6', 'ipv4_ext', 'ipv6_ext', 'ipv6_ext2', 'ipv6_frag'],
"L4": ['tcp', 'udp', 'frag', 'sctp', 'icmp', 'nofrag'],
+ # The NVGRE pkt format is
+ # <'ether type'=0x0800 'version'=4, 'protocol'=47 'protocol type'=0x6558>
+ # or
+ # <'ether type'=0x86DD 'version'=6, 'next header'=47 'protocol type'=0x6558'>
+ # The GRE pkt format is
+ # <'ether type'=0x0800 'version'=4, 'protocol'=17 'destination port'=4789>
+ # or
+ # <'ether type'=0x86DD 'version'=6, 'next header'=17 'destination port'=4789>
"TUNNEL": ['ip', 'gre', 'vxlan', 'nvgre', 'geneve', 'grenat'],
"INNER L2": ['inner_mac', 'inner_vlan'],
# inner_ipv4_unknown, inner_ipv6_unknown
@@ -145,14 +152,14 @@ class scapy(object):
'inner_sctp': SCTP(),
'inner_icmp': ICMP(),
- 'lldp': LLDP() / LLDPManagementAddress(),
+ 'lldp': LLDPDU() / LLDPDUManagementAddress(_length=6, _management_address_string_length=6,management_address=':12') / IP(),
'ip_frag': IP(frag=5),
'ipv6_frag': IPv6(src="::1") / IPv6ExtHdrFragment(),
'ip_in_ip': IP() / IP(),
'ip_in_ip_frag': IP() / IP(frag=5),
'ipv6_in_ip': IP() / IPv6(src="::1"),
'ipv6_frag_in_ip': IP() / IPv6(src="::1", nh=44) / IPv6ExtHdrFragment(),
- 'nvgre': NVGRE(),
+ 'nvgre': GRE(key_present=1,proto=0x6558,key=0x00000100),
'geneve': "Not Implement",
}
@@ -685,8 +692,34 @@ class Packet(object):
pkts_str = method_pattern.sub(i.strip('<>')+'()', pkts_str, count=1)
return pkts_str
+ # use the GRE to configure the nvgre package
+ # the field key last Byte configure the reserved1 of NVGRE, first 3 Bytes configure the TNI value of NVGRE
+ def transform_nvgre_layer(self, pkt_str):
+ tni = re.search('TNI\s*=\s*(0x)*(\d*)', pkt_str)
+ if tni is None:
+ nvgre = 'GRE(key_present=1,proto=0x6558,key=0x00000100)'
+ else:
+ tni = int(tni.group(2))
+ tni = tni<<8
+ nvgre = 'GRE(key_present=1,proto=0x6558,key=%d)' % tni
+ pkt_str = re.sub(r'NVGRE\(\)|NVGRE\(TNI=\s*(0x)*\d*\)', nvgre, pkt_str)
+ return pkt_str
+
+ def gernerator_pkt_str(self):
+ pkt_str_list = []
+ for p in self.pktgen.pkts:
+ if not isinstance(p, str):
+ p_str = p.command()
+ else:
+ p_str = p
+ # process the NVGRE
+ if 'NVGRE' in p_str:
+ p_str = self.transform_nvgre_layer(p_str)
+ pkt_str_list.append(p_str)
+ return '[' + ','.join(pkt_str_list) + ']'
+
def send_pkt(self, crb, tx_port='', count=1, interval=0, timeout=120):
- p_str = '[' + ','.join([p.command() if not isinstance(p, str) else p for p in self.pktgen.pkts]) + ']'
+ p_str = self.gernerator_pkt_str()
pkts_str = self._recompose_pkts_str(pkts_str=p_str)
cmd = 'sendp(' + pkts_str + f',iface="{tx_port}",count={count},inter={interval},verbose=False)'
if crb.name == 'tester':
@@ -700,7 +733,7 @@ class Packet(object):
if crb.name != 'tester':
raise Exception('crb should be tester')
scapy_session_bg = crb.prepare_scapy_env()
- p_str = '[' + ','.join([p.command() if not isinstance(p, str) else p for p in self.pktgen.pkts]) + ']'
+ p_str = self.gernerator_pkt_str()
pkts_str = self._recompose_pkts_str(pkts_str=p_str)
cmd = 'sendp(' + pkts_str + f',iface="{tx_port}",count={count},inter={interval},loop={loop},verbose=False)'
scapy_session_bg.send_command(cmd)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dts] [PATCH V1 3/4] tests: use scapy modules vxlan instead of local modules
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules instead of local 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
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
4 siblings, 0 replies; 6+ messages in thread
From: LihongX Ma @ 2020-10-19 18:31 UTC (permalink / raw)
To: dts; +Cc: LihongX Ma
- 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dts] [PATCH V1 4/4] tests: use scapy modules gre instead of local modules nvgre
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules instead of local modules LihongX Ma
` (2 preceding siblings ...)
2020-10-19 18:31 ` [dts] [PATCH V1 3/4] tests: use scapy modules vxlan " LihongX Ma
@ 2020-10-19 18:31 ` LihongX Ma
2020-10-28 6:35 ` [dts] [PATCH V1 0/4] use scapy modules instead of local modules Tu, Lijuan
4 siblings, 0 replies; 6+ messages in thread
From: LihongX Ma @ 2020-10-19 18:31 UTC (permalink / raw)
To: dts; +Cc: LihongX Ma
- 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(-)
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)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dts] [PATCH V1 0/4] use scapy modules instead of local modules
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules instead of local modules LihongX Ma
` (3 preceding siblings ...)
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 ` Tu, Lijuan
4 siblings, 0 replies; 6+ messages in thread
From: Tu, Lijuan @ 2020-10-28 6:35 UTC (permalink / raw)
To: Ma, LihongX, dts; +Cc: Ma, LihongX
> LihongX Ma (4):
> dep: remove the scapy modules in dep
> framework/packet: use scapy modules instead of local modules
> tests: use scapy modules vxlan instead of local modules
> tests: use scapy modules gre instead of local modules nvgre
Applied the series, thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-28 6:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 18:31 [dts] [PATCH V1 0/4] use scapy modules instead of local 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 ` [dts] [PATCH V1 3/4] tests: use scapy modules vxlan " LihongX Ma
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
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).