aboutsummaryrefslogtreecommitdiffstats
path: root/test/patches
diff options
context:
space:
mode:
authorSachin Saxena <sachin.saxena@freescale.com>2018-02-28 20:28:52 +0530
committerSachin Saxena <sachin.saxena@nxp.com>2018-02-28 20:34:56 +0530
commit0689fce93ba269c48f83a2f70f971b3976d04c90 (patch)
tree4cc2908df3598507cc1828ac19d8c43b22450ffa /test/patches
parent746b57564deede624261ab8a96c94f562f24d22c (diff)
parentd594711a5d79859a7d0bde83a516f7ab52051d9b (diff)
Merge branch 'stable/1710' of https://gerrit.fd.io/r/vpp into 17101710
Diffstat (limited to 'test/patches')
-rw-r--r--test/patches/scapy-2.3.3/dhcp6-options.patch58
-rw-r--r--test/patches/scapy-2.3.3/gre-layers.patch25
-rw-r--r--test/patches/scapy-2.3.3/inet6.py.patch185
-rw-r--r--test/patches/scapy-2.3.3/mpls.py.patch18
4 files changed, 286 insertions, 0 deletions
diff --git a/test/patches/scapy-2.3.3/dhcp6-options.patch b/test/patches/scapy-2.3.3/dhcp6-options.patch
new file mode 100644
index 00000000..0e649398
--- /dev/null
+++ b/test/patches/scapy-2.3.3/dhcp6-options.patch
@@ -0,0 +1,58 @@
+diff --git a/scapy/layers/dhcp6.py b/scapy/layers/dhcp6.py
+index 4cb9291..a1adcfc 100644
+--- a/scapy/layers/dhcp6.py
++++ b/scapy/layers/dhcp6.py
+@@ -74,7 +74,9 @@ dhcp6opts = { 1: "CLIENTID",
+ 36: "OPTION_GEOCONF_CIVIC", #RFC-ietf-geopriv-dhcp-civil-09.txt
+ 37: "OPTION_REMOTE_ID", #RFC4649
+ 38: "OPTION_SUBSCRIBER_ID", #RFC4580
+- 39: "OPTION_CLIENT_FQDN" } #RFC4704
++ 39: "OPTION_CLIENT_FQDN", #RFC4704
++ 68: "OPTION_VSS", #RFC6607
++ 79: "OPTION_CLIENT_LINKLAYER_ADDR" } #RFC6939
+
+ dhcp6opts_by_code = { 1: "DHCP6OptClientId",
+ 2: "DHCP6OptServerId",
+@@ -116,12 +118,14 @@ dhcp6opts_by_code = { 1: "DHCP6OptClientId",
+ #40: "DHCP6OptPANAAgent", #RFC-ietf-dhc-paa-option-05.txt
+ #41: "DHCP6OptNewPOSIXTimeZone, #RFC4833
+ #42: "DHCP6OptNewTZDBTimeZone, #RFC4833
+- 43: "DHCP6OptRelayAgentERO" #RFC4994
++ 43: "DHCP6OptRelayAgentERO", #RFC4994
+ #44: "DHCP6OptLQQuery", #RFC5007
+ #45: "DHCP6OptLQClientData", #RFC5007
+ #46: "DHCP6OptLQClientTime", #RFC5007
+ #47: "DHCP6OptLQRelayData", #RFC5007
+ #48: "DHCP6OptLQClientLink", #RFC5007
++ 68: "DHCP6OptVSS", #RFC6607
++ 79: "DHCP6OptClientLinkLayerAddr", #RFC6939
+ }
+
+
+@@ -838,6 +842,26 @@ class DHCP6OptRelayAgentERO(_DHCP6OptGuessPayload): # RFC4994
+ _OptReqListField("reqopts", [23, 24],
+ length_from = lambda pkt: pkt.optlen) ]
+
++# "Client link-layer address type. The link-layer type MUST be a valid hardware
++# type assigned by the IANA, as described in [RFC0826]
++class DHCP6OptClientLinkLayerAddr(_DHCP6OptGuessPayload): #RFC6939
++ name = "DHCP6 Option - Client Link Layer address"
++ fields_desc = [ ShortEnumField("optcode", 79, dhcp6opts),
++ FieldLenField("optlen", None, length_of="clladdr",
++ adjust = lambda pkt,x: x+1),
++ ShortField("lltype", 1), # ethernet
++ _LLAddrField("clladdr", ETHER_ANY) ]
++
++# Virtual Subnet selection
++class DHCP6OptVSS(_DHCP6OptGuessPayload): #RFC6607
++ name = "DHCP6 Option - Virtual Subnet Selection"
++ fields_desc = [ ShortEnumField("optcode", 68, dhcp6opts),
++ FieldLenField("optlen", None, length_of="data",
++ adjust = lambda pkt,x: x+1),
++ ByteField("type", 255), # Default Global/default table
++ StrLenField("data", "",
++ length_from = lambda pkt: pkt.optlen) ]
++
+ #####################################################################
+ ### DHCPv6 messages ###
+ #####################################################################
diff --git a/test/patches/scapy-2.3.3/gre-layers.patch b/test/patches/scapy-2.3.3/gre-layers.patch
new file mode 100644
index 00000000..605a705b
--- /dev/null
+++ b/test/patches/scapy-2.3.3/gre-layers.patch
@@ -0,0 +1,25 @@
+diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
+index 03b80ec..a7e1e0f 100644
+--- a/scapy/layers/inet6.py
++++ b/scapy/layers/inet6.py
+@@ -3722,6 +3722,7 @@ conf.l2types.register(31, IPv6)
+
+ bind_layers(Ether, IPv6, type = 0x86dd )
+ bind_layers(CookedLinux, IPv6, proto = 0x86dd )
++bind_layers(GRE, IPv6, proto = 0x86dd )
+ bind_layers(IPerror6, TCPerror, nh = socket.IPPROTO_TCP )
+ bind_layers(IPerror6, UDPerror, nh = socket.IPPROTO_UDP )
+ bind_layers(IPv6, TCP, nh = socket.IPPROTO_TCP )
+diff --git a/scapy/layers/l2.py b/scapy/layers/l2.py
+index 4f491d2..661a5da 100644
+--- a/scapy/layers/l2.py
++++ b/scapy/layers/l2.py
+@@ -628,7 +628,7 @@ bind_layers( CookedLinux, EAPOL, proto=34958)
+ bind_layers( GRE, LLC, proto=122)
+ bind_layers( GRE, Dot1Q, proto=33024)
+ bind_layers( GRE, Dot1AD, type=0x88a8)
+-bind_layers( GRE, Ether, proto=1)
++bind_layers( GRE, Ether, proto=0x6558)
+ bind_layers( GRE, ARP, proto=2054)
+ bind_layers( GRE, EAPOL, proto=34958)
+ bind_layers( GRE, GRErouting, { "routing_present" : 1 } )
diff --git a/test/patches/scapy-2.3.3/inet6.py.patch b/test/patches/scapy-2.3.3/inet6.py.patch
new file mode 100644
index 00000000..f98e7091
--- /dev/null
+++ b/test/patches/scapy-2.3.3/inet6.py.patch
@@ -0,0 +1,185 @@
+diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
+--- a/scapy/layers/inet6.py 2017-06-01 14:04:18.160881034 +0200
++++ b/scapy/layers/inet6.py 2017-06-02 09:08:40.133800208 +0200
+@@ -369,6 +369,8 @@
+ return Raw
+ elif self.nh == 135 and len(p) > 3: # Mobile IPv6
+ return _mip6_mhtype2cls.get(ord(p[2]), MIP6MH_Generic)
++ elif self.nh == 43 and ord(p[2]) == 4: # Segment Routing header
++ return IPv6ExtHdrSegmentRouting
+ else:
+ return get_cls(ipv6nhcls.get(self.nh,"Raw"), "Raw")
+
+@@ -430,6 +432,14 @@
+ sd = strxor(sd, a)
+ sd = inet_ntop(socket.AF_INET6, sd)
+
++ if self.nh == 43 and isinstance(self.payload, IPv6ExtHdrSegmentRouting):
++ # With segment routing header (rh == 4), the destination is
++ # the first address of the IPv6 addresses list
++ try:
++ sd = self.addresses[0]
++ except IndexError:
++ sd = self.dst
++
+ if self.nh == 44 and isinstance(self.payload, IPv6ExtHdrFragment):
+ nh = self.payload.nh
+
+@@ -489,6 +499,8 @@
+ return self.payload.answers(other.payload.payload)
+ elif other.nh == 43 and isinstance(other.payload, IPv6ExtHdrRouting):
+ return self.payload.answers(other.payload.payload) # Buggy if self.payload is a IPv6ExtHdrRouting
++ elif other.nh == 43 and isinstance(other.payload, IPv6ExtHdrSegmentRouting):
++ return self.payload.answers(other.payload.payload) # Buggy if self.payload is a IPv6ExtHdrRouting
+ elif other.nh == 60 and isinstance(other.payload, IPv6ExtHdrDestOpt):
+ return self.payload.payload.answers(other.payload.payload)
+ elif self.nh == 60 and isinstance(self.payload, IPv6ExtHdrDestOpt): # BU in reply to BRR, for instance
+@@ -919,6 +931,148 @@
+ pkt = pkt[:3]+struct.pack("B", len(self.addresses))+pkt[4:]
+ return _IPv6ExtHdr.post_build(self, pkt, pay)
+
++######################### Segment Routing Header ############################
++
++# This implementation is based on draft 06, available at:
++# https://tools.ietf.org/html/draft-ietf-6man-segment-routing-header-06
++
++class IPv6ExtHdrSegmentRoutingTLV(Packet):
++ name = "IPv6 Option Header Segment Routing - Generic TLV"
++ fields_desc = [ ByteField("type", 0),
++ ByteField("len", 0),
++ ByteField("reserved", 0),
++ ByteField("flags", 0),
++ StrLenField("value", "", length_from=lambda pkt: pkt.len) ]
++
++ def extract_padding(self, p):
++ return "",p
++
++ registered_sr_tlv = {}
++ @classmethod
++ def register_variant(cls):
++ cls.registered_sr_tlv[cls.type.default] = cls
++
++ @classmethod
++ def dispatch_hook(cls, pkt=None, *args, **kargs):
++ if pkt:
++ tmp_type = ord(pkt[0])
++ return cls.registered_sr_tlv.get(tmp_type, cls)
++ return cls
++
++
++class IPv6ExtHdrSegmentRoutingTLVIngressNode(IPv6ExtHdrSegmentRoutingTLV):
++ name = "IPv6 Option Header Segment Routing - Ingress Node TLV"
++ fields_desc = [ ByteField("type", 1),
++ ByteField("len", 18),
++ ByteField("reserved", 0),
++ ByteField("flags", 0),
++ IP6Field("ingress_node", "::1") ]
++
++
++class IPv6ExtHdrSegmentRoutingTLVEgressNode(IPv6ExtHdrSegmentRoutingTLV):
++ name = "IPv6 Option Header Segment Routing - Egress Node TLV"
++ fields_desc = [ ByteField("type", 2),
++ ByteField("len", 18),
++ ByteField("reserved", 0),
++ ByteField("flags", 0),
++ IP6Field("egress_node", "::1") ]
++
++
++class IPv6ExtHdrSegmentRoutingTLVPadding(IPv6ExtHdrSegmentRoutingTLV):
++ name = "IPv6 Option Header Segment Routing - Padding TLV"
++ fields_desc = [ ByteField("type", 4),
++ FieldLenField("len", None, length_of="padding", fmt="B"),
++ StrLenField("padding", b"\x00", length_from=lambda pkt: pkt.len) ]
++
++
++class IPv6ExtHdrSegmentRouting(_IPv6ExtHdr):
++ # 0 1 2 3
++ # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #| Next Header | Hdr Ext Len | Routing Type | Segments Left |
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #| Last Entry | Flags | Tag |
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #| |
++ #| Segment List[0] (128 bits IPv6 address) |
++ #| |
++ #| |
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #| |
++ #| |
++ # ...
++ #| |
++ #| |
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #| |
++ #| Segment List[n] (128 bits IPv6 address) |
++ #| |
++ #| |
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #// //
++ #// Optional Type Length Value objects (variable) //
++ #// //
++ #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++ #
++ # 0 1 2 3 4 5 6 7
++ # +-+-+-+-+-+-+-+-+
++ # |U|P|O|A|H| U |
++ # +-+-+-+-+-+-+-+-+
++
++ name = "IPv6 Segment Routing Extension Header"
++ fields_desc = [ ByteEnumField("nh", 59, ipv6nh),
++ ByteField("len", None),
++ ByteField("type", 4),
++ ByteField("segleft", None),
++ ByteField("lastentry", None),
++ BitField("unused1", 0, 1),
++ BitField("protected", 0, 1),
++ BitField("oam", 0, 1),
++ BitField("alert", 0, 1),
++ BitField("hmac", 0, 1),
++ BitField("unused2", 0, 3),
++ ShortField("tag", 0),
++ IP6ListField("addresses", ["::1"],
++ count_from=lambda pkt: pkt.lastentry+1),
++ PacketListField("tlv_objects", [], IPv6ExtHdrSegmentRoutingTLV,
++ length_from=lambda pkt: 8*pkt.len - 16*(pkt.lastentry+1)) ]
++
++ overload_fields = { IPv6: { "nh": 43 } }
++
++ def post_build(self, pkt, pay):
++
++ if self.len is None:
++
++ # The extension must be align on 8 bytes
++ tmp_mod = (len(pkt) - 8) % 8
++ if tmp_mod == 1:
++ warning("IPv6ExtHdrSegmentRouting(): can't pad 1 byte !")
++ elif tmp_mod >= 2:
++ #Add the padding extension
++ tmp_pad = b"\x00" * (tmp_mod-2)
++ tlv = IPv6ExtHdrSegmentRoutingTLVPadding(padding=tmp_pad)
++ pkt += str(tlv)
++
++ tmp_len = (len(pkt) - 8) / 8
++ pkt = pkt[:1] + struct.pack("B", tmp_len)+ pkt[2:]
++
++ if self.segleft is None:
++ tmp_len = len(self.addresses)
++ if tmp_len:
++ tmp_len -= 1
++ pkt = pkt[:3] + struct.pack("B", tmp_len) + pkt[4:]
++
++ if self.lastentry is None:
++ #km - changed to contain n-1
++ tmp_len = len(self.addresses)
++ if tmp_len:
++ tmp_len -= 1
++ #pkt = pkt[:4] + struct.pack("B", len(self.addresses)) + pkt[5:]
++ pkt = pkt[:4] + struct.pack("B", tmp_len) + pkt[5:]
++
++ return _IPv6ExtHdr.post_build(self, pkt, pay)
++
++
+ ########################### Fragmentation Header ############################
+
+ class IPv6ExtHdrFragment(_IPv6ExtHdr):
diff --git a/test/patches/scapy-2.3.3/mpls.py.patch b/test/patches/scapy-2.3.3/mpls.py.patch
new file mode 100644
index 00000000..f63a70a3
--- /dev/null
+++ b/test/patches/scapy-2.3.3/mpls.py.patch
@@ -0,0 +1,18 @@
+diff --git a/scapy/contrib/mpls.py b/scapy/contrib/mpls.py
+index 640a0c5..6af1d4a 100644
+--- a/scapy/contrib/mpls.py
++++ b/scapy/contrib/mpls.py
+@@ -18,6 +18,8 @@ class MPLS(Packet):
+
+ def guess_payload_class(self, payload):
+ if len(payload) >= 1:
++ if not self.s:
++ return MPLS
+ ip_version = (ord(payload[0]) >> 4) & 0xF
+ if ip_version == 4:
+ return IP
+@@ -27,3 +29,4 @@ class MPLS(Packet):
+
+ bind_layers(Ether, MPLS, type=0x8847)
+ bind_layers(GRE, MPLS, proto=0x8847)
++bind_layers(MPLS, MPLS, s=0)