aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-05-01 05:17:55 -0700
committerOle Trøan <otroan@employees.org>2019-06-18 13:31:39 +0000
commit097fa66b986f06281f603767d321ab13ab6c88c3 (patch)
treeed052819615d08ee4bd0afbc34de7e64e4598105 /test
parent39baa32186fd3e4b20d9f58afbbfe7b8daebed62 (diff)
fib: fib api updates
Enhance the route add/del APIs to take a set of paths rather than just one. Most unicast routing protocols calcualte all the available paths in one run of the algorithm so updating all the paths at once is beneficial for the client. two knobs control the behaviour: is_multipath - if set the the set of paths passed will be added to those that already exist, otherwise the set will replace them. is_add - add or remove the set is_add=0, is_multipath=1 and an empty set, results in deleting the route. It is also considerably faster to add multiple paths at once, than one at a time: vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.11 100000 routes in .572240 secs, 174751.80 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.12 100000 routes in .528383 secs, 189256.54 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.13 100000 routes in .757131 secs, 132077.52 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.14 100000 routes in .878317 secs, 113854.12 routes/sec vat# ip_route_add_del 1.1.1.1/32 count 100000 multipath via 10.10.10.11 via 10.10.10.12 via 10.10.10.13 via 10.10.10.14 100000 routes in .900212 secs, 111084.93 routes/sec Change-Id: I416b93f7684745099c1adb0b33edac58c9339c1a Signed-off-by: Neale Ranns <neale.ranns@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test')
-rw-r--r--test/remote_test.py22
-rw-r--r--test/test_abf.py41
-rw-r--r--test/test_bfd.py8
-rw-r--r--test/test_bier.py38
-rw-r--r--test/test_classifier.py31
-rw-r--r--test/test_dhcp6.py44
-rw-r--r--test/test_dvr.py40
-rw-r--r--test/test_gbp.py17
-rw-r--r--test/test_geneve.py17
-rw-r--r--test/test_gre.py23
-rw-r--r--test/test_gtpu.py17
-rw-r--r--test/test_interface_crud.py6
-rw-r--r--test/test_ip4.py201
-rw-r--r--test/test_ip4_vrf_multi_instance.py20
-rw-r--r--test/test_ip6.py167
-rw-r--r--test/test_ip6_vrf_multi_instance.py33
-rw-r--r--test/test_ip_ecmp.py21
-rw-r--r--test/test_ip_mcast.py33
-rw-r--r--test/test_ipip.py10
-rw-r--r--test/test_ipsec_ah.py3
-rw-r--r--test/test_ipsec_esp.py3
-rw-r--r--test/test_ipsec_nat.py3
-rw-r--r--test/test_ipsec_tun_if_esp.py44
-rw-r--r--test/test_l3xc.py29
-rw-r--r--test/test_lb.py20
-rw-r--r--test/test_map.py20
-rw-r--r--test/test_memif.py13
-rw-r--r--test/test_mpls.py144
-rw-r--r--test/test_mtu.py2
-rw-r--r--test/test_nat.py212
-rw-r--r--test/test_neighbor.py14
-rw-r--r--test/test_p2p_ethernet.py34
-rw-r--r--test/test_punt.py3
-rw-r--r--test/test_qos.py10
-rw-r--r--test/test_reassembly.py9
-rw-r--r--test/test_sixrd.py10
-rw-r--r--test/test_srv6.py64
-rw-r--r--test/test_srv6_ad.py9
-rwxr-xr-xtest/test_srv6_as.py14
-rw-r--r--test/test_udp.py65
-rw-r--r--test/test_vcl.py12
-rw-r--r--test/test_vxlan.py21
-rw-r--r--test/test_vxlan6.py13
-rw-r--r--test/test_vxlan_gbp.py17
-rw-r--r--test/test_vxlan_gpe.py20
-rw-r--r--test/vpp_bier.py53
-rw-r--r--test/vpp_interface.py13
-rw-r--r--test/vpp_ip.py79
-rw-r--r--test/vpp_ip_route.py588
-rw-r--r--test/vpp_memif.py28
-rw-r--r--test/vpp_mpls_tunnel_interface.py51
-rw-r--r--test/vpp_papi_provider.py237
52 files changed, 1224 insertions, 1422 deletions
diff --git a/test/remote_test.py b/test/remote_test.py
index 21913b6c959..092d3f8d2e7 100644
--- a/test/remote_test.py
+++ b/test/remote_test.py
@@ -10,7 +10,7 @@ import six
from six import moves
from framework import VppTestCase
-from enum import Enum
+from aenum import Enum
class SerializableClassCopy(object):
@@ -19,6 +19,9 @@ class SerializableClassCopy(object):
"""
pass
+ def __repr__(self):
+ return '<SerializableClassCopy dict=%s>' % self.__dict__
+
class RemoteClassAttr(object):
"""
@@ -44,7 +47,8 @@ class RemoteClassAttr(object):
def __getattr__(self, attr):
if attr[0] == '_':
if not (attr.startswith('__') and attr.endswith('__')):
- raise AttributeError
+ raise AttributeError('tried to get private attribute: %s ',
+ attr)
self._path.append(attr)
return self
@@ -58,8 +62,9 @@ class RemoteClassAttr(object):
True, value=val)
def __call__(self, *args, **kwargs):
+ ret = True if 'vapi' in self.path_to_str() else False
return self._remote._remote_exec(RemoteClass.CALL, self.path_to_str(),
- True, *args, **kwargs)
+ ret, *args, **kwargs)
class RemoteClass(Process):
@@ -119,7 +124,7 @@ class RemoteClass(Process):
if not (attr.startswith('__') and attr.endswith('__')):
if hasattr(super(RemoteClass, self), '__getattr__'):
return super(RemoteClass, self).__getattr__(attr)
- raise AttributeError
+ raise AttributeError('missing: %s', attr)
return RemoteClassAttr(self, attr)
def __setattr__(self, attr, val):
@@ -137,12 +142,12 @@ class RemoteClass(Process):
mutable_args = list(args)
for i, val in enumerate(mutable_args):
if isinstance(val, RemoteClass) or \
- isinstance(val, RemoteClassAttr):
+ isinstance(val, RemoteClassAttr):
mutable_args[i] = val.get_remote_value()
args = tuple(mutable_args)
for key, val in six.iteritems(kwargs):
if isinstance(val, RemoteClass) or \
- isinstance(val, RemoteClassAttr):
+ isinstance(val, RemoteClassAttr):
kwargs[key] = val.get_remote_value()
# send request
args = self._make_serializable(args)
@@ -244,7 +249,10 @@ class RemoteClass(Process):
# copy at least serializable attributes and properties
for name, member in inspect.getmembers(obj):
- if name[0] == '_': # skip private members
+ # skip private members and non-writable dunder methods.
+ if name[0] == '_':
+ if name in ['__weakref__']:
+ continue
if not (name.startswith('__') and name.endswith('__')):
continue
if callable(member) and not isinstance(member, property):
diff --git a/test/test_abf.py b/test/test_abf.py
index 350af0dce07..221a793fed3 100644
--- a/test/test_abf.py
+++ b/test/test_abf.py
@@ -5,7 +5,8 @@ import unittest
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsLabel, VppIpTable
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsLabel, \
+ VppIpTable, FibPathProto
from scapy.packet import Raw
from scapy.layers.l2 import Ether
@@ -45,30 +46,9 @@ class VppAbfPolicy(VppObject):
self.policy_id = policy_id
self.acl = acl
self.paths = paths
-
- def encode_paths(self):
- br_paths = []
- for p in self.paths:
- lstack = []
- for l in p.nh_labels:
- if type(l) == VppMplsLabel:
- lstack.append(l.encode())
- else:
- lstack.append({'label': l, 'ttl': 255})
- n_labels = len(lstack)
- while (len(lstack) < 16):
- lstack.append({})
- br_paths.append({'next_hop': p.nh_addr,
- 'weight': 1,
- 'afi': p.proto,
- 'sw_if_index': 0xffffffff,
- 'preference': 0,
- 'table_id': p.nh_table_id,
- 'next_hop_id': p.next_hop_id,
- 'is_udp_encap': p.is_udp_encap,
- 'n_labels': n_labels,
- 'label_stack': lstack})
- return br_paths
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
def add_vpp_config(self):
self._test.vapi.abf_policy_add_del(
@@ -76,7 +56,7 @@ class VppAbfPolicy(VppObject):
{'policy_id': self.policy_id,
'acl_index': self.acl.acl_index,
'n_paths': len(self.paths),
- 'paths': self.encode_paths()})
+ 'paths': self.encoded_paths})
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
@@ -85,7 +65,7 @@ class VppAbfPolicy(VppObject):
{'policy_id': self.policy_id,
'acl_index': self.acl.acl_index,
'n_paths': len(self.paths),
- 'paths': self.encode_paths()})
+ 'paths': self.encoded_paths})
def query_vpp_config(self):
return find_abf_policy(self._test, self.policy_id)
@@ -324,8 +304,7 @@ class TestAbf(VppTestCase):
#
abf_1 = VppAbfPolicy(self, 10, acl_1,
[VppRoutePath("3001::1",
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)])
+ 0xffffffff)])
abf_1.add_vpp_config()
attach_1 = VppAbfAttach(self, 10, self.pg0.sw_if_index,
@@ -352,9 +331,7 @@ class TestAbf(VppTestCase):
#
route = VppIpRoute(self, "3001::1", 32,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
#
diff --git a/test/test_bfd.py b/test/test_bfd.py
index 4dca11247ce..9a37eb8fed7 100644
--- a/test/test_bfd.py
+++ b/test/test_bfd.py
@@ -1764,14 +1764,10 @@ class BFDFIBTestCase(VppTestCase):
# will have a BFD session
ip_2001_s_64 = VppIpRoute(self, "2001::", 64,
[VppRoutePath(self.pg0.remote_ip6,
- self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg0.sw_if_index)])
ip_2002_s_64 = VppIpRoute(self, "2002::", 64,
[VppRoutePath(self.pg0.remote_ip6,
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ 0xffffffff)])
ip_2001_s_64.add_vpp_config()
ip_2002_s_64.add_vpp_config()
diff --git a/test/test_bier.py b/test/test_bier.py
index b8130ce93f2..793c8ca0362 100644
--- a/test/test_bier.py
+++ b/test/test_bier.py
@@ -7,7 +7,7 @@ from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, \
VppMplsTable, VppIpMRoute, VppMRoutePath, VppIpTable, \
MRouteEntryFlags, MRouteItfFlags, MPLS_LABEL_INVALID, \
- VppMplsLabel
+ VppMplsLabel, FibPathProto, FibPathType
from vpp_bier import BIER_HDR_PAYLOAD, VppBierImp, VppBierDispEntry, \
VppBierDispTable, VppBierTable, VppBierTableID, VppBierRoute
from vpp_udp_encap import VppUdpEncap
@@ -278,6 +278,7 @@ class TestBier(VppTestCase):
labels=[VppMplsLabel(101)])])
rx = self.send_and_expect(self.pg0, pkts, self.pg1)
+
for nh in nhs:
self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
@@ -353,7 +354,8 @@ class TestBier(VppTestCase):
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi.bi_index)])
route_ing_232_1_1_1.add_vpp_config()
@@ -418,7 +420,7 @@ class TestBier(VppTestCase):
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xffffffff,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
nh_table_id=8)])
bier_route_1.add_vpp_config()
@@ -427,7 +429,7 @@ class TestBier(VppTestCase):
#
bier_de_1 = VppBierDispEntry(self, bdt.id, 99,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 0, rpf_id=8192)
bier_de_1.add_vpp_config()
@@ -477,7 +479,7 @@ class TestBier(VppTestCase):
#
bier_de_2 = VppBierDispEntry(self, bdt.id, 0,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 0, rpf_id=8192)
bier_de_2.add_vpp_config()
@@ -501,6 +503,7 @@ class TestBier(VppTestCase):
paths=[VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
proto=DpoProto.DPO_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi.bi_index),
VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
@@ -552,7 +555,8 @@ class TestBier(VppTestCase):
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi_low.bi_index)])
route_ing_232_1_1_1.add_vpp_config()
route_ing_232_1_1_2 = VppIpMRoute(
@@ -564,7 +568,8 @@ class TestBier(VppTestCase):
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi_high.bi_index)])
route_ing_232_1_1_2.add_vpp_config()
@@ -582,15 +587,15 @@ class TestBier(VppTestCase):
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xffffffff,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
nh_table_id=8)])
bier_route_1.add_vpp_config()
bier_route_max = VppBierRoute(
self, bti, max_bp,
[VppRoutePath("0.0.0.0",
0xffffffff,
- nh_table_id=8,
- proto=DpoProto.DPO_PROTO_BIER)])
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ nh_table_id=8)])
bier_route_max.add_vpp_config()
#
@@ -599,12 +604,12 @@ class TestBier(VppTestCase):
#
bier_de_1 = VppBierDispEntry(self, bdt.id, 333,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 10, rpf_id=8192)
bier_de_1.add_vpp_config()
bier_de_1 = VppBierDispEntry(self, bdt.id, 334,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 10, rpf_id=8193)
bier_de_1.add_vpp_config()
@@ -713,7 +718,7 @@ class TestBier(VppTestCase):
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xFFFFFFFF,
- is_udp_encap=1,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
next_hop_id=udp_encap.id)])
bier_route.add_vpp_config()
@@ -739,7 +744,8 @@ class TestBier(VppTestCase):
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(0xffffffff,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
+ type=FibPathType.FIB_PATH_TYPE_BIER_IMP,
bier_imp=bi2.bi_index)])
route_ing_232_1_1_1.add_vpp_config()
@@ -793,7 +799,7 @@ class TestBier(VppTestCase):
self, bti, 1,
[VppRoutePath("0.0.0.0",
0xffffffff,
- proto=DpoProto.DPO_PROTO_BIER,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_BIER,
nh_table_id=8)])
bier_route_1.add_vpp_config()
@@ -802,7 +808,7 @@ class TestBier(VppTestCase):
#
bier_de_1 = VppBierDispEntry(self, bdt.id, 99,
BIER_HDR_PAYLOAD.BIER_HDR_PROTO_IPV4,
- DpoProto.DPO_PROTO_BIER,
+ FibPathProto.FIB_PATH_NH_PROTO_BIER,
"0.0.0.0", 0, rpf_id=8192)
bier_de_1.add_vpp_config()
diff --git a/test/test_classifier.py b/test/test_classifier.py
index 5b0eddb5bce..4892d26a515 100644
--- a/test/test_classifier.py
+++ b/test/test_classifier.py
@@ -10,6 +10,8 @@ from scapy.packet import Raw
from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP, TCP
from util import ppp
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
class TestClassifier(VppTestCase):
@@ -95,18 +97,6 @@ class TestClassifier(VppTestCase):
self.logger.info(self.vapi.cli("show classify table verbose"))
self.logger.info(self.vapi.cli("show ip fib"))
- def config_pbr_fib_entry(self, intf, is_add=1):
- """Configure fib entry to route traffic toward PBR VRF table
-
- :param VppInterface intf: destination interface to be routed for PBR.
-
- """
- addr_len = 24
- self.vapi.ip_add_del_route(dst_address=intf.local_ip4n,
- dst_address_length=addr_len,
- next_hop_address=intf.remote_ip4n,
- table_id=self.pbr_vrfid, is_add=is_add)
-
def create_stream(self, src_if, dst_if, packet_sizes,
proto_l=UDP(sport=1234, dport=5678)):
"""Create input packet stream for defined interfaces.
@@ -183,11 +173,9 @@ class TestClassifier(VppTestCase):
:param int vrf_id: The FIB table / VRF ID to be verified.
:return: 1 if the FIB table / VRF ID is configured, otherwise return 0.
"""
- ip_fib_dump = self.vapi.ip_fib_dump()
- vrf_count = 0
- for ip_fib_details in ip_fib_dump:
- if ip_fib_details[2] == vrf_id:
- vrf_count += 1
+ ip_fib_dump = self.vapi.ip_route_dump(vrf_id, False)
+ vrf_count = len(ip_fib_dump)
+
if vrf_count == 0:
self.logger.info("IPv4 VRF ID %d is not configured" % vrf_id)
return 0
@@ -846,7 +834,12 @@ class TestClassifierPBR(TestClassifier):
self.build_ip_match(src_ip=self.pg0.remote_ip4),
pbr_option, self.pbr_vrfid)
self.assertTrue(self.verify_vrf(self.pbr_vrfid))
- self.config_pbr_fib_entry(self.pg3)
+ r = VppIpRoute(self, self.pg3.local_ip4, 24,
+ [VppRoutePath(self.pg3.remote_ip4,
+ INVALID_INDEX)],
+ table_id=self.pbr_vrfid)
+ r.add_vpp_config()
+
self.input_acl_set_interface(self.pg0, self.acl_tbl_idx.get(key))
self.pg_enable_capture(self.pg_interfaces)
@@ -860,7 +853,7 @@ class TestClassifierPBR(TestClassifier):
self.pg2.assert_nothing_captured(remark="packets forwarded")
# remove the classify session and the route
- self.config_pbr_fib_entry(self.pg3, is_add=0)
+ r.remove_vpp_config()
self.create_classify_session(
self.acl_tbl_idx.get(key),
self.build_ip_match(src_ip=self.pg0.remote_ip4),
diff --git a/test/test_dhcp6.py b/test/test_dhcp6.py
index e017feebffe..2037e62e9ea 100644
--- a/test/test_dhcp6.py
+++ b/test/test_dhcp6.py
@@ -226,7 +226,7 @@ class TestDHCPv6IANAControlPlane(VppTestCase):
self.T1 = 1
self.T2 = 2
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
self.initial_addresses = set(self.get_interface_addresses(fib,
self.pg0))
@@ -247,14 +247,14 @@ class TestDHCPv6IANAControlPlane(VppTestCase):
def get_interface_addresses(fib, pg):
lst = []
for entry in fib:
- if entry.address_length == 128:
- path = entry.path[0]
+ if entry.route.prefix.prefixlen == 128:
+ path = entry.route.paths[0]
if path.sw_if_index == pg.sw_if_index:
- lst.append(entry.address)
+ lst.append(str(entry.route.prefix.network_address))
return lst
def get_addresses(self):
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg0))
return addresses.difference(self.initial_addresses)
@@ -376,12 +376,12 @@ class TestDHCPv6IANAControlPlane(VppTestCase):
new_addresses = self.get_addresses()
self.assertEqual(len(new_addresses), 1)
addr = list(new_addresses)[0]
- self.assertEqual(inet_ntop(AF_INET6, addr), '7:8::2')
+ self.assertEqual(addr, '7:8::2')
self.sleep(2)
# check that the address is deleted
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg0))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 0)
@@ -430,7 +430,7 @@ class TestDHCPv6IANAControlPlane(VppTestCase):
self.sleep(0.5)
# check FIB contains no addresses
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg0))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 0)
@@ -447,7 +447,7 @@ class TestDHCPv6IANAControlPlane(VppTestCase):
self.sleep(0.5)
# check FIB contains no addresses
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg0))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 0)
@@ -477,7 +477,7 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.T1 = 1
self.T2 = 2
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
self.initial_addresses = set(self.get_interface_addresses(fib,
self.pg1))
@@ -503,14 +503,14 @@ class TestDHCPv6PDControlPlane(VppTestCase):
def get_interface_addresses(fib, pg):
lst = []
for entry in fib:
- if entry.address_length == 128:
- path = entry.path[0]
+ if entry.route.prefix.prefixlen == 128:
+ path = entry.route.paths[0]
if path.sw_if_index == pg.sw_if_index:
- lst.append(entry.address)
+ lst.append(str(entry.route.prefix.network_address))
return lst
def get_addresses(self):
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg1))
return addresses.difference(self.initial_addresses)
@@ -642,7 +642,7 @@ class TestDHCPv6PDControlPlane(VppTestCase):
new_addresses = self.get_addresses()
self.assertEqual(len(new_addresses), 1)
addr = list(new_addresses)[0]
- self.assertEqual(inet_ntop(AF_INET6, addr), '7:8:0:2::405')
+ self.assertEqual(addr, '7:8:0:2::405')
self.sleep(1)
@@ -656,21 +656,21 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.sleep(1)
# check FIB contains 2 addresses
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg1))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 2)
addr1 = list(new_addresses)[0]
addr2 = list(new_addresses)[1]
- if inet_ntop(AF_INET6, addr1) == '7:8:0:76::406':
+ if addr1 == '7:8:0:76::406':
addr1, addr2 = addr2, addr1
- self.assertEqual(inet_ntop(AF_INET6, addr1), '7:8:0:2::405')
- self.assertEqual(inet_ntop(AF_INET6, addr2), '7:8:0:76::406')
+ self.assertEqual(addr1, '7:8:0:2::405')
+ self.assertEqual(addr2, '7:8:0:76::406')
self.sleep(1)
# check that the addresses are deleted
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg1))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 0)
@@ -738,7 +738,7 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.sleep(0.5)
# check FIB contains no addresses
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg1))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 0)
@@ -771,7 +771,7 @@ class TestDHCPv6PDControlPlane(VppTestCase):
self.sleep(0.5)
# check FIB contains no addresses
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg1))
new_addresses = addresses.difference(self.initial_addresses)
self.assertEqual(len(new_addresses), 0)
diff --git a/test/test_dvr.py b/test/test_dvr.py
index ae7864cc3e6..62dcb611d55 100644
--- a/test/test_dvr.py
+++ b/test/test_dvr.py
@@ -2,7 +2,7 @@
import unittest
from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathType
from vpp_l2 import L2_PORT_TYPE
from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint
@@ -120,7 +120,7 @@ class TestDVR(VppTestCase):
self, ip_non_tag_bridged, 32,
[VppRoutePath("0.0.0.0",
self.pg1.sw_if_index,
- is_dvr=1)])
+ type=FibPathType.FIB_PATH_TYPE_DVR)])
route_no_tag.add_vpp_config()
#
@@ -138,7 +138,7 @@ class TestDVR(VppTestCase):
self, ip_tag_bridged, 32,
[VppRoutePath("0.0.0.0",
sub_if_on_pg3.sw_if_index,
- is_dvr=1)])
+ type=FibPathType.FIB_PATH_TYPE_DVR)])
route_with_tag.add_vpp_config()
#
@@ -235,17 +235,19 @@ class TestDVR(VppTestCase):
#
# Do a FIB dump to make sure the paths are correctly reported as DVR
#
- routes = self.vapi.ip_fib_dump()
+ routes = self.vapi.ip_route_dump(0)
for r in routes:
- if (inet_pton(AF_INET, ip_tag_bridged) == r.address):
- self.assertEqual(r.path[0].sw_if_index,
+ if (ip_tag_bridged == str(r.route.prefix.network_address)):
+ self.assertEqual(r.route.paths[0].sw_if_index,
sub_if_on_pg3.sw_if_index)
- self.assertEqual(r.path[0].is_dvr, 1)
- if (inet_pton(AF_INET, ip_non_tag_bridged) == r.address):
- self.assertEqual(r.path[0].sw_if_index,
+ self.assertEqual(r.route.paths[0].type,
+ FibPathType.FIB_PATH_TYPE_DVR)
+ if (ip_non_tag_bridged == str(r.route.prefix.network_address)):
+ self.assertEqual(r.route.paths[0].sw_if_index,
self.pg1.sw_if_index)
- self.assertEqual(r.path[0].is_dvr, 1)
+ self.assertEqual(r.route.paths[0].type,
+ FibPathType.FIB_PATH_TYPE_DVR)
#
# the explicit route delete is require so it happens before
@@ -332,14 +334,16 @@ class TestDVR(VppTestCase):
#
# Add a DVR route to steer traffic at L3
#
- route_1 = VppIpRoute(self, "1.1.1.1", 32,
- [VppRoutePath("0.0.0.0",
- self.pg1.sw_if_index,
- is_dvr=1)])
- route_2 = VppIpRoute(self, "1.1.1.2", 32,
- [VppRoutePath("0.0.0.0",
- sub_if_on_pg2.sw_if_index,
- is_dvr=1)])
+ route_1 = VppIpRoute(
+ self, "1.1.1.1", 32,
+ [VppRoutePath("0.0.0.0",
+ self.pg1.sw_if_index,
+ type=FibPathType.FIB_PATH_TYPE_DVR)])
+ route_2 = VppIpRoute(
+ self, "1.1.1.2", 32,
+ [VppRoutePath("0.0.0.0",
+ sub_if_on_pg2.sw_if_index,
+ type=FibPathType.FIB_PATH_TYPE_DVR)])
route_1.add_vpp_config()
route_2.add_vpp_config()
diff --git a/test/test_gbp.py b/test/test_gbp.py
index 19ca81b9cfe..42defbf0d5c 100644
--- a/test/test_gbp.py
+++ b/test/test_gbp.py
@@ -17,7 +17,8 @@ from framework import VppTestCase, VppTestRunner
from vpp_object import VppObject
from vpp_interface import VppInterface
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, \
- VppIpInterfaceAddress, VppIpInterfaceBind, find_route
+ VppIpInterfaceAddress, VppIpInterfaceBind, find_route, FibPathProto, \
+ FibPathType
from vpp_l2 import VppBridgeDomain, VppBridgeDomainPort, \
VppBridgeDomainArpEntry, VppL2FibEntry, find_bridge_domain_port, VppL2Vtr
from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint
@@ -920,13 +921,13 @@ class TestGBP(VppTestCase):
ba.add_vpp_config()
# floating IPs route via EPG recirc
- r = VppIpRoute(self, fip.address, fip.length,
- [VppRoutePath(fip.address,
- ep.recirc.recirc.sw_if_index,
- is_dvr=1,
- proto=fip.dpo_proto)],
- table_id=20,
- is_ip6=fip.is_ip6)
+ r = VppIpRoute(
+ self, fip.address, fip.length,
+ [VppRoutePath(fip.address,
+ ep.recirc.recirc.sw_if_index,
+ type=FibPathType.FIB_PATH_TYPE_DVR,
+ proto=fip.dpo_proto)],
+ table_id=20)
r.add_vpp_config()
# L2 FIB entries in the NAT EPG BD to bridge the packets from
diff --git a/test/test_geneve.py b/test/test_geneve.py
index 86515f40430..04271e31b69 100644
--- a/test/test_geneve.py
+++ b/test/test_geneve.py
@@ -10,6 +10,8 @@ from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP
from scapy.layers.geneve import GENEVE
from scapy.utils import atol
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
class TestGeneve(BridgeDomain, VppTestCase):
@@ -85,13 +87,16 @@ class TestGeneve(BridgeDomain, VppTestCase):
# Create 10 ucast geneve tunnels under bd
ip_range_start = 10
ip_range_end = ip_range_start + n_ucast_tunnels
- next_hop_address = cls.pg0.remote_ip4n
- for dest_ip4n in ip4n_range(next_hop_address, ip_range_start,
- ip_range_end):
+ next_hop_address = cls.pg0.remote_ip4
+ for dest_ip4 in ip4_range(next_hop_address, ip_range_start,
+ ip_range_end):
# add host route so dest_ip4n will not be resolved
- cls.vapi.ip_add_del_route(dst_address=dest_ip4n,
- dst_address_length=32,
- next_hop_address=next_hop_address)
+ rip = VppIpRoute(cls, dest_ip4, 32,
+ [VppRoutePath(next_hop_address,
+ INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
+ dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
r = cls.vapi.geneve_add_del_tunnel(
local_address=cls.pg0.local_ip4n, remote_address=dest_ip4n,
vni=vni)
diff --git a/test/test_gre.py b/test/test_gre.py
index 7936334ba77..c5239b2cf9d 100644
--- a/test/test_gre.py
+++ b/test/test_gre.py
@@ -13,7 +13,7 @@ from framework import VppTestCase, VppTestRunner
from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint
from vpp_gre_interface import VppGreInterface
from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
from util import ppp, ppc
from vpp_papi import VppEnum
@@ -576,8 +576,7 @@ class TestGRE(VppTestCase):
self, "2001::1", 128,
[VppRoutePath("::",
gre_if.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
route6_via_tun.add_vpp_config()
tx = self.create_stream_ip6(self.pg0, "2001::2", "2001::1")
@@ -615,12 +614,9 @@ class TestGRE(VppTestCase):
gre_if.admin_up()
gre_if.config_ip6()
- route_via_tun = VppIpRoute(
- self, "4004::1", 128,
- [VppRoutePath("0::0",
- gre_if.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ route_via_tun = VppIpRoute(self, "4004::1", 128,
+ [VppRoutePath("0::0",
+ gre_if.sw_if_index)])
route_via_tun.add_vpp_config()
@@ -638,12 +634,9 @@ class TestGRE(VppTestCase):
#
# Add a route that resolves the tunnel's destination
#
- route_tun_dst = VppIpRoute(
- self, "1002::1", 128,
- [VppRoutePath(self.pg2.remote_ip6,
- self.pg2.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ route_tun_dst = VppIpRoute(self, "1002::1", 128,
+ [VppRoutePath(self.pg2.remote_ip6,
+ self.pg2.sw_if_index)])
route_tun_dst.add_vpp_config()
#
diff --git a/test/test_gtpu.py b/test/test_gtpu.py
index 23f1bd8f694..957181a71e4 100644
--- a/test/test_gtpu.py
+++ b/test/test_gtpu.py
@@ -11,6 +11,8 @@ from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
from scapy.contrib.gtp import GTP_U_Header
from scapy.utils import atol
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
class TestGtpuUDP(VppTestCase):
@@ -224,13 +226,16 @@ class TestGtpu(BridgeDomain, VppTestCase):
# Create 10 ucast gtpu tunnels under bd
ip_range_start = 10
ip_range_end = ip_range_start + n_ucast_tunnels
- next_hop_address = cls.pg0.remote_ip4n
- for dest_ip4n in ip4n_range(next_hop_address, ip_range_start,
- ip_range_end):
+ next_hop_address = cls.pg0.remote_ip4
+ for dest_ip4 in ip4_range(next_hop_address, ip_range_start,
+ ip_range_end):
# add host route so dest_ip4n will not be resolved
- cls.vapi.ip_add_del_route(dst_address=dest_ip4n,
- dst_address_length=32,
- next_hop_address=next_hop_address)
+ rip = VppIpRoute(cls, dest_ip4, 32,
+ [VppRoutePath(next_hop_address,
+ INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
+ dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
r = cls.vapi.gtpu_add_del_tunnel(
src_addr=cls.pg0.local_ip4n,
dst_addr=dest_ip4n,
diff --git a/test/test_interface_crud.py b/test/test_interface_crud.py
index b41b2fe5b7c..ae30a6d47ea 100644
--- a/test/test_interface_crud.py
+++ b/test/test_interface_crud.py
@@ -91,7 +91,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# read (check sw if dump, ip4 fib, ip6 fib)
if_dump = self.vapi.sw_interface_dump()
- fib4_dump = self.vapi.ip_fib_dump()
+ fib4_dump = self.vapi.ip_route_dump(0)
for i in loopbacks:
self.assertTrue(i.is_interface_config_in_dump(if_dump))
self.assertTrue(i.is_ip4_entry_in_fib_dump(fib4_dump))
@@ -111,7 +111,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# read (check not in sw if dump, ip4 fib, ip6 fib)
if_dump = self.vapi.sw_interface_dump()
- fib4_dump = self.vapi.ip_fib_dump()
+ fib4_dump = self.vapi.ip_route_dump(0)
for i in loopbacks:
self.assertFalse(i.is_interface_config_in_dump(if_dump))
self.assertFalse(i.is_ip4_entry_in_fib_dump(fib4_dump))
@@ -138,7 +138,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# read (check not in sw if dump, ip4 fib, ip6 fib)
if_dump = self.vapi.sw_interface_dump()
- fib4_dump = self.vapi.ip_fib_dump()
+ fib4_dump = self.vapi.ip_route_dump(0)
for i in loopbacks:
self.assertTrue(i.is_interface_config_in_dump(if_dump))
self.assertFalse(i.is_ip4_entry_in_fib_dump(fib4_dump))
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 6d6aeb0a5d9..933958911fe 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -15,7 +15,7 @@ from framework import VppTestCase, VppTestRunner
from util import ppp
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
- VppMplsTable, VppIpTable
+ VppMplsTable, VppIpTable, FibPathType, find_route
from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
from vpp_papi import VppEnum
@@ -80,7 +80,6 @@ class TestIPv4(VppTestCase):
i.resolve_arp()
# config 2M FIB entries
- self.config_fib_entries(200)
def tearDown(self):
"""Run standard test teardown and log ``show ip arp``."""
@@ -90,33 +89,6 @@ class TestIPv4(VppTestCase):
self.logger.info(self.vapi.cli("show ip arp"))
# info(self.vapi.cli("show ip fib")) # many entries
- def config_fib_entries(self, count):
- """For each interface add to the FIB table *count* routes to
- "10.0.0.1/32" destination with interface's local address as next-hop
- address.
-
- :param int count: Number of FIB entries.
-
- - *TODO:* check if the next-hop address shouldn't be remote address
- instead of local address.
- """
- n_int = len(self.interfaces)
- percent = 0
- counter = 0.0
- dest_addr = socket.inet_pton(socket.AF_INET, "10.0.0.1")
- dest_addr_len = 32
- for i in self.interfaces:
- next_hop_address = i.local_ip4n
- for j in range(count / n_int):
- self.vapi.ip_add_del_route(dst_address=dest_addr,
- dst_address_length=dest_addr_len,
- next_hop_address=next_hop_address)
- counter += 1
- if counter / count * 100 > percent:
- self.logger.info("Configure %d FIB entries .. %d%% done" %
- (count, percent))
- percent += 1
-
def modify_packet(self, src_if, packet_size, pkt):
"""Add load, set destination IP and extend packet to required packet
size for defined interface.
@@ -318,7 +290,8 @@ class TestIPv4FibCrud(VppTestCase):
..note:: Python API is too slow to add many routes, needs replacement.
"""
- def config_fib_many_to_one(self, start_dest_addr, next_hop_addr, count):
+ def config_fib_many_to_one(self, start_dest_addr, next_hop_addr,
+ count, start=0):
"""
:param start_dest_addr:
@@ -326,42 +299,30 @@ class TestIPv4FibCrud(VppTestCase):
:param count:
:return list: added ips with 32 prefix
"""
- added_ips = []
- dest_addr = int(binascii.hexlify(socket.inet_pton(socket.AF_INET,
- start_dest_addr)), 16)
- dest_addr_len = 32
- n_next_hop_addr = socket.inet_pton(socket.AF_INET, next_hop_addr)
- for _ in range(count):
- n_dest_addr = binascii.unhexlify('{:08x}'.format(dest_addr))
- self.vapi.ip_add_del_route(dst_address=n_dest_addr,
- dst_address_length=dest_addr_len,
- next_hop_address=n_next_hop_addr)
- added_ips.append(socket.inet_ntoa(n_dest_addr))
- dest_addr += 1
- return added_ips
-
- def unconfig_fib_many_to_one(self, start_dest_addr, next_hop_addr, count):
-
- removed_ips = []
- dest_addr = int(binascii.hexlify(socket.inet_pton(socket.AF_INET,
- start_dest_addr)), 16)
- dest_addr_len = 32
- n_next_hop_addr = socket.inet_pton(socket.AF_INET, next_hop_addr)
- for _ in range(count):
- n_dest_addr = binascii.unhexlify('{:08x}'.format(dest_addr))
- self.vapi.ip_add_del_route(dst_address=n_dest_addr,
- dst_address_length=dest_addr_len,
- next_hop_address=n_next_hop_addr,
- is_add=0)
- removed_ips.append(socket.inet_ntoa(n_dest_addr))
- dest_addr += 1
- return removed_ips
-
- def create_stream(self, src_if, dst_if, dst_ips, count):
+ routes = []
+ for i in range(count):
+ r = VppIpRoute(self, start_dest_addr % (i + start), 32,
+ [VppRoutePath(next_hop_addr, 0xffffffff)])
+ r.add_vpp_config()
+ routes.append(r)
+ return routes
+
+ def unconfig_fib_many_to_one(self, start_dest_addr, next_hop_addr,
+ count, start=0):
+
+ routes = []
+ for i in range(count):
+ r = VppIpRoute(self, start_dest_addr % (i + start), 32,
+ [VppRoutePath(next_hop_addr, 0xffffffff)])
+ r.remove_vpp_config()
+ routes.append(r)
+ return routes
+
+ def create_stream(self, src_if, dst_if, routes, count):
pkts = []
for _ in range(count):
- dst_addr = random.choice(dst_ips)
+ dst_addr = random.choice(routes).prefix.address
info = self.create_packet_info(src_if, dst_if)
payload = self.info_to_payload(info)
p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
@@ -389,18 +350,6 @@ class TestIPv4FibCrud(VppTestCase):
return p
return None
- @staticmethod
- def _match_route_detail(route_detail, ip, address_length=32, table_id=0):
- if route_detail.address == socket.inet_pton(socket.AF_INET, ip):
- if route_detail.table_id != table_id:
- return False
- elif route_detail.address_length != address_length:
- return False
- else:
- return True
- else:
- return False
-
def verify_capture(self, dst_interface, received_pkts, expected_pkts):
self.assertEqual(len(received_pkts), len(expected_pkts))
to_verify = list(expected_pkts)
@@ -411,27 +360,13 @@ class TestIPv4FibCrud(VppTestCase):
to_verify.remove(x)
self.assertListEqual(to_verify, [])
- def verify_route_dump(self, fib_dump, ips):
-
- def _ip_in_route_dump(ip, fib_dump):
- return next((route for route in fib_dump
- if self._match_route_detail(route, ip)),
- False)
-
- for ip in ips:
- self.assertTrue(_ip_in_route_dump(ip, fib_dump),
- 'IP {!s} is not in fib dump.'.format(ip))
-
- def verify_not_in_route_dump(self, fib_dump, ips):
-
- def _ip_in_route_dump(ip, fib_dump):
- return next((route for route in fib_dump
- if self._match_route_detail(route, ip)),
- False)
+ def verify_route_dump(self, routes):
+ for r in routes:
+ self.assertTrue(find_route(self, r.prefix.address, r.prefix.len))
- for ip in ips:
- self.assertFalse(_ip_in_route_dump(ip, fib_dump),
- 'IP {!s} is in fib dump.'.format(ip))
+ def verify_not_in_route_dump(self, routes):
+ for r in routes:
+ self.assertFalse(find_route(self, r.prefix.address, r.prefix.len))
@classmethod
def setUpClass(cls):
@@ -474,16 +409,13 @@ class TestIPv4FibCrud(VppTestCase):
self.deleted_routes = []
def test_1_add_routes(self):
- """ Add 1k routes
+ """ Add 1k routes """
- - add 100 routes check with traffic script.
- """
- # config 1M FIB entries
+ # add 100 routes check with traffic script.
self.configured_routes.extend(self.config_fib_many_to_one(
- "10.0.0.0", self.pg0.remote_ip4, 100))
+ "10.0.0.%d", self.pg0.remote_ip4, 100))
- fib_dump = self.vapi.ip_fib_dump()
- self.verify_route_dump(fib_dump, self.configured_routes)
+ self.verify_route_dump(self.configured_routes)
self.stream_1 = self.create_stream(
self.pg1, self.pg0, self.configured_routes, 100)
@@ -505,14 +437,13 @@ class TestIPv4FibCrud(VppTestCase):
"""
# config 1M FIB entries
self.configured_routes.extend(self.config_fib_many_to_one(
- "10.0.0.0", self.pg0.remote_ip4, 100))
+ "10.0.0.%d", self.pg0.remote_ip4, 100))
self.deleted_routes.extend(self.unconfig_fib_many_to_one(
- "10.0.0.10", self.pg0.remote_ip4, 10))
+ "10.0.0.%d", self.pg0.remote_ip4, 10, start=10))
for x in self.deleted_routes:
self.configured_routes.remove(x)
- fib_dump = self.vapi.ip_fib_dump()
- self.verify_route_dump(fib_dump, self.configured_routes)
+ self.verify_route_dump(self.configured_routes)
self.stream_1 = self.create_stream(
self.pg1, self.pg0, self.configured_routes, 100)
@@ -538,23 +469,22 @@ class TestIPv4FibCrud(VppTestCase):
"""
# config 1M FIB entries
self.configured_routes.extend(self.config_fib_many_to_one(
- "10.0.0.0", self.pg0.remote_ip4, 100))
+ "10.0.0.%d", self.pg0.remote_ip4, 100))
self.deleted_routes.extend(self.unconfig_fib_many_to_one(
- "10.0.0.10", self.pg0.remote_ip4, 10))
+ "10.0.0.%d", self.pg0.remote_ip4, 10, start=10))
for x in self.deleted_routes:
self.configured_routes.remove(x)
tmp = self.config_fib_many_to_one(
- "10.0.0.10", self.pg0.remote_ip4, 5)
+ "10.0.0.%d", self.pg0.remote_ip4, 5, start=10)
self.configured_routes.extend(tmp)
for x in tmp:
self.deleted_routes.remove(x)
self.configured_routes.extend(self.config_fib_many_to_one(
- "10.0.1.0", self.pg0.remote_ip4, 100))
+ "10.0.1.%d", self.pg0.remote_ip4, 100))
- fib_dump = self.vapi.ip_fib_dump()
- self.verify_route_dump(fib_dump, self.configured_routes)
+ self.verify_route_dump(self.configured_routes)
self.stream_1 = self.create_stream(
self.pg1, self.pg0, self.configured_routes, 300)
@@ -573,20 +503,15 @@ class TestIPv4FibCrud(VppTestCase):
pkts = self.pg0.get_capture(len(self.stream_1) + len(self.stream_2))
self.verify_capture(self.pg0, pkts, self.stream_1 + self.stream_2)
- def test_4_del_routes(self):
- """ Delete 1.5k routes
-
- - delete 5 routes check with traffic script.
- - add 100 routes check with traffic script.
- """
+ # delete 5 routes check with traffic script.
+ # add 100 routes check with traffic script.
self.deleted_routes.extend(self.unconfig_fib_many_to_one(
- "10.0.0.0", self.pg0.remote_ip4, 15))
+ "10.0.0.%d", self.pg0.remote_ip4, 15))
self.deleted_routes.extend(self.unconfig_fib_many_to_one(
- "10.0.0.20", self.pg0.remote_ip4, 85))
+ "10.0.0.%d", self.pg0.remote_ip4, 85))
self.deleted_routes.extend(self.unconfig_fib_many_to_one(
- "10.0.1.0", self.pg0.remote_ip4, 100))
- fib_dump = self.vapi.ip_fib_dump()
- self.verify_not_in_route_dump(fib_dump, self.deleted_routes)
+ "10.0.1.%d", self.pg0.remote_ip4, 100))
+ self.verify_not_in_route_dump(self.deleted_routes)
class TestIPNull(VppTestCase):
@@ -623,7 +548,11 @@ class TestIPNull(VppTestCase):
#
# A route via IP NULL that will reply with ICMP unreachables
#
- ip_unreach = VppIpRoute(self, "10.0.0.1", 32, [], is_unreach=1)
+ ip_unreach = VppIpRoute(
+ self, "10.0.0.1", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ type=FibPathType.FIB_PATH_TYPE_ICMP_UNREACH)])
ip_unreach.add_vpp_config()
p_unreach = (Ether(src=self.pg0.remote_mac,
@@ -631,7 +560,6 @@ class TestIPNull(VppTestCase):
IP(src=self.pg0.remote_ip4, dst="10.0.0.1") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
-
self.pg0.add_stream(p_unreach)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -653,7 +581,11 @@ class TestIPNull(VppTestCase):
#
# A route via IP NULL that will reply with ICMP prohibited
#
- ip_prohibit = VppIpRoute(self, "10.0.0.2", 32, [], is_prohibit=1)
+ ip_prohibit = VppIpRoute(
+ self, "10.0.0.2", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ type=FibPathType.FIB_PATH_TYPE_ICMP_PROHIBIT)])
ip_prohibit.add_vpp_config()
p_prohibit = (Ether(src=self.pg0.remote_mac,
@@ -695,7 +627,10 @@ class TestIPNull(VppTestCase):
#
# insert a more specific as a drop
#
- r2 = VppIpRoute(self, "1.1.1.1", 32, [], is_drop=1)
+ r2 = VppIpRoute(self, "1.1.1.1", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ type=FibPathType.FIB_PATH_TYPE_DROP)])
r2.add_vpp_config()
self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS, "Drop Route")
@@ -1452,11 +1387,12 @@ class TestIPDeag(VppTestCase):
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=1)])
- route_to_src = VppIpRoute(self, "1.1.1.2", 32,
- [VppRoutePath("0.0.0.0",
- 0xffffffff,
- nh_table_id=2,
- is_source_lookup=1)])
+ route_to_src = VppIpRoute(
+ self, "1.1.1.2", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ nh_table_id=2,
+ type=FibPathType.FIB_PATH_TYPE_SOURCE_LOOKUP)])
route_to_dst.add_vpp_config()
route_to_src.add_vpp_config()
@@ -1490,6 +1426,7 @@ class TestIPDeag(VppTestCase):
self.pg1.sw_if_index)],
table_id=1)
route_in_dst.add_vpp_config()
+
self.send_and_expect(self.pg0, pkts_dst, self.pg1)
#
diff --git a/test/test_ip4_vrf_multi_instance.py b/test/test_ip4_vrf_multi_instance.py
index 38604a53474..1004814b8f1 100644
--- a/test/test_ip4_vrf_multi_instance.py
+++ b/test/test_ip4_vrf_multi_instance.py
@@ -337,17 +337,19 @@ class TestIp4VrfMultiInst(VppTestCase):
:param int vrf_id: The FIB table / VRF ID to be verified.
:return: 1 if the FIB table / VRF ID is configured, otherwise return 0.
"""
- ip_fib_dump = self.vapi.ip_fib_dump()
- vrf_exist = False
+ ip_fib_dump = self.vapi.ip_route_dump(vrf_id)
+ vrf_exist = len(ip_fib_dump)
vrf_count = 0
for ip_fib_details in ip_fib_dump:
- if ip_fib_details.table_id == vrf_id:
- if not vrf_exist:
- vrf_exist = True
- addr = socket.inet_ntoa(ip_fib_details.address)
- found = False
- for pg_if in self.pg_if_by_vrf_id[vrf_id]:
- if found:
+ addr = ip_fib_details.route.prefix.network_address
+ found = False
+ for pg_if in self.pg_if_by_vrf_id[vrf_id]:
+ if found:
+ break
+ for host in pg_if.remote_hosts:
+ if str(addr) == host.ip4:
+ vrf_count += 1
+ found = True
break
for host in pg_if.remote_hosts:
if scapy.compat.raw(addr) == \
diff --git a/test/test_ip6.py b/test/test_ip6.py
index 4f267b815c4..35061b0b53c 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -23,11 +23,11 @@ from util import ppp, ip6_normalize, mk_ll_addr
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
- VppMplsRoute, VppMplsTable, VppIpTable
+ VppMplsRoute, VppMplsTable, VppIpTable, FibPathType
from vpp_neighbor import find_nbr, VppNeighbor
from vpp_pg_interface import is_ipv6_misc
from vpp_sub_interface import VppSubInterface, VppDot1QSubint
-from ipaddress import IPv6Network, IPv4Network
+from ipaddress import IPv6Network, IPv4Network, IPv6Address
AF_INET6 = socket.AF_INET6
@@ -217,9 +217,6 @@ class TestIPv6(TestIPv6ND):
i.config_ip6()
i.resolve_ndp()
- # config 2M FIB entries
- self.config_fib_entries(200)
-
def tearDown(self):
"""Run standard test teardown and log ``show ip6 neighbors``."""
for i in self.interfaces:
@@ -234,34 +231,6 @@ class TestIPv6(TestIPv6ND):
self.logger.info(self.vapi.cli("show ip6 neighbors"))
# info(self.vapi.cli("show ip6 fib")) # many entries
- def config_fib_entries(self, count):
- """For each interface add to the FIB table *count* routes to
- "fd02::1/128" destination with interface's local address as next-hop
- address.
-
- :param int count: Number of FIB entries.
-
- - *TODO:* check if the next-hop address shouldn't be remote address
- instead of local address.
- """
- n_int = len(self.interfaces)
- percent = 0
- counter = 0.0
- dest_addr = inet_pton(AF_INET6, "fd02::1")
- dest_addr_len = 128
- for i in self.interfaces:
- next_hop_address = i.local_ip6n
- for j in range(count / n_int):
- self.vapi.ip_add_del_route(dst_address=dest_addr,
- dst_address_length=dest_addr_len,
- next_hop_address=next_hop_address,
- is_ipv6=1)
- counter += 1
- if counter / count * 100 > percent:
- self.logger.info("Configure %d FIB entries .. %d%% done" %
- (count, percent))
- percent += 1
-
def modify_packet(self, src_if, packet_size, pkt):
"""Add load, set destination IP and extend packet to required packet
size for defined interface.
@@ -483,8 +452,7 @@ class TestIPv6(TestIPv6ND):
self.pg0._remote_hosts[2].ip6))
self.assertFalse(find_route(self,
self.pg0._remote_hosts[2].ip6,
- 128,
- inet=AF_INET6))
+ 128))
#
# send an NS from a link local address to the interface's global
@@ -511,8 +479,7 @@ class TestIPv6(TestIPv6ND):
self.pg0._remote_hosts[2].ip6_ll))
self.assertFalse(find_route(self,
self.pg0._remote_hosts[2].ip6_ll,
- 128,
- inet=AF_INET6))
+ 128))
#
# An NS to the router's own Link-local
@@ -538,8 +505,7 @@ class TestIPv6(TestIPv6ND):
self.pg0._remote_hosts[3].ip6_ll))
self.assertFalse(find_route(self,
self.pg0._remote_hosts[3].ip6_ll,
- 128,
- inet=AF_INET6))
+ 128))
def test_ns_duplicates(self):
""" ND Duplicates"""
@@ -1204,33 +1170,33 @@ class TestIPv6RDControlPlane(TestIPv6ND):
def get_default_routes(fib):
list = []
for entry in fib:
- if entry.address_length == 0:
- for path in entry.path:
+ if entry.route.prefix.prefixlen == 0:
+ for path in entry.route.paths:
if path.sw_if_index != 0xFFFFFFFF:
- default_route = {}
- default_route['sw_if_index'] = path.sw_if_index
- default_route['next_hop'] = path.next_hop
- list.append(default_route)
+ defaut_route = {}
+ defaut_route['sw_if_index'] = path.sw_if_index
+ defaut_route['next_hop'] = path.nh.address.ip6
+ list.append(defaut_route)
return list
@staticmethod
def get_interface_addresses(fib, pg):
list = []
for entry in fib:
- if entry.address_length == 128:
- path = entry.path[0]
+ if entry.route.prefix.prefixlen == 128:
+ path = entry.route.paths[0]
if path.sw_if_index == pg.sw_if_index:
- list.append(entry.address)
+ list.append(str(entry.route.prefix.network_address))
return list
def test_all(self):
""" Test handling of SLAAC addresses and default routes """
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
default_routes = self.get_default_routes(fib)
initial_addresses = set(self.get_interface_addresses(fib, self.pg0))
self.assertEqual(default_routes, [])
- router_address = self.pg0.remote_ip6n_ll
+ router_address = IPv6Address(text_type(self.pg0.remote_ip6_ll))
self.vapi.ip6_nd_address_autoconfig(self.pg0.sw_if_index, 1, 1)
@@ -1258,14 +1224,15 @@ class TestIPv6RDControlPlane(TestIPv6ND):
self.sleep(0.1)
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
# check FIB for new address
addresses = set(self.get_interface_addresses(fib, self.pg0))
new_addresses = addresses.difference(initial_addresses)
self.assertEqual(len(new_addresses), 1)
- prefix = list(new_addresses)[0][:8] + '\0\0\0\0\0\0\0\0'
- self.assertEqual(inet_ntop(AF_INET6, prefix), '1::')
+ prefix = IPv6Network(text_type("%s/%d" % (list(new_addresses)[0], 20)),
+ strict=False)
+ self.assertEqual(prefix, IPv6Network(text_type('1::/20')))
# check FIB for new default route
default_routes = self.get_default_routes(fib)
@@ -1282,7 +1249,7 @@ class TestIPv6RDControlPlane(TestIPv6ND):
self.sleep(0.1)
# check that default route is deleted
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
default_routes = self.get_default_routes(fib)
self.assertEqual(len(default_routes), 0)
@@ -1296,7 +1263,7 @@ class TestIPv6RDControlPlane(TestIPv6ND):
self.sleep(0.1)
# check FIB for new default route
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
default_routes = self.get_default_routes(fib)
self.assertEqual(len(default_routes), 1)
dr = default_routes[0]
@@ -1311,7 +1278,7 @@ class TestIPv6RDControlPlane(TestIPv6ND):
self.sleep(0.1)
# check that default route still exists
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
default_routes = self.get_default_routes(fib)
self.assertEqual(len(default_routes), 1)
dr = default_routes[0]
@@ -1321,7 +1288,7 @@ class TestIPv6RDControlPlane(TestIPv6ND):
self.sleep(1)
# check that default route is deleted
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
default_routes = self.get_default_routes(fib)
self.assertEqual(len(default_routes), 0)
@@ -1330,13 +1297,14 @@ class TestIPv6RDControlPlane(TestIPv6ND):
new_addresses = addresses.difference(initial_addresses)
self.assertEqual(len(new_addresses), 1)
- prefix = list(new_addresses)[0][:8] + '\0\0\0\0\0\0\0\0'
- self.assertEqual(inet_ntop(AF_INET6, prefix), '1::')
+ prefix = IPv6Network(text_type("%s/%d" % (list(new_addresses)[0], 20)),
+ strict=False)
+ self.assertEqual(prefix, IPv6Network(text_type('1::/20')))
self.sleep(1)
# check that SLAAC address is deleted
- fib = self.vapi.ip6_fib_dump()
+ fib = self.vapi.ip_route_dump(0, True)
addresses = set(self.get_interface_addresses(fib, self.pg0))
new_addresses = addresses.difference(initial_addresses)
self.assertEqual(len(new_addresses), 0)
@@ -1579,7 +1547,10 @@ class TestIPNull(VppTestCase):
#
# A route via IP NULL that will reply with ICMP unreachables
#
- ip_unreach = VppIpRoute(self, "2001::", 64, [], is_unreach=1, is_ip6=1)
+ ip_unreach = VppIpRoute(
+ self, "2001::", 64,
+ [VppRoutePath("::", 0xffffffff,
+ type=FibPathType.FIB_PATH_TYPE_ICMP_UNREACH)])
ip_unreach.add_vpp_config()
self.pg0.add_stream(p)
@@ -1599,8 +1570,10 @@ class TestIPNull(VppTestCase):
#
# A route via IP NULL that will reply with ICMP prohibited
#
- ip_prohibit = VppIpRoute(self, "2001::1", 128, [],
- is_prohibit=1, is_ip6=1)
+ ip_prohibit = VppIpRoute(
+ self, "2001::1", 128,
+ [VppRoutePath("::", 0xffffffff,
+ type=FibPathType.FIB_PATH_TYPE_ICMP_PROHIBIT)])
ip_prohibit.add_vpp_config()
self.pg0.add_stream(p)
@@ -1661,8 +1634,7 @@ class TestIPDisabled(VppTestCase):
[VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT),
VppMRoutePath(self.pg0.sw_if_index,
- MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)],
- is_ip6=1)
+ MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
route_ff_01.add_vpp_config()
pu = (Ether(src=self.pg1.remote_mac,
@@ -1821,12 +1793,9 @@ class TestIP6LoadBalance(VppTestCase):
#
route_3000_1 = VppIpRoute(self, "3000::1", 128,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6),
+ self.pg1.sw_if_index),
VppRoutePath(self.pg2.remote_ip6,
- self.pg2.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg2.sw_if_index)])
route_3000_1.add_vpp_config()
#
@@ -1841,12 +1810,10 @@ class TestIP6LoadBalance(VppTestCase):
route_67 = VppMplsRoute(self, 67, 0,
[VppRoutePath(self.pg1.remote_ip6,
self.pg1.sw_if_index,
- labels=[67],
- proto=DpoProto.DPO_PROTO_IP6),
+ labels=[67]),
VppRoutePath(self.pg2.remote_ip6,
self.pg2.sw_if_index,
- labels=[67],
- proto=DpoProto.DPO_PROTO_IP6)])
+ labels=[67])])
route_67.add_vpp_config()
#
@@ -1920,22 +1887,16 @@ class TestIP6LoadBalance(VppTestCase):
route_3000_2 = VppIpRoute(self, "3000::2", 128,
[VppRoutePath(self.pg3.remote_ip6,
- self.pg3.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6),
+ self.pg3.sw_if_index),
VppRoutePath(self.pg4.remote_ip6,
- self.pg4.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg4.sw_if_index)])
route_3000_2.add_vpp_config()
route_4000_1 = VppIpRoute(self, "4000::1", 128,
[VppRoutePath("3000::1",
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6),
+ 0xffffffff),
VppRoutePath("3000::2",
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ 0xffffffff)])
route_4000_1.add_vpp_config()
#
@@ -1966,16 +1927,12 @@ class TestIP6LoadBalance(VppTestCase):
route_5000_2 = VppIpRoute(self, "5000::2", 128,
[VppRoutePath(self.pg3.remote_ip6,
- self.pg3.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg3.sw_if_index)])
route_5000_2.add_vpp_config()
route_6000_1 = VppIpRoute(self, "6000::1", 128,
[VppRoutePath("5000::2",
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ 0xffffffff)])
route_6000_1.add_vpp_config()
#
@@ -2168,16 +2125,14 @@ class TestIPDeag(VppTestCase):
route_to_dst = VppIpRoute(self, "1::1", 128,
[VppRoutePath("::",
0xffffffff,
- nh_table_id=1,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
- route_to_src = VppIpRoute(self, "1::2", 128,
- [VppRoutePath("::",
- 0xffffffff,
- nh_table_id=2,
- is_source_lookup=1,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ nh_table_id=1)])
+ route_to_src = VppIpRoute(
+ self, "1::2", 128,
+ [VppRoutePath("::",
+ 0xffffffff,
+ nh_table_id=2,
+ type=FibPathType.FIB_PATH_TYPE_SOURCE_LOOKUP)])
+
route_to_dst.add_vpp_config()
route_to_src.add_vpp_config()
@@ -2208,9 +2163,7 @@ class TestIPDeag(VppTestCase):
#
route_in_dst = VppIpRoute(self, "1::1", 128,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1,
+ self.pg1.sw_if_index)],
table_id=1)
route_in_dst.add_vpp_config()
@@ -2221,9 +2174,7 @@ class TestIPDeag(VppTestCase):
#
route_in_src = VppIpRoute(self, "2::2", 128,
[VppRoutePath(self.pg2.remote_ip6,
- self.pg2.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1,
+ self.pg2.sw_if_index)],
table_id=2)
route_in_src.add_vpp_config()
self.send_and_expect(self.pg0, pkts_src, self.pg2)
@@ -2233,9 +2184,7 @@ class TestIPDeag(VppTestCase):
#
route_loop = VppIpRoute(self, "3::3", 128,
[VppRoutePath("::",
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ 0xffffffff)])
route_loop.add_vpp_config()
p_l = (Ether(src=self.pg0.remote_mac,
diff --git a/test/test_ip6_vrf_multi_instance.py b/test/test_ip6_vrf_multi_instance.py
index c4b057ba29d..88aed978d97 100644
--- a/test/test_ip6_vrf_multi_instance.py
+++ b/test/test_ip6_vrf_multi_instance.py
@@ -17,7 +17,7 @@
- send IP6 packets between all pg-ip6 interfaces in all VRF groups
**verify 1**
- - check VRF data by parsing output of ip6_fib_dump API command
+ - check VRF data by parsing output of ip_route_dump API command
- all packets received correctly in case of pg-ip6 interfaces in the same
VRF
- no packet received in case of pg-ip6 interfaces not in VRF
@@ -30,7 +30,7 @@
- send IP6 packets between all pg-ip6 interfaces in all VRF groups
**verify 2**
- - check VRF data by parsing output of ip6_fib_dump API command
+ - check VRF data by parsing output of ip_route_dump API command
- all packets received correctly in case of pg-ip6 interfaces in the same
VRF
- no packet received in case of pg-ip6 interfaces not in VRF
@@ -43,7 +43,7 @@
- send IP6 packets between all pg-ip6 interfaces in all VRF groups
**verify 3**
- - check VRF data by parsing output of ip6_fib_dump API command
+ - check VRF data by parsing output of ip_route_dump API command
- all packets received correctly in case of pg-ip6 interfaces in the same
VRF
- no packet received in case of pg-ip6 interfaces not in VRF
@@ -56,7 +56,7 @@
- send IP6 packets between all pg-ip6 interfaces in all VRF groups
**verify 4**
- - check VRF data by parsing output of ip6_fib_dump API command
+ - check VRF data by parsing output of ip_route_dump API command
- all packets received correctly in case of pg-ip6 interfaces in the same
VRF
- no packet received in case of pg-ip6 interfaces not in VRF
@@ -349,23 +349,20 @@ class TestIP6VrfMultiInst(VppTestCase):
:param int vrf_id: The FIB table / VRF ID to be verified.
:return: 1 if the FIB table / VRF ID is configured, otherwise return 0.
"""
- ip6_fib_dump = self.vapi.ip6_fib_dump()
- vrf_exist = False
+ ip6_fib_dump = self.vapi.ip_route_dump(vrf_id, True)
+ vrf_exist = len(ip6_fib_dump)
vrf_count = 0
for ip6_fib_details in ip6_fib_dump:
- if ip6_fib_details.table_id == vrf_id:
- if not vrf_exist:
- vrf_exist = True
- addr = inet_ntop(socket.AF_INET6, ip6_fib_details.address)
- found = False
- for pg_if in self.pg_if_by_vrf_id[vrf_id]:
- if found:
+ addr = ip6_fib_details.route.prefix.network_address
+ found = False
+ for pg_if in self.pg_if_by_vrf_id[vrf_id]:
+ if found:
+ break
+ for host in pg_if.remote_hosts:
+ if str(addr) == host.ip6:
+ vrf_count += 1
+ found = True
break
- for host in pg_if.remote_hosts:
- if str(addr) == str(host.ip6):
- vrf_count += 1
- found = True
- break
if not vrf_exist and vrf_count == 0:
self.logger.info("IPv6 VRF ID %d is not configured" % vrf_id)
return VRFState.not_configured
diff --git a/test/test_ip_ecmp.py b/test/test_ip_ecmp.py
index e3ceb594826..2fe266023f7 100644
--- a/test/test_ip_ecmp.py
+++ b/test/test_ip_ecmp.py
@@ -12,6 +12,7 @@ from scapy.packet import Raw
from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
+from vpp_ip_route import VppIpRoute, VppRoutePath
try:
text_type = unicode
@@ -178,22 +179,18 @@ class TestECMP(VppTestCase):
:param int dst_prefix_len: IP address prefix length.
:param int is_ipv6: 0 if an ip4 route, else ip6
"""
- af = socket.AF_INET if is_ipv6 == 0 else socket.AF_INET6
- dst_ip = socket.inet_pton(af, dst_ip_net)
+ paths = []
for pg_if in self.pg_interfaces[1:]:
for nh_host in pg_if.remote_hosts:
nh_host_ip = nh_host.ip4 if is_ipv6 == 0 else nh_host.ip6
- next_hop_address = socket.inet_pton(af, nh_host_ip)
- next_hop_sw_if_index = pg_if.sw_if_index
- self.vapi.ip_add_del_route(
- dst_address=dst_ip,
- dst_address_length=dst_prefix_len,
- next_hop_address=next_hop_address,
- next_hop_sw_if_index=next_hop_sw_if_index,
- is_ipv6=is_ipv6, is_multipath=1)
- self.logger.info("Route via %s on %s created" %
- (nh_host_ip, pg_if.name))
+ paths.append(VppRoutePath(nh_host_ip,
+ pg_if.sw_if_index))
+
+ rip = VppIpRoute(self, dst_ip_net, dst_prefix_len, paths)
+ rip.add_vpp_config()
+ self.logger.info("Route via %s on %s created" %
+ (nh_host_ip, pg_if.name))
self.logger.debug(self.vapi.ppcli("show ip fib"))
self.logger.debug(self.vapi.ppcli("show ip6 fib"))
diff --git a/test/test_ip_mcast.py b/test/test_ip_mcast.py
index 21794d63c3e..b753f9a3354 100644
--- a/test/test_ip_mcast.py
+++ b/test/test_ip_mcast.py
@@ -5,7 +5,7 @@ import unittest
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal, \
- MRouteItfFlags, MRouteEntryFlags, VppIpTable
+ MRouteItfFlags, MRouteEntryFlags, VppIpTable, FibPathProto
from scapy.packet import Raw
from scapy.layers.l2 import Ether
@@ -421,17 +421,16 @@ class TestIPMcast(VppTestCase):
MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
[VppMRoutePath(self.pg0.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg2.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg3.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
route_ff01_1.add_vpp_config()
#
@@ -445,14 +444,13 @@ class TestIPMcast(VppTestCase):
MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
[VppMRoutePath(self.pg0.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg2.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
route_2001_ff01_1.add_vpp_config()
#
@@ -466,11 +464,10 @@ class TestIPMcast(VppTestCase):
MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
[VppMRoutePath(self.pg0.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
route_ff01.add_vpp_config()
#
@@ -687,6 +684,7 @@ class TestIPMcast(VppTestCase):
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
route_232_1_1_1.add_vpp_config()
+
route_232_1_1_1.update_entry_flags(
MRouteEntryFlags.MFIB_ENTRY_FLAG_SIGNAL)
@@ -811,15 +809,14 @@ class TestIPMcast(VppTestCase):
MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
[VppMRoutePath(self.pg8.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_ACCEPT,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg1.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6),
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6),
VppMRoutePath(self.pg2.sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
- proto=DpoProto.DPO_PROTO_IP6)],
- table_id=10,
- is_ip6=1)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)],
+ table_id=10)
route_2001_ff01_1.add_vpp_config()
#
diff --git a/test/test_ipip.py b/test/test_ipip.py
index 6f1d3b883c0..1887417a5e0 100644
--- a/test/test_ipip.py
+++ b/test/test_ipip.py
@@ -6,7 +6,7 @@ from scapy.layers.inet6 import IPv6, Ether, IP, UDP, IPv6ExtHdrFragment
from scapy.all import fragment, fragment6, RandShort, defragment6
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
from socket import AF_INET, AF_INET6, inet_pton
from util import reassemble4
@@ -101,14 +101,14 @@ class TestIPIP(VppTestCase):
self, "130.67.0.0", 16,
[VppRoutePath("0.0.0.0",
sw_if_index,
- proto=DpoProto.DPO_PROTO_IP4)], is_ip6=0)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP4)])
ip4_via_tunnel.add_vpp_config()
ip6_via_tunnel = VppIpRoute(
self, "dead::", 16,
[VppRoutePath("::",
sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)], is_ip6=1)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
ip6_via_tunnel.add_vpp_config()
# IPv6 in to IPv4 tunnel
@@ -308,14 +308,14 @@ class TestIPIP6(VppTestCase):
self, "130.67.0.0", 16,
[VppRoutePath("0.0.0.0",
sw_if_index,
- proto=DpoProto.DPO_PROTO_IP4)], is_ip6=0)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP4)])
ip4_via_tunnel.add_vpp_config()
ip6_via_tunnel = VppIpRoute(
self, "dead::", 16,
[VppRoutePath("::",
sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)], is_ip6=1)
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
ip6_via_tunnel.add_vpp_config()
self.tunnel_ip6_via_tunnel = ip6_via_tunnel
diff --git a/test/test_ipsec_ah.py b/test/test_ipsec_ah.py
index d6cbf58a46e..94c7ffc634e 100644
--- a/test/test_ipsec_ah.py
+++ b/test/test_ipsec_ah.py
@@ -93,8 +93,7 @@ class ConfigIpsecAH(TemplateIpsec):
r = VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
[VppRoutePath(self.tun_if.remote_addr[p.addr_type],
0xffffffff,
- proto=d)],
- is_ip6=p.is_ipv6)
+ proto=d)])
r.add_vpp_config()
self.net_objs.append(r)
self.logger.info(self.vapi.ppcli("show ipsec all"))
diff --git a/test/test_ipsec_esp.py b/test/test_ipsec_esp.py
index 0abd96d4a10..8ed80c3d8de 100644
--- a/test/test_ipsec_esp.py
+++ b/test/test_ipsec_esp.py
@@ -74,8 +74,7 @@ class ConfigIpsecESP(TemplateIpsec):
r = VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
[VppRoutePath(self.tun_if.remote_addr[p.addr_type],
0xffffffff,
- proto=d)],
- is_ip6=p.is_ipv6)
+ proto=d)])
r.add_vpp_config()
self.net_objs.append(r)
diff --git a/test/test_ipsec_nat.py b/test/test_ipsec_nat.py
index 3209def213b..07670d71b03 100644
--- a/test/test_ipsec_nat.py
+++ b/test/test_ipsec_nat.py
@@ -63,8 +63,7 @@ class IPSecNATTestCase(TemplateIpsec):
VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
[VppRoutePath(self.tun_if.remote_addr[p.addr_type],
0xffffffff,
- proto=d)],
- is_ip6=p.is_ipv6).add_vpp_config()
+ proto=d)]).add_vpp_config()
def tearDown(self):
super(IPSecNATTestCase, self).tearDown()
diff --git a/test/test_ipsec_tun_if_esp.py b/test/test_ipsec_tun_if_esp.py
index 47b138fe486..5ef0bdbb8c6 100644
--- a/test/test_ipsec_tun_if_esp.py
+++ b/test/test_ipsec_tun_if_esp.py
@@ -47,14 +47,15 @@ class TemplateIpsec4TunIfEsp(TemplateIpsec):
p.tun_if.config_ip4()
p.tun_if.config_ip6()
- VppIpRoute(self, p.remote_tun_if_host, 32,
- [VppRoutePath(p.tun_if.remote_ip4,
- 0xffffffff)]).add_vpp_config()
- VppIpRoute(self, p.remote_tun_if_host6, 128,
- [VppRoutePath(p.tun_if.remote_ip6,
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1).add_vpp_config()
+ r = VppIpRoute(self, p.remote_tun_if_host, 32,
+ [VppRoutePath(p.tun_if.remote_ip4,
+ 0xffffffff)])
+ r.add_vpp_config()
+ r = VppIpRoute(self, p.remote_tun_if_host6, 128,
+ [VppRoutePath(p.tun_if.remote_ip6,
+ 0xffffffff,
+ proto=DpoProto.DPO_PROTO_IP6)])
+ r.add_vpp_config()
def tearDown(self):
if not self.vpp_dead:
@@ -119,14 +120,15 @@ class TemplateIpsec6TunIfEsp(TemplateIpsec):
tun_if.config_ip6()
tun_if.config_ip4()
- VppIpRoute(self, p.remote_tun_if_host, 128,
- [VppRoutePath(tun_if.remote_ip6,
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1).add_vpp_config()
- VppIpRoute(self, p.remote_tun_if_host4, 32,
- [VppRoutePath(tun_if.remote_ip4,
- 0xffffffff)]).add_vpp_config()
+ r = VppIpRoute(self, p.remote_tun_if_host, 128,
+ [VppRoutePath(tun_if.remote_ip6,
+ 0xffffffff,
+ proto=DpoProto.DPO_PROTO_IP6)])
+ r.add_vpp_config()
+ r = VppIpRoute(self, p.remote_tun_if_host4, 32,
+ [VppRoutePath(tun_if.remote_ip4,
+ 0xffffffff)])
+ r.add_vpp_config()
def tearDown(self):
if not self.vpp_dead:
@@ -433,11 +435,11 @@ class TestIpsec6MultiTunIfEsp(TemplateIpsec, IpsecTun6):
p.tun_if.admin_up()
p.tun_if.config_ip6()
- VppIpRoute(self, p.remote_tun_if_host, 128,
- [VppRoutePath(p.tun_if.remote_ip6,
- 0xffffffff,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1).add_vpp_config()
+ r = VppIpRoute(self, p.remote_tun_if_host, 128,
+ [VppRoutePath(p.tun_if.remote_ip6,
+ 0xffffffff,
+ proto=DpoProto.DPO_PROTO_IP6)])
+ r.add_vpp_config()
def tearDown(self):
if not self.vpp_dead:
diff --git a/test/test_l3xc.py b/test/test_l3xc.py
index ceb95ce02dd..696e23507ac 100644
--- a/test/test_l3xc.py
+++ b/test/test_l3xc.py
@@ -34,30 +34,9 @@ class VppL3xc(VppObject):
self.intf = intf
self.is_ip6 = is_ip6
self.paths = paths
-
- def encode_paths(self):
- br_paths = []
- for p in self.paths:
- lstack = []
- for l in p.nh_labels:
- if type(l) == VppMplsLabel:
- lstack.append(l.encode())
- else:
- lstack.append({'label': l, 'ttl': 255})
- n_labels = len(lstack)
- while (len(lstack) < 16):
- lstack.append({})
- br_paths.append({'next_hop': p.nh_addr,
- 'weight': 1,
- 'afi': p.proto,
- 'sw_if_index': p.nh_itf,
- 'preference': 0,
- 'table_id': p.nh_table_id,
- 'next_hop_id': p.next_hop_id,
- 'is_udp_encap': p.is_udp_encap,
- 'n_labels': n_labels,
- 'label_stack': lstack})
- return br_paths
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
def add_vpp_config(self):
self._test.vapi.l3xc_update(
@@ -65,7 +44,7 @@ class VppL3xc(VppObject):
'is_ip6': self.is_ip6,
'sw_if_index': self.intf.sw_if_index,
'n_paths': len(self.paths),
- 'paths': self.encode_paths()
+ 'paths': self.encoded_paths
})
self._test.registry.register(self, self._test.logger)
diff --git a/test/test_lb.py b/test/test_lb.py
index 93b389a1444..4603bd10db8 100644
--- a/test/test_lb.py
+++ b/test/test_lb.py
@@ -9,6 +9,8 @@ from scapy.data import IP_PROTOS
from framework import VppTestCase
from util import ppp
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
""" TestLB is a subclass of VPPTestCase classes.
@@ -50,13 +52,17 @@ class TestLB(VppTestCase):
i.disable_ipv6_ra()
i.resolve_arp()
i.resolve_ndp()
- dst4 = socket.inet_pton(socket.AF_INET, "10.0.0.0")
- dst6 = socket.inet_pton(socket.AF_INET6, "2002::")
- cls.vapi.ip_add_del_route(dst_address=dst4, dst_address_length=24,
- next_hop_address=cls.pg1.remote_ip4n)
- cls.vapi.ip_add_del_route(dst_address=dst6, dst_address_length=16,
- next_hop_address=cls.pg1.remote_ip6n,
- is_ipv6=1)
+
+ dst4 = VppIpRoute(cls, "10.0.0.0", 24,
+ [VppRoutePath(cls.pg1.remote_ip4,
+ INVALID_INDEX)],
+ register=False)
+ dst4.add_vpp_config()
+ dst6 = VppIpRoute(cls, "2002::", 16,
+ [VppRoutePath(cls.pg1.remote_ip6,
+ INVALID_INDEX)],
+ register=False)
+ dst6.add_vpp_config()
cls.vapi.lb_conf(ip4_src_address="39.40.41.42",
ip6_src_address="2004::1")
except Exception:
diff --git a/test/test_map.py b/test/test_map.py
index 39698cd2f7d..f1388b39c65 100644
--- a/test/test_map.py
+++ b/test/test_map.py
@@ -2,6 +2,7 @@
import ipaddress
import unittest
+from ipaddress import IPv6Network, IPv4Network
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
@@ -105,9 +106,7 @@ class TestMAP(VppTestCase):
map_br_pfx,
map_br_pfx_len,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
map_route.add_vpp_config()
#
@@ -198,12 +197,9 @@ class TestMAP(VppTestCase):
# Add a route to 4001::1. Expect the encapped traffic to be
# sent via that routes next-hop
#
- pre_res_route = VppIpRoute(
- self, "4001::1", 128,
- [VppRoutePath(self.pg1.remote_hosts[2].ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ pre_res_route = VppIpRoute(self, "4001::1", 128,
+ [VppRoutePath(self.pg1.remote_hosts[2].ip6,
+ self.pg1.sw_if_index)])
pre_res_route.add_vpp_config()
self.send_and_assert_encapped(v4, "3000::1",
@@ -214,8 +210,7 @@ class TestMAP(VppTestCase):
# change the route to the pre-solved next-hop
#
pre_res_route.modify([VppRoutePath(self.pg1.remote_hosts[3].ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)])
+ self.pg1.sw_if_index)])
pre_res_route.add_vpp_config()
self.send_and_assert_encapped(v4, "3000::1",
@@ -289,8 +284,7 @@ class TestMAP(VppTestCase):
32,
[VppRoutePath(self.pg1.remote_ip6,
self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
map_route.add_vpp_config()
#
diff --git a/test/test_memif.py b/test/test_memif.py
index d89e06bfb4b..c41d0aac983 100644
--- a/test/test_memif.py
+++ b/test/test_memif.py
@@ -9,8 +9,10 @@ from framework import VppTestCase, VppTestRunner, running_extended_tests
from remote_test import RemoteClass, RemoteVppTestCase
from vpp_memif import MEMIF_MODE, MEMIF_ROLE, remove_all_memif_vpp_config, \
VppSocketFilename, VppMemif
+from vpp_ip_route import VppIpRoute, VppRoutePath
+@unittest.skipIf(True, "doesn't work with VppEnums")
class TestMemif(VppTestCase):
""" Memif Test Case """
@@ -51,7 +53,7 @@ class TestMemif(VppTestCase):
return False
def test_memif_socket_filename_add_del(self):
- """ Memif socket filenale add/del """
+ """ Memif socket filename add/del """
# dump default socket filename
dump = self.vapi.memif_socket_filename_dump()
@@ -225,6 +227,7 @@ class TestMemif(VppTestCase):
def test_memif_ping(self):
""" Memif ping """
+
memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)
remote_socket = VppSocketFilename(self.remote_test, 1,
@@ -247,12 +250,8 @@ class TestMemif(VppTestCase):
self.assertTrue(remote_memif.wait_for_link_up(5))
# add routing to remote vpp
- dst_addr = socket.inet_pton(socket.AF_INET, self.pg0._local_ip4_subnet)
- dst_addr_len = 24
- next_hop_addr = socket.inet_pton(socket.AF_INET, memif.ip4_addr)
- self.remote_test.vapi.ip_add_del_route(dst_address=dst_addr,
- dst_address_length=dst_addr_len,
- next_hop_address=next_hop_addr)
+ VppIpRoute(self.remote_test, self.pg0._local_ip4_subnet, 24,
+ [VppRoutePath(memif.ip4_addr, 0xffffffff)]).add_vpp_config()
# create ICMP echo-request from local pg to remote memif
packet_num = 10
diff --git a/test/test_mpls.py b/test/test_mpls.py
index 79f3204c53e..d068bc37ee2 100644
--- a/test/test_mpls.py
+++ b/test/test_mpls.py
@@ -8,7 +8,8 @@ from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute, \
VppMplsIpBind, VppIpMRoute, VppMRoutePath, \
MRouteItfFlags, MRouteEntryFlags, VppIpTable, VppMplsTable, \
- VppMplsLabel, MplsLspMode, find_mpls_route
+ VppMplsLabel, MplsLspMode, find_mpls_route, \
+ FibPathProto, FibPathType, FibPathFlags, VppMplsLabel, MplsLspMode
from vpp_mpls_tunnel_interface import VppMPLSTunnelInterface
import scapy.compat
@@ -498,8 +499,8 @@ class TestMPLS(VppTestCase):
self, 333, 1,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- labels=[],
- proto=DpoProto.DPO_PROTO_IP6)])
+ labels=[])],
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)
route_333_eos.add_vpp_config()
tx = self.create_stream_labelled_ip6(self.pg0, [VppMplsLabel(333)])
@@ -523,8 +524,8 @@ class TestMPLS(VppTestCase):
self, 334, 1,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- labels=[VppMplsLabel(3)],
- proto=DpoProto.DPO_PROTO_IP6)])
+ labels=[VppMplsLabel(3)])],
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)
route_334_eos.add_vpp_config()
tx = self.create_stream_labelled_ip6(self.pg0,
@@ -539,8 +540,8 @@ class TestMPLS(VppTestCase):
self, 335, 1,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- labels=[VppMplsLabel(3, MplsLspMode.UNIFORM)],
- proto=DpoProto.DPO_PROTO_IP6)])
+ labels=[VppMplsLabel(3, MplsLspMode.UNIFORM)])],
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)
route_335_eos.add_vpp_config()
tx = self.create_stream_labelled_ip6(
@@ -586,6 +587,7 @@ class TestMPLS(VppTestCase):
labels=[VppMplsLabel(44),
VppMplsLabel(45)])])
route_34_eos.add_vpp_config()
+ self.logger.info(self.vapi.cli("sh mpls fib 34"))
tx = self.create_stream_labelled_ip4(self.pg0,
[VppMplsLabel(34, ttl=3)])
@@ -775,10 +777,8 @@ class TestMPLS(VppTestCase):
self, "2001::3", 128,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6,
labels=[VppMplsLabel(32,
- mode=MplsLspMode.UNIFORM)])],
- is_ip6=1)
+ mode=MplsLspMode.UNIFORM)])])
route_2001_3.add_vpp_config()
tx = self.create_stream_ip6(self.pg0, "2001::3",
@@ -968,7 +968,7 @@ class TestMPLS(VppTestCase):
VppMplsLabel(33, ttl=47)])
def test_mpls_tunnel_many(self):
- """ Multiple Tunnels """
+ """ MPLS Multiple Tunnels """
for ii in range(10):
mpls_tun = VppMPLSTunnelInterface(
@@ -1111,10 +1111,11 @@ class TestMPLS(VppTestCase):
# if the packet egresses, then we must have swapped to pg1
# so as to have matched the route in table 1
#
- route_34_eos = VppMplsRoute(self, 34, 1,
- [VppRoutePath("0.0.0.0",
- self.pg1.sw_if_index,
- is_interface_rx=1)])
+ route_34_eos = VppMplsRoute(
+ self, 34, 1,
+ [VppRoutePath("0.0.0.0",
+ self.pg1.sw_if_index,
+ type=FibPathType.FIB_PATH_TYPE_INTERFACE_RX)])
route_34_eos.add_vpp_config()
#
@@ -1154,7 +1155,7 @@ class TestMPLS(VppTestCase):
labels=[VppMplsLabel(3402)]),
VppRoutePath("0.0.0.0",
self.pg1.sw_if_index,
- is_interface_rx=1)],
+ type=FibPathType.FIB_PATH_TYPE_INTERFACE_RX)],
is_multicast=1)
route_3400_eos.add_vpp_config()
@@ -1235,6 +1236,7 @@ class TestMPLS(VppTestCase):
VppMRoutePath(mpls_tun._sw_if_index,
MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)])
route_232_1_1_1.add_vpp_config()
+ self.logger.info(self.vapi.cli("sh ip mfib index 0"))
self.vapi.cli("clear trace")
tx = self.create_stream_ip4(self.pg0, "232.1.1.1")
@@ -1273,12 +1275,14 @@ class TestMPLS(VppTestCase):
# if the packet egresses, then we must have matched the route in
# table 1
#
- route_34_eos = VppMplsRoute(self, 34, 1,
- [VppRoutePath("0.0.0.0",
- self.pg1.sw_if_index,
- nh_table_id=1,
- rpf_id=55)],
- is_multicast=1)
+ route_34_eos = VppMplsRoute(
+ self, 34, 1,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ nh_table_id=1,
+ rpf_id=55)],
+ is_multicast=1,
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_IP4)
route_34_eos.add_vpp_config()
@@ -1294,6 +1298,7 @@ class TestMPLS(VppTestCase):
# set the RPF-ID of the entry to match the input packet's
#
route_232_1_1_1.update_rpf_id(55)
+ self.logger.info(self.vapi.cli("sh ip mfib index 1 232.1.1.1"))
tx = self.create_stream_labelled_ip4(self.pg0, [VppMplsLabel(34)],
dst_ip="232.1.1.1")
@@ -1330,8 +1335,8 @@ class TestMPLS(VppTestCase):
MRouteEntryFlags.MFIB_ENTRY_FLAG_NONE,
table_id=1,
paths=[VppMRoutePath(self.pg1.sw_if_index,
- MRouteItfFlags.MFIB_ITF_FLAG_FORWARD)],
- is_ip6=1)
+ MRouteItfFlags.MFIB_ITF_FLAG_FORWARD,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
route_ff.add_vpp_config()
#
@@ -1345,11 +1350,11 @@ class TestMPLS(VppTestCase):
route_34_eos = VppMplsRoute(
self, 34, 1,
[VppRoutePath("::",
- self.pg1.sw_if_index,
+ 0xffffffff,
nh_table_id=1,
- rpf_id=55,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_multicast=1)
+ rpf_id=55)],
+ is_multicast=1,
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)
route_34_eos.add_vpp_config()
@@ -1572,16 +1577,19 @@ class TestMPLSPIC(VppTestCase):
pkts = []
for ii in range(NUM_PKTS):
dst = "192.168.1.%d" % ii
- vpn_routes.append(VppIpRoute(self, dst, 32,
- [VppRoutePath("10.0.0.45",
- 0xffffffff,
- labels=[145],
- is_resolve_host=1),
- VppRoutePath("10.0.0.46",
- 0xffffffff,
- labels=[146],
- is_resolve_host=1)],
- table_id=1))
+ vpn_routes.append(VppIpRoute(
+ self, dst, 32,
+ [VppRoutePath(
+ "10.0.0.45",
+ 0xffffffff,
+ labels=[145],
+ flags=FibPathFlags.FIB_PATH_FLAG_RESOLVE_VIA_HOST),
+ VppRoutePath(
+ "10.0.0.46",
+ 0xffffffff,
+ labels=[146],
+ flags=FibPathFlags.FIB_PATH_FLAG_RESOLVE_VIA_HOST)],
+ table_id=1))
vpn_routes[ii].add_vpp_config()
pkts.append(Ether(dst=self.pg2.local_mac,
@@ -1686,16 +1694,19 @@ class TestMPLSPIC(VppTestCase):
for ii in range(NUM_PKTS):
dst = "192.168.1.%d" % ii
local_label = 1600 + ii
- vpn_routes.append(VppIpRoute(self, dst, 32,
- [VppRoutePath(self.pg2.remote_ip4,
- 0xffffffff,
- nh_table_id=1,
- is_resolve_attached=1),
- VppRoutePath(self.pg3.remote_ip4,
- 0xffffffff,
- nh_table_id=1,
- is_resolve_attached=1)],
- table_id=1))
+ vpn_routes.append(VppIpRoute(
+ self, dst, 32,
+ [VppRoutePath(
+ self.pg2.remote_ip4,
+ 0xffffffff,
+ nh_table_id=1,
+ flags=FibPathFlags.FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED),
+ VppRoutePath(
+ self.pg3.remote_ip4,
+ 0xffffffff,
+ nh_table_id=1,
+ flags=FibPathFlags.FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED)],
+ table_id=1))
vpn_routes[ii].add_vpp_config()
vpn_bindings.append(VppMplsIpBind(self, local_label, dst, 32,
@@ -1807,23 +1818,21 @@ class TestMPLSPIC(VppTestCase):
local_label = 1600 + ii
vpn_routes.append(VppIpRoute(
self, dst, 128,
- [VppRoutePath(self.pg2.remote_ip6,
- 0xffffffff,
- nh_table_id=1,
- is_resolve_attached=1,
- proto=DpoProto.DPO_PROTO_IP6),
- VppRoutePath(self.pg3.remote_ip6,
- 0xffffffff,
- nh_table_id=1,
- proto=DpoProto.DPO_PROTO_IP6,
- is_resolve_attached=1)],
- table_id=1,
- is_ip6=1))
+ [VppRoutePath(
+ self.pg2.remote_ip6,
+ 0xffffffff,
+ nh_table_id=1,
+ flags=FibPathFlags.FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED),
+ VppRoutePath(
+ self.pg3.remote_ip6,
+ 0xffffffff,
+ nh_table_id=1,
+ flags=FibPathFlags.FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED)],
+ table_id=1))
vpn_routes[ii].add_vpp_config()
vpn_bindings.append(VppMplsIpBind(self, local_label, dst, 128,
- ip_table_id=1,
- is_ip6=1))
+ ip_table_id=1))
vpn_bindings[ii].add_vpp_config()
pkts.append(Ether(dst=self.pg0.local_mac,
@@ -1832,6 +1841,7 @@ class TestMPLSPIC(VppTestCase):
IPv6(src=self.pg0.remote_ip6, dst=dst) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
+ self.logger.info(self.vapi.cli("sh ip6 fib %s" % dst))
self.pg0.add_stream(pkts)
self.pg_enable_capture(self.pg_interfaces)
@@ -1988,8 +1998,9 @@ class TestMPLSL2(VppTestCase):
self, 55, 1,
[VppRoutePath("0.0.0.0",
mpls_tun_1.sw_if_index,
- is_interface_rx=1,
- proto=DpoProto.DPO_PROTO_ETHERNET)])
+ type=FibPathType.FIB_PATH_TYPE_INTERFACE_RX,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_ETHERNET)],
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_ETHERNET)
route_55_eos.add_vpp_config()
#
@@ -2050,8 +2061,9 @@ class TestMPLSL2(VppTestCase):
self, 55, 1,
[VppRoutePath("0.0.0.0",
mpls_tun.sw_if_index,
- is_interface_rx=1,
- proto=DpoProto.DPO_PROTO_ETHERNET)])
+ type=FibPathType.FIB_PATH_TYPE_INTERFACE_RX,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_ETHERNET)],
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_ETHERNET)
route_55_eos.add_vpp_config()
#
diff --git a/test/test_mtu.py b/test/test_mtu.py
index 1c7f6413f61..568a147a9a4 100644
--- a/test/test_mtu.py
+++ b/test/test_mtu.py
@@ -13,7 +13,7 @@ from scapy.layers.inet6 import IPv6, Ether, IP, UDP, ICMPv6PacketTooBig
from scapy.layers.inet import ICMP
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto
from socket import AF_INET, AF_INET6, inet_pton
from util import reassemble4
diff --git a/test/test_nat.py b/test/test_nat.py
index f7364747efd..bf22602059e 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -25,6 +25,8 @@ from syslog_rfc5424_parser import SyslogMessage, ParseError
from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity
from io import BytesIO
from vpp_papi import VppEnum
+from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathType
+from vpp_neighbor import VppNeighbor
from scapy.all import bind_layers, Packet, ByteEnumField, ShortField, \
IPField, IntField, LongField, XByteField, FlagsField, FieldLenField, \
PacketListField
@@ -83,29 +85,6 @@ class MethodHolder(VppTestCase):
Clear NAT44 configuration.
"""
if hasattr(self, 'pg7') and hasattr(self, 'pg8'):
- # I found no elegant way to do this
- self.vapi.ip_add_del_route(
- dst_address=self.pg7.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg7.remote_ip4n,
- next_hop_sw_if_index=self.pg7.sw_if_index,
- is_add=0)
- self.vapi.ip_add_del_route(
- dst_address=self.pg8.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg8.remote_ip4n,
- next_hop_sw_if_index=self.pg8.sw_if_index,
- is_add=0)
-
- for intf in [self.pg7, self.pg8]:
- self.vapi.ip_neighbor_add_del(
- intf.sw_if_index,
- intf.remote_mac,
- intf.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC),
- is_add=0)
-
if self.pg7.has_ip4_config:
self.pg7.unconfig_ip4()
@@ -3159,31 +3138,32 @@ class TestNAT44(MethodHolder):
capture = self.pg2.get_capture(len(pkts))
self.verify_capture_out(capture, nat_ip1)
+ def create_routes_and_neigbors(self):
+ r1 = VppIpRoute(self, self.pg7.remote_ip4, 32,
+ [VppRoutePath(self.pg7.remote_ip4,
+ self.pg7.sw_if_index)])
+ r2 = VppIpRoute(self, self.pg8.remote_ip4, 32,
+ [VppRoutePath(self.pg8.remote_ip4,
+ self.pg8.sw_if_index)])
+ r1.add_vpp_config()
+ r2.add_vpp_config()
+
+ n1 = VppNeighbor(self,
+ self.pg7.sw_if_index,
+ self.pg7.remote_mac,
+ self.pg7.remote_ip4,
+ is_static=1)
+ n2 = VppNeighbor(self,
+ self.pg8.sw_if_index,
+ self.pg8.remote_mac,
+ self.pg8.remote_ip4,
+ is_static=1)
+ n1.add_vpp_config()
+ n2.add_vpp_config()
+
def test_dynamic_ipless_interfaces(self):
""" NAT44 interfaces without configured IP address """
-
- self.vapi.ip_neighbor_add_del(
- self.pg7.sw_if_index,
- self.pg7.remote_mac,
- self.pg7.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC))
- self.vapi.ip_neighbor_add_del(
- self.pg8.sw_if_index,
- self.pg8.remote_mac,
- self.pg8.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC))
-
- self.vapi.ip_add_del_route(dst_address=self.pg7.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg7.remote_ip4n,
- next_hop_sw_if_index=self.pg7.sw_if_index)
- self.vapi.ip_add_del_route(dst_address=self.pg8.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg8.remote_ip4n,
- next_hop_sw_if_index=self.pg8.sw_if_index)
-
+ self.create_routes_and_neigbors()
self.nat44_add_address(self.nat_addr)
flags = self.config_flags.NAT_IS_INSIDE
self.vapi.nat44_interface_add_del_feature(
@@ -3212,28 +3192,7 @@ class TestNAT44(MethodHolder):
def test_static_ipless_interfaces(self):
""" NAT44 interfaces without configured IP address - 1:1 NAT """
- self.vapi.ip_neighbor_add_del(
- self.pg7.sw_if_index,
- self.pg7.remote_mac,
- self.pg7.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC))
- self.vapi.ip_neighbor_add_del(
- self.pg8.sw_if_index,
- self.pg8.remote_mac,
- self.pg8.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC))
-
- self.vapi.ip_add_del_route(dst_address=self.pg7.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg7.remote_ip4n,
- next_hop_sw_if_index=self.pg7.sw_if_index)
- self.vapi.ip_add_del_route(dst_address=self.pg8.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg8.remote_ip4n,
- next_hop_sw_if_index=self.pg8.sw_if_index)
-
+ self.create_routes_and_neigbors()
self.nat44_add_static_mapping(self.pg7.remote_ip4, self.nat_addr)
flags = self.config_flags.NAT_IS_INSIDE
self.vapi.nat44_interface_add_del_feature(
@@ -3266,28 +3225,7 @@ class TestNAT44(MethodHolder):
self.udp_port_out = 30607
self.icmp_id_out = 30608
- self.vapi.ip_neighbor_add_del(
- self.pg7.sw_if_index,
- self.pg7.remote_mac,
- self.pg7.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC))
- self.vapi.ip_neighbor_add_del(
- self.pg8.sw_if_index,
- self.pg8.remote_mac,
- self.pg8.remote_ip4,
- flags=(VppEnum.vl_api_ip_neighbor_flags_t.
- IP_API_NEIGHBOR_FLAG_STATIC))
-
- self.vapi.ip_add_del_route(dst_address=self.pg7.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg7.remote_ip4n,
- next_hop_sw_if_index=self.pg7.sw_if_index)
- self.vapi.ip_add_del_route(dst_address=self.pg8.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg8.remote_ip4n,
- next_hop_sw_if_index=self.pg8.sw_if_index)
-
+ self.create_routes_and_neigbors()
self.nat44_add_address(self.nat_addr)
self.nat44_add_static_mapping(self.pg7.remote_ip4, self.nat_addr,
self.tcp_port_in, self.tcp_port_out,
@@ -3476,16 +3414,16 @@ class TestNAT44(MethodHolder):
nat_ip_vrf10 = "10.0.0.10"
nat_ip_vrf20 = "10.0.0.20"
- self.vapi.ip_add_del_route(dst_address=self.pg3.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg3.remote_ip4n,
- next_hop_sw_if_index=self.pg3.sw_if_index,
- table_id=10)
- self.vapi.ip_add_del_route(dst_address=self.pg3.remote_ip4n,
- dst_address_length=32,
- next_hop_address=self.pg3.remote_ip4n,
- next_hop_sw_if_index=self.pg3.sw_if_index,
- table_id=20)
+ r1 = VppIpRoute(self, self.pg3.remote_ip4, 32,
+ [VppRoutePath(self.pg3.remote_ip4,
+ self.pg3.sw_if_index)],
+ table_id=10)
+ r2 = VppIpRoute(self, self.pg3.remote_ip4, 32,
+ [VppRoutePath(self.pg3.remote_ip4,
+ self.pg3.sw_if_index)],
+ table_id=20)
+ r1.add_vpp_config()
+ r2.add_vpp_config()
self.nat44_add_address(nat_ip_vrf10, vrf_id=10)
self.nat44_add_address(nat_ip_vrf20, vrf_id=20)
@@ -4499,11 +4437,12 @@ class TestNAT44EndpointDependent(MethodHolder):
cls.pg5.set_table_ip4(1)
cls.pg5.config_ip4()
cls.pg5.admin_up()
- cls.vapi.ip_add_del_route(dst_address=cls.pg5.remote_ip4n,
- dst_address_length=32,
- next_hop_address=zero_ip4n,
- next_hop_sw_if_index=cls.pg5.sw_if_index,
- table_id=1)
+ r1 = VppIpRoute(cls, cls.pg5.remote_ip4, 32,
+ [VppRoutePath("0.0.0.0",
+ cls.pg5.sw_if_index)],
+ table_id=1,
+ register=False)
+ r1.add_vpp_config()
cls.pg6._local_ip4 = "10.1.2.1"
cls.pg6._local_ip4n = socket.inet_pton(socket.AF_INET,
@@ -4514,25 +4453,31 @@ class TestNAT44EndpointDependent(MethodHolder):
cls.pg6.set_table_ip4(1)
cls.pg6.config_ip4()
cls.pg6.admin_up()
- cls.vapi.ip_add_del_route(dst_address=cls.pg6.remote_ip4n,
- dst_address_length=32,
- next_hop_address=zero_ip4n,
- next_hop_sw_if_index=cls.pg6.sw_if_index,
- table_id=1)
-
- cls.vapi.ip_add_del_route(dst_address=cls.pg6.remote_ip4n,
- dst_address_length=16,
- next_hop_address=zero_ip4n, table_id=0,
- next_hop_table_id=1)
- cls.vapi.ip_add_del_route(dst_address=zero_ip4n,
- dst_address_length=0,
- next_hop_address=zero_ip4n, table_id=1,
- next_hop_table_id=0)
- cls.vapi.ip_add_del_route(dst_address=zero_ip4n,
- dst_address_length=0,
- next_hop_address=cls.pg1.local_ip4n,
- next_hop_sw_if_index=cls.pg1.sw_if_index,
- table_id=0)
+
+ r2 = VppIpRoute(cls, cls.pg6.remote_ip4, 32,
+ [VppRoutePath("0.0.0.0",
+ cls.pg6.sw_if_index)],
+ table_id=1,
+ register=False)
+ r3 = VppIpRoute(cls, cls.pg6.remote_ip4, 16,
+ [VppRoutePath("0.0.0.0",
+ 0xffffffff,
+ nh_table_id=1)],
+ table_id=0,
+ register=False)
+ r4 = VppIpRoute(cls, "0.0.0.0", 0,
+ [VppRoutePath("0.0.0.0", 0xffffffff,
+ nh_table_id=0)],
+ table_id=1,
+ register=False)
+ r5 = VppIpRoute(cls, "0.0.0.0", 0,
+ [VppRoutePath(cls.pg1.local_ip4,
+ cls.pg1.sw_if_index)],
+ register=False)
+ r2.add_vpp_config()
+ r3.add_vpp_config()
+ r4.add_vpp_config()
+ r5.add_vpp_config()
cls.pg5.resolve_arp()
cls.pg6.resolve_arp()
@@ -6938,11 +6883,11 @@ class TestNAT44Out2InDPO(MethodHolder):
cls.pg1.config_ip6()
cls.pg1.resolve_ndp()
- cls.vapi.ip_add_del_route(dst_address=b'\x00' * 16,
- dst_address_length=0,
- next_hop_address=cls.pg1.remote_ip6n,
- next_hop_sw_if_index=cls.pg1.sw_if_index,
- is_ipv6=True)
+ r1 = VppIpRoute(cls, "::", 0,
+ [VppRoutePath(cls.pg1.remote_ip6,
+ cls.pg1.sw_if_index)],
+ register=False)
+ r1.add_vpp_config()
except Exception:
super(TestNAT44Out2InDPO, cls).tearDownClass()
@@ -9386,11 +9331,10 @@ class TestDSliteCE(MethodHolder):
aftr_ip6_n = socket.inet_pton(socket.AF_INET6, aftr_ip6)
self.vapi.dslite_set_aftr_addr(ip4_addr=aftr_ip4, ip6_addr=aftr_ip6)
- self.vapi.ip_add_del_route(dst_address=aftr_ip6_n,
- dst_address_length=128,
- next_hop_address=self.pg1.remote_ip6n,
- next_hop_sw_if_index=self.pg1.sw_if_index,
- is_ipv6=1)
+ r1 = VppIpRoute(self, aftr_ip6, 128,
+ [VppRoutePath(self.pg1.remote_ip6,
+ self.pg1.sw_if_index)])
+ r1.add_vpp_config()
# UDP encapsulation
p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
diff --git a/test/test_neighbor.py b/test/test_neighbor.py
index 6f781ff54c2..69b00ea6ff2 100644
--- a/test/test_neighbor.py
+++ b/test/test_neighbor.py
@@ -6,7 +6,7 @@ from socket import AF_INET, AF_INET6, inet_pton
from framework import VppTestCase, VppTestRunner
from vpp_neighbor import VppNeighbor, find_nbr
from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, \
- VppIpTable, DpoProto
+ VppIpTable, DpoProto, FibPathType
from vpp_papi import VppEnum
import scapy.compat
@@ -1362,8 +1362,7 @@ class ARPTestCase(VppTestCase):
ip_10_1 = VppIpRoute(self, "10::1", 128,
[VppRoutePath(self.pg0.remote_hosts[1].ip6,
self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
ip_10_1.add_vpp_config()
p1 = (Ether(dst=self.pg1.local_mac,
@@ -1396,10 +1395,11 @@ class ARPTestCase(VppTestCase):
#
self.pg0.generate_remote_hosts(2)
- forus = VppIpRoute(self, self.pg0.remote_hosts[1].ip4, 32,
- [VppRoutePath(self.pg0.remote_hosts[1].ip4,
- self.pg0.sw_if_index)],
- is_local=1)
+ forus = VppIpRoute(
+ self, self.pg0.remote_hosts[1].ip4, 32,
+ [VppRoutePath("0.0.0.0",
+ self.pg0.sw_if_index,
+ type=FibPathType.FIB_PATH_TYPE_LOCAL)])
forus.add_vpp_config()
p = (Ether(dst="ff:ff:ff:ff:ff:ff",
diff --git a/test/test_p2p_ethernet.py b/test/test_p2p_ethernet.py
index 6719400cb5c..8ae6cb26fe0 100644
--- a/test/test_p2p_ethernet.py
+++ b/test/test_p2p_ethernet.py
@@ -192,9 +192,7 @@ class P2PEthernetIPV6(VppTestCase):
route_8000 = VppIpRoute(self, "8000::", 64,
[VppRoutePath(self.pg0.remote_ip6,
- self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg0.sw_if_index)])
route_8000.add_vpp_config()
self.packets = [(Ether(dst=self.pg1.local_mac,
@@ -212,9 +210,7 @@ class P2PEthernetIPV6(VppTestCase):
route_9001 = VppIpRoute(self, "9001::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route_9001.add_vpp_config()
self.packets.append(
@@ -237,9 +233,7 @@ class P2PEthernetIPV6(VppTestCase):
route_3 = VppIpRoute(self, "9000::", 64,
[VppRoutePath(self.pg1._remote_hosts[0].ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route_3.add_vpp_config()
self.packets.append(
@@ -262,9 +256,7 @@ class P2PEthernetIPV6(VppTestCase):
route_9001 = VppIpRoute(self, "9000::", 64,
[VppRoutePath(self.pg1._remote_hosts[0].ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route_9001.add_vpp_config()
self.packets.append(
@@ -283,21 +275,17 @@ class P2PEthernetIPV6(VppTestCase):
route_8000 = VppIpRoute(self, "8000::", 64,
[VppRoutePath(self.pg0.remote_ip6,
- self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg0.sw_if_index)])
route_8000.add_vpp_config()
route_8001 = VppIpRoute(self, "8001::", 64,
- [VppRoutePath(self.p2p_sub_ifs[0].remote_ip6,
- self.p2p_sub_ifs[0].sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ [VppRoutePath(
+ self.p2p_sub_ifs[0].remote_ip6,
+ self.p2p_sub_ifs[0].sw_if_index)])
route_8001.add_vpp_config()
route_8002 = VppIpRoute(self, "8002::", 64,
- [VppRoutePath(self.p2p_sub_ifs[1].remote_ip6,
- self.p2p_sub_ifs[1].sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ [VppRoutePath(
+ self.p2p_sub_ifs[1].remote_ip6,
+ self.p2p_sub_ifs[1].sw_if_index)])
route_8002.add_vpp_config()
for i in range(0, 3):
diff --git a/test/test_punt.py b/test/test_punt.py
index b93188e4fe2..e7ac4dd3fd6 100644
--- a/test/test_punt.py
+++ b/test/test_punt.py
@@ -1080,8 +1080,7 @@ class TestPunt(VppTestCase):
ip_1_2 = VppIpRoute(self, "1::2", 128,
[VppRoutePath(self.pg3.remote_ip6,
self.pg3.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
ip_1_2.add_vpp_config()
p4 = (Ether(src=self.pg2.remote_mac,
diff --git a/test/test_qos.py b/test/test_qos.py
index d4bd0872243..94062b89ae2 100644
--- a/test/test_qos.py
+++ b/test/test_qos.py
@@ -6,7 +6,7 @@ from framework import VppTestCase, VppTestRunner
from vpp_sub_interface import VppDot1QSubint
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute, \
- VppMplsLabel, VppMplsTable
+ VppMplsLabel, VppMplsTable, FibPathProto
import scapy.compat
from scapy.packet import Raw
@@ -521,15 +521,11 @@ class TestQOS(VppTestCase):
route_10_0_0_2.add_vpp_config()
route_2001_1 = VppIpRoute(self, "2001::1", 128,
[VppRoutePath(sub_if.remote_ip6,
- sub_if.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ sub_if.sw_if_index)])
route_2001_1.add_vpp_config()
route_2001_2 = VppIpRoute(self, "2001::2", 128,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route_2001_2.add_vpp_config()
p_v1 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
diff --git a/test/test_reassembly.py b/test/test_reassembly.py
index 26ff7486b92..6a356a00b0c 100644
--- a/test/test_reassembly.py
+++ b/test/test_reassembly.py
@@ -17,7 +17,7 @@ from framework import VppTestCase, VppTestRunner
from util import ppp, fragment_rfc791, fragment_rfc8200
from vpp_gre_interface import VppGreInterface
from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto
# 35 is enough to have >257 400-byte fragments
test_packet_count = 35
@@ -1203,10 +1203,9 @@ class TestFIFReassembly(VppTestCase):
sw_if_index=self.gre6.sw_if_index, enable_ip6=True)
self.route6 = VppIpRoute(self, self.tun_ip6, 128,
- [VppRoutePath(self.src_if.remote_ip6,
- self.src_if.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ [VppRoutePath(
+ self.src_if.remote_ip6,
+ self.src_if.sw_if_index)])
self.route6.add_vpp_config()
self.reset_packet_infos()
diff --git a/test/test_sixrd.py b/test/test_sixrd.py
index 9eeae57d37f..ae4af15c2e3 100644
--- a/test/test_sixrd.py
+++ b/test/test_sixrd.py
@@ -7,7 +7,7 @@ from scapy.layers.inet6 import IPv6
from scapy.packet import Raw
from framework import VppTestCase, VppTestRunner
from vpp_ip import DpoProto
-from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, FibPathProto
from socket import AF_INET, AF_INET6, inet_pton
""" Test6rd is a subclass of VPPTestCase classes.
@@ -335,11 +335,9 @@ class Test6RD(VppTestCase):
self.tunnel_index = rv.sw_if_index
- default_route = VppIpRoute(
- self, "DEAD::", 16, [VppRoutePath("2002:0808:0808::",
- self.tunnel_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ default_route = VppIpRoute(self, "DEAD::", 16,
+ [VppRoutePath("2002:0808:0808::",
+ self.tunnel_index)])
default_route.add_vpp_config()
ip4_route = VppIpRoute(self, "8.0.0.0", 8,
diff --git a/test/test_srv6.py b/test/test_srv6.py
index de98ff28a03..b3e69724028 100644
--- a/test/test_srv6.py
+++ b/test/test_srv6.py
@@ -5,7 +5,7 @@ import binascii
from socket import AF_INET6
from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpTable
+from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto, VppIpTable
from vpp_srv6 import SRv6LocalSIDBehaviors, VppSRv6LocalSID, VppSRv6Policy, \
SRv6PolicyType, VppSRv6Steering, SRv6PolicySteeringTypes
@@ -146,9 +146,7 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
# configure encaps IPv6 source address
@@ -248,9 +246,7 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
# configure encaps IPv6 source address
@@ -341,9 +337,7 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
# configure encaps IPv6 source address
@@ -425,9 +419,7 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
# configure encaps IPv6 source address
@@ -512,9 +504,7 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
# configure SRv6 localSID End without PSP behavior
@@ -584,9 +574,7 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg1.sw_if_index)])
route.add_vpp_config()
# configure SRv6 localSID End with PSP behavior
@@ -655,12 +643,9 @@ class TestSRv6(VppTestCase):
# a4::/64 via pg1 and pg2
route = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6),
+ self.pg1.sw_if_index),
VppRoutePath(self.pg2.remote_ip6,
- self.pg2.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg2.sw_if_index)])
route.add_vpp_config()
self.logger.debug(self.vapi.cli("show ip6 fib"))
@@ -734,13 +719,11 @@ class TestSRv6(VppTestCase):
# configure FIB entries
# a4::/64 via pg1 and pg2
route = VppIpRoute(self, "a4::", 64,
- [VppRoutePath(self.pg1.remote_ip6,
- self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6),
+ [VppRoutePath(
+ self.pg1.remote_ip6,
+ self.pg1.sw_if_index),
VppRoutePath(self.pg2.remote_ip6,
- self.pg2.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg2.sw_if_index)])
route.add_vpp_config()
# configure SRv6 localSID End with PSP behavior
@@ -880,18 +863,14 @@ class TestSRv6(VppTestCase):
route0 = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg1.remote_ip6,
self.pg1.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6,
nh_table_id=0)],
- table_id=0,
- is_ip6=1)
+ table_id=0)
route0.add_vpp_config()
route1 = VppIpRoute(self, "a4::", 64,
[VppRoutePath(self.pg2.remote_ip6,
self.pg2.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6,
nh_table_id=vrf_1)],
- table_id=vrf_1,
- is_ip6=1)
+ table_id=vrf_1)
route1.add_vpp_config()
self.logger.debug(self.vapi.cli("show ip6 fib"))
@@ -1038,15 +1017,13 @@ class TestSRv6(VppTestCase):
[VppRoutePath(self.pg1.remote_ip4,
self.pg1.sw_if_index,
nh_table_id=0)],
- table_id=0,
- is_ip6=0)
+ table_id=0)
route0.add_vpp_config()
route1 = VppIpRoute(self, "4.1.1.0", 24,
[VppRoutePath(self.pg2.remote_ip4,
self.pg2.sw_if_index,
nh_table_id=vrf_1)],
- table_id=vrf_1,
- is_ip6=0)
+ table_id=vrf_1)
route1.add_vpp_config()
self.logger.debug(self.vapi.cli("show ip fib"))
@@ -1200,10 +1177,9 @@ class TestSRv6(VppTestCase):
# configure FIB entries
route = VppIpRoute(self, "a4::", 64,
- [VppRoutePath(self.pg4.remote_ip6,
- self.pg4.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ [VppRoutePath(
+ self.pg4.remote_ip6,
+ self.pg4.sw_if_index)])
route.add_vpp_config()
# configure encaps IPv6 source address
diff --git a/test/test_srv6_ad.py b/test/test_srv6_ad.py
index a788f1e4974..aa4b8d3c088 100644
--- a/test/test_srv6_ad.py
+++ b/test/test_srv6_ad.py
@@ -151,8 +151,7 @@ class TestSRv6(VppTestCase):
route = VppIpRoute(self, self.sid_list[self.test_sid_index + 1], 128,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
route.add_vpp_config()
# configure SRv6 localSID behavior
@@ -286,8 +285,7 @@ class TestSRv6(VppTestCase):
route = VppIpRoute(self, self.sid_list[self.test_sid_index + 1], 128,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
route.add_vpp_config()
# configure SRv6 localSID behavior
@@ -429,8 +427,7 @@ class TestSRv6(VppTestCase):
route = VppIpRoute(self, self.sid_list[self.test_sid_index + 1], 128,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ proto=DpoProto.DPO_PROTO_IP6)])
route.add_vpp_config()
# configure SRv6 localSID behavior
diff --git a/test/test_srv6_as.py b/test/test_srv6_as.py
index 108fcdb5d27..2be7865d5bd 100755
--- a/test/test_srv6_as.py
+++ b/test/test_srv6_as.py
@@ -5,7 +5,7 @@ import binascii
from socket import AF_INET6
from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpTable
+from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto, VppIpTable
from vpp_srv6 import SRv6LocalSIDBehaviors, VppSRv6LocalSID, VppSRv6Policy, \
SRv6PolicyType, VppSRv6Steering, SRv6PolicySteeringTypes
@@ -196,9 +196,7 @@ class TestSRv6(VppTestCase):
# configure route to next segment
route = VppIpRoute(self, sid_list[test_sid_index + 1], 128,
[VppRoutePath(self.pg0.remote_ip6,
- self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg0.sw_if_index)])
route.add_vpp_config()
# configure SRv6 localSID behavior
@@ -267,9 +265,7 @@ class TestSRv6(VppTestCase):
# configure route to next segment
route = VppIpRoute(self, sid_list[test_sid_index + 1], 128,
[VppRoutePath(self.pg0.remote_ip6,
- self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg0.sw_if_index)])
route.add_vpp_config()
# configure SRv6 localSID behavior
@@ -338,9 +334,7 @@ class TestSRv6(VppTestCase):
# configure route to next segment
route = VppIpRoute(self, sid_list[test_sid_index + 1], 128,
[VppRoutePath(self.pg0.remote_ip6,
- self.pg0.sw_if_index,
- proto=DpoProto.DPO_PROTO_IP6)],
- is_ip6=1)
+ self.pg0.sw_if_index)])
route.add_vpp_config()
# configure SRv6 localSID behavior
diff --git a/test/test_udp.py b/test/test_udp.py
index c714f25e27f..fc77434184c 100644
--- a/test/test_udp.py
+++ b/test/test_udp.py
@@ -1,8 +1,10 @@
#!/usr/bin/env python
import unittest
from framework import VppTestCase, VppTestRunner
+
from vpp_udp_encap import find_udp_encap, VppUdpEncap
-from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel, \
+ FibPathType
from scapy.packet import Raw
from scapy.layers.l2 import Ether
@@ -131,32 +133,34 @@ class TestUdpEncap(VppTestCase):
#
# Routes via each UDP encap object - all combinations of v4 and v6.
#
- route_4o4 = VppIpRoute(self, "1.1.0.1", 32,
- [VppRoutePath("0.0.0.0",
- 0xFFFFFFFF,
- is_udp_encap=1,
- next_hop_id=udp_encap_0.id)])
- route_4o6 = VppIpRoute(self, "1.1.2.1", 32,
- [VppRoutePath("0.0.0.0",
- 0xFFFFFFFF,
- is_udp_encap=1,
- next_hop_id=udp_encap_2.id)])
- route_6o4 = VppIpRoute(self, "2001::1", 128,
- [VppRoutePath("0.0.0.0",
- 0xFFFFFFFF,
- is_udp_encap=1,
- next_hop_id=udp_encap_1.id)],
- is_ip6=1)
- route_6o6 = VppIpRoute(self, "2001::3", 128,
- [VppRoutePath("0.0.0.0",
- 0xFFFFFFFF,
- is_udp_encap=1,
- next_hop_id=udp_encap_3.id)],
- is_ip6=1)
- route_4o4.add_vpp_config()
+ route_4o4 = VppIpRoute(
+ self, "1.1.0.1", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xFFFFFFFF,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
+ next_hop_id=udp_encap_0.id)])
+ route_4o6 = VppIpRoute(
+ self, "1.1.2.1", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xFFFFFFFF,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
+ next_hop_id=udp_encap_2.id)])
+ route_6o4 = VppIpRoute(
+ self, "2001::1", 128,
+ [VppRoutePath("0.0.0.0",
+ 0xFFFFFFFF,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
+ next_hop_id=udp_encap_1.id)])
+ route_6o6 = VppIpRoute(
+ self, "2001::3", 128,
+ [VppRoutePath("0.0.0.0",
+ 0xFFFFFFFF,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
+ next_hop_id=udp_encap_3.id)])
route_4o6.add_vpp_config()
route_6o6.add_vpp_config()
route_6o4.add_vpp_config()
+ route_4o4.add_vpp_config()
#
# 4o4 encap
@@ -222,12 +226,13 @@ class TestUdpEncap(VppTestCase):
# A route with an output label
# the TTL of the inner packet is decremented on LSP ingress
#
- route_4oMPLSo4 = VppIpRoute(self, "1.1.2.22", 32,
- [VppRoutePath("0.0.0.0",
- 0xFFFFFFFF,
- is_udp_encap=1,
- next_hop_id=1,
- labels=[VppMplsLabel(66)])])
+ route_4oMPLSo4 = VppIpRoute(
+ self, "1.1.2.22", 32,
+ [VppRoutePath("0.0.0.0",
+ 0xFFFFFFFF,
+ type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP,
+ next_hop_id=1,
+ labels=[VppMplsLabel(66)])])
route_4oMPLSo4.add_vpp_config()
p_4omo4 = (Ether(src=self.pg0.remote_mac,
diff --git a/test/test_vcl.py b/test/test_vcl.py
index 3e10764c1e3..18279e9f226 100644
--- a/test/test_vcl.py
+++ b/test/test_vcl.py
@@ -7,7 +7,7 @@ import subprocess
import signal
from framework import VppTestCase, VppTestRunner, running_extended_tests, \
Worker
-from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath, DpoProto
+from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath, FibPathProto
class VCLAppWorker(Worker):
@@ -152,14 +152,12 @@ class VCLTestCase(VppTestCase):
# Add inter-table routes
ip_t01 = VppIpRoute(self, self.loop1.local_ip6, 128,
[VppRoutePath("::0", 0xffffffff,
- nh_table_id=2,
- proto=DpoProto.DPO_PROTO_IP6)],
- table_id=1, is_ip6=1)
+ nh_table_id=2)],
+ table_id=1)
ip_t10 = VppIpRoute(self, self.loop0.local_ip6, 128,
[VppRoutePath("::0", 0xffffffff,
- nh_table_id=1,
- proto=DpoProto.DPO_PROTO_IP6)],
- table_id=2, is_ip6=1)
+ nh_table_id=1)],
+ table_id=2)
ip_t01.add_vpp_config()
ip_t10.add_vpp_config()
self.logger.debug(self.vapi.cli("show interface addr"))
diff --git a/test/test_vxlan.py b/test/test_vxlan.py
index aa069dc6e7b..c74efe7d062 100644
--- a/test/test_vxlan.py
+++ b/test/test_vxlan.py
@@ -10,6 +10,8 @@ from scapy.layers.l2 import Ether, Raw
from scapy.layers.inet import IP, UDP
from scapy.layers.vxlan import VXLAN
from scapy.utils import atol
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
class TestVxlan(BridgeDomain, VppTestCase):
@@ -84,17 +86,20 @@ class TestVxlan(BridgeDomain, VppTestCase):
# Create 10 ucast vxlan tunnels under bd
ip_range_start = 10
ip_range_end = ip_range_start + n_ucast_tunnels
- next_hop_address = cls.pg0.remote_ip4n
- for dest_ip4n in ip4n_range(next_hop_address, ip_range_start,
- ip_range_end):
+ next_hop_address = cls.pg0.remote_ip4
+ for dest_ip4 in ip4_range(next_hop_address, ip_range_start,
+ ip_range_end):
# add host route so dest_ip4n will not be resolved
- cls.vapi.ip_add_del_route(dst_address=dest_ip4n,
- dst_address_length=32,
- next_hop_address=next_hop_address)
+ rip = VppIpRoute(cls, dest_ip4, 32,
+ [VppRoutePath(next_hop_address,
+ INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
+ dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
+
r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
dst_address=dest_ip4n, vni=vni)
- cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
- bd_id=vni)
+ cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index, bd_id=vni)
@classmethod
def add_del_shared_mcast_dst_load(cls, is_add):
diff --git a/test/test_vxlan6.py b/test/test_vxlan6.py
index 4053fadff8b..1e382e349c7 100644
--- a/test/test_vxlan6.py
+++ b/test/test_vxlan6.py
@@ -9,6 +9,8 @@ from scapy.layers.l2 import Ether
from scapy.layers.inet6 import IPv6, UDP
from scapy.layers.vxlan import VXLAN
from scapy.utils import atol
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
class TestVxlan6(BridgeDomain, VppTestCase):
@@ -85,18 +87,17 @@ class TestVxlan6(BridgeDomain, VppTestCase):
# Create 10 ucast vxlan tunnels under bd
start = 10
end = start + n_ucast_tunnels
- next_hop = cls.pg0.remote_ip6n
for dest_ip6 in cls.ip_range(start, end):
dest_ip6n = socket.inet_pton(socket.AF_INET6, dest_ip6)
# add host route so dest ip will not be resolved
- cls.vapi.ip_add_del_route(dst_address=dest_ip6n,
- dst_address_length=128,
- next_hop_address=next_hop, is_ipv6=1)
+ rip = VppIpRoute(cls, dest_ip6, 128,
+ [VppRoutePath(cls.pg0.remote_ip6, INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip6n,
dst_address=dest_ip6n, is_ipv6=1,
vni=vni)
- cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
- bd_id=vni)
+ cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index, bd_id=vni)
@classmethod
def add_mcast_tunnels_load(cls):
diff --git a/test/test_vxlan_gbp.py b/test/test_vxlan_gbp.py
index b4eb069cc89..9abff19bb79 100644
--- a/test/test_vxlan_gbp.py
+++ b/test/test_vxlan_gbp.py
@@ -11,6 +11,8 @@ from scapy.layers.l2 import Ether, Raw
from scapy.layers.inet import IP, UDP
from scapy.layers.vxlan import VXLAN
from scapy.utils import atol
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
class TestVxlanGbp(VppTestCase):
@@ -90,18 +92,19 @@ class TestVxlanGbp(VppTestCase):
# Create 2 ucast vxlan tunnels under bd
ip_range_start = 10
ip_range_end = ip_range_start + n_ucast_tunnels
- next_hop_address = cls.pg0.remote_ip4n
+ next_hop_address = cls.pg0.remote_ip4
for dest_ip4 in ip4_range(cls.pg0.remote_ip4,
ip_range_start,
ip_range_end):
# add host route so dest_ip4n will not be resolved
- vip = VppIpAddress(dest_ip4)
- cls.vapi.ip_add_del_route(dst_address=vip.bytes,
- dst_address_length=32,
- next_hop_address=next_hop_address)
+ rip = VppIpRoute(cls, dest_ip4, 32,
+ [VppRoutePath(next_hop_address,
+ INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
r = cls.vapi.vxlan_gbp_tunnel_add_del(
- VppIpAddress(cls.pg0.local_ip4).encode(),
- vip.encode(),
+ cls.pg0.local_ip4,
+ dest_ip4,
vni=vni)
cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
bd_id=vni)
diff --git a/test/test_vxlan_gpe.py b/test/test_vxlan_gpe.py
index 7ee1225dd8c..f13a5287172 100644
--- a/test/test_vxlan_gpe.py
+++ b/test/test_vxlan_gpe.py
@@ -10,6 +10,8 @@ from scapy.layers.l2 import Ether, Raw
from scapy.layers.inet import IP, UDP
from scapy.layers.vxlan import VXLAN
from scapy.utils import atol
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
@unittest.skipUnless(running_extended_tests, "part of extended tests")
@@ -80,16 +82,20 @@ class TestVxlanGpe(BridgeDomain, VppTestCase):
@classmethod
def create_vxlan_gpe_flood_test_bd(cls, vni, n_ucast_tunnels):
- # Create 10 ucast vxlan_gpe tunnels under bd
+ # Create 10 ucast vxlan tunnels under bd
ip_range_start = 10
ip_range_end = ip_range_start + n_ucast_tunnels
- next_hop_address = cls.pg0.remote_ip4n
- for dest_ip4n in ip4n_range(next_hop_address, ip_range_start,
- ip_range_end):
+ next_hop_address = cls.pg0.remote_ip4
+ for dest_ip4 in ip4_range(next_hop_address, ip_range_start,
+ ip_range_end):
# add host route so dest_ip4n will not be resolved
- cls.vapi.ip_add_del_route(dst_address=dest_ip4n,
- dst_address_length=32,
- next_hop_address=next_hop_address)
+ rip = VppIpRoute(cls, dest_ip4, 32,
+ [VppRoutePath(next_hop_address,
+ INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
+ dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
+
r = cls.vapi.vxlan_gpe_add_del_tunnel(
src_addr=cls.pg0.local_ip4n,
dst_addr=dest_ip4n,
diff --git a/test/vpp_bier.py b/test/vpp_bier.py
index 8e27f25d10f..6e087a8ee0b 100644
--- a/test/vpp_bier.py
+++ b/test/vpp_bier.py
@@ -38,10 +38,10 @@ def find_bier_table(test, bti):
def find_bier_route(test, bti, bp):
routes = test.vapi.bier_route_dump(bti)
for r in routes:
- if bti.set_id == r.br_tbl_id.bt_set \
- and bti.sub_domain_id == r.br_tbl_id.bt_sub_domain \
- and bti.hdr_len_id == r.br_tbl_id.bt_hdr_len_id \
- and bp == r.br_bp:
+ if bti.set_id == r.br_route.br_tbl_id.bt_set \
+ and bti.sub_domain_id == r.br_route.br_tbl_id.bt_sub_domain \
+ and bti.hdr_len_id == r.br_route.br_tbl_id.bt_hdr_len_id \
+ and bp == r.br_route.br_bp:
return True
return False
@@ -116,39 +116,15 @@ class VppBierRoute(VppObject):
self.tbl_id = tbl_id
self.bp = bp
self.paths = paths
-
- def encode_path(self, p):
- lstack = []
- for l in p.nh_labels:
- if type(l) == VppMplsLabel:
- lstack.append(l.encode())
- else:
- lstack.append({'label': l, 'ttl': 255})
- n_labels = len(lstack)
- while (len(lstack) < 16):
- lstack.append({})
- return {'next_hop': p.nh_addr,
- 'weight': 1,
- 'afi': p.proto,
- 'sw_if_index': 0xffffffff,
- 'preference': 0,
- 'table_id': p.nh_table_id,
- 'next_hop_id': p.next_hop_id,
- 'is_udp_encap': p.is_udp_encap,
- 'n_labels': n_labels,
- 'label_stack': lstack}
-
- def encode_paths(self):
- br_paths = []
- for p in self.paths:
- br_paths.append(self.encode_path(p))
- return br_paths
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
def add_vpp_config(self):
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- self.encode_paths(),
+ self.encoded_paths,
is_add=1)
self._test.registry.register(self, self._test.logger)
@@ -156,32 +132,37 @@ class VppBierRoute(VppObject):
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- self.encode_paths(),
+ self.encoded_paths,
is_add=0)
def update_paths(self, paths):
self.paths = paths
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- self.encode_paths(),
+ self.encoded_paths,
is_replace=1)
def add_path(self, path):
+ self.encoded_paths.append(path.encode())
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- [self.encode_path(path)],
+ [path.encode()],
is_add=1,
is_replace=0)
self.paths.append(path)
self._test.registry.register(self, self._test.logger)
def remove_path(self, path):
+ self.encoded_paths.remove(path.encode())
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- [self.encode_path(path)],
+ [path.encode()],
is_add=0,
is_replace=0)
self.paths.remove(path)
diff --git a/test/vpp_interface.py b/test/vpp_interface.py
index 36118192915..7b9de828e6c 100644
--- a/test/vpp_interface.py
+++ b/test/vpp_interface.py
@@ -7,6 +7,12 @@ from six import moves
from util import Host, mk_ll_addr
from vpp_papi import mac_ntop
+from ipaddress import IPv4Network
+
+try:
+ text_type = unicode
+except NameError:
+ text_type = str
@six.add_metaclass(abc.ABCMeta)
@@ -406,9 +412,10 @@ class VppInterface(object):
def is_ip4_entry_in_fib_dump(self, dump):
for i in dump:
- if i.address == self.local_ip4n and \
- i.address_length == self.local_ip4_prefix_len and \
- i.table_id == self.ip4_table_id:
+ n = IPv4Network(text_type("%s/%d" % (self.local_ip4,
+ self.local_ip4_prefix_len)))
+ if i.route.prefix == n and \
+ i.route.table_id == self.ip4_table_id:
return True
return False
diff --git a/test/vpp_ip.py b/test/vpp_ip.py
index 8b7ea222a67..5396e8457e2 100644
--- a/test/vpp_ip.py
+++ b/test/vpp_ip.py
@@ -34,9 +34,9 @@ class VppIpAddressUnion():
def encode(self):
if self.version == 6:
- return {'ip6': self.ip_addr.packed}
+ return {'ip6': self.ip_addr}
else:
- return {'ip4': self.ip_addr.packed}
+ return {'ip4': self.ip_addr}
@property
def version(self):
@@ -69,6 +69,9 @@ class VppIpAddressUnion():
self, other)
return NotImplemented
+ def __str__(self):
+ return str(self.ip_addr)
+
class VppIpAddress():
def __init__(self, addr):
@@ -153,11 +156,20 @@ class VppIpPrefix():
self.addr = VppIpAddress(addr)
self.len = len
+ def __eq__(self, other):
+ if self.address == other.address and self.len == other.len:
+ return True
+ return False
+
def encode(self):
return {'address': self.addr.encode(),
'address_length': self.len}
@property
+ def version(self):
+ return self.addr.version
+
+ @property
def address(self):
return self.addr.address
@@ -191,12 +203,12 @@ class VppIpPrefix():
class VppIpMPrefix():
- def __init__(self, saddr, gaddr, len):
+ def __init__(self, saddr, gaddr, glen):
self.saddr = saddr
self.gaddr = gaddr
- self.len = len
- self.ip_saddr = ip_address(text_type(self.saddr))
- self.ip_gaddr = ip_address(text_type(self.gaddr))
+ self.glen = glen
+ self.ip_saddr = VppIpAddressUnion(text_type(self.saddr))
+ self.ip_gaddr = VppIpAddressUnion(text_type(self.gaddr))
if self.ip_saddr.version != self.ip_gaddr.version:
raise ValueError('Source and group addresses must be of the '
'same address family.')
@@ -205,15 +217,58 @@ class VppIpMPrefix():
if 6 == self.ip_saddr.version:
prefix = {
'af': VppEnum.vl_api_address_family_t.ADDRESS_IP6,
- 'grp_address': {'ip6': self.ip_gaddr.packed},
- 'src_address': {'ip6': self.ip_saddr.packed},
- 'grp_address_length': self.len,
+ 'grp_address': {
+ 'ip6': self.gaddr
+ },
+ 'src_address': {
+ 'ip6': self.saddr
+ },
+ 'grp_address_length': self.glen,
}
else:
prefix = {
'af': VppEnum.vl_api_address_family_t.ADDRESS_IP4,
- 'grp_address': {'ip4': self.ip_gaddr.packed},
- 'src_address': {'ip4': self.ip_saddr.packed},
- 'grp_address_length': self.len,
+ 'grp_address': {
+ 'ip4': self.gaddr
+ },
+ 'src_address': {
+ 'ip4': self.saddr
+ },
+ 'grp_address_length': self.glen,
}
return prefix
+
+ @property
+ def length(self):
+ return self.glen
+
+ @property
+ def version(self):
+ return self.ip_gaddr.version
+
+ def __str__(self):
+ return "(%s,%s)/%d" % (self.saddr, self.gaddr, self.glen)
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return (self.glen == other.glen and
+ self.ip_saddr == other.ip_gaddr and
+ self.ip_saddr == other.ip_saddr)
+ elif (hasattr(other, "grp_address_length") and
+ hasattr(other, "grp_address") and
+ hasattr(other, "src_address")):
+ # vl_api_mprefix_t
+ if 4 == self.ip_saddr.version:
+ if self.glen == other.grp_address_length and \
+ self.gaddr == str(other.grp_address.ip4) and \
+ self.saddr == str(other.src_address.ip4):
+ return True
+ return False
+ else:
+ return (self.glen == other.grp_address_length and
+ self.gaddr == other.grp_address.ip6 and
+ self.saddr == other.src_address.ip6)
+ else:
+ raise Exception("Comparing VppIpPrefix:%s with unknown type: %s" %
+ (self, other))
+ return False
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py
index db5f4b636bf..5175de7dd0f 100644
--- a/test/vpp_ip_route.py
+++ b/test/vpp_ip_route.py
@@ -6,12 +6,19 @@
from vpp_object import VppObject
from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
-from vpp_ip import DpoProto, VppIpPrefix
+from vpp_ip import DpoProto, VppIpPrefix, INVALID_INDEX, VppIpAddressUnion, \
+ VppIpMPrefix
+from ipaddress import ip_address, IPv4Network, IPv6Network
# from vnet/vnet/mpls/mpls_types.h
MPLS_IETF_MAX_LABEL = 0xfffff
MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1
+try:
+ text_type = unicode
+except NameError:
+ text_type = str
+
class MRouteItfFlags:
MFIB_ITF_FLAG_NONE = 0
@@ -30,6 +37,35 @@ class MRouteEntryFlags:
MFIB_ENTRY_FLAG_INHERIT_ACCEPT = 8
+class FibPathProto:
+ FIB_PATH_NH_PROTO_IP4 = 0
+ FIB_PATH_NH_PROTO_IP6 = 1
+ FIB_PATH_NH_PROTO_MPLS = 2
+ FIB_PATH_NH_PROTO_ETHERNET = 3
+ FIB_PATH_NH_PROTO_BIER = 4
+ FIB_PATH_NH_PROTO_NSH = 5
+
+
+class FibPathType:
+ FIB_PATH_TYPE_NORMAL = 0
+ FIB_PATH_TYPE_LOCAL = 1
+ FIB_PATH_TYPE_DROP = 2
+ FIB_PATH_TYPE_UDP_ENCAP = 3
+ FIB_PATH_TYPE_BIER_IMP = 4
+ FIB_PATH_TYPE_ICMP_UNREACH = 5
+ FIB_PATH_TYPE_ICMP_PROHIBIT = 6
+ FIB_PATH_TYPE_SOURCE_LOOKUP = 7
+ FIB_PATH_TYPE_DVR = 8
+ FIB_PATH_TYPE_INTERFACE_RX = 9
+ FIB_PATH_TYPE_CLASSIFY = 10
+
+
+class FibPathFlags:
+ FIB_PATH_FLAG_NONE = 0
+ FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED = 1
+ FIB_PATH_FLAG_RESOLVE_VIA_HOST = 2
+
+
class MplsLspMode:
PIPE = 0
UNIFORM = 1
@@ -42,73 +78,80 @@ def ip_to_dpo_proto(addr):
return DpoProto.DPO_PROTO_IP4
-def find_route(test, ip_addr, len, table_id=0, inet=AF_INET):
- if inet == AF_INET:
- s = 4
- routes = test.vapi.ip_fib_dump()
+def address_proto(ip_addr):
+ if ip_addr.ip_addr.version is 4:
+ return FibPathProto.FIB_PATH_NH_PROTO_IP4
else:
- s = 16
- routes = test.vapi.ip6_fib_dump()
+ return FibPathProto.FIB_PATH_NH_PROTO_IP6
+
+
+def find_route(test, addr, len, table_id=0):
+ ip_addr = ip_address(text_type(addr))
+
+ if 4 is ip_addr.version:
+ routes = test.vapi.ip_route_dump(table_id, False)
+ prefix = IPv4Network("%s/%d" % (text_type(addr), len), strict=False)
+ else:
+ routes = test.vapi.ip_route_dump(table_id, True)
+ prefix = IPv6Network("%s/%d" % (text_type(addr), len), strict=False)
- route_addr = inet_pton(inet, ip_addr)
for e in routes:
- if route_addr == e.address[:s] \
- and len == e.address_length \
- and table_id == e.table_id:
+ if table_id == e.route.table_id \
+ and prefix == e.route.prefix:
return True
return False
def find_mroute(test, grp_addr, src_addr, grp_addr_len,
- table_id=0, inet=AF_INET):
- if inet == AF_INET:
- s = 4
- routes = test.vapi.ip_mfib_dump()
+ table_id=0):
+ ip_mprefix = VppIpMPrefix(text_type(src_addr),
+ text_type(grp_addr),
+ grp_addr_len)
+
+ if 4 is ip_mprefix.version:
+ routes = test.vapi.ip_mroute_dump(table_id, False)
else:
- s = 16
- routes = test.vapi.ip6_mfib_dump()
- gaddr = inet_pton(inet, grp_addr)
- saddr = inet_pton(inet, src_addr)
+ routes = test.vapi.ip_mroute_dump(table_id, True)
+
for e in routes:
- if gaddr == e.grp_address[:s] \
- and grp_addr_len == e.address_length \
- and saddr == e.src_address[:s] \
- and table_id == e.table_id:
+ if table_id == e.route.table_id and ip_mprefix == e.route.prefix:
return True
return False
def find_mpls_route(test, table_id, label, eos_bit, paths=None):
- dump = test.vapi.mpls_fib_dump()
+ dump = test.vapi.mpls_route_dump(table_id)
for e in dump:
- if label == e.label \
- and eos_bit == e.eos_bit \
- and table_id == e.table_id:
+ if label == e.mr_route.mr_label \
+ and eos_bit == e.mr_route.mr_eos \
+ and table_id == e.mr_route.mr_table_id:
if not paths:
return True
else:
- if (len(paths) != len(e.path)):
+ if (len(paths) != len(e.mr_route.mr_paths)):
return False
for i in range(len(paths)):
- if (paths[i] != e.path[i]):
+ if (paths[i] != e.mr_route.mr_paths[i]):
return False
return True
return False
def fib_interface_ip_prefix(test, address, length, sw_if_index):
- vp = VppIpPrefix(address, length)
- addrs = test.vapi.ip_address_dump(sw_if_index, is_ipv6=vp.is_ip6)
+ ip_addr = ip_address(text_type(address))
- if vp.is_ip6:
- n = 16
+ if 4 is ip_addr.version:
+ addrs = test.vapi.ip_address_dump(sw_if_index)
+ prefix = IPv4Network("%s/%d" % (text_type(address), length),
+ strict=False)
else:
- n = 4
+ addrs = test.vapi.ip_address_dump(sw_if_index, is_ipv6=1)
+ prefix = IPv6Network("%s/%d" % (text_type(address), length),
+ strict=False)
for a in addrs:
- if a.prefix_length == length and \
- a.sw_if_index == sw_if_index and \
- a.ip[:n] == vp.bytes:
+ if a.sw_if_index == sw_if_index and \
+ a.prefix == prefix:
return True
return False
@@ -140,8 +183,7 @@ class VppIpTable(VppObject):
return find_route(self._test,
"::" if self.is_ip6 else "0.0.0.0",
0,
- self.table_id,
- inet=AF_INET6 if self.is_ip6 == 1 else AF_INET)
+ self.table_id)
def object_id(self):
return ("table-%s-%d" %
@@ -244,6 +286,37 @@ class VppMplsLabel(object):
return not (self == other)
+class VppFibPathNextHop(object):
+ def __init__(self, addr,
+ via_label=MPLS_LABEL_INVALID,
+ next_hop_id=INVALID_INDEX):
+ self.addr = VppIpAddressUnion(addr)
+ self.via_label = via_label
+ self.obj_id = next_hop_id
+
+ def encode(self):
+ if self.via_label is not MPLS_LABEL_INVALID:
+ return {'via_label': self.via_label}
+ if self.obj_id is not INVALID_INDEX:
+ return {'obj_id': self.obj_id}
+ else:
+ return {'address': self.addr.encode()}
+
+ def proto(self):
+ if self.via_label is MPLS_LABEL_INVALID:
+ return address_proto(self.addr)
+ else:
+ return FibPathProto.FIB_PATH_NH_PROTO_MPLS
+
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ # try the other instance's __eq__.
+ return NotImplemented
+ return (self.addr == other.addr and
+ self.via_label == other.via_label and
+ self.obj_id == other.obj_id)
+
+
class VppRoutePath(object):
def __init__(
@@ -254,40 +327,26 @@ class VppRoutePath(object):
labels=[],
nh_via_label=MPLS_LABEL_INVALID,
rpf_id=0,
- is_interface_rx=0,
- is_resolve_host=0,
- is_resolve_attached=0,
- is_source_lookup=0,
- is_udp_encap=0,
- is_dvr=0,
- next_hop_id=0xffffffff,
- proto=DpoProto.DPO_PROTO_IP4):
- self.proto = proto
+ next_hop_id=INVALID_INDEX,
+ proto=None,
+ flags=FibPathFlags.FIB_PATH_FLAG_NONE,
+ type=FibPathType.FIB_PATH_TYPE_NORMAL):
self.nh_itf = nh_sw_if_index
self.nh_table_id = nh_table_id
- self.nh_via_label = nh_via_label
self.nh_labels = labels
self.weight = 1
self.rpf_id = rpf_id
- if self.proto is DpoProto.DPO_PROTO_IP6:
- self.nh_addr = inet_pton(AF_INET6, nh_addr)
- elif self.proto is DpoProto.DPO_PROTO_IP4:
- self.nh_addr = inet_pton(AF_INET, nh_addr)
+ self.proto = proto
+ self.flags = flags
+ self.type = type
+ self.nh = VppFibPathNextHop(nh_addr, nh_via_label, next_hop_id)
+ if proto is None:
+ self.proto = self.nh.proto()
else:
- self.nh_addr = inet_pton(AF_INET6, "::")
- self.is_resolve_host = is_resolve_host
- self.is_resolve_attached = is_resolve_attached
- self.is_interface_rx = is_interface_rx
- self.is_source_lookup = is_source_lookup
- self.is_rpf_id = 0
- if rpf_id != 0:
- self.is_rpf_id = 1
- self.nh_itf = rpf_id
- self.is_udp_encap = is_udp_encap
+ self.proto = proto
self.next_hop_id = next_hop_id
- self.is_dvr = is_dvr
- def encode_labels(self, pad_labels=False):
+ def encode_labels(self):
lstack = []
for l in self.nh_labels:
if type(l) == VppMplsLabel:
@@ -295,26 +354,28 @@ class VppRoutePath(object):
else:
lstack.append({'label': l,
'ttl': 255})
- if (pad_labels):
- while (len(lstack) < 16):
- lstack.append({})
+ while (len(lstack) < 16):
+ lstack.append({})
+
return lstack
- def encode(self, pad_labels=False):
- return {'next_hop': self.nh_addr,
- 'weight': 1,
+ def encode(self):
+ return {'weight': 1,
'preference': 0,
'table_id': self.nh_table_id,
+ 'nh': self.nh.encode(),
'next_hop_id': self.next_hop_id,
'sw_if_index': self.nh_itf,
- 'afi': self.proto,
- 'is_udp_encap': self.is_udp_encap,
+ 'rpf_id': self.rpf_id,
+ 'proto': self.proto,
+ 'type': self.type,
+ 'flags': self.flags,
'n_labels': len(self.nh_labels),
- 'label_stack': self.encode_labels(pad_labels)}
+ 'label_stack': self.encode_labels()}
def __eq__(self, other):
if isinstance(other, self.__class__):
- return self.nh_addr == other.nh_addr
+ return self.nh == other.nh
elif hasattr(other, 'sw_if_index'):
# vl_api_fib_path_t
if (len(self.nh_labels) != other.n_labels):
@@ -334,16 +395,24 @@ class VppMRoutePath(VppRoutePath):
def __init__(self, nh_sw_if_index, flags,
nh=None,
- proto=DpoProto.DPO_PROTO_IP4,
- bier_imp=0):
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP4,
+ type=FibPathType.FIB_PATH_TYPE_NORMAL,
+ bier_imp=INVALID_INDEX):
if not nh:
- nh = "::" if proto is DpoProto.DPO_PROTO_IP6 else "0.0.0.0"
+ nh = "::" if proto is FibPathProto.FIB_PATH_NH_PROTO_IP6 \
+ else "0.0.0.0"
super(VppMRoutePath, self).__init__(nh,
nh_sw_if_index,
- proto=proto)
+ proto=proto,
+ type=type,
+ next_hop_id=bier_imp)
self.nh_i_flags = flags
self.bier_imp = bier_imp
+ def encode(self):
+ return {'path': super(VppMRoutePath, self).encode(),
+ 'itf_flags': self.nh_i_flags}
+
class VppIpRoute(VppObject):
"""
@@ -351,107 +420,72 @@ class VppIpRoute(VppObject):
"""
def __init__(self, test, dest_addr,
- dest_addr_len, paths, table_id=0, is_ip6=0, is_local=0,
- is_unreach=0, is_prohibit=0, is_drop=0):
+ dest_addr_len, paths, table_id=0, register=True):
self._test = test
self.paths = paths
- self.dest_addr_len = dest_addr_len
self.table_id = table_id
- self.is_ip6 = is_ip6
- self.is_local = is_local
- self.is_unreach = is_unreach
- self.is_prohibit = is_prohibit
- self.is_drop = is_drop
- self.dest_addr_p = dest_addr
- if is_ip6:
- self.dest_addr = inet_pton(AF_INET6, dest_addr)
- else:
- self.dest_addr = inet_pton(AF_INET, dest_addr)
+ self.prefix = VppIpPrefix(dest_addr, dest_addr_len)
+ self.register = register
+
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
+
+ def __eq__(self, other):
+ if self.table_id == other.table_id and \
+ self.prefix == other.prefix:
+ return True
+ return False
- def modify(self, paths, is_local=0,
- is_unreach=0, is_prohibit=0):
+ def modify(self, paths):
self.paths = paths
- self.is_local = is_local
- self.is_unreach = is_unreach
- self.is_prohibit = is_prohibit
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
+
+ self._test.vapi.ip_route_add_del(route={'table_id': self.table_id,
+ 'prefix': self.prefix.encode(),
+ 'n_paths': len(
+ self.encoded_paths),
+ 'paths': self.encoded_paths,
+ },
+ is_add=1,
+ is_multipath=0)
def add_vpp_config(self):
- if self.is_unreach or self.is_prohibit or self.is_drop:
- r = self._test.vapi.ip_add_del_route(
- dst_address=self.dest_addr,
- dst_address_length=self.dest_addr_len,
- next_hop_address=inet_pton(
- AF_INET6, "::"),
- next_hop_sw_if_index=0xffffffff,
- table_id=self.table_id,
- is_drop=self.is_drop,
- is_unreach=self.is_unreach,
- is_prohibit=self.is_prohibit,
- is_ipv6=self.is_ip6,
- is_local=self.is_local)
- else:
- for path in self.paths:
- lstack = path.encode_labels()
-
- r = self._test.vapi.ip_add_del_route(
- dst_address=self.dest_addr,
- dst_address_length=self.dest_addr_len,
- next_hop_address=path.nh_addr,
- next_hop_sw_if_index=path.nh_itf, table_id=self.table_id,
- next_hop_table_id=path.nh_table_id,
- next_hop_n_out_labels=len(lstack),
- next_hop_out_label_stack=lstack,
- next_hop_via_label=path.nh_via_label,
- next_hop_id=path.next_hop_id,
- is_resolve_host=path.is_resolve_host,
- is_resolve_attached=path.is_resolve_attached,
- is_ipv6=self.is_ip6, is_local=self.is_local,
- is_multipath=1 if len(self.paths) > 1 else 0,
- is_dvr=path.is_dvr, is_udp_encap=path.is_udp_encap,
- is_source_lookup=path.is_source_lookup)
+ r = self._test.vapi.ip_route_add_del(
+ route={'table_id': self.table_id,
+ 'prefix': self.prefix.encode(),
+ 'n_paths': len(self.encoded_paths),
+ 'paths': self.encoded_paths,
+ },
+ is_add=1,
+ is_multipath=0)
self.stats_index = r.stats_index
- self._test.registry.register(self, self._test.logger)
+ if self.register:
+ self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- if self.is_unreach or self.is_prohibit or self.is_drop:
- self._test.vapi.ip_add_del_route(
- dst_address=self.dest_addr,
- dst_address_length=self.dest_addr_len,
- next_hop_address=inet_pton(
- AF_INET6, "::"),
- next_hop_sw_if_index=0xffffffff,
- table_id=self.table_id, is_add=0,
- is_unreach=self.is_unreach,
- is_prohibit=self.is_prohibit,
- is_ipv6=self.is_ip6,
- is_local=self.is_local)
- else:
- for path in self.paths:
- self._test.vapi.ip_add_del_route(
- dst_address=self.dest_addr,
- dst_address_length=self.dest_addr_len,
- next_hop_address=path.nh_addr,
- next_hop_sw_if_index=path.nh_itf,
- table_id=self.table_id,
- next_hop_table_id=path.nh_table_id,
- next_hop_via_label=path.nh_via_label,
- next_hop_id=path.next_hop_id,
- is_add=0, is_ipv6=self.is_ip6,
- is_dvr=path.is_dvr,
- is_udp_encap=path.is_udp_encap)
+ self._test.vapi.ip_route_add_del(route={'table_id': self.table_id,
+ 'prefix': self.prefix.encode(),
+ 'n_paths': len(
+ self.encoded_paths),
+ 'paths': self.encoded_paths,
+ },
+ is_add=0,
+ is_multipath=0)
def query_vpp_config(self):
return find_route(self._test,
- self.dest_addr_p,
- self.dest_addr_len,
- self.table_id,
- inet=AF_INET6 if self.is_ip6 == 1 else AF_INET)
+ self.prefix.address,
+ self.prefix.len,
+ self.table_id)
def object_id(self):
return ("%d:%s/%d"
% (self.table_id,
- self.dest_addr_p,
- self.dest_addr_len))
+ self.prefix.address,
+ self.prefix.len))
def get_stats_to(self):
c = self._test.statistics.get_counter("/net/route/to")
@@ -469,120 +503,81 @@ class VppIpMRoute(VppObject):
def __init__(self, test, src_addr, grp_addr,
grp_addr_len, e_flags, paths, table_id=0,
- rpf_id=0, is_ip6=0):
+ rpf_id=0):
self._test = test
self.paths = paths
- self.grp_addr_len = grp_addr_len
self.table_id = table_id
self.e_flags = e_flags
- self.is_ip6 = is_ip6
self.rpf_id = rpf_id
- self.grp_addr_p = grp_addr
- self.src_addr_p = src_addr
- if is_ip6:
- self.grp_addr = inet_pton(AF_INET6, grp_addr)
- self.src_addr = inet_pton(AF_INET6, src_addr)
- else:
- self.grp_addr = inet_pton(AF_INET, grp_addr)
- self.src_addr = inet_pton(AF_INET, src_addr)
+ self.prefix = VppIpMPrefix(src_addr, grp_addr, grp_addr_len)
+ self.encoded_paths = []
+ for path in self.paths:
+ self.encoded_paths.append(path.encode())
def add_vpp_config(self):
- for path in self.paths:
- r = self._test.vapi.ip_mroute_add_del(self.src_addr,
- self.grp_addr,
- self.grp_addr_len,
- self.e_flags,
- path.proto,
- path.nh_itf,
- path.nh_addr,
- path.nh_i_flags,
- bier_imp=path.bier_imp,
- rpf_id=self.rpf_id,
- table_id=self.table_id,
- is_ipv6=self.is_ip6)
- self.stats_index = r.stats_index
+ r = self._test.vapi.ip_mroute_add_del(self.table_id,
+ self.prefix.encode(),
+ self.e_flags,
+ self.rpf_id,
+ self.encoded_paths,
+ is_add=1)
+ self.stats_index = r.stats_index
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- for path in self.paths:
- self._test.vapi.ip_mroute_add_del(self.src_addr,
- self.grp_addr,
- self.grp_addr_len,
- self.e_flags,
- path.proto,
- path.nh_itf,
- path.nh_addr,
- path.nh_i_flags,
- table_id=self.table_id,
- bier_imp=path.bier_imp,
- is_add=0,
- is_ipv6=self.is_ip6)
+ self._test.vapi.ip_mroute_add_del(self.table_id,
+ self.prefix.encode(),
+ self.e_flags,
+ self.rpf_id,
+ self.encoded_paths,
+ is_add=0)
def update_entry_flags(self, flags):
self.e_flags = flags
- self._test.vapi.ip_mroute_add_del(self.src_addr,
- self.grp_addr,
- self.grp_addr_len,
+ self._test.vapi.ip_mroute_add_del(self.table_id,
+ self.prefix.encode(),
self.e_flags,
- 0,
- 0xffffffff,
- "",
- 0,
- table_id=self.table_id,
- is_ipv6=self.is_ip6)
+ self.rpf_id,
+ [],
+ is_add=1)
def update_rpf_id(self, rpf_id):
self.rpf_id = rpf_id
- self._test.vapi.ip_mroute_add_del(self.src_addr,
- self.grp_addr,
- self.grp_addr_len,
+ self._test.vapi.ip_mroute_add_del(self.table_id,
+ self.prefix.encode(),
self.e_flags,
- 0,
- 0xffffffff,
- "",
- 0,
- rpf_id=self.rpf_id,
- table_id=self.table_id,
- is_ipv6=self.is_ip6)
+ self.rpf_id,
+ [],
+ is_add=1)
def update_path_flags(self, itf, flags):
- for path in self.paths:
- if path.nh_itf == itf:
- path.nh_i_flags = flags
- break
- self._test.vapi.ip_mroute_add_del(self.src_addr,
- self.grp_addr,
- self.grp_addr_len,
+ for p in range(len(self.paths)):
+ if self.paths[p].nh_itf == itf:
+ self.paths[p].nh_i_flags = flags
+ self.encoded_paths[p] = self.paths[p].encode()
+ break
+
+ self._test.vapi.ip_mroute_add_del(self.table_id,
+ self.prefix.encode(),
self.e_flags,
- path.proto,
- path.nh_itf,
- path.nh_addr,
- path.nh_i_flags,
- table_id=self.table_id,
- is_ipv6=self.is_ip6)
+ self.rpf_id,
+ [self.encoded_paths[p]],
+ is_add=1,
+ is_multipath=0)
def query_vpp_config(self):
return find_mroute(self._test,
- self.grp_addr_p,
- self.src_addr_p,
- self.grp_addr_len,
- self.table_id,
- inet=AF_INET6 if self.is_ip6 == 1 else AF_INET)
+ self.prefix.gaddr,
+ self.prefix.saddr,
+ self.prefix.length,
+ self.table_id)
def object_id(self):
- if self.is_ip6:
- return ("%d:(%s,%s/%d)"
- % (self.table_id,
- inet_ntop(AF_INET6, self.src_addr),
- inet_ntop(AF_INET6, self.grp_addr),
- self.grp_addr_len))
- else:
- return ("%d:(%s,%s/%d)"
- % (self.table_id,
- inet_ntop(AF_INET, self.src_addr),
- inet_ntop(AF_INET, self.grp_addr),
- self.grp_addr_len))
+ return ("%d:(%s,%s/%d)" % (self.table_id,
+ self.prefix.saddr,
+ self.prefix.gaddr,
+ self.prefix.length))
def get_stats(self):
c = self._test.statistics.get_counter("/net/mroute")
@@ -599,15 +594,7 @@ class VppMFibSignal(object):
def compare(self, signal):
self.test.assertEqual(self.interface, signal.sw_if_index)
self.test.assertEqual(self.route.table_id, signal.table_id)
- self.test.assertEqual(self.route.grp_addr_len,
- signal.grp_address_len)
- for i in range(self.route.grp_addr_len / 8):
- self.test.assertEqual(self.route.grp_addr[i],
- signal.grp_address[i])
- if (self.route.grp_addr_len > 32):
- for i in range(4):
- self.test.assertEqual(self.route.src_addr[i],
- signal.src_address[i])
+ self.test.assertEqual(self.route.prefix, signal.prefix)
class VppMplsIpBind(VppObject):
@@ -620,38 +607,31 @@ class VppMplsIpBind(VppObject):
self._test = test
self.dest_addr_len = dest_addr_len
self.dest_addr = dest_addr
+ self.ip_addr = ip_address(text_type(dest_addr))
self.local_label = local_label
self.table_id = table_id
self.ip_table_id = ip_table_id
- self.is_ip6 = is_ip6
- if is_ip6:
- self.dest_addrn = inet_pton(AF_INET6, dest_addr)
- else:
- self.dest_addrn = inet_pton(AF_INET, dest_addr)
+ self.prefix = VppIpPrefix(dest_addr, dest_addr_len)
def add_vpp_config(self):
self._test.vapi.mpls_ip_bind_unbind(self.local_label,
- self.dest_addrn,
- self.dest_addr_len,
+ self.prefix.encode(),
table_id=self.table_id,
- ip_table_id=self.ip_table_id,
- is_ip4=(self.is_ip6 == 0))
+ ip_table_id=self.ip_table_id)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.mpls_ip_bind_unbind(self.local_label,
- self.dest_addrn,
- self.dest_addr_len,
+ self.prefix.encode(),
table_id=self.table_id,
ip_table_id=self.ip_table_id,
- is_bind=0,
- is_ip4=(self.is_ip6 == 0))
+ is_bind=0)
def query_vpp_config(self):
- dump = self._test.vapi.mpls_fib_dump()
+ dump = self._test.vapi.mpls_route_dump(self.table_id)
for e in dump:
- if self.local_label == e.label \
- and self.table_id == e.table_id:
+ if self.local_label == e.mr_route.mr_label \
+ and self.table_id == e.mr_route.mr_table_id:
return True
return False
@@ -684,10 +664,10 @@ class VppMplsTable(VppObject):
is_add=0)
def query_vpp_config(self):
- # find the default route
- dump = self._test.vapi.mpls_fib_dump()
- if len(dump):
- return True
+ dump = self._test.vapi.mpls_table_dump()
+ for d in dump:
+ if d.mt_table.mt_table_id == self.table_id:
+ return True
return False
def object_id(self):
@@ -700,49 +680,41 @@ class VppMplsRoute(VppObject):
"""
def __init__(self, test, local_label, eos_bit, paths, table_id=0,
- is_multicast=0):
+ is_multicast=0,
+ eos_proto=FibPathProto.FIB_PATH_NH_PROTO_IP4):
self._test = test
self.paths = paths
self.local_label = local_label
self.eos_bit = eos_bit
+ self.eos_proto = eos_proto
self.table_id = table_id
self.is_multicast = is_multicast
def add_vpp_config(self):
- is_multipath = len(self.paths) > 1
+ paths = []
for path in self.paths:
- lstack = path.encode_labels()
-
- r = self._test.vapi.mpls_route_add_del(
- mr_label=self.local_label,
- mr_eos=self.eos_bit,
- mr_next_hop_proto=path.proto,
- mr_next_hop=path.nh_addr,
- mr_next_hop_sw_if_index=path.nh_itf,
- mr_table_id=self.table_id,
- mr_next_hop_table_id=path.nh_table_id,
- mr_next_hop_n_out_labels=len(
- lstack),
- mr_next_hop_out_label_stack=lstack,
- mr_next_hop_via_label=path.nh_via_label,
- mr_is_interface_rx=path.is_interface_rx,
- mr_is_rpf_id=path.is_rpf_id,
- mr_is_multicast=self.is_multicast,
- mr_is_multipath=is_multipath)
+ paths.append(path.encode())
+
+ r = self._test.vapi.mpls_route_add_del(self.table_id,
+ self.local_label,
+ self.eos_bit,
+ self.eos_proto,
+ self.is_multicast,
+ paths, 1, 0)
self.stats_index = r.stats_index
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
+ paths = []
for path in self.paths:
- self._test.vapi.mpls_route_add_del(
- mr_label=self.local_label,
- mr_eos=self.eos_bit,
- mr_next_hop_proto=path.proto,
- mr_next_hop=path.nh_addr,
- mr_next_hop_sw_if_index=path.nh_itf,
- mr_table_id=self.table_id,
- mr_is_rpf_id=path.is_rpf_id,
- mr_is_add=0)
+ paths.append(path.encode())
+
+ self._test.vapi.mpls_route_add_del(self.table_id,
+ self.local_label,
+ self.eos_bit,
+ self.eos_proto,
+ self.is_multicast,
+ paths, 0, 0)
def query_vpp_config(self):
return find_mpls_route(self._test, self.table_id,
diff --git a/test/vpp_memif.py b/test/vpp_memif.py
index 7836dc14a09..7fa45092740 100644
--- a/test/vpp_memif.py
+++ b/test/vpp_memif.py
@@ -65,7 +65,7 @@ class VppSocketFilename(VppObject):
return self._test.vapi.memif_socket_filename_dump()
def object_id(self):
- return "%d" % (self.socket_id)
+ return "socket-filename-%d-%s" % (self.socket_id, self.socket_filename)
class VppMemif(VppObject):
@@ -88,12 +88,26 @@ class VppMemif(VppObject):
self.ip4_addr_len = 24
def add_vpp_config(self):
- rv = self._test.vapi.memif_create(self.role, self.mode, self.rx_queues,
- self.tx_queues, self.if_id,
- self.socket_id, self.secret,
- self.ring_size, self.buffer_size,
- self.hw_addr)
- self.sw_if_index = rv.sw_if_index
+ rv = self._test.vapi.memif_create(
+ role=self.role,
+ mode=self.mode,
+ rx_queues=self.rx_queues,
+ tx_queues=self.tx_queues,
+ id=self.if_id,
+ socket_id=self.socket_id,
+ secret=self.secret,
+ ring_size=self.ring_size,
+ buffer_size=self.buffer_size,
+ hw_addr=self.hw_addr)
+ try:
+ self.sw_if_index = 0
+ except AttributeError:
+ raise AttributeError('self: %s' % self.__dict__)
+ try:
+ self.sw_if_index = rv.sw_if_index
+ except AttributeError:
+ raise AttributeError("%s %s", self, rv)
+
return self.sw_if_index
def admin_up(self):
diff --git a/test/vpp_mpls_tunnel_interface.py b/test/vpp_mpls_tunnel_interface.py
index 12f62fb4b51..598936136ad 100644
--- a/test/vpp_mpls_tunnel_interface.py
+++ b/test/vpp_mpls_tunnel_interface.py
@@ -13,50 +13,31 @@ class VppMPLSTunnelInterface(VppInterface):
self.t_paths = paths
self.is_multicast = is_multicast
self.is_l2 = is_l2
-
- def add_vpp_config(self):
- sw_if_index = 0xffffffff
+ self.encoded_paths = []
for path in self.t_paths:
- lstack = path.encode_labels()
+ self.encoded_paths.append(path.encode())
- reply = self.test.vapi.mpls_tunnel_add_del(
- sw_if_index,
- 1, # IPv4 next-hop
- path.nh_addr,
- path.nh_itf,
- path.nh_table_id,
- path.weight,
- next_hop_via_label=path.nh_via_label,
- next_hop_out_label_stack=lstack,
- next_hop_n_out_labels=len(lstack),
- is_multicast=self.is_multicast,
- l2_only=self.is_l2)
- sw_if_index = reply.sw_if_index
- self.tunnel_index = reply.tunnel_index
- self.set_sw_if_index(sw_if_index)
+ def add_vpp_config(self):
+ reply = self.test.vapi.mpls_tunnel_add_del(
+ 0xffffffff,
+ self.encoded_paths,
+ is_multicast=self.is_multicast,
+ l2_only=self.is_l2)
+ self.set_sw_if_index(reply.sw_if_index)
+ self.tunnel_index = reply.tunnel_index
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- for path in self.t_paths:
- lstack = path.encode_labels()
-
- self.test.vapi.mpls_tunnel_add_del(
- self.sw_if_index,
- 1, # IPv4 next-hop
- path.nh_addr,
- path.nh_itf,
- path.nh_table_id,
- path.weight,
- next_hop_via_label=path.nh_via_label,
- next_hop_out_label_stack=lstack,
- next_hop_n_out_labels=len(lstack),
- is_add=0)
+ reply = self.test.vapi.mpls_tunnel_add_del(
+ self.sw_if_index,
+ self.encoded_paths,
+ is_add=0)
def query_vpp_config(self):
dump = self._test.vapi.mpls_tunnel_dump()
for t in dump:
- if self.sw_if_index == t.mt_sw_if_index and \
- self.tunnel_index == t.mt_tunnel_index:
+ if self.sw_if_index == t.mt_tunnel.mt_sw_if_index and \
+ self.tunnel_index == t.mt_tunnel.mt_tunnel_index:
return True
return False
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 6a6fb45529e..038a3718dde 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -67,6 +67,7 @@ defaultmapping = {
'ip_neighbor_add_del': {'is_add': 1, },
'ip_punt_police': {'is_add': 1, },
'ip_punt_redirect': {'is_add': 1, },
+ 'ip_route_add_del': {'is_add': 1, },
'ip_table_add_del': {'is_add': 1, },
'ip_unnumbered_dump': {'sw_if_index': 4294967295, },
'ipsec_interface_add_del_spd': {'is_add': 1, },
@@ -506,6 +507,37 @@ class VppPapiProvider(object):
return self.api(self.papi.create_loopback,
{'mac_address': mac})
+ def ip_table_add_del(self,
+ table_id,
+ is_add=1,
+ is_ipv6=0):
+ """
+
+ :param table_id
+ :param is_add: (Default value = 1)
+ :param is_ipv6: (Default value = 0)
+
+ """
+
+ return self.api(
+ self.papi.ip_table_add_del,
+ {'table':
+ {
+ 'table_id': table_id,
+ 'is_ip6': is_ipv6
+ },
+ 'is_add': is_add})
+
+ def ip_table_dump(self):
+ return self.api(self.papi.ip_table_dump, {})
+
+ def ip_route_dump(self, table_id, is_ip6=False):
+ return self.api(self.papi.ip_route_dump,
+ {'table': {
+ 'table_id': table_id,
+ 'is_ip6': is_ip6
+ }})
+
def ip_neighbor_add_del(self,
sw_if_index,
mac_address,
@@ -631,6 +663,26 @@ class VppPapiProvider(object):
}
})
+ def udp_encap_del(self, id):
+ return self.api(self.papi.udp_encap_del, {'id': id})
+
+ def udp_encap_dump(self):
+ return self.api(self.papi.udp_encap_dump, {})
+
+ def want_udp_encap_stats(self, enable=1):
+ return self.api(self.papi.want_udp_encap_stats,
+ {'enable': enable,
+ 'pid': os.getpid()})
+
+ def mpls_route_dump(self, table_id):
+ return self.api(self.papi.mpls_route_dump,
+ {'table': {
+ 'mt_table_id': table_id
+ }})
+
+ def mpls_table_dump(self):
+ return self.api(self.papi.mpls_table_dump, {})
+
def mpls_table_add_del(
self,
table_id,
@@ -644,17 +696,43 @@ class VppPapiProvider(object):
return self.api(
self.papi.mpls_table_add_del,
- {'mt_table_id': table_id,
+ {'mt_table':
+ {
+ 'mt_table_id': table_id,
+ },
'mt_is_add': is_add})
+ def mpls_route_add_del(self,
+ table_id,
+ label,
+ eos,
+ eos_proto,
+ is_multicast,
+ paths,
+ is_add,
+ is_multipath):
+ """ MPLS Route add/del """
+ return self.api(
+ self.papi.mpls_route_add_del,
+ {'mr_route':
+ {
+ 'mr_table_id': table_id,
+ 'mr_label': label,
+ 'mr_eos': eos,
+ 'mr_eos_proto': eos_proto,
+ 'mr_is_multicast': is_multicast,
+ 'mr_n_paths': len(paths),
+ 'mr_paths': paths,
+ },
+ 'mr_is_add': is_add,
+ 'mr_is_multipath': is_multipath})
+
def mpls_ip_bind_unbind(
self,
label,
- dst_address,
- dst_address_length,
+ prefix,
table_id=0,
ip_table_id=0,
- is_ip4=1,
is_bind=1):
"""
"""
@@ -664,60 +742,28 @@ class VppPapiProvider(object):
'mb_label': label,
'mb_ip_table_id': ip_table_id,
'mb_is_bind': is_bind,
- 'mb_is_ip4': is_ip4,
- 'mb_address_length': dst_address_length,
- 'mb_address': dst_address})
+ 'mb_prefix': prefix})
def mpls_tunnel_add_del(
self,
tun_sw_if_index,
- next_hop_proto_is_ip4,
- next_hop_address,
- next_hop_sw_if_index=0xFFFFFFFF,
- next_hop_table_id=0,
- next_hop_weight=1,
- next_hop_n_out_labels=0,
- next_hop_out_label_stack=[],
- next_hop_via_label=MPLS_LABEL_INVALID,
+ paths,
is_add=1,
l2_only=0,
is_multicast=0):
"""
-
- :param dst_address_length:
- :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
- :param dst_address:
- :param next_hop_address:
- :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
- :param vrf_id: (Default value = 0)
- :param lookup_in_vrf: (Default value = 0)
- :param classify_table_index: (Default value = 0xFFFFFFFF)
- :param is_add: (Default value = 1)
- :param is_drop: (Default value = 0)
- :param is_ipv6: (Default value = 0)
- :param is_local: (Default value = 0)
- :param is_classify: (Default value = 0)
- :param is_multipath: (Default value = 0)
- :param is_resolve_host: (Default value = 0)
- :param is_resolve_attached: (Default value = 0)
- :param next_hop_weight: (Default value = 1)
- :param is_multicast: (Default value = 0)
-
"""
return self.api(
self.papi.mpls_tunnel_add_del,
- {'mt_sw_if_index': tun_sw_if_index,
- 'mt_is_add': is_add,
- 'mt_l2_only': l2_only,
- 'mt_is_multicast': is_multicast,
- 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
- 'mt_next_hop_weight': next_hop_weight,
- 'mt_next_hop': next_hop_address,
- 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
- 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
- 'mt_next_hop_table_id': next_hop_table_id,
- 'mt_next_hop_via_label': next_hop_via_label,
- 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
+ {'mt_is_add': is_add,
+ 'mt_tunnel':
+ {
+ 'mt_sw_if_index': tun_sw_if_index,
+ 'mt_l2_only': l2_only,
+ 'mt_is_multicast': is_multicast,
+ 'mt_n_paths': len(paths),
+ 'mt_paths': paths,
+ }})
def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
detect_mult, local_addr, peer_addr, is_ipv6=0,
@@ -1004,39 +1050,40 @@ class VppPapiProvider(object):
})
def ip_mroute_add_del(self,
- src_address,
- grp_address,
- grp_address_length,
+ table_id,
+ prefix,
e_flags,
- next_hop_afi,
- next_hop_sw_if_index,
- next_hop_address,
- i_flags,
- bier_imp=0,
- rpf_id=0,
- table_id=0,
+ rpf_id,
+ paths,
is_add=1,
- is_ipv6=0,
- is_local=0):
+ is_multipath=1):
"""
IP Multicast Route add/del
"""
return self.api(
self.papi.ip_mroute_add_del,
- {'next_hop_sw_if_index': next_hop_sw_if_index,
- 'entry_flags': e_flags,
- 'itf_flags': i_flags,
- 'table_id': table_id,
- 'rpf_id': rpf_id,
- 'is_add': is_add,
- 'is_ipv6': is_ipv6,
- 'is_local': is_local,
- 'bier_imp': bier_imp,
- 'next_hop_afi': next_hop_afi,
- 'grp_address_length': grp_address_length,
- 'grp_address': grp_address,
- 'src_address': src_address,
- 'nh_address': next_hop_address})
+ {
+ 'is_add': is_add,
+ 'is_multipath': is_multipath,
+ 'route': {
+ 'table_id': table_id,
+ 'entry_flags': e_flags,
+ 'rpf_id': rpf_id,
+ 'prefix': prefix,
+ 'n_paths': len(paths),
+ 'paths': paths,
+ }
+ })
+
+ def mfib_signal_dump(self):
+ return self.api(self.papi.mfib_signal_dump, {})
+
+ def ip_mroute_dump(self, table_id, is_ip6=False):
+ return self.api(self.papi.ip_mroute_dump,
+ {'table': {
+ 'table_id': table_id,
+ 'is_ip6': is_ip6
+ }})
def lisp_enable_disable(self, is_enabled):
return self.api(
@@ -1633,14 +1680,18 @@ class VppPapiProvider(object):
""" BIER Route add/del """
return self.api(
self.papi.bier_route_add_del,
- {'br_tbl_id': {"bt_set": bti.set_id,
- "bt_sub_domain": bti.sub_domain_id,
- "bt_hdr_len_id": bti.hdr_len_id},
- 'br_bp': bp,
- 'br_n_paths': len(paths),
- 'br_paths': paths,
- 'br_is_add': is_add,
- 'br_is_replace': is_replace})
+ {
+ 'br_route': {
+ 'br_tbl_id': {"bt_set": bti.set_id,
+ "bt_sub_domain": bti.sub_domain_id,
+ "bt_hdr_len_id": bti.hdr_len_id},
+ 'br_bp': bp,
+ 'br_n_paths': len(paths),
+ 'br_paths': paths,
+ },
+ 'br_is_add': is_add,
+ 'br_is_replace': is_replace
+ })
def bier_route_dump(self, bti):
return self.api(
@@ -2238,30 +2289,6 @@ class VppPapiProvider(object):
return self.api(self.papi.pipe_delete,
{'parent_sw_if_index': parent_sw_if_index})
- def memif_create(
- self,
- role,
- mode,
- rx_queues=None,
- tx_queues=None,
- _id=None,
- socket_id=None,
- secret=None,
- ring_size=None,
- buffer_size=None,
- hw_addr=None):
- return self.api(self.papi.memif_create,
- {'role': role,
- 'mode': mode,
- 'rx_queues': rx_queues,
- 'tx_queues': tx_queues,
- 'id': _id,
- 'socket_id': socket_id,
- 'secret': secret,
- 'ring_size': ring_size,
- 'buffer_size': buffer_size,
- 'hw_addr': hw_addr})
-
def svs_table_add_del(self, af, table_id, is_add=1):
return self.api(self.papi.svs_table_add_del,
{