tests: changes for scapy 2.4.3 migration 99/23999/3
authorsnaramre <snaramre@cisco.com>
Fri, 13 Dec 2019 23:39:35 +0000 (23:39 +0000)
committerPaul Vinciguerra <pvinci@vinciconsulting.com>
Sat, 14 Dec 2019 22:14:12 +0000 (22:14 +0000)
Type: fix
Change-Id: I7e041b666dabd90df23a920a1f1d99db4c10ddfe
Signed-off-by: snaramre <snaramre@cisco.com>
27 files changed:
src/plugins/acl/test/test_acl_plugin_macip.py
src/plugins/dhcp/test/test_dhcp.py
src/plugins/dhcp/test/test_dhcp6.py
src/plugins/gbp/test/test_gbp.py
src/plugins/gtpu/test/test_gtpu.py
src/plugins/igmp/test/test_igmp.py
src/plugins/map/test/test_map.py
src/plugins/srv6-ad/test/test_srv6_ad.py
src/plugins/srv6-am/test/test_srv6.py
src/plugins/srv6-as/test/test_srv6_as.py
test/Makefile
test/patches/scapy-2.4.3/cdp.patch [new file with mode: 0644]
test/patches/scapy-2.4.3/ipsec.patch [new file with mode: 0644]
test/requirements-3.txt
test/requirements.txt
test/template_bd.py
test/template_ipsec.py
test/test_bier.py
test/test_geneve.py
test/test_ip4_vrf_multi_instance.py
test/test_ip6.py
test/test_ipsec_tun_if_esp.py
test/test_l2bd_arp_term.py
test/test_vxlan.py
test/test_vxlan_gbp.py
test/test_vxlan_gpe.py
test/vpp_pg_interface.py

index e139369..0f178a3 100644 (file)
@@ -442,7 +442,7 @@ class MethodHolder(VppTestCase):
 
             packet /= UDP(sport=src_port, dport=dst_port)/Raw(payload)
 
 
             packet /= UDP(sport=src_port, dport=dst_port)/Raw(payload)
 
-            packet[Raw].load += b" mac:%s" % scapy.compat.raw(src_mac)
+            packet[Raw].load += b" mac:%s" % src_mac.encode('utf-8')
 
             size = self.pg_if_packet_sizes[p % len(self.pg_if_packet_sizes)]
             if isinstance(src_if, VppSubInterface):
 
             size = self.pg_if_packet_sizes[p % len(self.pg_if_packet_sizes)]
             if isinstance(src_if, VppSubInterface):
index 14e20c4..07db35d 100644 (file)
@@ -18,8 +18,7 @@ from scapy.layers.dhcp import DHCP, BOOTP, DHCPTypes
 from scapy.layers.dhcp6 import DHCP6, DHCP6_Solicit, DHCP6_RelayForward, \
     DHCP6_RelayReply, DHCP6_Advertise, DHCP6OptRelayMsg, DHCP6OptIfaceId, \
     DHCP6OptStatusCode, DHCP6OptVSS, DHCP6OptClientLinkLayerAddr, DHCP6_Request
 from scapy.layers.dhcp6 import DHCP6, DHCP6_Solicit, DHCP6_RelayForward, \
     DHCP6_RelayReply, DHCP6_Advertise, DHCP6OptRelayMsg, DHCP6OptIfaceId, \
     DHCP6OptStatusCode, DHCP6OptVSS, DHCP6OptClientLinkLayerAddr, DHCP6_Request
-from socket import AF_INET, AF_INET6
-from scapy.utils import inet_pton, inet_ntop
+from socket import AF_INET, AF_INET6, inet_pton, inet_ntop
 from scapy.utils6 import in6_ptop
 from vpp_papi import mac_pton, VppEnum
 from vpp_sub_interface import VppDot1QSubint
 from scapy.utils6 import in6_ptop
 from vpp_papi import mac_pton, VppEnum
 from vpp_sub_interface import VppDot1QSubint
index 9beff5a..7254496 100644 (file)
@@ -1,4 +1,4 @@
-from socket import AF_INET6
+from socket import AF_INET6, inet_ntop, inet_pton
 
 from scapy.layers.dhcp6 import DHCP6_Advertise, DHCP6OptClientId, \
     DHCP6OptStatusCode, DHCP6OptPref, DHCP6OptIA_PD, DHCP6OptIAPrefix, \
 
 from scapy.layers.dhcp6 import DHCP6_Advertise, DHCP6OptClientId, \
     DHCP6OptStatusCode, DHCP6OptPref, DHCP6OptIA_PD, DHCP6OptIAPrefix, \
