Skip to content

Commit 20ccc7c

Browse files
matttbePaolo Abeni
authored andcommitted
selftests: mptcp: join: validate event numbers
This test extends "delete and re-add" and "delete re-add signal" to validate the previous commit: the number of MPTCP events are checked to make sure there are no duplicated or unexpected ones. A new helper has been introduced to easily check these events. The missing events have been added to the lib. The 'Fixes' tag here below is the same as the one from the previous commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID. Fixes: b911c97 ("mptcp: add netlink event support") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent d82809b commit 20ccc7c

2 files changed

Lines changed: 75 additions & 3 deletions

File tree

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

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,17 @@ reset_with_fail()
420420
fi
421421
}
422422

423+
start_events()
424+
{
425+
mptcp_lib_events "${ns1}" "${evts_ns1}" evts_ns1_pid
426+
mptcp_lib_events "${ns2}" "${evts_ns2}" evts_ns2_pid
427+
}
428+
423429
reset_with_events()
424430
{
425431
reset "${1}" || return 1
426432

427-
mptcp_lib_events "${ns1}" "${evts_ns1}" evts_ns1_pid
428-
mptcp_lib_events "${ns2}" "${evts_ns2}" evts_ns2_pid
433+
start_events
429434
}
430435

431436
reset_with_tcp_filter()
@@ -3333,6 +3338,36 @@ userspace_pm_chk_get_addr()
33333338
fi
33343339
}
33353340

3341+
# $1: ns ; $2: event type ; $3: count
3342+
chk_evt_nr()
3343+
{
3344+
local ns=${1}
3345+
local evt_name="${2}"
3346+
local exp="${3}"
3347+
3348+
local evts="${evts_ns1}"
3349+
local evt="${!evt_name}"
3350+
local count
3351+
3352+
evt_name="${evt_name:16}" # without MPTCP_LIB_EVENT_
3353+
[ "${ns}" == "ns2" ] && evts="${evts_ns2}"
3354+
3355+
print_check "event ${ns} ${evt_name} (${exp})"
3356+
3357+
if [[ "${evt_name}" = "LISTENER_"* ]] &&
3358+
! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then
3359+
print_skip "event not supported"
3360+
return
3361+
fi
3362+
3363+
count=$(grep -cw "type:${evt}" "${evts}")
3364+
if [ "${count}" != "${exp}" ]; then
3365+
fail_test "got ${count} events, expected ${exp}"
3366+
else
3367+
print_ok
3368+
fi
3369+
}
3370+
33363371
userspace_tests()
33373372
{
33383373
# userspace pm type prevents add_addr
@@ -3572,6 +3607,7 @@ endpoint_tests()
35723607

35733608
if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT &&
35743609
mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
3610+
start_events
35753611
pm_nl_set_limits $ns1 0 3
35763612
pm_nl_set_limits $ns2 0 3
35773613
pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags subflow
@@ -3623,12 +3659,28 @@ endpoint_tests()
36233659

36243660
mptcp_lib_kill_wait $tests_pid
36253661

3662+
kill_events_pids
3663+
chk_evt_nr ns1 MPTCP_LIB_EVENT_LISTENER_CREATED 1
3664+
chk_evt_nr ns1 MPTCP_LIB_EVENT_CREATED 1
3665+
chk_evt_nr ns1 MPTCP_LIB_EVENT_ESTABLISHED 1
3666+
chk_evt_nr ns1 MPTCP_LIB_EVENT_ANNOUNCED 0
3667+
chk_evt_nr ns1 MPTCP_LIB_EVENT_REMOVED 4
3668+
chk_evt_nr ns1 MPTCP_LIB_EVENT_SUB_ESTABLISHED 6
3669+
chk_evt_nr ns1 MPTCP_LIB_EVENT_SUB_CLOSED 4
3670+
3671+
chk_evt_nr ns2 MPTCP_LIB_EVENT_CREATED 1
3672+
chk_evt_nr ns2 MPTCP_LIB_EVENT_ESTABLISHED 1
3673+
chk_evt_nr ns2 MPTCP_LIB_EVENT_ANNOUNCED 0
3674+
chk_evt_nr ns2 MPTCP_LIB_EVENT_REMOVED 0
3675+
chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 6
3676+
chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 5 # one has been closed before estab
3677+
36263678
chk_join_nr 6 6 6
36273679
chk_rm_nr 4 4
36283680
fi
36293681

36303682
# remove and re-add
3631-
if reset "delete re-add signal" &&
3683+
if reset_with_events "delete re-add signal" &&
36323684
mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
36333685
pm_nl_set_limits $ns1 0 3
36343686
pm_nl_set_limits $ns2 3 3
@@ -3669,6 +3721,22 @@ endpoint_tests()
36693721
chk_mptcp_info subflows 3 subflows 3
36703722
mptcp_lib_kill_wait $tests_pid
36713723

3724+
kill_events_pids
3725+
chk_evt_nr ns1 MPTCP_LIB_EVENT_LISTENER_CREATED 1
3726+
chk_evt_nr ns1 MPTCP_LIB_EVENT_CREATED 1
3727+
chk_evt_nr ns1 MPTCP_LIB_EVENT_ESTABLISHED 1
3728+
chk_evt_nr ns1 MPTCP_LIB_EVENT_ANNOUNCED 0
3729+
chk_evt_nr ns1 MPTCP_LIB_EVENT_REMOVED 0
3730+
chk_evt_nr ns1 MPTCP_LIB_EVENT_SUB_ESTABLISHED 4
3731+
chk_evt_nr ns1 MPTCP_LIB_EVENT_SUB_CLOSED 2
3732+
3733+
chk_evt_nr ns2 MPTCP_LIB_EVENT_CREATED 1
3734+
chk_evt_nr ns2 MPTCP_LIB_EVENT_ESTABLISHED 1
3735+
chk_evt_nr ns2 MPTCP_LIB_EVENT_ANNOUNCED 5
3736+
chk_evt_nr ns2 MPTCP_LIB_EVENT_REMOVED 3
3737+
chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 4
3738+
chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2
3739+
36723740
chk_join_nr 4 4 4
36733741
chk_add_nr 5 5
36743742
chk_rm_nr 3 2 invert

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ readonly KSFT_SKIP=4
1212
readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"
1313

1414
# These variables are used in some selftests, read-only
15+
declare -rx MPTCP_LIB_EVENT_CREATED=1 # MPTCP_EVENT_CREATED
16+
declare -rx MPTCP_LIB_EVENT_ESTABLISHED=2 # MPTCP_EVENT_ESTABLISHED
17+
declare -rx MPTCP_LIB_EVENT_CLOSED=3 # MPTCP_EVENT_CLOSED
1518
declare -rx MPTCP_LIB_EVENT_ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED
1619
declare -rx MPTCP_LIB_EVENT_REMOVED=7 # MPTCP_EVENT_REMOVED
1720
declare -rx MPTCP_LIB_EVENT_SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED
1821
declare -rx MPTCP_LIB_EVENT_SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED
22+
declare -rx MPTCP_LIB_EVENT_SUB_PRIORITY=13 # MPTCP_EVENT_SUB_PRIORITY
1923
declare -rx MPTCP_LIB_EVENT_LISTENER_CREATED=15 # MPTCP_EVENT_LISTENER_CREATED
2024
declare -rx MPTCP_LIB_EVENT_LISTENER_CLOSED=16 # MPTCP_EVENT_LISTENER_CLOSED
2125

0 commit comments

Comments
 (0)