test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan
@ 2020-01-05 22:09 lihong
  2020-01-06  5:43 ` Ma, LihongX
  2020-01-06  8:53 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: lihong @ 2020-01-05 22:09 UTC (permalink / raw)
  To: dts; +Cc: lihong

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 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
 
 vxlanmagic = "0x8"
 
 VXLAN_PORT=4789
+_GP_FLAGS = ["R", "R", "R", "A", "R", "R", "D", "R"]
 
 class VXLAN(Packet):
     name = "VXLAN"
-    fields_desc = [ByteField("flags", 8),
-                   X3BytesField("reserved1", 0),
-                   X3BytesField("vni", 0),
-                   ByteField("reserved2", 0)]
+    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:
@@ -26,9 +67,13 @@ class VXLAN(Packet):
         else:
             return Packet.guess_payload_class(self, payload)
 
-    def mysummary(self):
-        return self.sprintf("VXLAN (vni=%VXLAN.vni%)")
-
 split_layers(UDP, DNS, sport=53)
-bind_layers(UDP, VXLAN, dport=VXLAN_PORT)
-bind_layers(VXLAN, Ether)
+bind_layers(UDP, VXLAN, dport=4789)  # RFC standard 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(VXLAN, Ether, {'flags': 0x8})
+bind_layers(VXLAN, Ether, {'flags': 0x88})
+bind_layers(VXLAN, Ether, {'flags': 0xC, 'NextProtocol': 0}, NextProtocol=0)
+bind_layers(VXLAN, IP, {'flags': 0xC, 'NextProtocol': 1}, NextProtocol=1)
+bind_layers(VXLAN, IPv6, {'flags': 0xC, 'NextProtocol': 2}, NextProtocol=2)
+bind_layers(VXLAN, Ether, {'flags': 0xC, 'NextProtocol': 3}, NextProtocol=3)
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan
  2020-01-05 22:09 [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan lihong
@ 2020-01-06  5:43 ` Ma, LihongX
  2020-01-06  8:53 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Ma, LihongX @ 2020-01-06  5:43 UTC (permalink / raw)
  To: dts

Tested-by: ma,lihong<lihongx.ma@intel.com>

-----Original Message-----
From: Ma, LihongX 
Sent: Monday, January 6, 2020 6:10 AM
To: dts@dpdk.org
Cc: Ma, LihongX <lihongx.ma@intel.com>
Subject: [dts][PATCH V1] dep/vxlan: optimization the pkt of vxlan

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 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
 
 vxlanmagic = "0x8"
 
 VXLAN_PORT=4789
+_GP_FLAGS = ["R", "R", "R", "A", "R", "R", "D", "R"]
 
 class VXLAN(Packet):
     name = "VXLAN"
-    fields_desc = [ByteField("flags", 8),
-                   X3BytesField("reserved1", 0),
-                   X3BytesField("vni", 0),
-                   ByteField("reserved2", 0)]
+    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:
@@ -26,9 +67,13 @@ class VXLAN(Packet):
         else:
             return Packet.guess_payload_class(self, payload)
 
-    def mysummary(self):
-        return self.sprintf("VXLAN (vni=%VXLAN.vni%)")
-
 split_layers(UDP, DNS, sport=53)
-bind_layers(UDP, VXLAN, dport=VXLAN_PORT) -bind_layers(VXLAN, Ether)
+bind_layers(UDP, VXLAN, dport=4789)  # RFC standard 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(VXLAN, Ether, {'flags': 0x8}) bind_layers(VXLAN, 
+Ether, {'flags': 0x88}) bind_layers(VXLAN, Ether, {'flags': 0xC, 
+'NextProtocol': 0}, NextProtocol=0) bind_layers(VXLAN, IP, {'flags': 
+0xC, 'NextProtocol': 1}, NextProtocol=1) bind_layers(VXLAN, IPv6, 
+{'flags': 0xC, 'NextProtocol': 2}, NextProtocol=2) bind_layers(VXLAN, 
+Ether, {'flags': 0xC, 'NextProtocol': 3}, NextProtocol=3)
--
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan
  2020-01-05 22:09 [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan lihong
  2020-01-06  5:43 ` Ma, LihongX
@ 2020-01-06  8:53 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2020-01-06  8:53 UTC (permalink / raw)
  To: Ma, LihongX, dts; +Cc: Ma, LihongX

applied

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong
> Sent: Monday, January 6, 2020 6:10 AM
> To: dts@dpdk.org
> Cc: Ma, LihongX <lihongx.ma@intel.com>
> Subject: [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan
> 
> Signed-off-by: lihong <lihongx.ma@intel.com>
> ---
>  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
> 
>  vxlanmagic = "0x8"
> 
>  VXLAN_PORT=4789
> +_GP_FLAGS = ["R", "R", "R", "A", "R", "R", "D", "R"]
> 
>  class VXLAN(Packet):
>      name = "VXLAN"
> -    fields_desc = [ByteField("flags", 8),
> -                   X3BytesField("reserved1", 0),
> -                   X3BytesField("vni", 0),
> -                   ByteField("reserved2", 0)]
> +    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:
> @@ -26,9 +67,13 @@ class VXLAN(Packet):
>          else:
>              return Packet.guess_payload_class(self, payload)
> 
> -    def mysummary(self):
> -        return self.sprintf("VXLAN (vni=%VXLAN.vni%)")
> -
>  split_layers(UDP, DNS, sport=53)
> -bind_layers(UDP, VXLAN, dport=VXLAN_PORT) -bind_layers(VXLAN, Ether)
> +bind_layers(UDP, VXLAN, dport=4789)  # RFC standard 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(VXLAN, Ether, {'flags': 0x8}) bind_layers(VXLAN,
> +Ether, {'flags': 0x88}) bind_layers(VXLAN, Ether, {'flags': 0xC,
> +'NextProtocol': 0}, NextProtocol=0) bind_layers(VXLAN, IP, {'flags':
> +0xC, 'NextProtocol': 1}, NextProtocol=1) bind_layers(VXLAN, IPv6,
> +{'flags': 0xC, 'NextProtocol': 2}, NextProtocol=2) bind_layers(VXLAN,
> +Ether, {'flags': 0xC, 'NextProtocol': 3}, NextProtocol=3)
> --
> 2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-06  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-05 22:09 [dts] [PATCH V1] dep/vxlan: optimization the pkt of vxlan lihong
2020-01-06  5:43 ` Ma, LihongX
2020-01-06  8:53 ` 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).