mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [RFC mptcp-next] selftests: mptcp: Add a test for self-conn fallback
@ 2025-08-14  6:58 Gang Yan
  2025-08-14  8:51 ` MPTCP CI
  0 siblings, 1 reply; 4+ messages in thread
From: Gang Yan @ 2025-08-14  6:58 UTC (permalink / raw)
  To: mptcp; +Cc: Gang Yan

The 'simultaneous_connect' is not coverd by selftests, so this patch
adds a test according to issue#35. When a client tries to connect to
itself, the msk should fallback to tcp due to 'SIMULTCONN'.

Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
 .../selftests/net/mptcp/mptcp_connect.c       | 32 ++++++++++++++++++-
 .../selftests/net/mptcp/mptcp_connect.sh      | 29 +++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 4f07ac9fa207..e0caef9cbe5f 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -44,6 +44,7 @@ extern int optind;
 #endif
 
 static int  poll_timeout = 10 * 1000;
+static bool abnormal_connection;
 static bool listen_mode;
 static bool quit;
 
@@ -1422,7 +1423,7 @@ static void parse_opts(int argc, char **argv)
 {
 	int c;
 
-	while ((c = getopt(argc, argv, "6c:f:hi:I:jlm:M:o:p:P:r:R:s:S:t:T:w:")) != -1) {
+	while ((c = getopt(argc, argv, "6c:f:hi:I:jlAm:M:o:p:P:r:R:s:S:t:T:w:")) != -1) {
 		switch (c) {
 		case 'f':
 			cfg_truncate = atoi(optarg);
@@ -1500,6 +1501,9 @@ static void parse_opts(int argc, char **argv)
 		case 'o':
 			parse_setsock_options(optarg);
 			break;
+		case 'A':
+			abnormal_connection = true;
+			break;
 		}
 	}
 
@@ -1511,6 +1515,29 @@ static void parse_opts(int argc, char **argv)
 		pf = AF_INET6;
 }
 
+int self_conn_no_listen(void)
+{
+	int fd = sock_listen_mptcp(cfg_host, cfg_port);
+	socklen_t addr_len = sizeof(struct sockaddr_in);
+	struct sockaddr_in addr;
+
+	if (fd < 0)
+		return 1;
+
+	if (getsockname(fd, (struct sockaddr *)&addr, &addr_len) < 0) {
+		perror("getsockname() failed");
+		close(fd);
+		exit(1);
+	}
+
+	shutdown(fd, SHUT_RD);
+
+	connect(fd, (struct sockaddr *)&addr, addr_len);
+
+	close(fd);
+	return 0;
+}
+
 int main(int argc, char *argv[])
 {
 	init_rng();
@@ -1536,5 +1563,8 @@ int main(int argc, char *argv[])
 		return main_loop_s(fd);
 	}
 
+	if (abnormal_connection)
+		return self_conn_no_listen();
+
 	return main_loop();
 }
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 5e3c56253274..b0c68d83a28b 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -819,6 +819,32 @@ run_tests_disconnect()
 	connect_per_transfer=1
 }
 
+run_tests_selfconn_no_listen()
+{
+	local count
+	local msg
+
+	mptcp_lib_pr_info "${TEST_GROUP} test"
+
+	print_larger_title "Client fallback due to connecting to itself "
+	ip netns exec $1 ./mptcp_connect -p 10000 -s MPTCP -A 127.0.0.1
+	count=$(mptcp_lib_get_counter $1 "MPTcpExtSimultConnectFallback")
+
+	if [ -z "$count" ]; then
+		mptcp_lib_pr_skip "Self conn fallback counter not supported"
+		mptcp_lib_result_skip "${TEST_GROUP}"
+		msg="SKIP"
+	elif [ "$count" -le 0 ]; then
+		mptcp_lib_pr_fail "got $count self conn fallback expected 1"
+		msg="Fail"
+	else
+		mptcp_lib_pr_ok
+		msg="Pass"
+	fi
+
+	mptcp_lib_pr_info "test ${TEST_GROUP} ${msg}"
+}
+
 display_time()
 {
 	time_end=$(date +%s)
@@ -883,6 +909,9 @@ mptcp_lib_result_code "${ret}" "ping tests"
 stop_if_error "Could not even run ping tests"
 mptcp_lib_pr_ok
 
+TEST_GROUP=" test self connection"
+run_tests_selfconn_no_listen ${ns1}
+
 [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms
 tc_info="loss of $tc_loss "
 test "$tc_delay" -gt 0 && tc_info+="delay $tc_delay ms "
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC mptcp-next] selftests: mptcp: Add a test for self-conn fallback
  2025-08-14  6:58 [RFC mptcp-next] selftests: mptcp: Add a test for self-conn fallback Gang Yan
@ 2025-08-14  8:51 ` MPTCP CI
  2025-08-14  8:57   ` GangYan
  0 siblings, 1 reply; 4+ messages in thread
From: MPTCP CI @ 2025-08-14  8:51 UTC (permalink / raw)
  To: Gang Yan; +Cc: mptcp

Hi Gang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Unstable: 3 failed test(s): packetdrill_dss packetdrill_mp_capable selftest_mptcp_connect_checksum 🔴
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs_mptcp 🔴
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/16958528774

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a48b6ab5e005
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=991327


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC mptcp-next] selftests: mptcp: Add a test for self-conn fallback
  2025-08-14  8:51 ` MPTCP CI
