Skip to content

Commit 23a0485

Browse files
Geliang Tangkuba-moo
authored andcommitted
selftests: mptcp: declare event macros in mptcp_lib
MPTCP event macros (SUB_ESTABLISHED, LISTENER_CREATED, LISTENER_CLOSED), and the protocol family macros (AF_INET, AF_INET6) are defined in both mptcp_join.sh and userspace_pm.sh. In order not to duplicate code, this patch declares them all in mptcp_lib.sh with MPTCP_LIB_ prefixs. Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-14-4f42c347b653@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7f0782c commit 23a0485

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

tools/testing/selftests/net/mptcp/mptcp_join.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,23 +2785,16 @@ backup_tests()
27852785
fi
27862786
}
27872787

2788-
SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED
2789-
LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED
2790-
LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED
2791-
2792-
AF_INET=2
2793-
AF_INET6=10
2794-
27952788
verify_listener_events()
27962789
{
27972790
local e_type=$2
27982791
local e_saddr=$4
27992792
local e_sport=$5
28002793
local name
28012794

2802-
if [ $e_type = $LISTENER_CREATED ]; then
2795+
if [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CREATED ]; then
28032796
name="LISTENER_CREATED"
2804-
elif [ $e_type = $LISTENER_CLOSED ]; then
2797+
elif [ $e_type = $MPTCP_LIB_EVENT_LISTENER_CLOSED ]; then
28052798
name="LISTENER_CLOSED "
28062799
else
28072800
name="$e_type"
@@ -2856,8 +2849,10 @@ add_addr_ports_tests()
28562849
chk_add_nr 1 1 1
28572850
chk_rm_nr 1 1 invert
28582851

2859-
verify_listener_events $evts_ns1 $LISTENER_CREATED $AF_INET 10.0.2.1 10100
2860-
verify_listener_events $evts_ns1 $LISTENER_CLOSED $AF_INET 10.0.2.1 10100
2852+
verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CREATED \
2853+
$MPTCP_LIB_AF_INET 10.0.2.1 10100
2854+
verify_listener_events $evts_ns1 $MPTCP_LIB_EVENT_LISTENER_CLOSED \
2855+
$MPTCP_LIB_AF_INET 10.0.2.1 10100
28612856
kill_events_pids
28622857
fi
28632858

@@ -3463,11 +3458,11 @@ userspace_tests()
34633458
userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1"
34643459
userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1"
34653460
userspace_pm_rm_addr $ns1 10
3466-
userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED
3461+
userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $MPTCP_LIB_EVENT_SUB_ESTABLISHED
34673462
userspace_pm_chk_dump_addr "${ns1}" \
34683463
"id 20 flags signal 10.0.3.1" "after rm_addr 10"
34693464
userspace_pm_rm_addr $ns1 20
3470-
userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED
3465+
userspace_pm_rm_sf $ns1 10.0.3.1 $MPTCP_LIB_EVENT_SUB_ESTABLISHED
34713466
userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20"
34723467
chk_rm_nr 2 2 invert
34733468
chk_mptcp_info subflows 0 subflows 0
@@ -3494,7 +3489,7 @@ userspace_tests()
34943489
"subflow"
34953490
userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2"
34963491
userspace_pm_rm_addr $ns2 20
3497-
userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED
3492+
userspace_pm_rm_sf $ns2 10.0.3.2 $MPTCP_LIB_EVENT_SUB_ESTABLISHED
34983493
userspace_pm_chk_dump_addr "${ns2}" \
34993494
"" \
35003495
"after rm_addr 20"

tools/testing/selftests/net/mptcp/mptcp_lib.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ readonly KSFT_SKIP=4
88
# shellcheck disable=SC2155 # declare and assign separately
99
readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"
1010

11+
# These variables are used in some selftests, read-only
12+
declare -rx MPTCP_LIB_EVENT_ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED
13+
declare -rx MPTCP_LIB_EVENT_REMOVED=7 # MPTCP_EVENT_REMOVED
14+
declare -rx MPTCP_LIB_EVENT_SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED
15+
declare -rx MPTCP_LIB_EVENT_SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED
16+
declare -rx MPTCP_LIB_EVENT_LISTENER_CREATED=15 # MPTCP_EVENT_LISTENER_CREATED
17+
declare -rx MPTCP_LIB_EVENT_LISTENER_CLOSED=16 # MPTCP_EVENT_LISTENER_CLOSED
18+
19+
declare -rx MPTCP_LIB_AF_INET=2
20+
declare -rx MPTCP_LIB_AF_INET6=10
21+
1122
MPTCP_LIB_SUBTESTS=()
1223
MPTCP_LIB_SUBTESTS_DUPLICATED=0
1324
MPTCP_LIB_TEST_COUNTER=0

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
1919
fi
2020
mptcp_lib_check_tools ip
2121

22-
ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED
23-
REMOVED=7 # MPTCP_EVENT_REMOVED
24-
SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED
25-
SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED
26-
LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED
27-
LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED
28-
29-
AF_INET=2
30-
AF_INET6=10
22+
ANNOUNCED=${MPTCP_LIB_EVENT_ANNOUNCED}
23+
REMOVED=${MPTCP_LIB_EVENT_REMOVED}
24+
SUB_ESTABLISHED=${MPTCP_LIB_EVENT_SUB_ESTABLISHED}
25+
SUB_CLOSED=${MPTCP_LIB_EVENT_SUB_CLOSED}
26+
LISTENER_CREATED=${MPTCP_LIB_EVENT_LISTENER_CREATED}
27+
LISTENER_CLOSED=${MPTCP_LIB_EVENT_LISTENER_CLOSED}
28+
29+
AF_INET=${MPTCP_LIB_AF_INET}
30+
AF_INET6=${MPTCP_LIB_AF_INET6}
3131

3232
file=""
3333
server_evts=""

0 commit comments

Comments
 (0)