summaryrefslogtreecommitdiffstats
path: root/test/test_ip6.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_ip6.py')
-rw-r--r--test/test_ip6.py167
1 files changed, 58 insertions, 109 deletions
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,