Skip to content

Commit bc07b7f

Browse files
pmachataNipaLocal
authored andcommitted
selftests: test_vxlan_fdb_changelink: Convert to lib.sh
Instead of inlining equivalents, use lib.sh-provided primitives. Use defer to manage vx lifetime. This will make it easier to extend the test in the next patch. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 758a9ee commit bc07b7f

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4-
# Check FDB default-remote handling across "ip link set".
4+
ALL_TESTS="
5+
test_set_remote
6+
"
7+
source lib.sh
58

69
check_remotes()
710
{
811
local what=$1; shift
912
local N=$(bridge fdb sh dev vx | grep 00:00:00:00:00:00 | wc -l)
1013

11-
echo -ne "expected two remotes after $what\t"
12-
if [[ $N != 2 ]]; then
13-
echo "[FAIL]"
14-
EXIT_STATUS=1
15-
else
16-
echo "[ OK ]"
17-
fi
14+
((N == 2))
15+
check_err $? "expected 2 remotes after $what, got $N"
16+
}
17+
18+
# Check FDB default-remote handling across "ip link set".
19+
test_set_remote()
20+
{
21+
RET=0
22+
23+
ip_link_add vx up type vxlan id 2000 dstport 4789
24+
bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.20 self permanent
25+
bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.30 self permanent
26+
check_remotes "fdb append"
27+
28+
ip link set dev vx type vxlan remote 192.0.2.30
29+
check_remotes "link set"
30+
31+
log_test 'FDB default-remote handling across "ip link set"'
1832
}
1933

20-
ip link add name vx up type vxlan id 2000 dstport 4789
21-
bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.20 self permanent
22-
bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.30 self permanent
23-
check_remotes "fdb append"
34+
trap defer_scopes_cleanup EXIT
2435

25-
ip link set dev vx type vxlan remote 192.0.2.30
26-
check_remotes "link set"
36+
tests_run
2737

28-
ip link del dev vx
2938
exit $EXIT_STATUS

0 commit comments

Comments
 (0)