aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_gre.py21
-rw-r--r--test/test_reassembly.py4
-rw-r--r--test/test_span.py12
-rw-r--r--test/vpp_gre_interface.py62
-rw-r--r--test/vpp_papi_provider.py29
5 files changed, 47 insertions, 81 deletions
diff --git a/test/test_gre.py b/test/test_gre.py
index 6b3c23f273a..71117ad738c 100644
--- a/test/test_gre.py
+++ b/test/test_gre.py
@@ -11,16 +11,11 @@ from scapy.volatile import RandMAC, RandIP
from framework import VppTestCase, VppTestRunner
from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint
-from vpp_gre_interface import VppGreInterface, VppGre6Interface
+from vpp_gre_interface import VppGreInterface
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
from util import ppp, ppc
-
-
-class GreTunnelTypes:
- TT_L3 = 0
- TT_TEB = 1
- TT_ERSPAN = 2
+from vpp_papi import VppEnum
class TestGRE(VppTestCase):
@@ -567,9 +562,9 @@ class TestGRE(VppTestCase):
# - assign an IP Address
# - Add a route via the tunnel
#
- gre_if = VppGre6Interface(self,
- self.pg2.local_ip6,
- "1002::1")
+ gre_if = VppGreInterface(self,
+ self.pg2.local_ip6,
+ "1002::1")
gre_if.add_vpp_config()
gre_if.admin_up()
gre_if.config_ip6()
@@ -762,10 +757,12 @@ class TestGRE(VppTestCase):
#
gre_if1 = VppGreInterface(self, self.pg0.local_ip4,
"2.2.2.2",
- type=GreTunnelTypes.TT_TEB)
+ type=(VppEnum.vl_api_gre_tunnel_type_t.
+ GRE_API_TUNNEL_TYPE_TEB))
gre_if2 = VppGreInterface(self, self.pg0.local_ip4,
"2.2.2.3",
- type=GreTunnelTypes.TT_TEB)
+ type=(VppEnum.vl_api_gre_tunnel_type_t.
+ GRE_API_TUNNEL_TYPE_TEB))
gre_if1.add_vpp_config()
gre_if2.add_vpp_config()
diff --git a/test/test_reassembly.py b/test/test_reassembly.py
index 8cfb109b0b5..07d5737ffac 100644
--- a/test/test_reassembly.py
+++ b/test/test_reassembly.py
@@ -15,7 +15,7 @@ from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, ICMPv6ParamProblem,\
from framework import VppTestCase, VppTestRunner
from util import ppp, fragment_rfc791, fragment_rfc8200
-from vpp_gre_interface import VppGreInterface, VppGre6Interface
+from vpp_gre_interface import VppGreInterface
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath
@@ -1122,7 +1122,7 @@ class TestFIFReassembly(VppTestCase):
# it shared for multiple test cases
self.tun_ip6 = "1002::1"
- self.gre6 = VppGre6Interface(self, self.src_if.local_ip6, self.tun_ip6)
+ self.gre6 = VppGreInterface(self, self.src_if.local_ip6, self.tun_ip6)
self.gre6.add_vpp_config()
self.gre6.admin_up()
self.gre6.config_ip6()
diff --git a/test/test_span.py b/test/test_span.py
index 78a4f7608ed..e4b0d0ad2b4 100644
--- a/test/test_span.py
+++ b/test/test_span.py
@@ -10,8 +10,10 @@ from scapy.layers.vxlan import VXLAN
from framework import VppTestCase, VppTestRunner
from util import Host, ppp
from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint, VppDot1ADSubint
-from vpp_gre_interface import VppGreInterface, VppGre6Interface
+from vpp_gre_interface import VppGreInterface
from collections import namedtuple
+from vpp_papi import VppEnum
+
Tag = namedtuple('Tag', ['dot1', 'vlan'])
DOT1AD = 0x88A8
@@ -271,8 +273,9 @@ class TestSpan(VppTestCase):
gre_if = VppGreInterface(self, self.pg2.local_ip4,
self.pg2.remote_ip4,
- type=2,
- session=543)
+ session=543,
+ type=(VppEnum.vl_api_gre_tunnel_type_t.
+ GRE_API_TUNNEL_TYPE_ERSPAN))
gre_if.add_vpp_config()
gre_if.admin_up()
@@ -319,7 +322,8 @@ class TestSpan(VppTestCase):
gre_if = VppGreInterface(self, self.pg2.local_ip4,
self.pg2.remote_ip4,
- type=1)
+ type=(VppEnum.vl_api_gre_tunnel_type_t.
+ GRE_API_TUNNEL_TYPE_TEB))
gre_if.add_vpp_config()
gre_if.admin_up()
diff --git a/test/vpp_gre_interface.py b/test/vpp_gre_interface.py
index 46dce365a38..818f429f5c9 100644
--- a/test/vpp_gre_interface.py
+++ b/test/vpp_gre_interface.py
@@ -1,6 +1,7 @@
from vpp_interface import VppInterface
import socket
+from vpp_papi import VppEnum
class VppGreInterface(VppInterface):
@@ -8,20 +9,22 @@ class VppGreInterface(VppInterface):
VPP GRE interface
"""
- def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
+ def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=None,
session=0):
""" Create VPP GRE interface """
super(VppGreInterface, self).__init__(test)
self.t_src = src_ip
self.t_dst = dst_ip
self.t_outer_fib = outer_fib_id
- self.t_type = type
self.t_session = session
+ self.t_type = type
+ if not self.t_type:
+ self.t_type = (VppEnum.vl_api_gre_tunnel_type_t.
+ GRE_API_TUNNEL_TYPE_L3)
def add_vpp_config(self):
- s = socket.inet_pton(socket.AF_INET, self.t_src)
- d = socket.inet_pton(socket.AF_INET, self.t_dst)
- r = self.test.vapi.gre_add_del_tunnel(s, d,
+ r = self.test.vapi.gre_tunnel_add_del(self.t_src,
+ self.t_dst,
outer_fib_id=self.t_outer_fib,
tunnel_type=self.t_type,
session_id=self.t_session)
@@ -30,10 +33,9 @@ class VppGreInterface(VppInterface):
self.test.registry.register(self, self.test.logger)
def remove_vpp_config(self):
- s = socket.inet_pton(socket.AF_INET, self.t_src)
- d = socket.inet_pton(socket.AF_INET, self.t_dst)
self.unconfig()
- self.test.vapi.gre_add_del_tunnel(s, d,
+ self.test.vapi.gre_tunnel_add_del(self.t_src,
+ self.t_dst,
outer_fib_id=self.t_outer_fib,
tunnel_type=self.t_type,
session_id=self.t_session,
@@ -42,44 +44,6 @@ class VppGreInterface(VppInterface):
def object_id(self):
return "gre-%d" % self.sw_if_index
-
-class VppGre6Interface(VppInterface):
- """
- VPP GRE IPv6 interface
- """
-
- def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
- session=0):
- """ Create VPP GRE interface """
- super(VppGre6Interface, self).__init__(test)
- self.t_src = src_ip
- self.t_dst = dst_ip
- self.t_outer_fib = outer_fib_id
- self.t_type = type
- self.t_session = session
-
- def add_vpp_config(self):
- s = socket.inet_pton(socket.AF_INET6, self.t_src)
- d = socket.inet_pton(socket.AF_INET6, self.t_dst)
- r = self.test.vapi.gre_add_del_tunnel(s, d,
- outer_fib_id=self.t_outer_fib,
- tunnel_type=self.t_type,
- session_id=self.t_session,
- is_ip6=1)
- self.set_sw_if_index(r.sw_if_index)
- self.generate_remote_hosts()
- self.test.registry.register(self, self.test.logger)
-
- def remove_vpp_config(self):
- s = socket.inet_pton(socket.AF_INET6, self.t_src)
- d = socket.inet_pton(socket.AF_INET6, self.t_dst)
- self.unconfig()
- self.test.vapi.gre_add_del_tunnel(s, d,
- outer_fib_id=self.t_outer_fib,
- tunnel_type=self.t_type,
- session_id=self.t_session,
- is_add=0,
- is_ip6=1)
-
- def object_id(self):
- return "gre-%d" % self._sw_if_index
+ def query_vpp_config(self):
+ return (self.test.vapi.gre_tunnel_dump(
+ sw_if_index=self._sw_if_index))
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 06fa31bd586..62fc0aa42b3 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -68,7 +68,7 @@ defaultmapping = {
'gbp_subnet_add_del': {'sw_if_index': 4294967295, 'epg_id': 65535, },
'geneve_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
'decap_next_index': 4294967295, },
- 'gre_add_del_tunnel': {'instance': 4294967295, 'is_add': 1, },
+ 'gre_tunnel_add_del': {'instance': 4294967295, 'is_add': 1, },
'gtpu_add_del_tunnel': {'is_add': 1, 'mcast_sw_if_index': 4294967295,
'decap_next_index': 4294967295, },
'input_acl_set_interface': {'ip4_table_index': 4294967295,
@@ -604,15 +604,14 @@ class VppPapiProvider(object):
}
)
- def gre_add_del_tunnel(self,
- src_address,
- dst_address,
+ def gre_tunnel_add_del(self,
+ src,
+ dst,
outer_fib_id=0,
tunnel_type=0,
instance=0xFFFFFFFF,
session_id=0,
- is_add=1,
- is_ip6=0):
+ is_add=1):
""" Add a GRE tunnel
:param src_address:
@@ -626,15 +625,17 @@ class VppPapiProvider(object):
"""
return self.api(
- self.papi.gre_add_del_tunnel,
+ self.papi.gre_tunnel_add_del,
{'is_add': is_add,
- 'is_ipv6': is_ip6,
- 'tunnel_type': tunnel_type,
- 'instance': instance,
- 'src_address': src_address,
- 'dst_address': dst_address,
- 'outer_fib_id': outer_fib_id,
- 'session_id': session_id}
+ 'tunnel':
+ {
+ 'type': tunnel_type,
+ 'instance': instance,
+ 'src': src,
+ 'dst': dst,
+ 'outer_fib_id': outer_fib_id,
+ 'session_id': session_id}
+ }
)
def udp_encap_add(self,