Commit 00af023d authored by Ido Schimmel's avatar Ido Schimmel Committed by Jakub Kicinski
Browse files

selftests: fib_nexthops: Add test cases for FDB status change



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: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20250921150824.149157-4-idosch@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c2991310
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -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"