tests: allow to add paths to default route 01/40601/4
authorMaxime Peim <mpeim@cisco.com>
Tue, 9 Apr 2024 07:08:00 +0000 (09:08 +0200)
committerDave Wallace <dwallacelf@gmail.com>
Tue, 9 Apr 2024 17:30:57 +0000 (17:30 +0000)
After adding a path to the default route, the prefix still be there
in the table as it is a mandatory prefix. However, the registry hence
fail to remove the route from VPP.

Type: fix
Change-Id: Ic4ad72455ac7a1a2f1d8baba59a7a3afe1610726
Signed-off-by: Maxime Peim <mpeim@cisco.com>
test/vpp_ip_route.py

index 06a963c..9b3a138 100644 (file)
@@ -75,7 +75,9 @@ def address_proto(ip_addr):
         return FibPathProto.FIB_PATH_NH_PROTO_IP6
 
 
-def find_route(test, addr, len, table_id=0, sw_if_index=None):
+def find_route(
+    test, addr, len, table_id=0, sw_if_index=None, ignore_default_route=False
+):
     prefix = mk_network(addr, len)
 
     if 4 == prefix.version:
@@ -86,7 +88,13 @@ def find_route(test, addr, len, table_id=0, sw_if_index=None):
     for e in routes:
         if table_id == e.route.table_id and str(e.route.prefix) == str(prefix):
             if not sw_if_index:
-                return True
+                # if the route is a default one of the table:
+                # 0.0.0.0/0, 0.0.0.0/32, 240.0.0.0/4, 255.255.255.255/32
+                return not (
+                    ignore_default_route
+                    and e.route.n_paths == 1
+                    and e.route.paths[0].type == FibPathType.FIB_PATH_TYPE_DROP
+                )
             else:
                 # should be only one path if the user is looking
                 # for the interface the route is reachable through
@@ -601,6 +609,7 @@ class VppIpRoute(VppObject):
             self.prefix.network_address,
             self.prefix.prefixlen,
             self.table_id,
+            ignore_default_route=True,
         )
 
     def object_id(self):
@@ -716,6 +725,7 @@ class VppIpRouteV2(VppObject):
             self.prefix.network_address,
             self.prefix.prefixlen,
             self.table_id,
+            ignore_default_route=True,
         )
 
     def object_id(self):