Skip to content

Commit 584247f

Browse files
committed
DO-NOT-MERGE: mptcp: improve code coverage for CI
tcp: warn if tcp_done() is called on a closed socket This is an extra check mainly for the CIs: to make sure we don't call tcp_done() on an already closed socket as it happened in the past. If we do such call, better to catch the error earlier. mptcp: warn in case of bogus mpc option on established client sk As discussed on [1], an additional check is done to catch local software bug. This patch is supposed to land only in our tree, for both 'export' and 'export-net' branches, because the warning could be triggered by bugged / malicious peer. We want it in our tree for our CI to detect internal bugs. Link: https://lore.kernel.org/all/[email protected]/ [1] Signed-off-by: Matthieu Baerts <[email protected]>
1 parent 2ad9f5d commit 584247f

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

net/ipv4/tcp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4855,6 +4855,8 @@ void tcp_done(struct sock *sk)
48554855
*/
48564856
req = rcu_dereference_protected(tcp_sk(sk)->fastopen_rsk, 1);
48574857

4858+
WARN_ON_ONCE(sk->sk_state == TCP_CLOSE);
4859+
48584860
if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)
48594861
TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
48604862

net/mptcp/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@ config MPTCP_KUNIT_TEST
3636

3737
If unsure, say N.
3838

39+
config GCOV_PROFILE_MPTCP
40+
bool "Enable GCOV profiling on MPTCP"
41+
depends on GCOV_KERNEL
42+
help
43+
Enable GCOV profiling on MPTCP for checking which functions/lines
44+
are executed.
45+
46+
If unsure, say N.
47+
3948
endif

net/mptcp/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ mptcp_token_test-objs := token_test.o
1313
obj-$(CONFIG_MPTCP_KUNIT_TEST) += mptcp_crypto_test.o mptcp_token_test.o
1414

1515
obj-$(CONFIG_BPF_SYSCALL) += bpf.o
16+
17+
# for GCOV coverage profiling
18+
ifdef CONFIG_GCOV_PROFILE_MPTCP
19+
GCOV_PROFILE := y
20+
endif

net/mptcp/options.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
983983
WRITE_ONCE(msk->pm.remote_deny_join_id0, true);
984984

985985
if (unlikely(!READ_ONCE(msk->pm.server_side)))
986-
pr_warn_once("bogus mpc option on established client sk");
986+
/* DO-NOT-MERGE: use WARN i/o pr_warn: only for MPTCP export */
987+
WARN_ONCE(1, "bogus mpc option on established client sk");
987988

988989
set_fully_established:
989990
mptcp_data_lock((struct sock *)msk);

0 commit comments

Comments
 (0)