@@ -7,7 +7,6 @@ from scapy.layers.dhcp6 import DHCP6_Advertise, DHCP6OptClientId, \
     DHCP6OptIAAddress
 from scapy.layers.inet6 import IPv6, Ether, UDP
 from scapy.utils6 import in6_mactoifaceid
     DHCP6OptIAAddress
 from scapy.layers.inet6 import IPv6, Ether, UDP
 from scapy.utils6 import in6_mactoifaceid
-from scapy.utils import inet_ntop, inet_pton
 
 from framework import VppTestCase
 from vpp_papi import VppEnum
 
 from framework import VppTestCase
 from vpp_papi import VppEnum
index ab4e3a5..5038237 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
 #!/usr/bin/env python3
 
-from socket import AF_INET, AF_INET6
+from socket import AF_INET, AF_INET6, inet_pton, inet_ntop
 import unittest
 from ipaddress import ip_address, IPv4Network, IPv6Network
 
 import unittest
 from ipaddress import ip_address, IPv4Network, IPv6Network
 
@@ -12,7 +12,6 @@ from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6NDOptSrcLLAddr, \
 from scapy.utils6 import in6_getnsma, in6_getnsmac
 from scapy.layers.vxlan import VXLAN
 from scapy.data import ETH_P_IP, ETH_P_IPV6, ETH_P_ARP
 from scapy.utils6 import in6_getnsma, in6_getnsmac
 from scapy.layers.vxlan import VXLAN
 from scapy.data import ETH_P_IP, ETH_P_IPV6, ETH_P_ARP
-from scapy.utils import inet_pton, inet_ntop
 
 from framework import VppTestCase, VppTestRunner
 from vpp_object import VppObject
 
 from framework import VppTestCase, VppTestRunner
 from vpp_object import VppObject
index e6d9c9e..667d61c 100644 (file)
@@ -6,7 +6,8 @@ import unittest
 from framework import VppTestCase, VppTestRunner
 from template_bd import BridgeDomain
 
 from framework import VppTestCase, VppTestRunner
 from template_bd import BridgeDomain
 
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6
 from scapy.contrib.gtp import GTP_U_Header
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6
 from scapy.contrib.gtp import GTP_U_Header
index 3f9b99b..1974794 100644 (file)
@@ -2,7 +2,8 @@
 
 import unittest
 
 
 import unittest
 
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, IPOption
 from scapy.contrib.igmpv3 import IGMPv3, IGMPv3gr, IGMPv3mq, IGMPv3mr
 
 from scapy.layers.inet import IP, IPOption
 from scapy.contrib.igmpv3 import IGMPv3, IGMPv3gr, IGMPv3mq, IGMPv3mr
 
index 9da3d0c..592e49e 100644 (file)
@@ -9,7 +9,8 @@ from vpp_ip_route import VppIpRoute, VppRoutePath
 from util import fragment_rfc791, fragment_rfc8200
 
 import scapy.compat
 from util import fragment_rfc791, fragment_rfc8200
 
 import scapy.compat
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP, ICMP, TCP, fragment
 from scapy.layers.inet6 import IPv6, ICMPv6TimeExceeded
 
 from scapy.layers.inet import IP, UDP, ICMP, TCP, fragment
 from scapy.layers.inet6 import IPv6, ICMPv6TimeExceeded
 
index 545553e..55f3da0 100644 (file)
@@ -16,8 +16,6 @@ from scapy.layers.l2 import Ether, Dot1Q
 from scapy.layers.inet6 import IPv6, UDP, IPv6ExtHdrSegmentRouting
 from scapy.layers.inet import IP, UDP
 
 from scapy.layers.inet6 import IPv6, UDP, IPv6ExtHdrSegmentRouting
 from scapy.layers.inet import IP, UDP
 
-from scapy.utils import inet_pton, inet_ntop
-
 from util import ppp
 
 
 from util import ppp
 
 
index 0f0358f..ac880f1 100644 (file)
@@ -15,8 +15,6 @@ from scapy.layers.l2 import Ether, Dot1Q
 from scapy.layers.inet6 import IPv6, UDP, IPv6ExtHdrSegmentRouting
 from scapy.layers.inet import IP, UDP
 
 from scapy.layers.inet6 import IPv6, UDP, IPv6ExtHdrSegmentRouting
 from scapy.layers.inet import IP, UDP
 
-from scapy.utils import inet_pton, inet_ntop
-
 from util import ppp
 
 
 from util import ppp
 
 
index 26a4bf4..9c4f3e2 100755 (executable)
@@ -15,8 +15,6 @@ from scapy.layers.l2 import Ether, Dot1Q
 from scapy.layers.inet6 import IPv6, UDP, IPv6ExtHdrSegmentRouting
 from scapy.layers.inet import IP, UDP
 
 from scapy.layers.inet6 import IPv6, UDP, IPv6ExtHdrSegmentRouting
 from scapy.layers.inet import IP, UDP
 
