aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_ip4.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_ip4.py')
-rw-r--r--test/test_ip4.py66
1 files changed, 63 insertions, 3 deletions
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 926ca77a5f8..150ea629308 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -34,6 +34,7 @@ from vpp_papi import vpp_papi, VppEnum
from vpp_neighbor import VppNeighbor
from vpp_lo_interface import VppLoInterface
from vpp_policer import VppPolicer, PolicerAction
+from config import config
NUM_PKTS = 67
@@ -244,12 +245,13 @@ class TestIPv4RouteLookup(VppTestCase):
"""IPv4 Route Lookup Test Case"""
routes = []
+ tables = []
- def route_lookup(self, prefix, exact):
+ def route_lookup(self, prefix, exact, table_id=0):
return self.vapi.api(
self.vapi.papi.ip_route_lookup,
{
- "table_id": 0,
+ "table_id": table_id,
"exact": exact,
"prefix": prefix,
},
@@ -283,11 +285,30 @@ class TestIPv4RouteLookup(VppTestCase):
r.add_vpp_config()
self.routes.append(r)
+ custom_vrf = VppIpTable(self, 200)
+ custom_vrf.add_vpp_config()
+ self.tables.append(custom_vrf)
+
+ r = VppIpRoute(self, "2.2.0.0", 16, [drop_nh], 200)
+ r.add_vpp_config()
+ self.routes.append(r)
+
+ r = VppIpRoute(self, "2.2.2.0", 24, [drop_nh], 200)
+ r.add_vpp_config()
+ self.routes.append(r)
+
+ r = VppIpRoute(self, "2.2.2.2", 32, [drop_nh], 200)
+ r.add_vpp_config()
+ self.routes.append(r)
+
def tearDown(self):
# Remove the routes we added
for r in self.routes:
r.remove_vpp_config()
+ for vrf in self.tables:
+ vrf.remove_vpp_config()
+
super(TestIPv4RouteLookup, self).tearDown()
def test_exact_match(self):
@@ -305,6 +326,20 @@ class TestIPv4RouteLookup(VppTestCase):
with self.vapi.assert_negative_api_retval():
self.route_lookup("1.1.1.2/32", True)
+ # Verify we find the host route
+ prefix = "2.2.2.2/32"
+ result = self.route_lookup(prefix, True, 200)
+ assert prefix == str(result.route.prefix)
+
+ # Verify we find a middle prefix route
+ prefix = "2.2.2.0/24"
+ result = self.route_lookup(prefix, True, 200)
+ assert prefix == str(result.route.prefix)
+
+ # Verify we do not find an available LPM.
+ with self.vapi.assert_negative_api_retval():
+ self.route_lookup("2.2.2.1/32", True, 200)
+
def test_longest_prefix_match(self):
# verify we find lpm
lpm_prefix = "1.1.1.0/24"
@@ -315,6 +350,15 @@ class TestIPv4RouteLookup(VppTestCase):
result = self.route_lookup(lpm_prefix, False)
assert lpm_prefix == str(result.route.prefix)
+ # verify we find lpm
+ lpm_prefix = "2.2.2.0/24"
+ result = self.route_lookup("2.2.2.1/32", False, 200)
+ assert lpm_prefix == str(result.route.prefix)
+
+ # Verify we find the exact when not requested
+ result = self.route_lookup(lpm_prefix, False, 200)
+ assert lpm_prefix == str(result.route.prefix)
+
# Can't seem to delete the default route so no negative LPM test.
@@ -459,6 +503,9 @@ class TestIPv4IfAddrRoute(VppTestCase):
)
+@unittest.skipIf(
+ "ping" in config.excluded_plugins, "Exclude tests requiring Ping plugin"
+)
class TestICMPEcho(VppTestCase):
"""ICMP Echo Test Case"""
@@ -929,6 +976,19 @@ class TestIPNull(VppTestCase):
r2.remove_vpp_config()
rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1)
+ t = VppIpTable(self, 2, False)
+ t.add_vpp_config()
+ r3 = VppIpRoute(
+ self,
+ "1.1.1.0",
+ 31,
+ [VppRoutePath("0.0.0.0", 0xFFFFFFFF, type=FibPathType.FIB_PATH_TYPE_DROP)],
+ table_id=2,
+ )
+ r3.add_vpp_config()
+ r3.remove_vpp_config()
+ t.remove_vpp_config()
+
class TestIPDisabled(VppTestCase):
"""IPv4 disabled"""
@@ -1396,7 +1456,7 @@ class TestIPLoadBalance(VppTestCase):
src_pkts.append(
(
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
- / IP(dst="1.1.1.1", src="20.0.0.%d" % ii)
+ / IP(dst="1.1.1.1", src="20.0.0.%d" % (ii % 256))
/ UDP(sport=1234, dport=1234)
/ Raw(b"\xa5" * 100)
)