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 7BE0AA04A3; Mon, 4 Nov 2019 06:33:15 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 47314493D; Mon, 4 Nov 2019 06:33:15 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id BCA5E3256 for ; Mon, 4 Nov 2019 06:33:13 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2019 21:33:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,266,1569308400"; d="scan'208";a="191640497" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga007.jf.intel.com with ESMTP; 03 Nov 2019 21:33:12 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 3 Nov 2019 21:33:12 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 3 Nov 2019 21:33:11 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.200]) with mapi id 14.03.0439.000; Mon, 4 Nov 2019 13:33:10 +0800 From: "Chen, Zhaoyan" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Ma, LihongX" , "Chen, Zhaoyan" Thread-Topic: [dts] [PATCH V2 1/3][nsh] dep: add support of mpls and nsh Thread-Index: AQHVgxdn+ARMRefThkqMT2c8bC8J1qd6nDvg Date: Mon, 4 Nov 2019 05:33:09 +0000 Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41E0F174@SHSMSX104.ccr.corp.intel.com> References: <1571089742-7077-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1571089742-7077-1-git-send-email-lihongx.ma@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGVlYjgzNmYtZjVmNS00OWJjLWFkZTUtYjY0NmI5MTViZmJkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN25ZR211dTJOdWdCOXNmMzM5Q1BLUUtGRXZVRm5lXC9pakhFV0FzSlp0QVdvYzhIRkZDTlU5bUx0eklQVVVtRGYifQ== dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action 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 V2 1/3][nsh] dep: add support of mpls and nsh 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" Acked-by: Chen, Zhaoyan Regards, Zhaoyan Chen > -----Original Message----- > From: dts On Behalf Of lihong > Sent: Tuesday, October 15, 2019 5:49 AM > To: dts@dpdk.org > Cc: Ma, LihongX > Subject: [dts] [PATCH V2 1/3][nsh] dep: add support of mpls and nsh >=20 > Signed-off-by: lihong > --- > dep/mpls.py | 24 ++++++++++++++++++++++ dep/nsh.py | 67 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 91 insertions(+) > create mode 100644 dep/mpls.py > create mode 100644 dep/nsh.py >=20 > diff --git a/dep/mpls.py b/dep/mpls.py > new file mode 100644 > index 0000000..0b37bba > --- /dev/null > +++ b/dep/mpls.py > @@ -0,0 +1,24 @@ > +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 =3D "MPLS" > + fields_desc =3D [ BitField("label", 3, 20), > + BitField("cos", 0, 3), > + BitField("s", 1, 1), > + ByteField("ttl", 0) ] > + > + def guess_payload_class(self, payload): > + if len(payload) >=3D 1: > + ip_version =3D (ord(payload[0]) >> 4) & 0xF > + if ip_version =3D=3D 4: > + return IP > + elif ip_version =3D=3D 6: > + return IPv6 > + return Padding > + > +bind_layers(Ether, MPLS, type=3D0x8847) > +bind_layers(GRE, MPLS, proto=3D0x8847) > diff --git a/dep/nsh.py b/dep/nsh.py > new file mode 100644 > index 0000000..2e249c9 > --- /dev/null > +++ b/dep/nsh.py > @@ -0,0 +1,67 @@ > +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 =3D 'NSH metadata' > + fields_desc =3D [XIntField('value', 0)] > + > + > +class NSHTLV(Packet): > + "NSH MD-type 2 - Variable Length Context Headers" > + name =3D "NSHTLV" > + fields_desc =3D [ > + 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=3D'Len') > + ] > + > + > +class NSH(Packet): > + """Network Service Header. > + NSH MD-type 1 if there is no ContextHeaders""" > + name =3D "NSH" > + > + fields_desc =3D [ > + 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 =3D= =3D 1), > + ConditionalField(XIntField('NSC', 0), lambda pkt: pkt.MDType =3D= =3D 1), > + ConditionalField(XIntField('SPC', 0), lambda pkt: pkt.MDType =3D= =3D 1), > + ConditionalField(XIntField('SSC', 0), lambda pkt: pkt.MDType =3D= =3D 1), > + ConditionalField(PacketListField("ContextHeaders", None, > + NSHTLV, count_from=3D"Length"), > + lambda pkt: pkt.MDType =3D=3D 2) > + ] > + > + def mysummary(self): > + return self.sprintf("NSP: %NSP% - NSI: %NSI%") > + > + > +bind_layers(Ether, NSH, {'type': 0x894F}, type=3D0x894F) > +bind_layers(VXLAN, NSH, {'flags': 0xC, 'NextProtocol': 4}, > +NextProtocol=3D4) > + > +bind_layers(NSH, IP, {'NextProto': 1}, NextProto=3D1) bind_layers(NSH, > +IPv6, {'NextProto': 2}, NextProto=3D2) bind_layers(NSH, Ether, > +{'NextProto': 3}, NextProto=3D3) bind_layers(NSH, NSH, {'NextProto': 4}, > +NextProto=3D4) bind_layers(NSH, MPLS, {'NextProto': 5}, NextProto=3D5) > -- > 2.7.4