-from scapy.utils import inet_pton, inet_ntop
-
 from util import ppp
 
 
 from util import ppp
 
 
index 4dd77b9..facdc6e 100644 (file)
@@ -141,7 +141,7 @@ $(PIP_INSTALL_DONE): $(PYTHON_DEPENDS)
 $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE)
        @echo --- patching ---
        @sleep 1 # Ensure python recompiles patched *.py files -> *.pyc
 $(PIP_PATCH_DONE): $(PIP_INSTALL_DONE)
        @echo --- patching ---
        @sleep 1 # Ensure python recompiles patched *.py files -> *.pyc
-       for f in $(CURDIR)/patches/scapy-2.4/*.patch ; do \
+       for f in $(CURDIR)/patches/scapy-2.4.3/*.patch ; do \
                echo Applying patch: $$(basename $$f) ; \
                patch --forward -p1 -d $(SCAPY_SOURCE) < $$f ; \
                retCode=$$?; \
                echo Applying patch: $$(basename $$f) ; \
                patch --forward -p1 -d $(SCAPY_SOURCE) < $$f ; \
                retCode=$$?; \
diff --git a/test/patches/scapy-2.4.3/cdp.patch b/test/patches/scapy-2.4.3/cdp.patch
new file mode 100644 (file)
index 0000000..de16f5d
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/scapy/contrib/cdp.py b/scapy/contrib/cdp.py
+index c8b7f106..7b1ff64d 100644
+--- a/scapy/contrib/cdp.py
++++ b/scapy/contrib/cdp.py
+@@ -102,7 +102,8 @@ def _CDPGuessPayloadClass(p, **kargs):
+ class CDPMsgGeneric(Packet):
+     name = "CDP Generic Message"
+     fields_desc = [ XShortEnumField("type", None, _cdp_tlv_types),
+-                    FieldLenField("len", None, "val", "!H"),
++                    FieldLenField("len", None, "val", "!H",
++                                  adjust=lambda pkt, x: x + 4),
+                     StrLenField("val", "", length_from=lambda x:x.len - 4) ]
+@@ -178,5 +179,6 @@ class CDPMsgAddr(CDPMsgGeneric):
+ class CDPMsgPortID(CDPMsgGeneric):
+     name = "Port ID"
+     fields_desc = [ XShortEnumField("type", 0x0003, _cdp_tlv_types),
+-                    FieldLenField("len", None, "iface", "!H"),
++                    FieldLenField("len", None, "iface", "!H",
++                                  adjust=lambda pkt, x: x + 4),
+                     StrLenField("iface", "Port 1", length_from=lambda x:x.len - 4) ]
+@@ -319,7 +319,7 @@ class _CDPChecksum:
+         This padding is only used for checksum computation.  The original
+         packet should not be altered."""
+         if len(pkt) % 2:
+-            last_chr = pkt[-1]
++            last_chr = pkt[len(pkt)-1:]
+             if last_chr <= b'\x80':
+                 return pkt[:-1] + b'\x00' + last_chr
+             else:
diff --git a/test/patches/scapy-2.4.3/ipsec.patch b/test/patches/scapy-2.4.3/ipsec.patch
new file mode 100644 (file)
index 0000000..9936047
--- /dev/null
@@ -0,0 +1,162 @@
+diff --git a/scapy/layers/ipsec.py b/scapy/layers/ipsec.py
+index f8c601fa..f566d288 100644
+--- a/scapy/layers/ipsec.py
++++ b/scapy/layers/ipsec.py
+@@ -359,11 +359,8 @@ class CryptAlgo(object):
+             encryptor = cipher.encryptor()
+             if self.is_aead:
+-                if esn_en:
+-                    aad = struct.pack('!LLL', esp.spi, esn, esp.seq)
+-                else:
+-                    aad = struct.pack('!LL', esp.spi, esp.seq)
+-                encryptor.authenticate_additional_data(aad)
++                encryptor.authenticate_additional_data(sa.build_aead(esp))
++
+                 data = encryptor.update(data) + encryptor.finalize()
+                 data += encryptor.tag[:self.icv_size]
+             else:
+@@ -401,12 +398,7 @@ class CryptAlgo(object):
+             if self.is_aead:
+                 # Tag value check is done during the finalize method
+-                if esn_en:
+-                    decryptor.authenticate_additional_data(
+-                        struct.pack('!LLL', esp.spi, esn, esp.seq))
+-                else:
+-                    decryptor.authenticate_additional_data(
+-                        struct.pack('!LL', esp.spi, esp.seq))
++                decryptor.authenticate_additional_data(sa.build_aead(esp))
+             try:
+                 data = decryptor.update(data) + decryptor.finalize()
+             except InvalidTag as err:
+@@ -545,7 +537,7 @@ class AuthAlgo(object):
+         else:
+             return self.mac(key, self.digestmod(), default_backend())
+-    def sign(self, pkt, key):
++    def sign(self, pkt, key, trailer=None):
+         """
+         Sign an IPsec (ESP or AH) packet with this algo.
+@@ -561,16 +553,20 @@ class AuthAlgo(object):
+         if pkt.haslayer(ESP):
+             mac.update(raw(pkt[ESP]))
++            if trailer:
++                mac.update(trailer)
+             pkt[ESP].data += mac.finalize()[:self.icv_size]
+         elif pkt.haslayer(AH):
+             clone = zero_mutable_fields(pkt.copy(), sending=True)
+             mac.update(raw(clone))
++            if trailer:
++                mac.update(trailer)
+             pkt[AH].icv = mac.finalize()[:self.icv_size]
+         return pkt
+-    def verify(self, pkt, key):
++    def verify(self, pkt, key, trailer):
+         """
+         Check that the integrity check value (icv) of a packet is valid.
+@@ -602,6 +598,8 @@ class AuthAlgo(object):
+             clone = zero_mutable_fields(pkt.copy(), sending=False)
+         mac.update(raw(clone))
++        if trailer:
++            mac.update(trailer) # bytearray(4)) #raw(trailer))
+         computed_icv = mac.finalize()[:self.icv_size]
+         # XXX: Cannot use mac.verify because the ICV can be truncated
+@@ -864,6 +862,23 @@ class SecurityAssociation(object):
+                 raise TypeError('nat_t_header must be %s' % UDP.name)
+         self.nat_t_header = nat_t_header
++    def build_aead(self, esp):
++        if self.esn_en:
++            return (struct.pack('!LLL', esp.spi, self.seq_num >> 32, esp.seq))
++        else:
++            return (struct.pack('!LL', esp.spi, esp.seq))
++
++    def build_seq_num(self, num):
++        # only lower order bits are  transmitted
++        # higher order bits are used in the ICV
++        lower = num & 0xffffffff
++        upper = num >> 32
++
++        if self.esn_en:
++            return lower, struct.pack("!I", upper)
++        else:
++            return lower, None
++
+     def check_spi(self, pkt):
+         if pkt.spi != self.spi:
+             raise TypeError('packet spi=0x%x does not match the SA spi=0x%x' %
+@@ -877,7 +892,8 @@ class SecurityAssociation(object):
+             if len(iv) != self.crypt_algo.iv_size:
+                 raise TypeError('iv length must be %s' % self.crypt_algo.iv_size)  # noqa: E501
+-        esp = _ESPPlain(spi=self.spi, seq=seq_num or self.seq_num, iv=iv)
++        low_seq_num, high_seq_num = self.build_seq_num(seq_num or self.seq_num)
++        esp = _ESPPlain(spi=self.spi, seq=low_seq_num, iv=iv)
+         if self.tunnel_header:
+             tunnel = self.tunnel_header.copy()
+@@ -901,7 +917,7 @@ class SecurityAssociation(object):
+                                       esn_en=esn_en or self.esn_en,
+                                       esn=esn or self.esn)
+-        self.auth_algo.sign(esp, self.auth_key)
++        self.auth_algo.sign(esp, self.auth_key, high_seq_num)
+         if self.nat_t_header:
+             nat_t_header = self.nat_t_header.copy()
+@@ -928,7 +944,8 @@ class SecurityAssociation(object):
+     def _encrypt_ah(self, pkt, seq_num=None):
+-        ah = AH(spi=self.spi, seq=seq_num or self.seq_num,
++        low_seq_num, high_seq_num = self.build_seq_num(seq_num or self.seq_num)
++        ah = AH(spi=self.spi, seq=low_seq_num,
+                 icv=b"\x00" * self.auth_algo.icv_size)
+         if self.tunnel_header:
+@@ -968,7 +985,8 @@ class SecurityAssociation(object):
+         else:
+             ip_header.plen = len(ip_header.payload) + len(ah) + len(payload)
+-        signed_pkt = self.auth_algo.sign(ip_header / ah / payload, self.auth_key)  # noqa: E501
++        signed_pkt = self.auth_algo.sign(ip_header / ah / payload,
++                                         self.auth_key, high_seq_num)  # noqa: E501
+         # sequence number must always change, unless specified by the user
+         if seq_num is None:
+@@ -1005,11 +1023,12 @@ class SecurityAssociation(object):
+     def _decrypt_esp(self, pkt, verify=True, esn_en=None, esn=None):
++        low_seq_num, high_seq_num = self.build_seq_num(self.seq_num)
+         encrypted = pkt[ESP]
+         if verify:
+             self.check_spi(pkt)
+-            self.auth_algo.verify(encrypted, self.auth_key)
++            self.auth_algo.verify(encrypted, self.auth_key, high_seq_num)
+         esp = self.crypt_algo.decrypt(self, encrypted, self.crypt_key,
+                                       self.crypt_algo.icv_size or
+@@ -1050,9 +1069,10 @@ class SecurityAssociation(object):
+     def _decrypt_ah(self, pkt, verify=True):
++        low_seq_num, high_seq_num = self.build_seq_num(self.seq_num)
+         if verify:
+             self.check_spi(pkt)
+-            self.auth_algo.verify(pkt, self.auth_key)
++            self.auth_algo.verify(pkt, self.auth_key, high_seq_num)
+         ah = pkt[AH]
+         payload = ah.payload
+
index 479f65d..f5dbc22 100644 (file)
@@ -125,8 +125,8 @@ pyparsing==2.4.0 \
     --hash=sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a \
     --hash=sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03 \
     # via packaging
     --hash=sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a \
     --hash=sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03 \
     # via packaging
-scapy==2.4.0 ; python_version >= "2.7" or python_version >= "3.4" \
-    --hash=sha256:452f714f5c2eac6fd0a6146b1dbddfc24dd5f4103f3ed76227995a488cfb2b73
+scapy==2.4.3 ; python_version >= "2.7" or python_version >= "3.4" \
+    --hash=sha256:e2f8d11f6a941c14a789ae8b236b27bd634681f1b29b5e893861e284d234f6b0
 six==1.12.0 \
     --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
     --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73
 six==1.12.0 \
     --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
     --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73
index 1dab4fc..103bc19 100644 (file)
@@ -11,7 +11,7 @@ parameterized>=0.6.1                    # BSD
 pexpect                                 # ISC
 psutil                                  # BSD
 pycodestyle                             # MIT (Expat license)       https://pypi.org/project/pycodestyle/
 pexpect                                 # ISC
 psutil                                  # BSD
 pycodestyle                             # MIT (Expat license)       https://pypi.org/project/pycodestyle/
-scapy==2.4.0; python_version >= '2.7' or python_version >= '3.4'    # GPL2  https://github.com/secdev/scapy/blob/master/LICENSE
+scapy==2.4.3; python_version >= '2.7' or python_version >= '3.4'    # GPL2  https://github.com/secdev/scapy/blob/master/LICENSE
 six                                     # MIT
 subprocess32                            # PSF
 syslog_rfc5424_parser>=0.3.1            # ISC
 six                                     # MIT
 subprocess32                            # PSF
 syslog_rfc5424_parser>=0.3.1            # ISC
index c401761..bd55b9b 100644 (file)
@@ -3,7 +3,8 @@
 import abc
 import six
 
 import abc
 import six
 
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP
 
 from util import ip4_range
 from scapy.layers.inet import IP, UDP
 
 from util import ip4_range
index a59a213..034bc8e 100644 (file)
@@ -4,7 +4,8 @@ import struct
 
 from scapy.layers.inet import IP, ICMP, TCP, UDP
 from scapy.layers.ipsec import SecurityAssociation, ESP
 
 from scapy.layers.inet import IP, ICMP, TCP, UDP
 from scapy.layers.ipsec import SecurityAssociation, ESP
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet6 import IPv6, ICMPv6EchoRequest
 
 from framework import VppTestCase, VppTestRunner
 from scapy.layers.inet6 import IPv6, ICMPv6EchoRequest
 
 from framework import VppTestCase, VppTestRunner
@@ -93,8 +94,8 @@ def mk_scapy_crypt_key(p):
 
 def config_tun_params(p, encryption_type, tun_if):
     ip_class_by_addr_type = {socket.AF_INET: IP, socket.AF_INET6: IPv6}
 
 def config_tun_params(p, encryption_type, tun_if):
     ip_class_by_addr_type = {socket.AF_INET: IP, socket.AF_INET6: IPv6}
-    use_esn = bool(p.flags & (VppEnum.vl_api_ipsec_sad_flags_t.
-                              IPSEC_API_SAD_FLAG_USE_ESN))
+    esn_en = bool(p.flags & (VppEnum.vl_api_ipsec_sad_flags_t.
+                             IPSEC_API_SAD_FLAG_USE_ESN))
     crypt_key = mk_scapy_crypt_key(p)
     p.scapy_tun_sa = SecurityAssociation(
         encryption_type, spi=p.vpp_tun_spi,
     crypt_key = mk_scapy_crypt_key(p)
     p.scapy_tun_sa = SecurityAssociation(
         encryption_type, spi=p.vpp_tun_spi,
@@ -105,7 +106,7 @@ def config_tun_params(p, encryption_type, tun_if):
             src=tun_if.remote_addr[p.addr_type],
             dst=tun_if.local_addr[p.addr_type]),
         nat_t_header=p.nat_header,
             src=tun_if.remote_addr[p.addr_type],
             dst=tun_if.local_addr[p.addr_type]),
         nat_t_header=p.nat_header,
-        use_esn=use_esn)
+        esn_en=esn_en)
     p.vpp_tun_sa = SecurityAssociation(
         encryption_type, spi=p.scapy_tun_spi,
         crypt_algo=p.crypt_algo,
     p.vpp_tun_sa = SecurityAssociation(
         encryption_type, spi=p.scapy_tun_spi,
         crypt_algo=p.crypt_algo,
@@ -115,12 +116,12 @@ def config_tun_params(p, encryption_type, tun_if):
             dst=tun_if.remote_addr[p.addr_type],
             src=tun_if.local_addr[p.addr_type]),
         nat_t_header=p.nat_header,
             dst=tun_if.remote_addr[p.addr_type],
             src=tun_if.local_addr[p.addr_type]),
         nat_t_header=p.nat_header,
-        use_esn=use_esn)
+        esn_en=esn_en)
 
 
 def config_tra_params(p, encryption_type):
 
 
 def config_tra_params(p, encryption_type):
-    use_esn = bool(p.flags & (VppEnum.vl_api_ipsec_sad_flags_t.
-                              IPSEC_API_SAD_FLAG_USE_ESN))
+    esn_en = bool(p.flags & (VppEnum.vl_api_ipsec_sad_flags_t.
+                             IPSEC_API_SAD_FLAG_USE_ESN))
     crypt_key = mk_scapy_crypt_key(p)
     p.scapy_tra_sa = SecurityAssociation(
         encryption_type,
     crypt_key = mk_scapy_crypt_key(p)
     p.scapy_tra_sa = SecurityAssociation(
         encryption_type,
@@ -130,7 +131,7 @@ def config_tra_params(p, encryption_type):
         auth_algo=p.auth_algo,
         auth_key=p.auth_key,
         nat_t_header=p.nat_header,
         auth_algo=p.auth_algo,
         auth_key=p.auth_key,
         nat_t_header=p.nat_header,
-        use_esn=use_esn)
+        esn_en=esn_en)
     p.vpp_tra_sa = SecurityAssociation(
         encryption_type,
         spi=p.scapy_tra_spi,
     p.vpp_tra_sa = SecurityAssociation(
         encryption_type,
         spi=p.scapy_tra_spi,
@@ -139,7 +140,7 @@ def config_tra_params(p, encryption_type):
         auth_algo=p.auth_algo,
         auth_key=p.auth_key,
         nat_t_header=p.nat_header,
         auth_algo=p.auth_algo,
         auth_key=p.auth_key,
         nat_t_header=p.nat_header,
-        use_esn=use_esn)
+        esn_en=esn_en)
 
 
 class TemplateIpsec(VppTestCase):
 
 
 class TemplateIpsec(VppTestCase):
@@ -271,7 +272,7 @@ class IpsecTra4(object):
     """ verify methods for Transport v4 """
     def verify_tra_anti_replay(self):
         p = self.params[socket.AF_INET]
     """ verify methods for Transport v4 """
     def verify_tra_anti_replay(self):
         p = self.params[socket.AF_INET]
-        use_esn = p.vpp_tra_sa.use_esn
+        esn_en = p.vpp_tra_sa.esn_en
 
         seq_cycle_node_name = ('/err/%s/sequence number cycled' %
                                self.tra4_encrypt_node_name)
 
         seq_cycle_node_name = ('/err/%s/sequence number cycled' %
                                self.tra4_encrypt_node_name)
@@ -415,7 +416,7 @@ class IpsecTra4(object):
                                       seq_num=17))
         self.send_and_assert_no_replies(self.tra_if, pkt * 17)
 
                                       seq_num=17))
         self.send_and_assert_no_replies(self.tra_if, pkt * 17)
 
-        if use_esn:
+        if esn_en:
             # an out of window error with ESN looks like a high sequence
             # wrap. but since it isn't then the verify will fail.
             hash_failed_count += 17
             # an out of window error with ESN looks like a high sequence
             # wrap. but since it isn't then the verify will fail.
             hash_failed_count += 17
@@ -455,7 +456,7 @@ class IpsecTra4(object):
                                         seq_num=seq))
                 for seq in range(259, 280)]
 
                                         seq_num=seq))
                 for seq in range(259, 280)]
 
-        if use_esn:
+        if esn_en:
             rxs = self.send_and_expect(self.tra_if, pkts, self.tra_if)
 
             #
             rxs = self.send_and_expect(self.tra_if, pkts, self.tra_if)
 
             #
index b02014d..1c58ee5 100644 (file)
@@ -167,7 +167,7 @@ class TestBier(VppTestCase):
                 byte_val = scapy.compat.chb(1 << (bp - 1) % 8)
                 byte_pos = n_bytes - (((bp - 1) // 8) + 1)
                 byte_array[byte_pos] = byte_val
                 byte_val = scapy.compat.chb(1 << (bp - 1) % 8)
                 byte_pos = n_bytes - (((bp - 1) // 8) + 1)
                 byte_array[byte_pos] = byte_val
-                bitstring = b''.join([scapy.compat.chb(x) for x in byte_array])
+                bitstring = b''.join(byte_array)
 
                 self.assertEqual(len(bitstring), len(bier_hdr.BitString))
                 self.assertEqual(bitstring, bier_hdr.BitString)
 
                 self.assertEqual(len(bitstring), len(bier_hdr.BitString))
                 self.assertEqual(bitstring, bier_hdr.BitString)
index d5d621f..24019e7 100644 (file)
@@ -8,7 +8,7 @@ from template_bd import BridgeDomain
 
 from scapy.layers.l2 import Ether
 from scapy.layers.inet import IP, UDP
 
 from scapy.layers.l2 import Ether
 from scapy.layers.inet import IP, UDP
-from scapy.layers.geneve import GENEVE
+from scapy.contrib.geneve import GENEVE
 from scapy.utils import atol
 from vpp_ip_route import VppIpRoute, VppRoutePath
 from vpp_ip import INVALID_INDEX
 from scapy.utils import atol
 from vpp_ip_route import VppIpRoute, VppRoutePath
 from vpp_ip import INVALID_INDEX
index fba00eb..474ab70 100644 (file)
@@ -68,8 +68,8 @@ import socket
 
 import scapy.compat
 from scapy.packet import Raw
 
 import scapy.compat
 from scapy.packet import Raw
-from scapy.layers.l2 import Ether
-from scapy.layers.inet import IP, UDP, ARP
+from scapy.layers.l2 import Ether, ARP
+from scapy.layers.inet import IP, UDP
 
 from framework import VppTestCase, VppTestRunner
 from util import ppp
 
 from framework import VppTestCase, VppTestRunner
 from util import ppp
index c6cced9..205bea6 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
 #!/usr/bin/env python3
 
-import socket
+from socket import inet_pton, inet_ntop
 import unittest
 
 from parameterized import parameterized
 import unittest
 
 from parameterized import parameterized
@@ -13,7 +13,6 @@ from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6ND_RS, \
     ICMPv6TimeExceeded, ICMPv6EchoRequest, ICMPv6EchoReply, IPv6ExtHdrHopByHop
 from scapy.layers.l2 import Ether, Dot1Q
 from scapy.packet import Raw
     ICMPv6TimeExceeded, ICMPv6EchoRequest, ICMPv6EchoReply, IPv6ExtHdrHopByHop
 from scapy.layers.l2 import Ether, Dot1Q
 from scapy.packet import Raw
-from scapy.utils import inet_pton, inet_ntop
 from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ptop, in6_islladdr, \
     in6_mactoifaceid
 from six import moves
 from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ptop, in6_islladdr, \
     in6_mactoifaceid
 from six import moves
index 589fb10..3e578fa 100644 (file)
@@ -3,7 +3,8 @@ import socket
 import copy
 
 from scapy.layers.ipsec import SecurityAssociation, ESP
 import copy
 
 from scapy.layers.ipsec import SecurityAssociation, ESP
-from scapy.layers.l2 import Ether, Raw, GRE
+from scapy.layers.l2 import Ether, GRE
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6
 from framework import VppTestRunner
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6
 from framework import VppTestRunner
@@ -21,8 +22,8 @@ from vpp_papi import VppEnum
 
 def config_tun_params(p, encryption_type, tun_if):
     ip_class_by_addr_type = {socket.AF_INET: IP, socket.AF_INET6: IPv6}
 
 def config_tun_params(p, encryption_type, tun_if):
     ip_class_by_addr_type = {socket.AF_INET: IP, socket.AF_INET6: IPv6}
-    use_esn = bool(p.flags & (VppEnum.vl_api_ipsec_sad_flags_t.
-                              IPSEC_API_SAD_FLAG_USE_ESN))
+    esn_en = bool(p.flags & (VppEnum.vl_api_ipsec_sad_flags_t.
+                             IPSEC_API_SAD_FLAG_USE_ESN))
     crypt_key = mk_scapy_crypt_key(p)
     p.scapy_tun_sa = SecurityAssociation(
         encryption_type, spi=p.vpp_tun_spi,
     crypt_key = mk_scapy_crypt_key(p)
     p.scapy_tun_sa = SecurityAssociation(
         encryption_type, spi=p.vpp_tun_spi,
@@ -33,7 +34,7 @@ def config_tun_params(p, encryption_type, tun_if):
             src=tun_if.remote_ip,
             dst=tun_if.local_ip),
         nat_t_header=p.nat_header,
             src=tun_if.remote_ip,
             dst=tun_if.local_ip),
         nat_t_header=p.nat_header,
-        use_esn=use_esn)
+        esn_en=esn_en)
     p.vpp_tun_sa = SecurityAssociation(
         encryption_type, spi=p.scapy_tun_spi,
         crypt_algo=p.crypt_algo,
     p.vpp_tun_sa = SecurityAssociation(
         encryption_type, spi=p.scapy_tun_spi,
         crypt_algo=p.crypt_algo,
@@ -43,7 +44,7 @@ def config_tun_params(p, encryption_type, tun_if):
             dst=tun_if.remote_ip,
             src=tun_if.local_ip),
         nat_t_header=p.nat_header,
             dst=tun_if.remote_ip,
             src=tun_if.local_ip),
         nat_t_header=p.nat_header,
-        use_esn=use_esn)
+        esn_en=esn_en)
 
 
 class TemplateIpsec4TunIfEsp(TemplateIpsec):
 
 
 class TemplateIpsec4TunIfEsp(TemplateIpsec):
index e72a42e..975c324 100644 (file)
@@ -5,12 +5,11 @@ import unittest
 import random
 import copy
 
 import random
 import copy
 
-from socket import AF_INET, AF_INET6
+from socket import AF_INET, AF_INET6, inet_pton, inet_ntop
 
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether, ARP
 from scapy.layers.inet import IP
 
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether, ARP
 from scapy.layers.inet import IP
-from scapy.utils import inet_pton, inet_ntop
 from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ptop, in6_islladdr, \
     in6_mactoifaceid, in6_ismaddr
 from scapy.layers.inet6 import IPv6, UDP, ICMPv6ND_NS, ICMPv6ND_RS, \
 from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ptop, in6_islladdr, \
     in6_mactoifaceid, in6_ismaddr
 from scapy.layers.inet6 import IPv6, UDP, ICMPv6ND_NS, ICMPv6ND_RS, \
index 692930e..7613054 100644 (file)
@@ -6,7 +6,8 @@ import unittest
 from framework import VppTestCase, VppTestRunner
 from template_bd import BridgeDomain
 
 from framework import VppTestCase, VppTestRunner
 from template_bd import BridgeDomain
 
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP
 from scapy.layers.vxlan import VXLAN
 from scapy.utils import atol
 from scapy.layers.inet import IP, UDP
 from scapy.layers.vxlan import VXLAN
 from scapy.utils import atol
index 17ee662..19790df 100644 (file)
@@ -6,7 +6,8 @@ import unittest
 from framework import VppTestCase, VppTestRunner
 from template_bd import BridgeDomain
 
 from framework import VppTestCase, VppTestRunner
 from template_bd import BridgeDomain
 
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP
 from scapy.layers.vxlan import VXLAN
 from scapy.utils import atol
 from scapy.layers.inet import IP, UDP
 from scapy.layers.vxlan import VXLAN
 from scapy.utils import atol
index 5622a03..ca1ad9c 100644 (file)
@@ -6,7 +6,8 @@ import unittest
 from framework import VppTestCase, VppTestRunner, running_extended_tests
 from template_bd import BridgeDomain
 
 from framework import VppTestCase, VppTestRunner, running_extended_tests
 from template_bd import BridgeDomain
 
-from scapy.layers.l2 import Ether, Raw
+from scapy.layers.l2 import Ether
+from scapy.packet import Raw
 from scapy.layers.inet import IP, UDP
 from scapy.layers.vxlan import VXLAN
 from scapy.utils import atol
 from scapy.layers.inet import IP, UDP
 from scapy.layers.vxlan import VXLAN
 from scapy.utils import atol
index e5926fa..b7f1881 100755 (executable)
@@ -1,6 +1,6 @@
 import os
 import time
 import os
 import time
-import socket
+from socket import inet_pton, inet_ntop
 import struct
 from traceback import format_exc, format_stack
 
 import struct
 from traceback import format_exc, format_stack
 
@@ -15,7 +15,6 @@ from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6ND_NA,\
     IPv6ExtHdrHopByHop
 from util import ppp, ppc
 from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ismaddr
     IPv6ExtHdrHopByHop
 from util import ppp, ppc
 from scapy.utils6 import in6_getnsma, in6_getnsmac, in6_ismaddr
-from scapy.utils import inet_pton, inet_ntop
 
 
 class CaptureTimeoutError(Exception):
 
 
 class CaptureTimeoutError(Exception):