From patchwork Tue Sep 8 03:26:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76826 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C988A04AA; Tue, 8 Sep 2020 05:51:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B58C1C138; Tue, 8 Sep 2020 05:51:33 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id F20ED1C134 for ; Tue, 8 Sep 2020 05:51:30 +0200 (CEST) IronPort-SDR: sCKl/Wb+n4crpSfXNAFRw1to2qwHyA+6Gga6xDA/k/U+xccN3JyL1ZHw75KimzM8XM9iQm5wh2 elWhHpawGwSA== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088231" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088231" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:30 -0700 IronPort-SDR: ejzanh9RSOf9pOs0UvgNaVvGQFzzoyWO/f780gNeO+YfeUOw2Pe6hqoXnAsB9c24btlYr0P/7t SJXlXM5wUNMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407002992" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:28 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:39 +0000 Message-Id: <20200908032645.11852-2-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 1/7]dep: mv scapy modules to new folder scapy_modules X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- dep/gtp_v2.py | 934 ------------------------------ dep/{ => scapy_modules}/Dot1BR.py | 2 +- dep/{ => scapy_modules}/gtp.py | 55 +- dep/{ => scapy_modules}/igmp.py | 0 dep/{ => scapy_modules}/lldp.py | 2 +- dep/{ => scapy_modules}/mpls.py | 0 dep/{ => scapy_modules}/nsh.py | 0 dep/{ => scapy_modules}/nvgre.py | 6 +- dep/{ => scapy_modules}/pfcp.py | 0 dep/{ => scapy_modules}/vxlan.py | 0 10 files changed, 51 insertions(+), 948 deletions(-) delete mode 100644 dep/gtp_v2.py rename dep/{ => scapy_modules}/Dot1BR.py (98%) rename dep/{ => scapy_modules}/gtp.py (94%) rename dep/{ => scapy_modules}/igmp.py (100%) rename dep/{ => scapy_modules}/lldp.py (99%) rename dep/{ => scapy_modules}/mpls.py (100%) rename dep/{ => scapy_modules}/nsh.py (100%) rename dep/{ => scapy_modules}/nvgre.py (90%) rename dep/{ => scapy_modules}/pfcp.py (100%) rename dep/{ => scapy_modules}/vxlan.py (100%) diff --git a/dep/gtp_v2.py b/dep/gtp_v2.py deleted file mode 100644 index 6cffd47b..00000000 --- a/dep/gtp_v2.py +++ /dev/null @@ -1,934 +0,0 @@ -# Copyright (C) 2017 Alessio Deiana -# 2017 Alexis Sultan - -# 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 . - -# scapy.contrib.description = GPRS Tunneling Protocol v2 (GTPv2) -# scapy.contrib.status = loads - -import struct - - -from scapy.compat import orb -from scapy.fields import BitEnumField, BitField, ByteEnumField, ByteField, \ - ConditionalField, IntField, IPField, LongField, PacketField, \ - PacketListField, ShortEnumField, ShortField, StrFixedLenField, \ - StrLenField, ThreeBytesField, XBitField, XIntField, XShortField -from scapy.packet import bind_layers, Packet, Raw -from scapy.volatile import RandIP, RandShort - - -from scapy.contrib import gtp - - -RATType = { - 6: "EUTRAN", -} - -GTPmessageType = {1: "echo_request", - 2: "echo_response", - 32: "create_session_req", - 33: "create_session_res", - 34: "modify_bearer_req", - 35: "modify_bearer_res", - 36: "delete_session_req", - 37: "delete_session_res", - 70: "downlink_data_notif_failure_indic", - 170: "realease_bearers_req", - 171: "realease_bearers_res", - 176: "downlink_data_notif", - 177: "downlink_data_notif_ack", - } - -IEType = {1: "IMSI", - 2: "Cause", - 3: "Recovery Restart", - 71: "APN", - 72: "AMBR", - 73: "EPS Bearer ID", - 74: "IPv4", - 75: "MEI", - 76: "MSISDN", - 77: "Indication", - 78: "Protocol Configuration Options", - 79: "PAA", - 80: "Bearer QoS", - 82: "RAT", - 83: "Serving Network", - 86: "ULI", - 87: "F-TEID", - 93: "Bearer Context", - 94: "Charging ID", - 95: "Charging Characteristics", - 99: "PDN Type", - 114: "UE Time zone", - 126: "Port Number", - 127: "APN Restriction", - 128: "Selection Mode", - 161: "Max MBR/APN-AMBR (MMBR)" - } - -CauseValues = { - 16: "Request Accepted", -} - - -class GTPHeader(Packet): - # 3GPP TS 29.060 V9.1.0 (2009-12) - # without the version - name = "GTP v2 Header" - fields_desc = [BitField("version", 2, 3), - BitField("P", 1, 1), - BitField("T", 1, 1), - BitField("SPARE", 0, 1), - BitField("SPARE", 0, 1), - BitField("SPARE", 0, 1), - ByteEnumField("gtp_type", None, GTPmessageType), - ShortField("length", None), - ConditionalField(IntField("teid", 0), - lambda pkt:pkt.T == 1), - ThreeBytesField("seq", RandShort()), - ByteField("SPARE", 0) - ] - - def post_build(self, p, pay): - p += pay - if self.length is None: - tmp_len = len(p) - 8 - p = p[:2] + struct.pack("!H", tmp_len) + p[4:] - return p - - def hashret(self): - return struct.pack("B", self.version) + self.payload.hashret() - - def answers(self, other): - return (isinstance(other, GTPHeader) and - self.version == other.version and - self.payload.answers(other.payload)) - - -class IE_IPv4(gtp.IE_Base): - name = "IE IPv4" - fields_desc = [ByteEnumField("ietype", 74, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - IPField("address", RandIP())] - - -class IE_MEI(gtp.IE_Base): - name = "IE MEI" - fields_desc = [ByteEnumField("ietype", 75, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - LongField("MEI", 0)] - - -def IE_Dispatcher(s): - """Choose the correct Information Element class.""" - - # Get the IE type - ietype = orb(s[0]) - cls = ietypecls.get(ietype, Raw) - - # if ietype greater than 128 are TLVs - if cls is Raw and ietype > 128: - cls = IE_NotImplementedTLV - - return cls(s) - - -class IE_EPSBearerID(gtp.IE_Base): - name = "IE EPS Bearer ID" - fields_desc = [ByteEnumField("ietype", 73, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ByteField("EBI", 0)] - - -class IE_RAT(gtp.IE_Base): - name = "IE RAT" - fields_desc = [ByteEnumField("ietype", 82, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ByteEnumField("RAT_type", None, RATType)] - - -class IE_ServingNetwork(gtp.IE_Base): - name = "IE Serving Network" - fields_desc = [ByteEnumField("ietype", 83, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - gtp.TBCDByteField("MCC", "", 2), - gtp.TBCDByteField("MNC", "", 1)] - - -class ULI_RAI(gtp.IE_Base): - name = "IE Tracking Area Identity" - fields_desc = [ - gtp.TBCDByteField("MCC", "", 2), - # MNC: if the third digit of MCC is 0xf, then the length of - # MNC is 1 byte - gtp.TBCDByteField("MNC", "", 1), - ShortField("LAC", 0), - ShortField("RAC", 0)] - - -class ULI_SAI(gtp.IE_Base): - name = "IE Tracking Area Identity" - fields_desc = [ - gtp.TBCDByteField("MCC", "", 2), - gtp.TBCDByteField("MNC", "", 1), - ShortField("LAC", 0), - ShortField("SAC", 0)] - - -class ULI_TAI(gtp.IE_Base): - name = "IE Tracking Area Identity" - fields_desc = [ - gtp.TBCDByteField("MCC", "", 2), - gtp.TBCDByteField("MNC", "", 1), - ShortField("TAC", 0)] - - -class ULI_ECGI(gtp.IE_Base): - name = "IE E-UTRAN Cell Identifier" - fields_desc = [ - gtp.TBCDByteField("MCC", "", 2), - gtp.TBCDByteField("MNC", "", 1), - BitField("SPARE", 0, 4), - BitField("ECI", 0, 28)] - - -class IE_ULI(gtp.IE_Base): - name = "IE ULI" - fields_desc = [ByteEnumField("ietype", 86, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("SPARE", 0, 2), - BitField("LAI_Present", 0, 1), - BitField("ECGI_Present", 0, 1), - BitField("TAI_Present", 0, 1), - BitField("RAI_Present", 0, 1), - BitField("SAI_Present", 0, 1), - BitField("CGI_Present", 0, 1), - ConditionalField( - PacketField("SAI", 0, ULI_SAI), lambda pkt: bool(pkt.SAI_Present)), - ConditionalField( - PacketField("RAI", 0, ULI_RAI), lambda pkt: bool(pkt.RAI_Present)), - ConditionalField( - PacketField("TAI", 0, ULI_TAI), lambda pkt: bool(pkt.TAI_Present)), - ConditionalField(PacketField("ECGI", 0, ULI_ECGI), - lambda pkt: bool(pkt.ECGI_Present))] - - -class IE_FTEID(gtp.IE_Base): - name = "IE F-TEID" - fields_desc = [ByteEnumField("ietype", 87, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("ipv4_present", 0, 1), - BitField("ipv6_present", 0, 1), - BitField("InterfaceType", 0, 6), - XIntField("GRE_Key", 0), - ConditionalField( - IPField("ipv4", RandIP()), lambda pkt: pkt.ipv4_present), - ConditionalField(XBitField("ipv6", "2001::", 128), - lambda pkt: pkt.ipv6_present)] - - -class IE_BearerContext(gtp.IE_Base): - name = "IE Bearer Context" - fields_desc = [ByteEnumField("ietype", 93, IEType), - ShortField("length", 0), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - PacketListField("IE_list", None, IE_Dispatcher, - length_from=lambda pkt: pkt.length)] - - -class IE_NotImplementedTLV(gtp.IE_Base): - name = "IE not implemented" - fields_desc = [ByteEnumField("ietype", 0, IEType), - ShortField("length", None), - StrLenField("data", "", length_from=lambda x: x.length)] - - -class IE_IMSI(gtp.IE_Base): - name = "IE IMSI" - fields_desc = [ByteEnumField("ietype", 1, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - gtp.TBCDByteField("IMSI", "33607080910", - length_from=lambda x: x.length)] - - -class IE_Cause(gtp.IE_Base): - name = "IE Cause" - fields_desc = [ByteEnumField("ietype", 2, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ByteEnumField("Cause", 1, CauseValues), - BitField("SPARE", 0, 5), - BitField("PCE", 0, 1), - BitField("BCE", 0, 1), - BitField("CS", 0, 1)] - - -class IE_RecoveryRestart(gtp.IE_Base): - name = "IE Recovery Restart" - fields_desc = [ByteEnumField("ietype", 3, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ByteField("restart_counter", 0)] - - -class IE_APN(gtp.IE_Base): - name = "IE APN" - fields_desc = [ByteEnumField("ietype", 71, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - gtp.APNStrLenField("APN", "internet", - length_from=lambda x: x.length)] - - -class IE_AMBR(gtp.IE_Base): - name = "IE AMBR" - fields_desc = [ByteEnumField("ietype", 72, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - IntField("AMBR_Uplink", 0), - IntField("AMBR_Downlink", 0)] - - -class IE_MSISDN(gtp.IE_Base): - name = "IE MSISDN" - fields_desc = [ByteEnumField("ietype", 76, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - gtp.TBCDByteField("digits", "33123456789", - length_from=lambda x: x.length)] - - -class IE_Indication(gtp.IE_Base): - name = "IE Cause" - fields_desc = [ByteEnumField("ietype", 77, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("DAF", 0, 1), - BitField("DTF", 0, 1), - BitField("HI", 0, 1), - BitField("DFI", 0, 1), - BitField("OI", 0, 1), - BitField("ISRSI", 0, 1), - BitField("ISRAI", 0, 1), - BitField("SGWCI", 0, 1), - BitField("SQCI", 0, 1), - BitField("UIMSI", 0, 1), - BitField("CFSI", 0, 1), - BitField("CRSI", 0, 1), - BitField("PS", 0, 1), - BitField("PT", 0, 1), - BitField("SI", 0, 1), - BitField("MSV", 0, 1), - - ConditionalField( - BitField("RetLoc", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("PBIC", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("SRNI", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("S6AF", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("S4AF", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("MBMDT", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("ISRAU", 0, 1), lambda pkt: pkt.length > 2), - ConditionalField( - BitField("CCRSI", 0, 1), lambda pkt: pkt.length > 2), - - ConditionalField( - BitField("CPRAI", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("ARRL", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("PPOFF", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("PPON", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("PPSI", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("CSFBI", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("CLII", 0, 1), lambda pkt: pkt.length > 3), - ConditionalField( - BitField("CPSR", 0, 1), lambda pkt: pkt.length > 3), - - ] - - -PDN_TYPES = { - 1: "IPv4", - 2: "IPv6", - 3: "IPv4/IPv6", -} - -PCO_OPTION_TYPES = { - 3: "IPv4", - 129: "Primary DNS Server IP address", - 130: "Primary NBNS Server IP address", - 131: "Secondary DNS Server IP address", - 132: "Secondary NBNS Server IP address", -} - - -class PCO_Option(Packet): - def extract_padding(self, pkt): - return "", pkt - - -class PCO_IPv4(PCO_Option): - name = "IPv4" - fields_desc = [ByteEnumField("type", None, PCO_OPTION_TYPES), - ByteField("length", 0), - IPField("address", RandIP())] - - -class PCO_Primary_DNS(PCO_Option): - name = "Primary DNS Server IP Address" - fields_desc = [ByteEnumField("type", None, PCO_OPTION_TYPES), - ByteField("length", 0), - IPField("address", RandIP())] - - -class PCO_Primary_NBNS(PCO_Option): - name = "Primary DNS Server IP Address" - fields_desc = [ByteEnumField("type", None, PCO_OPTION_TYPES), - ByteField("length", 0), - IPField("address", RandIP())] - - -class PCO_Secondary_DNS(PCO_Option): - name = "Secondary DNS Server IP Address" - fields_desc = [ByteEnumField("type", None, PCO_OPTION_TYPES), - ByteField("length", 0), - IPField("address", RandIP())] - - -class PCO_Secondary_NBNS(PCO_Option): - name = "Secondary NBNS Server IP Address" - fields_desc = [ByteEnumField("type", None, PCO_OPTION_TYPES), - ByteField("length", 0), - IPField("address", RandIP())] - - -PCO_PROTOCOL_TYPES = { - 0x0001: 'P-CSCF IPv6 Address Request', - 0x0003: 'DNS Server IPv6 Address Request', - 0x0005: 'MS Support of Network Requested Bearer Control indicator', - 0x000a: 'IP Allocation via NAS', - 0x000d: 'DNS Server IPv4 Address Request', - 0x000c: 'P-CSCF IPv4 Address Request', - 0x0010: 'IPv4 Link MTU Request', - 0x8021: 'IPCP', - 0xc023: 'Password Authentication Protocol', - 0xc223: 'Challenge Handshake Authentication Protocol', -} - -PCO_OPTION_CLASSES = { - 3: PCO_IPv4, - 129: PCO_Primary_DNS, - 130: PCO_Primary_NBNS, - 131: PCO_Secondary_DNS, - 132: PCO_Secondary_NBNS, -} - - -def PCO_option_dispatcher(s): - """Choose the correct PCO element.""" - option = orb(s[0]) - - cls = PCO_OPTION_CLASSES.get(option, Raw) - return cls(s) - - -def len_options(pkt): - return pkt.length - 4 if pkt.length else 0 - - -class PCO_P_CSCF_IPv6_Address_Request(PCO_Option): - name = "PCO PCO-P CSCF IPv6 Address Request" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - ConditionalField(XBitField("address", - "2001:db8:0:42::", 128), - lambda pkt: pkt.length)] - - -class PCO_DNS_Server_IPv6(PCO_Option): - name = "PCO DNS Server IPv6 Address Request" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - ConditionalField(XBitField("address", - "2001:db8:0:42::", 128), - lambda pkt: pkt.length)] - - -class PCO_SOF(PCO_Option): - name = "PCO MS Support of Network Requested Bearer Control indicator" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - ] - - -class PCO_PPP(PCO_Option): - name = "PPP IP Control Protocol" - fields_desc = [ByteField("Code", 0), - ByteField("Identifier", 0), - ShortField("length", 0), - PacketListField("Options", None, PCO_option_dispatcher, - length_from=len_options)] - - def extract_padding(self, pkt): - return "", pkt - - -class PCO_IP_Allocation_via_NAS(PCO_Option): - name = "PCO IP Address allocation via NAS Signaling" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - PacketListField("Options", None, PCO_option_dispatcher, - length_from=len_options)] - - -class PCO_P_CSCF_IPv4_Address_Request(PCO_Option): - name = "PCO PCO-P CSCF IPv4 Address Request" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - ConditionalField(IPField("address", RandIP()), - lambda pkt: pkt.length)] - - -class PCO_DNS_Server_IPv4(PCO_Option): - name = "PCO DNS Server IPv4 Address Request" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - ConditionalField(IPField("address", RandIP()), - lambda pkt: pkt.length)] - - -class PCO_IPv4_Link_MTU_Request(PCO_Option): - name = "PCO IPv4 Link MTU Request" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - ConditionalField(ShortField("MTU_size", 1500), - lambda pkt: pkt.length)] - - -class PCO_IPCP(PCO_Option): - name = "PCO Internet Protocol Control Protocol" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - PacketField("PPP", None, PCO_PPP)] - - -class PCO_PPP_Auth(PCO_Option): - name = "PPP Password Authentication Protocol" - fields_desc = [ByteField("Code", 0), - ByteField("Identifier", 0), - ShortField("length", 0), - ByteField("PeerID_length", 0), - ConditionalField(StrFixedLenField( - "PeerID", - "", - length_from=lambda pkt: pkt.PeerID_length), - lambda pkt: pkt.PeerID_length), - ByteField("Password_length", 0), - ConditionalField( - StrFixedLenField( - "Password", - "", - length_from=lambda pkt: pkt.Password_length), - lambda pkt: pkt.Password_length)] - - -class PCO_PasswordAuthentificationProtocol(PCO_Option): - name = "PCO Password Authentication Protocol" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - PacketField("PPP", None, PCO_PPP_Auth)] - - -class PCO_PPP_Challenge(PCO_Option): - name = "PPP Password Authentication Protocol" - fields_desc = [ByteField("Code", 0), - ByteField("Identifier", 0), - ShortField("length", 0), - ByteField("value_size", 0), - ConditionalField(StrFixedLenField( - "value", "", - length_from=lambda pkt: pkt.value_size), - lambda pkt: pkt.value_size), - ConditionalField(StrFixedLenField( - "name", "", - length_from=lambda pkt: pkt.length - pkt.value_size - 5), # noqa: E501 - lambda pkt: pkt.length)] - - -class PCO_ChallengeHandshakeAuthenticationProtocol(PCO_Option): - name = "PCO Password Authentication Protocol" - fields_desc = [ShortEnumField("type", None, PCO_PROTOCOL_TYPES), - ByteField("length", 0), - PacketField("PPP", None, PCO_PPP_Challenge)] - - -PCO_PROTOCOL_CLASSES = { - 0x0001: PCO_P_CSCF_IPv6_Address_Request, - 0x0003: PCO_DNS_Server_IPv6, - 0x0005: PCO_SOF, - 0x000a: PCO_IP_Allocation_via_NAS, - 0x000c: PCO_P_CSCF_IPv4_Address_Request, - 0x000d: PCO_DNS_Server_IPv4, - 0x0010: PCO_IPv4_Link_MTU_Request, - 0x8021: PCO_IPCP, - 0xc023: PCO_PasswordAuthentificationProtocol, - 0xc223: PCO_ChallengeHandshakeAuthenticationProtocol, -} - - -def PCO_protocol_dispatcher(s): - """Choose the correct PCO element.""" - proto_num = orb(s[0]) * 256 + orb(s[1]) - cls = PCO_PROTOCOL_CLASSES.get(proto_num, Raw) - return cls(s) - - -class IE_PCO(gtp.IE_Base): - name = "IE Protocol Configuration Options" - fields_desc = [ByteEnumField("ietype", 78, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("Extension", 0, 1), - BitField("SPARE", 0, 4), - BitField("PPP", 0, 3), - PacketListField("Protocols", None, PCO_protocol_dispatcher, - length_from=lambda pkt: pkt.length - 1)] - - -class IE_PAA(gtp.IE_Base): - name = "IE PAA" - fields_desc = [ByteEnumField("ietype", 79, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("SPARE", 0, 5), - BitEnumField("PDN_type", None, 3, PDN_TYPES), - ConditionalField( - ByteField("ipv6_prefix_length", 8), - lambda pkt: pkt.PDN_type in (2, 3)), - ConditionalField( - XBitField("ipv6", "2001:db8:0:42::", 128), - lambda pkt: pkt.PDN_type in (2, 3)), - ConditionalField( - IPField("ipv4", 0), lambda pkt: pkt.PDN_type in (1, 3)), - ] - - -class IE_Bearer_QoS(gtp.IE_Base): - name = "IE Bearer Quality of Service" - fields_desc = [ByteEnumField("ietype", 80, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("SPARE", 0, 1), - BitField("PCI", 0, 1), - BitField("PriorityLevel", 0, 4), - BitField("SPARE", 0, 1), - BitField("PVI", 0, 1), - ByteField("QCI", 0), - BitField("MaxBitRateForUplink", 0, 40), - BitField("MaxBitRateForDownlink", 0, 40), - BitField("GuaranteedBitRateForUplink", 0, 40), - BitField("GuaranteedBitRateForDownlink", 0, 40)] - - -class IE_ChargingID(gtp.IE_Base): - name = "IE Charging ID" - fields_desc = [ByteEnumField("ietype", 94, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - IntField("ChargingID", 0)] - - -class IE_ChargingCharacteristics(gtp.IE_Base): - name = "IE Charging ID" - fields_desc = [ByteEnumField("ietype", 95, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - XShortField("ChargingCharacteristric", 0)] - - -class IE_PDN_type(gtp.IE_Base): - name = "IE PDN Type" - fields_desc = [ByteEnumField("ietype", 99, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("SPARE", 0, 5), - BitEnumField("PDN_type", None, 3, PDN_TYPES)] - - -class IE_UE_Timezone(gtp.IE_Base): - name = "IE UE Time zone" - fields_desc = [ByteEnumField("ietype", 114, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ByteField("Timezone", 0), - ByteField("DST", 0)] - - -class IE_Port_Number(gtp.IE_Base): - name = "IE Port Number" - fields_desc = [ByteEnumField("ietype", 126, IEType), - ShortField("length", 2), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ShortField("PortNumber", RandShort())] - - -class IE_APN_Restriction(gtp.IE_Base): - name = "IE APN Restriction" - fields_desc = [ByteEnumField("ietype", 127, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - ByteField("APN_Restriction", 0)] - - -class IE_SelectionMode(gtp.IE_Base): - name = "IE Selection Mode" - fields_desc = [ByteEnumField("ietype", 128, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - BitField("SPARE", 0, 6), - BitField("SelectionMode", 0, 2)] - - -class IE_MMBR(gtp.IE_Base): - name = "IE Max MBR/APN-AMBR (MMBR)" - fields_desc = [ByteEnumField("ietype", 72, IEType), - ShortField("length", None), - BitField("CR_flag", 0, 4), - BitField("instance", 0, 4), - IntField("uplink_rate", 0), - IntField("downlink_rate", 0)] - - -ietypecls = {1: IE_IMSI, - 2: IE_Cause, - 3: IE_RecoveryRestart, - 71: IE_APN, - 72: IE_AMBR, - 73: IE_EPSBearerID, - 74: IE_IPv4, - 75: IE_MEI, - 76: IE_MSISDN, - 77: IE_Indication, - 78: IE_PCO, - 79: IE_PAA, - 80: IE_Bearer_QoS, - 82: IE_RAT, - 83: IE_ServingNetwork, - 86: IE_ULI, - 87: IE_FTEID, - 93: IE_BearerContext, - 94: IE_ChargingID, - 95: IE_ChargingCharacteristics, - 99: IE_PDN_type, - 114: IE_UE_Timezone, - 126: IE_Port_Number, - 127: IE_APN_Restriction, - 128: IE_SelectionMode, - 161: IE_MMBR} - -# -# GTPv2 Commands -# 3GPP TS 29.060 V9.1.0 (2009-12) -# - - -class GTPV2Command(Packet): - fields_desc = [PacketListField("IE_list", None, IE_Dispatcher)] - - -class GTPV2EchoRequest(GTPV2Command): - name = "GTPv2 Echo Request" - - -class GTPV2EchoResponse(GTPV2Command): - name = "GTPv2 Echo Response" - - -class GTPV2CreateSessionRequest(GTPV2Command): - name = "GTPv2 Create Session Request" - - -class GTPV2CreateSessionResponse(GTPV2Command): - name = "GTPv2 Create Session Response" - - -class GTPV2DeleteSessionRequest(GTPV2Command): - name = "GTPv2 Delete Session Request" - - -class GTPV2DeleteSessionResponse(GTPV2Command): - name = "GTPv2 Delete Session Request" - - -class GTPV2ModifyBearerCommand(GTPV2Command): - name = "GTPv2 Modify Bearer Command" - - -class GTPV2ModifyBearerFailureNotification(GTPV2Command): - name = "GTPv2 Modify Bearer Command" - - -class GTPV2DownlinkDataNotifFailureIndication(GTPV2Command): - name = "GTPv2 Downlink Data Notification Failure Indication" - - -class GTPV2ModifyBearerRequest(GTPV2Command): - name = "GTPv2 Modify Bearer Request" - - -class GTPV2ModifyBearerResponse(GTPV2Command): - name = "GTPv2 Modify Bearer Response" - - -class GTPV2UpdateBearerRequest(GTPV2Command): - name = "GTPv2 Update Bearer Request" - - -class GTPV2UpdateBearerResponse(GTPV2Command): - name = "GTPv2 Update Bearer Response" - - -class GTPV2DeleteBearerRequest(GTPV2Command): - name = "GTPv2 Delete Bearer Request" - - -class GTPV2SuspendNotification(GTPV2Command): - name = "GTPv2 Suspend Notification" - - -class GTPV2SuspendAcknowledge(GTPV2Command): - name = "GTPv2 Suspend Acknowledge" - - -class GTPV2ResumeNotification(GTPV2Command): - name = "GTPv2 Resume Notification" - - -class GTPV2ResumeAcknowledge(GTPV2Command): - name = "GTPv2 Resume Acknowledge" - - -class GTPV2DeleteBearerResponse(GTPV2Command): - name = "GTPv2 Delete Bearer Response" - - -class GTPV2CreateIndirectDataForwardingTunnelRequest(GTPV2Command): - name = "GTPv2 Create Indirect Data Forwarding Tunnel Request" - - -class GTPV2CreateIndirectDataForwardingTunnelResponse(GTPV2Command): - name = "GTPv2 Create Indirect Data Forwarding Tunnel Response" - - -class GTPV2DeleteIndirectDataForwardingTunnelRequest(GTPV2Command): - name = "GTPv2 Delete Indirect Data Forwarding Tunnel Request" - - -class GTPV2DeleteIndirectDataForwardingTunnelResponse(GTPV2Command): - name = "GTPv2 Delete Indirect Data Forwarding Tunnel Response" - - -class GTPV2ReleaseBearerRequest(GTPV2Command): - name = "GTPv2 Release Bearer Request" - - -class GTPV2ReleaseBearerResponse(GTPV2Command): - name = "GTPv2 Release Bearer Response" - - -class GTPV2DownlinkDataNotif(GTPV2Command): - name = "GTPv2 Download Data Notification" - - -class GTPV2DownlinkDataNotifAck(GTPV2Command): - name = "GTPv2 Download Data Notification Acknowledgment" - - -bind_layers(GTPHeader, GTPV2EchoRequest, gtp_type=1, T=0) -bind_layers(GTPHeader, GTPV2EchoResponse, gtp_type=2, T=0) -bind_layers(GTPHeader, GTPV2CreateSessionRequest, gtp_type=32) -bind_layers(GTPHeader, GTPV2CreateSessionResponse, gtp_type=33) -bind_layers(GTPHeader, GTPV2ModifyBearerRequest, gtp_type=34) -bind_layers(GTPHeader, GTPV2ModifyBearerResponse, gtp_type=35) -bind_layers(GTPHeader, GTPV2DeleteSessionRequest, gtp_type=36) -bind_layers(GTPHeader, GTPV2DeleteSessionResponse, gtp_type=37) -bind_layers(GTPHeader, GTPV2ModifyBearerCommand, gtp_type=64) -bind_layers(GTPHeader, GTPV2ModifyBearerFailureNotification, gtp_type=65) -bind_layers(GTPHeader, GTPV2DownlinkDataNotifFailureIndication, gtp_type=70) -bind_layers(GTPHeader, GTPV2UpdateBearerRequest, gtp_type=97) -bind_layers(GTPHeader, GTPV2UpdateBearerResponse, gtp_type=98) -bind_layers(GTPHeader, GTPV2DeleteBearerRequest, gtp_type=99) -bind_layers(GTPHeader, GTPV2DeleteBearerResponse, gtp_type=100) -bind_layers(GTPHeader, GTPV2SuspendNotification, gtp_type=162) -bind_layers(GTPHeader, GTPV2SuspendAcknowledge, gtp_type=163) -bind_layers(GTPHeader, GTPV2ResumeNotification, gtp_type=164) -bind_layers(GTPHeader, GTPV2ResumeAcknowledge, gtp_type=165) -bind_layers( - GTPHeader, GTPV2CreateIndirectDataForwardingTunnelRequest, gtp_type=166) -bind_layers( - GTPHeader, GTPV2CreateIndirectDataForwardingTunnelResponse, gtp_type=167) -bind_layers( - GTPHeader, GTPV2DeleteIndirectDataForwardingTunnelRequest, gtp_type=168) -bind_layers( - GTPHeader, GTPV2DeleteIndirectDataForwardingTunnelResponse, gtp_type=169) -bind_layers(GTPHeader, GTPV2ReleaseBearerRequest, gtp_type=170) -bind_layers(GTPHeader, GTPV2ReleaseBearerResponse, gtp_type=171) -bind_layers(GTPHeader, GTPV2DownlinkDataNotif, gtp_type=176) -bind_layers(GTPHeader, GTPV2DownlinkDataNotifAck, gtp_type=177) diff --git a/dep/Dot1BR.py b/dep/scapy_modules/Dot1BR.py similarity index 98% rename from dep/Dot1BR.py rename to dep/scapy_modules/Dot1BR.py index cc3c01f4..4a681ad1 100644 --- a/dep/Dot1BR.py +++ b/dep/scapy_modules/Dot1BR.py @@ -17,7 +17,7 @@ from scapy.data import ETHER_TYPES class Dot1BR(Packet): name = "802.1BR" aliastypes = [ Ether ] - fields_desc = [ + fields_desc = [ BitField("EPCP", 0, 3), BitField("EEDI", 0, 1), BitField("IngressECIDbase", 0, 12), diff --git a/dep/gtp.py b/dep/scapy_modules/gtp.py similarity index 94% rename from dep/gtp.py rename to dep/scapy_modules/gtp.py index 76f5e8e4..df101c62 100644 --- a/dep/gtp.py +++ b/dep/scapy_modules/gtp.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python + # Copyright (C) 2018 Leonardo Monteiro # 2017 Alexis Sultan # 2017 Alessio Deiana @@ -9,7 +11,7 @@ # scapy.contrib.description = GPRS Tunneling Protocol (GTP) # scapy.contrib.status = loads - +from __future__ import absolute_import import struct @@ -20,9 +22,11 @@ from scapy.fields import BitEnumField, BitField, ByteEnumField, ByteField, \ IPField, PacketListField, ShortField, StrFixedLenField, StrLenField, \ XBitField, XByteField, XIntField from scapy.layers.inet import IP, UDP -from scapy.layers.inet6 import IP6Field +from scapy.layers.inet6 import IPv6, IP6Field +from scapy.layers.ppp import PPP from scapy.modules.six.moves import range -from scapy.packet import bind_layers, Packet, Raw +from scapy.packet import bind_layers, bind_bottom_up, bind_top_down, \ + Packet, Raw from scapy.volatile import RandInt, RandIP, RandNum, RandString @@ -144,6 +148,7 @@ ExtensionHeadersTypes = { 1: "Reserved", 2: "Reserved", 64: "UDP Port", + 133: "PDU Session Container", 192: "PDCP PDU Number", 193: "Reserved", 194: "Reserved" @@ -196,6 +201,19 @@ class GTP_UDPPort_ExtensionHeader(GTP_ExtensionHeader): ByteEnumField("next_ex", 0, ExtensionHeadersTypes), ] +class GTP_PDUSession_ExtensionHeader(GTP_ExtensionHeader): + fields_desc = [ByteField("length", 0x02), + BitField("pdu_type", 0, 4), + BitField("spare0", 0, 4), + BitField("ppp", 0, 1), + BitField("rqi", 0, 1), + BitField("qos_flow", 0, 6), + BitField("ppi", 0, 3), + BitField("spare1", 0, 5), + BitField("reserved", 0, 24), + ByteEnumField("next_ex", 0, ExtensionHeadersTypes), ] + + class GTP_PDCP_PDU_ExtensionHeader(GTP_ExtensionHeader): fields_desc = [ByteField("length", 0x01), ShortField("pdcp_pdu", None), @@ -252,6 +270,19 @@ class GTP_U_Header(GTPHeader): # encapsulated in G-PDUs. A G-PDU is a packet including a GTP-U header and a T-PDU. The Path Protocol # noqa: E501 # defines the path and the GTP-U header defines the tunnel. Several tunnels may be multiplexed on a single path. # noqa: E501 + def guess_payload_class(self, payload): + # Snooped from Wireshark + # https://github.com/boundary/wireshark/blob/07eade8124fd1d5386161591b52e177ee6ea849f/epan/dissectors/packet-gtp.c#L8195 # noqa: E501 + if self.gtp_type == 255: + sub_proto = orb(payload[0]) + if sub_proto >= 0x45 and sub_proto <= 0x4e: + return IP + elif (sub_proto & 0xf0) == 0x60: + return IPv6 + else: + return PPP + return GTPHeader.guess_payload_class(self, payload) + # Some gtp_types have to be associated with a certain type of header GTPforcedTypes = { @@ -706,7 +737,8 @@ class IE_ExtensionHeaderList(IE_Base): name = "Extension Header List" fields_desc = [ByteEnumField("ietype", 141, IEType), FieldLenField("length", None, length_of="extension_headers"), # noqa: E501 - FieldListField("extension_headers", [64, 192], ByteField("", 0))] # noqa: E501 + #FieldListField("extension_headers", [64, 192], ByteField("", 0))] # noqa: E501 + FieldListField("extension_headers", [64, 133, 192], ByteField("", 0))] # noqa: E501 class IE_NotImplementedTLV(Packet): @@ -885,8 +917,9 @@ class GTPmorethan1500(Packet): # Bind GTP-C -bind_layers(UDP, GTPHeader, dport=2123) -bind_layers(UDP, GTPHeader, sport=2123) +bind_bottom_up(UDP, GTPHeader, dport=2123) +bind_bottom_up(UDP, GTPHeader, sport=2123) +bind_layers(UDP, GTPHeader, dport=2123, sport=2123) bind_layers(GTPHeader, GTPEchoRequest, gtp_type=1, S=1) bind_layers(GTPHeader, GTPEchoResponse, gtp_type=2, S=1) bind_layers(GTPHeader, GTPCreatePDPContextRequest, gtp_type=16) @@ -898,10 +931,14 @@ bind_layers(GTPHeader, GTPDeletePDPContextResponse, gtp_type=21) bind_layers(GTPHeader, GTPPDUNotificationRequest, gtp_type=27) bind_layers(GTPHeader, GTPSupportedExtensionHeadersNotification, gtp_type=31, S=1) # noqa: E501 bind_layers(GTPHeader, GTP_UDPPort_ExtensionHeader, next_ex=64, E=1) +bind_layers(GTPHeader, GTP_PDUSession_ExtensionHeader, next_ex=133, E=1) bind_layers(GTPHeader, GTP_PDCP_PDU_ExtensionHeader, next_ex=192, E=1) # Bind GTP-U -bind_layers(UDP, GTP_U_Header, dport=2152) -bind_layers(UDP, GTP_U_Header, sport=2152) +bind_bottom_up(UDP, GTP_U_Header, dport=2152) +bind_bottom_up(UDP, GTP_U_Header, sport=2152) +bind_layers(UDP, GTP_U_Header, dport=2152, sport=2152) bind_layers(GTP_U_Header, GTPErrorIndication, gtp_type=26, S=1) -bind_layers(GTP_U_Header, IP, gtp_type=255) +bind_top_down(GTP_U_Header, IP, gtp_type=255) +bind_top_down(GTP_U_Header, IPv6, gtp_type=255) +bind_top_down(GTP_U_Header, PPP, gtp_type=255) diff --git a/dep/igmp.py b/dep/scapy_modules/igmp.py similarity index 100% rename from dep/igmp.py rename to dep/scapy_modules/igmp.py diff --git a/dep/lldp.py b/dep/scapy_modules/lldp.py similarity index 99% rename from dep/lldp.py rename to dep/scapy_modules/lldp.py index faa3b4d0..8eb8beaf 100644 --- a/dep/lldp.py +++ b/dep/scapy_modules/lldp.py @@ -89,7 +89,7 @@ class LLDPOrgSpecGeneric(LLDPGeneric): fields_desc = [BitField("type", 127, 7), BitFieldLenField("length", None, 9, length_of="value"), X3BytesField("oui", 0), - ByteField("subtype", 0), + ByteField("subtype", 0), StrLenField("value", "", length_from=lambda x: x.length - 4)] diff --git a/dep/mpls.py b/dep/scapy_modules/mpls.py similarity index 100% rename from dep/mpls.py rename to dep/scapy_modules/mpls.py diff --git a/dep/nsh.py b/dep/scapy_modules/nsh.py similarity index 100% rename from dep/nsh.py rename to dep/scapy_modules/nsh.py diff --git a/dep/nvgre.py b/dep/scapy_modules/nvgre.py similarity index 90% rename from dep/nvgre.py rename to dep/scapy_modules/nvgre.py index a3fcf49b..8cb9a87a 100644 --- a/dep/nvgre.py +++ b/dep/scapy_modules/nvgre.py @@ -1,5 +1,5 @@ ## This file is part of Scapy -## +## ## Copyright (C) Min Cao """ @@ -27,8 +27,8 @@ class NVGRE(Packet): X3BytesField("TNI", 1), ByteField("reserved1", 0)] - def mysummary(self): - return self.sprintf("NVGRE (tni=%NVGRE.tni%)") + def mysummary(self): + return self.sprintf("NVGRE (tni=%NVGRE.tni%)") bind_layers(NVGRE, Ether, protocoltype=0x6558) diff --git a/dep/pfcp.py b/dep/scapy_modules/pfcp.py similarity index 100% rename from dep/pfcp.py rename to dep/scapy_modules/pfcp.py diff --git a/dep/vxlan.py b/dep/scapy_modules/vxlan.py similarity index 100% rename from dep/vxlan.py rename to dep/scapy_modules/vxlan.py From patchwork Tue Sep 8 03:26:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76827 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4F77A04B1; Tue, 8 Sep 2020 05:51:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A5AC1C198; Tue, 8 Sep 2020 05:51:33 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 120491C134 for ; Tue, 8 Sep 2020 05:51:31 +0200 (CEST) IronPort-SDR: MtmqwcwSksCASf8XOw3gK5K9KWehfNjhqN/9bGjY2RzG4okZSTMCFSouCPQN0l3kTKG84HWOH6 L6p7UdNEwG4w== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088233" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088233" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:31 -0700 IronPort-SDR: dlaARiPNp3wAhmyH5IDUsXKuZUXlHtSiMRRMqXQsX1v6NWLVf71/YhoLUv5OndONisieJt7uSr oltTQoM2OtQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407003002" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:30 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:40 +0000 Message-Id: <20200908032645.11852-3-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 2/7]framework/dts: add suite log for scapy session X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- framework/dts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/dts.py b/framework/dts.py index 2d86bc35..2a657e53 100644 --- a/framework/dts.py +++ b/framework/dts.py @@ -265,6 +265,10 @@ def dts_log_testsuite(duts, tester, suite_obj, log_handler, test_classname): """ log_handler.config_suite(test_classname, 'dts') tester.logger.config_suite(test_classname, 'tester') + if hasattr(tester, 'logger_alt'): + tester.logger_alt.config_suite(test_classname, 'tester') + if hasattr(tester, 'logger_scapy'): + tester.logger_scapy.config_suite(test_classname, 'tester') for dutobj in duts: dutobj.logger.config_suite(test_classname, 'dut') From patchwork Tue Sep 8 03:26:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76828 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BD2A7A04AA; Tue, 8 Sep 2020 05:51:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B01911C19B; Tue, 8 Sep 2020 05:51:34 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9E54E1C19B for ; Tue, 8 Sep 2020 05:51:33 +0200 (CEST) IronPort-SDR: JJ9HVxxgiXkQ642SvDqTBBtJTa7DRcfkQUDTwjQSzegOLr7uxigRKrPGXLWJqPY0hGf5LPFPp8 X3U0xGMXrh/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088235" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088235" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:32 -0700 IronPort-SDR: vihbIlF2WkgbxkrM7QRsZBo8dmhR2h13zV75A9y/5Kw8S9qRHkSAl9WqQCFT5I+pKUzqCZ4htL o/Y57dLm2Mag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407003005" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:31 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:41 +0000 Message-Id: <20200908032645.11852-4-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 3/7]framework/packet: update packet module for saving sending packet time X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- framework/packet.py | 159 +++++++++++++++++++++++--------------------- 1 file changed, 83 insertions(+), 76 deletions(-) diff --git a/framework/packet.py b/framework/packet.py index 603840b4..6a306cba 100644 --- a/framework/packet.py +++ b/framework/packet.py @@ -34,35 +34,54 @@ Base on scapy(python program for packet manipulation) """ from socket import AF_INET6 +from importlib import import_module from scapy.all import * -from scapy.layers.sctp import SCTP, SCTPChunkData - # load extension layers exec_file = os.path.realpath(__file__) DTS_PATH = exec_file.replace('/framework/packet.py', '') # exec_file might be .pyc file, if so, remove 'c'. TMP_PATH = DTS_PATH[:-1] + '/output/tmp/pcap/' if exec_file.endswith('.pyc') else DTS_PATH + '/output/tmp/pcap/' - if not os.path.exists(TMP_PATH): os.system('mkdir -p %s' % TMP_PATH) + DEP_FOLDER = DTS_PATH + '/dep' sys.path.append(DEP_FOLDER) - -from vxlan import VXLAN -from nvgre import NVGRE, IPPROTO_NVGRE -from scapy.contrib.gtp import * -from lldp import LLDP, LLDPManagementAddress -from Dot1BR import Dot1BR -from nsh import NSH -from mpls import MPLS -from igmp import IGMP -from pfcp import PFCP +sys.path.append(DEP_FOLDER + '/scapy_modules') from utils import convert_ip2int from utils import convert_int2ip -# for saving command history -from utils import get_backtrace_object +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']} +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: + if m in local_modules: + module = import_module(m) + for clazz in scapy_modules_required[m]: + locals().update({clazz: getattr(module, clazz)}) + else: + if m == 'sctp': + module = import_module(f'scapy.layers.{m}') + for clazz in scapy_modules_required[m]: + locals().update({clazz: getattr(module, clazz)}) + else: + module = import_module(f'scapy.contrib.{m}') + for clazz in scapy_modules_required[m]: + locals().update({clazz: getattr(module, clazz)}) + +def get_scapy_module_impcmd(): + cmd_li = list() + for m in scapy_modules_required: + if m in local_modules: + cmd_li.append(f'from {m} import {",".join(scapy_modules_required[m])}') + else: + cmd_li.append(f'from scapy.contirb.{m} import {",".join(scapy_modules_required[m])}') + return ';'.join(cmd_li) + +SCAPY_IMP_CMD = get_scapy_module_impcmd() # packet generator type should be configured later PACKETGEN = "scapy" @@ -139,7 +158,7 @@ class scapy(object): def __init__(self): self.pkt = None - self.pkts = [] + self.pkts = list() def append_pkts(self): self.pkts.append(self.pkt) @@ -329,7 +348,7 @@ class scapy(object): pkt_layer.vni = vni def nsh(self, pkt_layer, ver=0, oam=0, critical=0, reserved=0, len=0, mdtype=1, nextproto=3, - nsp=0x0, nsi=1, npc= 0x0, nsc= 0x0, spc= 0x0, ssc= 0x0): + nsp=0x0, nsi=1, npc=0x0, nsc=0x0, spc=0x0, ssc=0x0): pkt_layer.Ver = ver pkt_layer.OAM = oam pkt_layer.Critical = critical @@ -354,7 +373,6 @@ class scapy(object): class Packet(object): - """ Module for config/create packet Based on scapy module @@ -469,8 +487,7 @@ class Packet(object): layer_li = [re.sub('\(.*?\)', '', i) for i in scapy_str.split('/')] self.pkt_type = '_'.join(layer_li) self._load_pkt_layers() - pkt = eval(scapy_str) - self.pktgen.assign_pkt(pkt) + self.pktgen.assign_pkt(scapy_str) def append_pkt(self, args=None, **kwargs): """ @@ -641,67 +658,58 @@ class Packet(object): self.pktgen.pkts.append(i) return p - def _send_pkt(self, crb, tx_port='', count=1, send_bg=False, loop=0, inter=0, timeout=15): + def send_pkt_bg_with_pcapfile(self, crb, tx_port='', count=1, loop=0, inter=0): """ - + send packet background with a pcap file, got an advantage in sending a large number of packets :param crb: session or crb object :param tx_port: ether to send packet :param count: send times - :param send_bg: send packet background :param loop: send packet in a loop - :param inter: interval time - :return: None + :param inter: interval time per packet + :return: send session """ - # save pkts to local pcap file, then copy to remote tester tmp directory - - time_stamp = str(time.time()) - pcap_file = 'scapy_{}.pcap'.format(tx_port) + time_stamp - self.save_pcapfile(crb, pcap_file) - scapy_cmd = 'scapy_{}.cmd'.format(tx_port) + time_stamp - cmd_str = 'from scapy.all import *\np=rdpcap("%s")\nprint("packet ready for sending...")\nfor i in p:\n\tprint(i.command())\nsendp(p, iface="%s", count=%d, loop=%d, inter=%0.3f, verbose=False)' % ( - crb.tmp_file + pcap_file, tx_port, count, loop, inter) - # write send cmd file to local tmp directory then copy to remote tester tmp folder - with open(TMP_PATH + scapy_cmd, 'w') as f: - f.write(cmd_str) - crb.session.copy_file_to(TMP_PATH + scapy_cmd, crb.tmp_file) - - if send_bg: # if send_bg create a new session to execute send action - session_prefix = 'scapy_bg_session' - scapy_session = crb.create_session(session_prefix + time_stamp) - scapy_session.send_command('python3 %s' % crb.tmp_file + scapy_cmd) + if crb.name != 'tester': + raise Exception('crb should be tester') + wrpcap('_', self.pktgen.pkts) + file_path = '/tmp/%s.pcap' % tx_port + scapy_session_bg = crb.prepare_scapy_env() + scapy_session_bg.copy_file_to('_', file_path) + scapy_session_bg.send_expect('pkts = rdpcap("%s")' % file_path, '>>> ') + scapy_session_bg.send_command('sendp(pkts, iface="%s",count=%s,loop=%s,inter=%s)' % (tx_port, count, loop, inter)) + return scapy_session_bg + + def _recompose_pkts_str(self, pkts_str): + method_pattern = re.compile('<.+?>') + method_li = method_pattern.findall(pkts_str) + for i in method_li: + pkts_str = method_pattern.sub(i.strip('<>')+'()', pkts_str, count=1) + return pkts_str + + 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]) + ']' + 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': + crb.scapy_session.send_expect(cmd, '>>> ', timeout=timeout) + elif crb.name.startswith("tester_scapy"): + crb.send_expect(cmd, '>>> ', timeout=timeout) else: - crb.send_expect('python3 %s' % crb.tmp_file + scapy_cmd, '# ', timeout=timeout) - return crb.tmp_file + scapy_cmd - - def send_pkt(self, crb, tx_port='', count=1, interval=0, timeout=15): - self._send_pkt(crb, tx_port, count, inter=interval, timeout=timeout) - - def send_pkt_bg(self, crb, tx_port='', count=-1, loop=1, interval=0, timeout=3): - return self._send_pkt(crb, tx_port=tx_port, count=count, send_bg=True, loop=loop, inter=interval, - timeout=timeout) - - def stop_send_pkt_bg(self, crb, filenames): + raise Exception("crb should be tester\'s session and initialized") + + def send_pkt_bg(self, crb, tx_port='', count=-1, interval=0, loop=1): + 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]) + ']' + 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) + return scapy_session_bg + + @staticmethod + def stop_send_pkt_bg(session): # stop sending action - pids = [] - if isinstance(filenames, list): - for file in filenames: - out = crb.send_expect('ps -ef |grep %s|grep -v grep' % file, expected='# ') - try: - pids.append(re.search('\d+', out).group()) - except AttributeError as e: - print((e, ' :%s not killed' % file)) - else: - out = crb.send_expect('ps -ef |grep %s|grep -v grep' % filenames, expected='# ') - try: - pids.append(re.search('\d+', out).group()) - except AttributeError as e: - print((e, ' :%s not killed' % filenames)) - pid = ' '.join(pids) - if pid: - crb.send_expect('kill -9 %s' % pid, expected='# ') - for i in crb.sessions: - if i.name.startswith('scapy_bg_session'): - crb.destroy_session(i) + session.send_expect('^C', '>>> ') def check_layer_config(self): """ @@ -835,7 +843,8 @@ class Packet(object): if 'inner' in layer: layer = layer[6:] - + if isinstance(self.pktgen.pkt, str): + raise Exception('string type packet not support config layer') pkt_layer = self.pktgen.pkt.getlayer(idx) layer_conf = getattr(self.pktgen, layer) setattr(self, 'configured_layer_%s' % layer, True) @@ -1081,10 +1090,8 @@ def strip_pktload(pkt=None, layer="L2", p_index=0): ############################################################################### ############################################################################### if __name__ == "__main__": - pkt = Packet('Ether(type=0x894f)/NSH(Len=0x6,NextProto=0x0,NSP=0x000002,NSI=0xff)') sendp(pkt, iface='lo') - pkt.config_layer('ipv4', {'dst': '192.168.8.8'}) pkt.append_pkt(pkt_type='IPv6_TCP', pkt_len=100) pkt.append_pkt(pkt_type='TCP', pkt_len=100) pkt.config_layer('tcp', config={'flags': 'A'}) From patchwork Tue Sep 8 03:26:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76829 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DCAC6A04AA; Tue, 8 Sep 2020 05:51:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D4F741C196; Tue, 8 Sep 2020 05:51:35 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 827021C134 for ; Tue, 8 Sep 2020 05:51:34 +0200 (CEST) IronPort-SDR: BEuT44m2lnX5ZIhexpuYhq5GmsyvZTH4iqSWJF+OQyppX+7/UkHriBowojeJT5oGqBjkZTfIc4 7VWnNJ1UMarQ== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088236" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088236" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:33 -0700 IronPort-SDR: b5b7x+WS3EtnpORLxWO3tkBcdZ7sTk1QccyERgf5iwgj0daC+oVD533osKW6cHOvHeN3wPmV+t FbJUwHmhOlwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407003009" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:32 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:42 +0000 Message-Id: <20200908032645.11852-5-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 4/7]framework/tester: prepare packet send session and update other packet related part X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- framework/tester.py | 70 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/framework/tester.py b/framework/tester.py index f55818e3..ca179b28 100644 --- a/framework/tester.py +++ b/framework/tester.py @@ -46,9 +46,9 @@ import random from utils import GREEN, convert_int2ip, convert_ip2int from exception import ParameterInvalidException from multiprocessing import Process - from pktgen import getPacketGenerator from config import PktgenConf +from packet import SCAPY_IMP_CMD class Tester(Crb): @@ -64,6 +64,7 @@ class Tester(Crb): def __init__(self, crb, serializer): self.NAME = 'tester' + self.scapy_session = None super(Tester, self).__init__(crb, serializer, self.NAME) self.bgProcIsRunning = False @@ -75,11 +76,34 @@ class Tester(Crb): self.re_run_time = 0 self.pktgen = None self.ixia_packet_gen = None + self.tmp_scapy_module_dir = '/tmp/dep' + # prepare for scapy env + self.scapy_sessions_li = list() + self.scapy_session = self.prepare_scapy_env() self.tmp_file = '/tmp/tester/' out = self.send_expect('ls -d %s' % self.tmp_file, '# ', verify=True) if out == 2: self.send_expect('mkdir -p %s' % self.tmp_file, '# ') + def prepare_scapy_env(self): + session_name = 'tester_scapy' if not self.scapy_sessions_li else f'tester_scapy_{random.random()}' + session = self.create_session(session_name) + self.scapy_sessions_li.append(session) + session.send_expect('scapy', '>>> ') + file_dir = os.path.dirname(__file__).split(os.path.sep) + lib_path = os.path.sep.join(file_dir[:-1]) + '/dep/scapy_modules/' + exists_flag = self.alt_session.session.send_expect(f'ls {self.tmp_scapy_module_dir}', '# ', verify=True) + if exists_flag == 2: + self.alt_session.session.send_expect(f'mkdir -p {self.tmp_scapy_module_dir}', '# ', verify=True) + scapy_modules_path = [lib_path+i for i in os.listdir(lib_path) if i.endswith('.py')] + path = ' '.join(scapy_modules_path) + session.copy_file_to(src=path, dst=self.tmp_scapy_module_dir) + session.session.send_expect(f"sys.path.append('{self.tmp_scapy_module_dir}')", ">>> ") + + out = session.session.send_expect(SCAPY_IMP_CMD, '>>> ') + if 'ImportError' in out: + session.logger.warning(f'entering import error: {out}') + return session def init_ext_gen(self): """ @@ -688,7 +712,7 @@ class Tester(Crb): Callable function for parallel processes """ print(GREEN("Transmitting and sniffing packets, please wait few minutes...")) - return pkt.send_pkt_bg(crb=self, tx_port=intf, count=send_times, loop=0, interval=interval) + return pkt.send_pkt_bg_with_pcapfile(crb=self, tx_port=intf, count=send_times, loop=0, inter=interval) def check_random_pkts(self, portList, pktnum=2000, interval=0.01, allow_miss=True, seq_check=False, params=None): """ @@ -716,22 +740,28 @@ class Tester(Crb): inst = module.start_tcpdump(self, rxIntf, count=pktnum, filters=[{'layer': 'network', 'config': {'srcport': '65535'}}, {'layer': 'network', 'config': {'dstport': '65535'}}]) - rx_inst[rxport] = inst - filenames = [] + bg_sessions = list() for txport, _ in portList: txIntf = self.get_interface(txport) - filenames.append(self.parallel_transmit_ptks(pkt=tx_pkts[txport], intf=txIntf, send_times=1, interval=interval)) + bg_sessions.append(self.parallel_transmit_ptks(pkt=tx_pkts[txport], intf=txIntf, send_times=1, interval=interval)) # Verify all packets sleep(interval * pktnum + 1) - flag = True - while flag: - for i in filenames: - flag = self.send_expect('ps -ef |grep %s|grep -v grep' % i, expected='# ') - if flag: + timeout = 60 + for i in bg_sessions: + while timeout: + try: + i.send_expect('', '>>> ', timeout=1) + except Exception as e: + print(e) self.logger.info('wait for the completion of sending pkts...') - sleep(1.5) + timeout -= 1 continue + else: + break + else: + self.logger.info('exceeded timeout, force to stop background packet sending to avoid dead loop') + pkt_c.stop_send_pkt_bg(i) prev_id = -1 for txport, rxport in portList: p = module.stop_and_load_tcpdump_packets(rx_inst[rxport]) @@ -814,7 +844,9 @@ class Tester(Crb): Kill all scapy process or DPDK application on tester. """ if not self.has_external_traffic_generator(): - self.alt_session.send_expect('killall scapy 2>/dev/null; echo tester', '# ', 5) + out = self.session.send_command('') + if '>>>' in out: + self.session.send_expect('quit()', '# ', timeout=3) if killall: super(Tester, self).kill_all() @@ -833,12 +865,20 @@ class Tester(Crb): self.ixia_packet_gen.close() self.ixia_packet_gen = None - if self.session: - self.session.close() - self.session = None + if self.scapy_sessions_li: + for i in self.scapy_sessions_li: + if i.session.isalive(): + i.session.send_expect("^c", ">>> ", timeout=2) + i.session.send_expect("^d", "#", timeout=2) + i.session.close() + self.scapy_sessions_li.clear() + if self.alt_session: self.alt_session.close() self.alt_session = None + if self.session: + self.session.close() + self.session = None def crb_exit(self): """ From patchwork Tue Sep 8 03:26:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76830 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1399BA04B1; Tue, 8 Sep 2020 05:51:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0979D1C1A6; Tue, 8 Sep 2020 05:51:37 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id F05921C1A2 for ; Tue, 8 Sep 2020 05:51:35 +0200 (CEST) IronPort-SDR: +95O/E4pnXiMiyPf38ybTP+bB7pEtNper9fNvj/6LwqKN526DJ46458sKFL1es259unPyTAJXp 5jmeReC6Ufig== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088239" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088239" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:35 -0700 IronPort-SDR: pSGB5tByz3DVozFQfipvcbHWKo8xmP3Q/tVL4dqq8qcVm7i/CMSflQjQV5t3WLIaSMxHMkPd2/ p9kMveEz7j5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407003012" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:34 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:43 +0000 Message-Id: <20200908032645.11852-6-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 5/7]tests/TestSuite_multiple_pthread: update argument for stop_send_pkt_bg method X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- tests/TestSuite_multiple_pthread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestSuite_multiple_pthread.py b/tests/TestSuite_multiple_pthread.py index 83ab7bd7..694993a6 100644 --- a/tests/TestSuite_multiple_pthread.py +++ b/tests/TestSuite_multiple_pthread.py @@ -229,7 +229,7 @@ class TestMultiplePthread(TestCase): Run after each test case. """ if len(self.send_sessions) != 0: - self.pkt.stop_send_pkt_bg(self.tester, self.send_sessions) + self.pkt.stop_send_pkt_bg(self.send_sessions) self.dut.kill_all() def tear_down_all(self): From patchwork Tue Sep 8 03:26:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76831 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 462B1A04AA; Tue, 8 Sep 2020 05:51:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 392311C1A2; Tue, 8 Sep 2020 05:51:38 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id B3FC31C134 for ; Tue, 8 Sep 2020 05:51:36 +0200 (CEST) IronPort-SDR: u3dnAh31DNCpbFXrIE5cm7eP9dvRnon9aHysghfDhcYMw+1f0kZeCBmGv7LgUwMTEb5AnFu7qh Z/MSMf2j8imQ== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088242" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088242" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:36 -0700 IronPort-SDR: DjI8rBBDNCi4Dh+IdL7LpcjgZ2uhVRq8OjW3kDd8OuPPQwRdCfr0c7hAV39taKMNevnXc7/7Np kp+l1amJrCqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407003018" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:35 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:44 +0000 Message-Id: <20200908032645.11852-7-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 6/7]tests/TestSuite_vf_packet_rxtx: update argument for stop_send_pkt_bg method X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- tests/TestSuite_vf_packet_rxtx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestSuite_vf_packet_rxtx.py b/tests/TestSuite_vf_packet_rxtx.py index a5963054..e8cdb112 100644 --- a/tests/TestSuite_vf_packet_rxtx.py +++ b/tests/TestSuite_vf_packet_rxtx.py @@ -287,7 +287,7 @@ class TestVfPacketRxtx(TestCase): dst_mac = pmd0_vf0_mac self.vm0_testpmd.execute_cmd('clear port stats all') pkt = Packet("Ether(dst='%s', src='%s')/IP(len=46)" % (dst_mac, self.tester.get_mac(tx_port))) - filename = pkt.send_pkt_bg(crb=self.tester, tx_port=self.tester.get_interface(tx_port), loop=1) + session_bg = pkt.send_pkt_bg(crb=self.tester, tx_port=self.tester.get_interface(tx_port), loop=1) #vf port stop/start can trigger reset action for num in range(1000): @@ -296,7 +296,7 @@ class TestVfPacketRxtx(TestCase): self.vm1_testpmd.execute_cmd('port start all') time.sleep(0.1) - pkt.stop_send_pkt_bg(self.tester, filename) + pkt.stop_send_pkt_bg(session_bg) pmd0_vf0_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) pmd0_vf1_stats = self.vm0_testpmd.get_pmd_stats(port_id_1) From patchwork Tue Sep 8 03:26:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiao, QimaiX" X-Patchwork-Id: 76832 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BE71A04AA; Tue, 8 Sep 2020 05:51:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 636AC1C190; Tue, 8 Sep 2020 05:51:39 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 1C5DF1C134 for ; Tue, 8 Sep 2020 05:51:37 +0200 (CEST) IronPort-SDR: TakkLXKNhFzoYKH3ldSaqAwVo6a1d40N+YGoqAVNX96OWJpKIT53/3S4M4EacgNy2mYMgoAIxY K7MSvuK5wwsw== X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="158088244" X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="158088244" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 20:51:37 -0700 IronPort-SDR: krC0WIDFF7rzxUFZrE/q5xPk7+uvuhhIu9b/1Ok6c6CGjnOfZTndTu+ZRTwHxjEGKnaUfuuwBI ShMNdDY8z3Bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,404,1592895600"; d="scan'208";a="407003027" Received: from unknown (HELO localhost.localdomain) ([10.240.183.52]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2020 20:51:36 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 8 Sep 2020 03:26:45 +0000 Message-Id: <20200908032645.11852-8-qimaix.xiao@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908032645.11852-1-qimaix.xiao@intel.com> References: <20200908032645.11852-1-qimaix.xiao@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V1 7/7]tests/TestSuite_vf_port_start_stop: update argument for stop_send_pkt_bg method X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: Xiao Qimai --- tests/TestSuite_vf_port_start_stop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestSuite_vf_port_start_stop.py b/tests/TestSuite_vf_port_start_stop.py index 933b1e2d..a55900c3 100644 --- a/tests/TestSuite_vf_port_start_stop.py +++ b/tests/TestSuite_vf_port_start_stop.py @@ -182,7 +182,7 @@ class TestVfPortStartStop(TestCase): def tear_down(self): if self.send_pks_session: - self.pkts.stop_send_pkt_bg(self.tester, self.send_pks_session) + self.pkts.stop_send_pkt_bg(self.send_pks_session) if self.setup_1pf_2vf_1vm_env_flag == 1: self.destroy_1pf_2vf_1vm_env()