]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: fib_nexthops: Add test cases for FDB status change
authorIdo Schimmel <idosch@nvidia.com>
Sun, 21 Sep 2025 15:08:24 +0000 (18:08 +0300)
committerJakub Kicinski <kuba@kernel.org>
Wed, 24 Sep 2025 00:01:05 +0000 (17:01 -0700)
Add the following test cases for both IPv4 and IPv6:

* Can change from FDB nexthop to non-FDB nexthop and vice versa.
* Can change FDB nexthop address while in a group.
* Cannot change from FDB nexthop to non-FDB nexthop and vice versa while
  in a group.

Output without "nexthop: Forbid FDB status change while nexthop is in a
group":

 # ./fib_nexthops.sh -t "ipv6_fdb_grp_fcnal ipv4_fdb_grp_fcnal"

 IPv6 fdb groups functional
 --------------------------
 [...]
 TEST: Replace FDB nexthop to non-FDB nexthop                        [ OK ]
 TEST: Replace non-FDB nexthop to FDB nexthop                        [ OK ]
 TEST: Replace FDB nexthop address while in a group                  [ OK ]
 TEST: Replace FDB nexthop to non-FDB nexthop while in a group       [FAIL]
 TEST: Replace non-FDB nexthop to FDB nexthop while in a group       [FAIL]
 [...]

 IPv4 fdb groups functional
 --------------------------
 [...]
 TEST: Replace FDB nexthop to non-FDB nexthop                        [ OK ]
 TEST: Replace non-FDB nexthop to FDB nexthop                        [ OK ]
 TEST: Replace FDB nexthop address while in a group                  [ OK ]
 TEST: Replace FDB nexthop to non-FDB nexthop while in a group       [FAIL]
 TEST: Replace non-FDB nexthop to FDB nexthop while in a group       [FAIL]
 [...]

 Tests passed:  36
 Tests failed:   4
 Tests skipped:  0

Output with "nexthop: Forbid FDB status change while nexthop is in a
group":

 # ./fib_nexthops.sh -t "ipv6_fdb_grp_fcnal ipv4_fdb_grp_fcnal"

 IPv6 fdb groups functional
 --------------------------
 [...]
 TEST: Replace FDB nexthop to non-FDB nexthop                        [ OK ]
 TEST: Replace non-FDB nexthop to FDB nexthop                        [ OK ]
 TEST: Replace FDB nexthop address while in a group                  [ OK ]
 TEST: Replace FDB nexthop to non-FDB nexthop while in a group       [ OK ]
 TEST: Replace non-FDB nexthop to FDB nexthop while in a group       [ OK ]
 [...]

 IPv4 fdb groups functional
 --------------------------
 [...]
 TEST: Replace FDB nexthop to non-FDB nexthop                        [ OK ]
 TEST: Replace non-FDB nexthop to FDB nexthop                        [ OK ]
 TEST: Replace FDB nexthop address while in a group                  [ OK ]
 TEST: Replace FDB nexthop to non-FDB nexthop while in a group       [ OK ]
 TEST: Replace non-FDB nexthop to FDB nexthop while in a group       [ OK ]
 [...]

 Tests passed:  40
 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/20250921150824.149157-4-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/fib_nexthops.sh

index 2ac394c99d018321c21510e8324732c29d4bb19a..2b0a90581e2f15e213ffaa1b6f002244d5cc6471 100755 (executable)
@@ -494,6 +494,26 @@ ipv6_fdb_grp_fcnal()
        run_cmd "$IP nexthop add id 69 encap mpls 101 via 2001:db8:91::8 dev veth1 fdb"
        log_test $? 2 "Fdb Nexthop with encap"
 
+       # Replace FDB nexthop to non-FDB and vice versa
+       run_cmd "$IP nexthop add id 70 via 2001:db8:91::2 fdb"
+       run_cmd "$IP nexthop replace id 70 via 2001:db8:91::2 dev veth1"
+       log_test $? 0 "Replace FDB nexthop to non-FDB nexthop"
+       run_cmd "$IP nexthop replace id 70 via 2001:db8:91::2 fdb"
+       log_test $? 0 "Replace non-FDB nexthop to FDB nexthop"
+
+       # Replace FDB nexthop address while in a group
+       run_cmd "$IP nexthop add id 71 group 70 fdb"
+       run_cmd "$IP nexthop replace id 70 via 2001:db8:91::3 fdb"
+       log_test $? 0 "Replace FDB nexthop address while in a group"
+
+       # Cannot replace FDB nexthop to non-FDB and vice versa while in a group
+       run_cmd "$IP nexthop replace id 70 via 2001:db8:91::2 dev veth1"
+       log_test $? 2 "Replace FDB nexthop to non-FDB nexthop while in a group"
+       run_cmd "$IP nexthop add id 72 via 2001:db8:91::2 dev veth1"
+       run_cmd "$IP nexthop add id 73 group 72"
+       run_cmd "$IP nexthop replace id 72 via 2001:db8:91::2 fdb"
+       log_test $? 2 "Replace non-FDB nexthop to FDB nexthop while in a group"
+
        run_cmd "$IP link add name vx10 type vxlan id 1010 local 2001:db8:91::9 remote 2001:db8:91::10 dstport 4789 nolearning noudpcsum tos inherit ttl 100"
        run_cmd "$BRIDGE fdb add 02:02:00:00:00:13 dev vx10 nhid 102 self"
        log_test $? 0 "Fdb mac add with nexthop group"
@@ -574,6 +594,26 @@ ipv4_fdb_grp_fcnal()
        run_cmd "$IP nexthop add id 17 encap mpls 101 via 172.16.1.2 dev veth1 fdb"
        log_test $? 2 "Fdb Nexthop with encap"
 
+       # Replace FDB nexthop to non-FDB and vice versa
+       run_cmd "$IP nexthop add id 18 via 172.16.1.2 fdb"
+       run_cmd "$IP nexthop replace id 18 via 172.16.1.2 dev veth1"
+       log_test $? 0 "Replace FDB nexthop to non-FDB nexthop"
+       run_cmd "$IP nexthop replace id 18 via 172.16.1.2 fdb"
+       log_test $? 0 "Replace non-FDB nexthop to FDB nexthop"
+
+       # Replace FDB nexthop address while in a group
+       run_cmd "$IP nexthop add id 19 group 18 fdb"
+       run_cmd "$IP nexthop replace id 18 via 172.16.1.3 fdb"
+       log_test $? 0 "Replace FDB nexthop address while in a group"
+
+       # Cannot replace FDB nexthop to non-FDB and vice versa while in a group
+       run_cmd "$IP nexthop replace id 18 via 172.16.1.2 dev veth1"
+       log_test $? 2 "Replace FDB nexthop to non-FDB nexthop while in a group"
+       run_cmd "$IP nexthop add id 20 via 172.16.1.2 dev veth1"
+       run_cmd "$IP nexthop add id 21 group 20"
+       run_cmd "$IP nexthop replace id 20 via 172.16.1.2 fdb"
+       log_test $? 2 "Replace non-FDB nexthop to FDB nexthop while in a group"
+
        run_cmd "$IP link add name vx10 type vxlan id 1010 local 10.0.0.1 remote 10.0.0.2 dstport 4789 nolearning noudpcsum tos inherit ttl 100"
        run_cmd "$BRIDGE fdb add 02:02:00:00:00:13 dev vx10 nhid 102 self"
        log_test $? 0 "Fdb mac add with nexthop group"