From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5E800A04F1; Mon, 6 Jan 2020 06:43:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A4921D5B8; Mon, 6 Jan 2020 06:43:55 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 6951C1D5B7 for ; Mon, 6 Jan 2020 06:43:53 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jan 2020 21:43:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,401,1571727600"; d="scan'208";a="420601578" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 05 Jan 2020 21:43:52 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 5 Jan 2020 21:43:51 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 5 Jan 2020 21:43:51 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 5 Jan 2020 21:43:51 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.30]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.39]) with mapi id 14.03.0439.000; Mon, 6 Jan 2020 13:43:50 +0800 From: "Ma, LihongX" To: "dts@dpdk.org" Thread-Topic: [dts][PATCH V1] dep/vxlan: optimization the pkt of vxlan Thread-Index: AQHVxFOJezkNOlx5bkWlAw/tBUHK1KfdH9DA Date: Mon, 6 Jan 2020 05:43:49 +0000 Message-ID: References: <1578262199-13378-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1578262199-13378-1-git-send-email-lihongx.ma@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan 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" Tested-by: ma,lihong -----Original Message----- From: Ma, LihongX=20 Sent: Monday, January 6, 2020 6:10 AM To: dts@dpdk.org Cc: Ma, LihongX Subject: [dts][PATCH V1] dep/vxlan: optimization the pkt of vxlan Signed-off-by: lihong --- dep/vxlan.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/dep/vxlan.py b/dep/vxlan.py index d160718..f60f2a1 100644 --- a/dep/vxlan.py +++ b/dep/vxlan.py @@ -6,19 +6,60 @@ Created on Jul 29, 2014 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 =20 vxlanmagic =3D "0x8" =20 VXLAN_PORT=3D4789 +_GP_FLAGS =3D ["R", "R", "R", "A", "R", "R", "D", "R"] =20 class VXLAN(Packet): name =3D "VXLAN" - fields_desc =3D [ByteField("flags", 8), - X3BytesField("reserved1", 0), - X3BytesField("vni", 0), - ByteField("reserved2", 0)] + fields_desc =3D [ + 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 =3D { + UDP: {'dport': 8472}, + } + + def mysummary(self): + if self.flags & 0x80: + return self.sprintf("VXLAN (vni=3D%VXLAN.vni% gpid=3D%VXLAN.gp= id%)") + else: + return self.sprintf("VXLAN (vni=3D%VXLAN.vni%)") =20 def guess_payload_class(self, payload): if self.flag =3D=3D vxlanmagic: @@ -26,9 +67,13 @@ class VXLAN(Packet): else: return Packet.guess_payload_class(self, payload) =20 - def mysummary(self): - return self.sprintf("VXLAN (vni=3D%VXLAN.vni%)") - split_layers(UDP, DNS, sport=3D53) -bind_layers(UDP, VXLAN, dport=3DVXLAN_PORT) -bind_layers(VXLAN, Ether) +bind_layers(UDP, VXLAN, dport=3D4789) # RFC standard port=20 +bind_layers(UDP, VXLAN, dport=3D6633) # New IANA assigned port for use=20 +with NSH bind_layers(UDP, VXLAN, dport=3D8472) # Linux implementation=20 +port bind_layers(VXLAN, Ether, {'flags': 0x8}) bind_layers(VXLAN,=20 +Ether, {'flags': 0x88}) bind_layers(VXLAN, Ether, {'flags': 0xC,=20 +'NextProtocol': 0}, NextProtocol=3D0) bind_layers(VXLAN, IP, {'flags':=20 +0xC, 'NextProtocol': 1}, NextProtocol=3D1) bind_layers(VXLAN, IPv6,=20 +{'flags': 0xC, 'NextProtocol': 2}, NextProtocol=3D2) bind_layers(VXLAN,=20 +Ether, {'flags': 0xC, 'NextProtocol': 3}, NextProtocol=3D3) -- 2.7.4