mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 19:13:47 +02:00
Merge branch 'mptcp-various-small-improvements'
Matthieu Baerts says: ==================== mptcp: various small improvements This series brings various small improvements to MPTCP and its selftests: Patch 1 prints an error if there are duplicated subtests names. It is important to have unique (sub)tests names in TAP, because some CI environments drop (sub)tests with duplicated names. Patch 2 is a preparation for patches 3 and 4, which check the protocol in tcp_sk() and mptcp_sk() with DEBUG_NET, only in code from net/mptcp/. We recently had the case where an MPTCP socket was wrongly treated as a TCP one, and fuzzers and static checkers never spot the issue. This would prevent such issues in the future. Patches 5 to 7 are some cleanup for the MPTCP selftests. These patches are not supposed to change the behaviour. Patch 8 sets the poll timeout in diag selftest to the same value as the one used in the other selftests. ==================== Link: https://lore.kernel.org/r/20240223-upstream-net-next-20240223-misc-improvements-v1-0-b6c8a10396bd@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
55a7246025
|
|
@ -348,7 +348,23 @@ static inline void msk_owned_by_me(const struct mptcp_sock *msk)
|
|||
sock_owned_by_me((const struct sock *)msk);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_NET
|
||||
/* MPTCP-specific: we might (indirectly) call this helper with the wrong sk */
|
||||
#undef tcp_sk
|
||||
#define tcp_sk(ptr) ({ \
|
||||
typeof(ptr) _ptr = (ptr); \
|
||||
WARN_ON(_ptr->sk_protocol != IPPROTO_TCP); \
|
||||
container_of_const(_ptr, struct tcp_sock, inet_conn.icsk_inet.sk); \
|
||||
})
|
||||
#define mptcp_sk(ptr) ({ \
|
||||
typeof(ptr) _ptr = (ptr); \
|
||||
WARN_ON(_ptr->sk_protocol != IPPROTO_MPTCP); \
|
||||
container_of_const(_ptr, struct mptcp_sock, sk.icsk_inet.sk); \
|
||||
})
|
||||
|
||||
#else /* !CONFIG_DEBUG_NET */
|
||||
#define mptcp_sk(ptr) container_of_const(ptr, struct mptcp_sock, sk.icsk_inet.sk)
|
||||
#endif
|
||||
|
||||
/* the msk socket don't use the backlog, also account for the bulk
|
||||
* free memory
|
||||
|
|
|
|||
|
|
@ -52,14 +52,19 @@ static struct mptcp_subflow_context *build_ctx(struct kunit *test)
|
|||
static struct mptcp_sock *build_msk(struct kunit *test)
|
||||
{
|
||||
struct mptcp_sock *msk;
|
||||
struct sock *sk;
|
||||
|
||||
msk = kunit_kzalloc(test, sizeof(struct mptcp_sock), GFP_USER);
|
||||
KUNIT_EXPECT_NOT_ERR_OR_NULL(test, msk);
|
||||
refcount_set(&((struct sock *)msk)->sk_refcnt, 1);
|
||||
sock_net_set((struct sock *)msk, &init_net);
|
||||
|
||||
sk = (struct sock *)msk;
|
||||
|
||||
/* be sure the token helpers can dereference sk->sk_prot */
|
||||
((struct sock *)msk)->sk_prot = &tcp_prot;
|
||||
sk->sk_prot = &tcp_prot;
|
||||
sk->sk_protocol = IPPROTO_MPTCP;
|
||||
|
||||
return msk;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
|
|||
ns="ns1-$rndh"
|
||||
ksft_skip=4
|
||||
test_cnt=1
|
||||
timeout_poll=100
|
||||
timeout_poll=30
|
||||
timeout_test=$((timeout_poll * 2 + 1))
|
||||
ret=0
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ iptables="iptables"
|
|||
ip6tables="ip6tables"
|
||||
timeout_poll=30
|
||||
timeout_test=$((timeout_poll * 2 + 1))
|
||||
capture=0
|
||||
checksum=0
|
||||
capture=false
|
||||
checksum=false
|
||||
ip_mptcp=0
|
||||
check_invert=0
|
||||
validate_checksum=0
|
||||
validate_checksum=false
|
||||
init=0
|
||||
evts_ns1=""
|
||||
evts_ns2=""
|
||||
|
|
@ -100,7 +100,7 @@ init_partial()
|
|||
ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true
|
||||
ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
|
||||
ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
|
||||
if [ $checksum -eq 1 ]; then
|
||||
if $checksum; then
|
||||
ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1
|
||||
fi
|
||||
done
|
||||
|
|
@ -380,7 +380,7 @@ reset_with_checksum()
|
|||
ip netns exec $ns1 sysctl -q net.mptcp.checksum_enabled=$ns1_enable
|
||||
ip netns exec $ns2 sysctl -q net.mptcp.checksum_enabled=$ns2_enable
|
||||
|
||||
validate_checksum=1
|
||||
validate_checksum=true
|
||||
}
|
||||
|
||||
reset_with_allow_join_id0()
|
||||
|
|
@ -413,7 +413,7 @@ reset_with_allow_join_id0()
|
|||
setup_fail_rules()
|
||||
{
|
||||
check_invert=1
|
||||
validate_checksum=1
|
||||
validate_checksum=true
|
||||
local i="$1"
|
||||
local ip="${2:-4}"
|
||||
local tables
|
||||
|
|
@ -1017,7 +1017,7 @@ do_transfer()
|
|||
:> "$sout"
|
||||
:> "$capout"
|
||||
|
||||
if [ $capture -eq 1 ]; then
|
||||
if $capture; then
|
||||
local capuser
|
||||
if [ -z $SUDO_USER ] ; then
|
||||
capuser=""
|
||||
|
|
@ -1119,7 +1119,7 @@ do_transfer()
|
|||
wait $spid
|
||||
local rets=$?
|
||||
|
||||
if [ $capture -eq 1 ]; then
|
||||
if $capture; then
|
||||
sleep 1
|
||||
kill $cappid
|
||||
fi
|
||||
|
|
@ -1507,7 +1507,7 @@ chk_join_nr()
|
|||
else
|
||||
print_ok
|
||||
fi
|
||||
if [ $validate_checksum -eq 1 ]; then
|
||||
if $validate_checksum; then
|
||||
chk_csum_nr $csum_ns1 $csum_ns2
|
||||
chk_fail_nr $fail_nr $fail_nr
|
||||
chk_rst_nr $rst_nr $rst_nr
|
||||
|
|
@ -3664,10 +3664,10 @@ while getopts "${all_tests_args}cCih" opt; do
|
|||
tests+=("${all_tests[${opt}]}")
|
||||
;;
|
||||
c)
|
||||
capture=1
|
||||
capture=true
|
||||
;;
|
||||
C)
|
||||
checksum=1
|
||||
checksum=true
|
||||
;;
|
||||
i)
|
||||
ip_mptcp=1
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ readonly KSFT_SKIP=4
|
|||
readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"
|
||||
|
||||
MPTCP_LIB_SUBTESTS=()
|
||||
MPTCP_LIB_SUBTESTS_DUPLICATED=0
|
||||
|
||||
# only if supported (or forced) and not disabled, see no-color.org
|
||||
if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
|
||||
|
|
@ -146,12 +147,26 @@ mptcp_lib_kversion_ge() {
|
|||
mptcp_lib_fail_if_expected_feature "kernel version ${1} lower than ${v}"
|
||||
}
|
||||
|
||||
__mptcp_lib_result_check_duplicated() {
|
||||
local subtest
|
||||
|
||||
for subtest in "${MPTCP_LIB_SUBTESTS[@]}"; do
|
||||
if [[ "${subtest}" == *" - ${KSFT_TEST}: ${*%% #*}" ]]; then
|
||||
MPTCP_LIB_SUBTESTS_DUPLICATED=1
|
||||
mptcp_lib_print_err "Duplicated entry: ${*}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
__mptcp_lib_result_add() {
|
||||
local result="${1}"
|
||||
shift
|
||||
|
||||
local id=$((${#MPTCP_LIB_SUBTESTS[@]} + 1))
|
||||
|
||||
__mptcp_lib_result_check_duplicated "${*}"
|
||||
|
||||
MPTCP_LIB_SUBTESTS+=("${result} ${id} - ${KSFT_TEST}: ${*}")
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +221,12 @@ mptcp_lib_result_print_all_tap() {
|
|||
for subtest in "${MPTCP_LIB_SUBTESTS[@]}"; do
|
||||
printf "%s\n" "${subtest}"
|
||||
done
|
||||
|
||||
if [ "${MPTCP_LIB_SUBTESTS_DUPLICATED}" = 1 ] &&
|
||||
mptcp_lib_expect_all_features; then
|
||||
mptcp_lib_print_err "Duplicated test entries"
|
||||
exit ${KSFT_FAIL}
|
||||
fi
|
||||
}
|
||||
|
||||
# get the value of keyword $1 in the line marked by keyword $2
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ sec=$(date +%s)
|
|||
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
|
||||
ns1="ns1-$rndh"
|
||||
err=$(mktemp)
|
||||
ret=0
|
||||
|
||||
cleanup()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ test_cnt=1
|
|||
ret=0
|
||||
bail=0
|
||||
slack=50
|
||||
large=""
|
||||
small=""
|
||||
sout=""
|
||||
cout=""
|
||||
capout=""
|
||||
size=0
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [ -b ] [ -c ] [ -d ]"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user