@ 2025-08-14  8:57   ` GangYan
  2025-08-14 14:41     ` Matthieu Baerts
  0 siblings, 1 reply; 4+ messages in thread
From: GangYan @ 2025-08-14  8:57 UTC (permalink / raw)
  To: mptcp

>On Thu, Aug 14, 2025 at 08:51:13AM +0000, MPTCP CI wrote:
Hi Matt,

I noticed the 'MPTCP_MIB_SIMULTCONNFALLBACK' is not coverd by selftests
through 'code_coverage'. So, I add a test according to issue#35, and I
would like to seek your advice on the following points:

-Is it suitable to add a test like this patch to cover this part of code?
-If yes, please give me some feedback on modification suggestions about
this patch.
    
Thanks.
Gang
> Hi Gang,
> 
> Thank you for your modifications, that's great!
> 
> Our CI did some validations and here is its report:
> 
> - KVM Validation: normal: Success! ✅
> - KVM Validation: debug: Unstable: 3 failed test(s): packetdrill_dss packetdrill_mp_capable selftest_mptcp_connect_checksum 🔴
> - KVM Validation: btf-normal (only bpftest_all): Success! ✅
> - KVM Validation: btf-debug (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs_mptcp 🔴
> - Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/16958528774
> 
> Initiator: Patchew Applier
> Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a48b6ab5e005
> Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=991327
> 
> 
> If there are some issues, you can reproduce them using the same environment as
> the one used by the CI thanks to a docker image, e.g.:
> 
>     $ cd [kernel source code]
>     $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
>         --pull always mptcp/mptcp-upstream-virtme-docker:latest \
>         auto-normal
> 
> For more details:
> 
>     https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
> 
> 
> Please note that despite all the efforts that have been already done to have a
> stable tests suite when executed on a public CI like here, it is possible some
> reported issues are not due to your modifications. Still, do not hesitate to
> help us improve that ;-)
> 
> Cheers,
> MPTCP GH Action bot
> Bot operated by Matthieu Baerts (NGI0 Core)
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC mptcp-next] selftests: mptcp: Add a test for self-conn fallback
  2025-08-14  8:57   ` GangYan
@ 2025-08-14 14:41     ` Matthieu Baerts
  0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2025-08-14 14:41 UTC (permalink / raw)
  To: GangYan, mptcp

Hi Gang,

On 14/08/2025 10:57, GangYan wrote:
>> On Thu, Aug 14, 2025 at 08:51:13AM +0000, MPTCP CI wrote:
> Hi Matt,
> 
> I noticed the 'MPTCP_MIB_SIMULTCONNFALLBACK' is not coverd by selftests
> through 'code_coverage'. So, I add a test according to issue#35, and I
> would like to seek your advice on the following points:
> 
> -Is it suitable to add a test like this patch to cover this part of code?
> -If yes, please give me some feedback on modification suggestions about
> this patch.

Good idea to cover this.

My fear is that this test might be unstable, no?

Is it not easier to reproduce this with Packetdrill test? e.g.

> `../common/defaults.sh`
> 
>  0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_MPTCP) = 3
> +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
> 
> +0 > S  0:0(0)                 <mss 1460, sackOK, TS val 100 ecr 0,   nop, wscale 8, mpcapable v1 flags[flag_h] nokey>
> +0 < S  0:0(0) win 1000        <mss 1460, sackOK, TS val 407 ecr 0,   nop, wscale 8, mpcapable v1 flags[flag_h] nokey>
> +0 > S. 0:0(0) ack 1           <mss 1460, sackOK, TS val 330 ecr 0,   nop, wscale 8, mpcapable v1 flags[flag_h] nokey>
> +0 < S. 0:0(0) ack 1 win 65535 <mss 1460, sackOK, TS val 700 ecr 100, nop, wscale 8, mpcapable v1 flags[flag_h] key[skey=2]>
> +0 >  . 1:1(0)     ack 1 <nop, nop, TS val 845707014 ecr 700, nop, nop, sack 0:1>
Then check the MIB counter.

(Note: I didn't check, the alignment is not OK, just wrote it very quickly)

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-14 14:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14  6:58 [RFC mptcp-next] selftests: mptcp: Add a test for self-conn fallback Gang Yan
2025-08-14  8:51 ` MPTCP CI
2025-08-14  8:57   ` GangYan
2025-08-14 14:41     ` Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).