-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests: net: fdb_notify: Add a test for FDB notifications
Check that only one notification is produced for various FDB edit operations. Regarding the ip_link_add() and ip_link_master() helpers. This pattern of action plus corresponding defer is bound to come up often, and a dedicated vocabulary to capture it will be handy. tunnel_create() and vlan_create() from forwarding/lib.sh are somewhat opaque and perhaps too kitchen-sinky, so I tried to go in the opposite direction with these ones, and wrapped only the bare minimum to schedule a corresponding cleanup. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Acked-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://patch.msgid.link/910c5880ae6d3b558d6889cbdba2be690c2615c6.1731589511.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Showing
3 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
source lib.sh | ||
|
||
ALL_TESTS=" | ||
test_dup_bridge | ||
test_dup_vxlan_self | ||
test_dup_vxlan_master | ||
test_dup_macvlan_self | ||
test_dup_macvlan_master | ||
" | ||
|
||
do_test_dup() | ||
{ | ||
local op=$1; shift | ||
local what=$1; shift | ||
local tmpf | ||
|
||
RET=0 | ||
|
||
tmpf=$(mktemp) | ||
defer rm "$tmpf" | ||
|
||
defer_scope_push | ||
bridge monitor fdb &> "$tmpf" & | ||
defer kill_process $! | ||
|
||
sleep 0.5 | ||
bridge fdb "$op" 00:11:22:33:44:55 vlan 1 "$@" | ||
sleep 0.5 | ||
defer_scope_pop | ||
|
||
local count=$(grep -c -e 00:11:22:33:44:55 $tmpf) | ||
((count == 1)) | ||
check_err $? "Got $count notifications, expected 1" | ||
|
||
log_test "$what $op: Duplicate notifications" | ||
} | ||
|
||
test_dup_bridge() | ||
{ | ||
ip_link_add br up type bridge vlan_filtering 1 | ||
do_test_dup add "bridge" dev br self | ||
do_test_dup del "bridge" dev br self | ||
} | ||
|
||
test_dup_vxlan_self() | ||
{ | ||
ip_link_add br up type bridge vlan_filtering 1 | ||
ip_link_add vx up type vxlan id 2000 dstport 4789 | ||
ip_link_master vx br | ||
|
||
do_test_dup add "vxlan" dev vx self dst 192.0.2.1 | ||
do_test_dup del "vxlan" dev vx self dst 192.0.2.1 | ||
} | ||
|
||
test_dup_vxlan_master() | ||
{ | ||
ip_link_add br up type bridge vlan_filtering 1 | ||
ip_link_add vx up type vxlan id 2000 dstport 4789 | ||
ip_link_master vx br | ||
|
||
do_test_dup add "vxlan master" dev vx master | ||
do_test_dup del "vxlan master" dev vx master | ||
} | ||
|
||
test_dup_macvlan_self() | ||
{ | ||
ip_link_add dd up type dummy | ||
ip_link_add mv up link dd type macvlan mode passthru | ||
|
||
do_test_dup add "macvlan self" dev mv self | ||
do_test_dup del "macvlan self" dev mv self | ||
} | ||
|
||
test_dup_macvlan_master() | ||
{ | ||
ip_link_add br up type bridge vlan_filtering 1 | ||
ip_link_add dd up type dummy | ||
ip_link_add mv up link dd type macvlan mode passthru | ||
ip_link_master mv br | ||
|
||
do_test_dup add "macvlan master" dev mv self | ||
do_test_dup del "macvlan master" dev mv self | ||
} | ||
|
||
cleanup() | ||
{ | ||
defer_scopes_cleanup | ||
} | ||
|
||
trap cleanup EXIT | ||
tests_run | ||
|
||
exit $EXIT_STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters