]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: fib_nexthops: Add test cases for error routes deletion
authorIdo Schimmel <idosch@nvidia.com>
Sun, 21 Dec 2025 14:48:29 +0000 (16:48 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 30 Dec 2025 09:39:22 +0000 (10:39 +0100)
Add test cases that check that error routes (e.g., blackhole) are
deleted when their nexthop is deleted.

Output without "ipv4: Fix reference count leak when using error routes
with nexthop objects":

 # ./fib_nexthops.sh -t "ipv4_fcnal ipv6_fcnal"

 IPv4 functional
 ----------------------
 [...]
       WARNING: Unexpected route entry
 TEST: Error route removed on nexthop deletion                       [FAIL]

 IPv6
 ----------------------
 [...]
 TEST: Error route removed on nexthop deletion                       [ OK ]

 Tests passed:  20
 Tests failed:   1
 Tests skipped:  0

Output with "ipv4: Fix reference count leak when using error routes
with nexthop objects":

 # ./fib_nexthops.sh -t "ipv4_fcnal ipv6_fcnal"

 IPv4 functional
 ----------------------
 [...]
 TEST: Error route removed on nexthop deletion                       [ OK ]

 IPv6
 ----------------------
 [...]
 TEST: Error route removed on nexthop deletion                       [ OK ]

 Tests passed:  21
 Tests failed:   0
 Tests skipped:  0

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20251221144829.197694-2-idosch@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/testing/selftests/net/fib_nexthops.sh

index 2b0a90581e2f15e213ffaa1b6f002244d5cc6471..21026b66766700eb504a2423ecafc14e9af8ecbb 100755 (executable)
@@ -800,6 +800,14 @@ ipv6_fcnal()
        set +e
        check_nexthop "dev veth1" ""
        log_test $? 0 "Nexthops removed on admin down"
+
+       # error routes should be deleted when their nexthop is deleted
+       run_cmd "$IP li set dev veth1 up"
+       run_cmd "$IP -6 nexthop add id 58 dev veth1"
+       run_cmd "$IP ro add blackhole 2001:db8:101::1/128 nhid 58"
+       run_cmd "$IP nexthop del id 58"
+       check_route6 "2001:db8:101::1" ""
+       log_test $? 0 "Error route removed on nexthop deletion"
 }
 
 ipv6_grp_refs()
@@ -1459,6 +1467,13 @@ ipv4_fcnal()
 
        run_cmd "$IP ro del 172.16.102.0/24"
        log_test $? 0 "Delete route when not specifying nexthop attributes"
+
+       # error routes should be deleted when their nexthop is deleted
+       run_cmd "$IP nexthop add id 23 dev veth1"
+       run_cmd "$IP ro add blackhole 172.16.102.100/32 nhid 23"
+       run_cmd "$IP nexthop del id 23"
+       check_route "172.16.102.100" ""
+       log_test $? 0 "Error route removed on nexthop deletion"
 }
 
 ipv4_grp_fcnal()