mptcp: prevent MPC handshake on port-based signal endpoints
Subsystems (3)
Matthieu Baerts (NGI0)
maintainerv2 cover mptcp: prevent MPC handshake on port-based signal endpoints
This is a v2 for the series sent by Paolo, related to the lockdep splat Syzbot reported a few weeks ago, and for which Cong Wang sent a different attempt (Thanks both!).
In this v2, I applied the suggestions I sent on the ML:
- patch 1:
- moving and renaming the MIB counters
- move comments/functions on one line when possbile
- rename subflow_reset_req -> _endp
- use MPTCP_RST_EPROHIBIT reason
- patch 2:
- fix shellcheck issues
- capture: handle $capout
- fix indentation issue
- helper for the port
- stop the capture after transfer like before
- move new test to 'add addr ports' ones
- move the validation part to a new helper
- add missing 'check' names (subtitles)
- skip if no counters
---
Paolo Abeni (2):
mptcp: prevent MPC handshake on port-based signal endpoints
selftests: mptcp: join: add test-case for MPC attempt towards signl ep
net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/pm_netlink.c | 1 + net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 11 +++ tools/testing/selftests/net/mptcp/mptcp_join.sh | 110 +++++++++++++++++++----- 6 files changed, 102 insertions(+), 23 deletions(-)
---
base-commit: 2ce52e0f26d35f97f56615bb7854afa633f5d231
change-id: 20241007-mpc-hs-port-13a6c6c11b38
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts (NGI0)
maintainerPATCH v2 1/2 mptcp: prevent MPC handshake on port-based signal endpoints
From: Paolo Abeni <[email protected]>
Syzkaller reported a lockdep splat:
============================================
WARNING: possible recursive locking detected 6.11.0-rc6-syzkaller-00019-g67784a74e258 #0 Not tainted
--------------------------------------------
syz-executor364/5113 is trying to acquire lock:
ffff8880449f1958 (k-slock-AF_INET){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline] ffff8880449f1958 (k-slock-AF_INET){+.-.}-{2:2}, at: sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
but task is already holding lock:
ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline] ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(k-slock-AF_INET);
lock(k-slock-AF_INET);*** DEADLOCK ***
May be due to missing lock nesting notation
7 locks held by syz-executor364/5113:
#0: ffff8880449f0e18 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1607 [inline] #0: ffff8880449f0e18 (sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_sendmsg+0x153/0x1b10 net/mptcp/protocol.c:1806 #1: ffff88803fe39ad8 (k-sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1607 [inline] #1: ffff88803fe39ad8 (k-sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_sendmsg_fastopen+0x11f/0x530 net/mptcp/protocol.c:1727 #2: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline] #2: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline] #2: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: __ip_queue_xmit+0x5f/0x1b80 net/ipv4/ip_output.c:470 #3: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline] #3: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline] #3: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: ip_finish_output2+0x45f/0x1390 net/ipv4/ip_output.c:228 #4: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: local_lock_acquire include/linux/local_lock_internal.h:29 [inline] #4: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: process_backlog+0x33b/0x15b0 net/core/dev.c:6104 #5: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline] #5: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline] #5: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: ip_local_deliver_finish+0x230/0x5f0 net/ipv4/ip_input.c:232 #6: ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline] #6: ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
stack backtrace: CPU: 0 UID: 0 PID: 5113 Comm: syz-executor364 Not tainted 6.11.0-rc6-syzkaller-00019-g67784a74e258 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 check_deadlock kernel/locking/lockdep.c:3061 [inline] validate_chain+0x15d3/0x5900 kernel/locking/lockdep.c:3855 __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5142 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline] _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154 spin_lock include/linux/spinlock.h:351 [inline] sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328 mptcp_sk_clone_init+0x32/0x13c0 net/mptcp/protocol.c:3279 subflow_syn_recv_sock+0x931/0x1920 net/mptcp/subflow.c:874 tcp_check_req+0xfe4/0x1a20 net/ipv4/tcp_minisocks.c:853 tcp_v4_rcv+0x1c3e/0x37f0 net/ipv4/tcp_ipv4.c:2267 ip_protocol_deliver_rcu+0x22e/0x440 net/ipv4/ip_input.c:205 ip_local_deliver_finish+0x341/0x5f0 net/ipv4/ip_input.c:233 NF_HOOK+0x3a4/0x450 include/linux/netfilter.h:314 NF_HOOK+0x3a4/0x450 include/linux/netfilter.h:314 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x2bf/0x650 net/core/dev.c:5775 process_backlog+0x662/0x15b0 net/core/dev.c:6108 __napi_poll+0xcb/0x490 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0x89b/0x1240 net/core/dev.c:6963 handle_softirqs+0x2c4/0x970 kernel/softirq.c:554 do_softirq+0x11b/0x1e0 kernel/softirq.c:455 </IRQ> <TASK> __local_bh_enable_ip+0x1bb/0x200 kernel/softirq.c:382 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:908 [inline] __dev_queue_xmit+0x1763/0x3e90 net/core/dev.c:4450 dev_queue_xmit include/linux/netdevice.h:3105 [inline] neigh_hh_output include/net/neighbour.h:526 [inline] neigh_output include/net/neighbour.h:540 [inline] ip_finish_output2+0xd41/0x1390 net/ipv4/ip_output.c:235 ip_local_out net/ipv4/ip_output.c:129 [inline] __ip_queue_xmit+0x118c/0x1b80 net/ipv4/ip_output.c:535 __tcp_transmit_skb+0x2544/0x3b30 net/ipv4/tcp_output.c:1466 tcp_rcv_synsent_state_process net/ipv4/tcp_input.c:6542 [inline] tcp_rcv_state_process+0x2c32/0x4570 net/ipv4/tcp_input.c:6729 tcp_v4_do_rcv+0x77d/0xc70 net/ipv4/tcp_ipv4.c:1934 sk_backlog_rcv include/net/sock.h:1111 [inline] __release_sock+0x214/0x350 net/core/sock.c:3004 release_sock+0x61/0x1f0 net/core/sock.c:3558 mptcp_sendmsg_fastopen+0x1ad/0x530 net/mptcp/protocol.c:1733 mptcp_sendmsg+0x1884/0x1b10 net/mptcp/protocol.c:1812 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x1a6/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2597 ___sys_sendmsg net/socket.c:2651 [inline] __sys_sendmmsg+0x3b2/0x740 net/socket.c:2737 __do_sys_sendmmsg net/socket.c:2766 [inline] __se_sys_sendmmsg net/socket.c:2763 [inline] __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2763 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f04fb13a6b9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 1a 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffd651f42d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000133 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f04fb13a6b9 RDX: 0000000000000001 RSI: 0000000020000d00 RDI: 0000000000000004 RBP: 00007ffd651f4310 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000020000080 R11: 0000000000000246 R12: 00000000000f4240 R13: 00007f04fb187449 R14: 00007ffd651f42f4 R15: 00007ffd651f4300 </TASK>
As noted by Cong Wang, the splat is false positive, but the code path leading to the report is an unexpected one: a client is attempting an MPC handshake towards the in-kernel listener created by the in-kernel PM for a port based signal endpoint.
Such connection will be never accepted; many of them can make the listener queue full and preventing the creation of MPJ subflow via such listener - its intended role.
Explicitly detect this scenario at initial-syn time and drop the incoming MPC request.
--- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/pm_netlink.c | 1 + net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 11 +++++++++++ 5 files changed, 15 insertions(+)
net/mptcp/mib.c +1 -0
@@ -17,6 +17,7 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("MPCapableFallbackSYNACK" ,MPTCP_MIB_MPCAPABLEACTIVEFALLBACK ),SNMP_MIB_ITEM ("MPCapableSYNTXDrop" ,MPTCP_MIB_MPCAPABLEACTIVEDROP ),SNMP_MIB_ITEM ("MPCapableSYNTXDisabled" ,MPTCP_MIB_MPCAPABLEACTIVEDISABLED ), +SNMP_MIB_ITEM ("MPCapableEndpAttempt" ,MPTCP_MIB_MPCAPABLEENDPATTEMPT ),SNMP_MIB_ITEM ("MPFallbackTokenInit" ,MPTCP_MIB_TOKENFALLBACKINIT ),SNMP_MIB_ITEM ("MPTCPRetrans" ,MPTCP_MIB_RETRANSSEGS ), SNMP_MIB_ITEM("MPJoinNoTokenFound", MPTCP_MIB_JOINNOTOKEN),
net/mptcp/mib.h +1 -0
@@ -12,6 +12,7 @@ enum linux_mptcp_mib_field {MPTCP_MIB_MPCAPABLEACTIVEFALLBACK ,/* Client-side fallback during 3-way handshake */ MPTCP_MIB_MPCAPABLEACTIVEDROP ,/* Client-side fallback due to a MPC drop */ MPTCP_MIB_MPCAPABLEACTIVEDISABLED ,/* Client-side disabled due to past issues */ +MPTCP_MIB_MPCAPABLEENDPATTEMPT ,/* Prohibited MPC attempted towards a port-based signal endp */ MPTCP_MIB_TOKENFALLBACKINIT ,/* Could not init/allocate token */ MPTCP_MIB_RETRANSSEGS ,/* Segments retransmitted at the MPTCP-level */ MPTCP_MIB_JOINNOTOKEN, /* Received MP_JOIN but the token was not found */
net/mptcp/pm_netlink.c +1 -0
@@ -1129,6 +1129,7 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,*/ inet_sk_state_store (newsk,TCP_LISTEN );lock_sock (ssk); +WRITE_ONCE (mptcp_subflow_ctx (ssk)->pm_listener, true); err =__inet_listen_sk (ssk, backlog);if (!err)mptcp_event_pm_listener (ssk,MPTCP_EVENT_LISTENER_CREATED );
net/mptcp/protocol.h +1 -0
@@ -532,6 +532,7 @@ struct mptcp_subflow_context { close_event_done : 1, /* has done the post-closed part */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ __unused : 9; +bool pm_listener;/* subflow is a listener managed by the in-kernel PM */ bool data_avail;bool scheduled;bool fully_established;/* path validated */
net/mptcp/subflow.c +11 -0
@@ -132,6 +132,13 @@ static void subflow_add_reset_reason(struct sk_buff *skb, u8 reason) } } +static int subflow_reset_req_endp (struct request_sock *req,struct sk_buff *skb) +{ +SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_MPCAPABLEENDPATTEMPT ); +subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); +return -EPERM ; +} +/* Init mptcp request socket. * * Returns an error code if a JOIN has failed and a TCP reset
@@ -165,6 +172,8 @@ static int subflow_check_req(struct request_sock *req,if (opt_mp_capable) {SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_MPCAPABLEPASSIVE ); +if (unlikely (listener->pm_listener)) +return subflow_reset_req_endp (req, skb);if (opt_mp_join)return 0 ; }else if (opt_mp_join) {
@@ -172,6 +181,8 @@ static int subflow_check_req(struct request_sock *req,if (mp_opt.backup)SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINSYNBACKUPRX ); + }else if (unlikely (listener->pm_listener)) { +return subflow_reset_req_endp (req, skb); }if (opt_mp_capable && listener->request_mptcp) {
Signature · 1 line
2.45.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
Matthieu Baerts
maintainerHi Paolo,
(I guess you dropped the MPTCP ML from Cc by mistake, re-adding it)
Quoted 4 lines · Paolo Abeni
Quoted 3 lines · On 10/7/24 20:22, Matthieu Baerts (NGI0) wrote:
From: Paolo Abeni <[email protected]>
Syzkaller reported a lockdep splat:
(...)
Quoted 8 lines
Quoted 6 lines
Fixes 1729cf186d8a ("mptcp: create the listening socket for new port")Reported-by [email protected]Cc Cong Wang <[email protected]>Signed-off-by Paolo Abeni <[email protected]>Reviewed-by Matthieu Baerts (NGI0) <[email protected]>Please add your co-dev tag instead here.
I only cleaned-up comments, etc. without changing the behaviour, I sent the v2 mainly because I had the suggested changes on my side already (when checking if comments could go on one line, checking shellcheck with the other patch, etc.). I can add it on the other patch, because I might have done more modifications changing a bit the behaviour, but I can add my co-dev tag here as well if you prefer.
(...)
Quoted 7 lines
Quoted 7 lines
net/mptcp/subflow.c +0
-0index
a1e28e1d8b4e39e14bc8f98164013d302d62595c..5958b63f84469b980bb1af472117643baf740713100644net/mptcp/subflow.c +0
-0@@ -132,6 +132,13 @@ static void subflow_add_reset_reason(struct sk_buff *skb, u8 reason)
Quoted 8 lines
Quoted 4 lines
net/mptcp/subflow.c +0
-0} }+static int
subflow_reset_req_endp(struct request_sock *req, struct sk_buff *skb)I used a different name because I was wondering about to re-using this helper in future patches for other req reset - passing explicitly reason and mib. I guess we can rename it as needed later.
Good point. But yes, probably better to rename it later on if we want something more generic, taking different parameters.
Quoted 3 lines
Side note: Jakub still strongly prefers not exceeding the 80 chars per column. A couple of comments and the above line are now above such threshold.
Mmh, I think we mostly followed the default 100 chars max per line in our code. We don't abuse it though: we use more than 80 to improve the readability, e.g. when the opening parenthesis is "too close" to the end of the line, when each line needs a comment next to, most multilines comments are under 80 chars, etc. In other words, if we want to enforce the max of 80 chars per line, we might uniform that, but I don't think that's worth it. Or do you think we should?
In this patch, only the comments are above 80 chars, but they are aligned with the ones just above and below. I can still reduce them I see:
/* Prohibited MPC attempted towards a port-based signal endp */ /* Prohibited MPC towards a port-based signal endp */
/* subflow is a listener managed by the in-kernel PM */ /* a listener managed by the kernel PM? */
No hurry, I guess we can send this patch later on.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Paolo Abeni
maintainerQuoted 5 lines · Matthieu Baerts
Quoted 4 lines · On 10/7/24 20:22, Matthieu Baerts (NGI0) wrote:
Side note: Jakub still strongly prefers not exceeding the 80 chars per column. A couple of comments and the above line are now above such threshold.
Quoted 7 lines
Mmh, I think we mostly followed the default 100 chars max per line in our code. We don't abuse it though: we use more than 80 to improve the readability, e.g. when the opening parenthesis is "too close" to the end of the line, when each line needs a comment next to, most multilines comments are under 80 chars, etc. In other words, if we want to enforce the max of 80 chars per line, we might uniform that, but I don't think that's worth it. Or do you think we should?
My take is that we should avoid adding more lines exceeding 80 chars, when possible.
Quoted 11 lines
In this patch, only the comments are above 80 chars, but they are aligned with the ones just above and below. I can still reduce them I see:
/* Prohibited MPC attempted towards a port-based signal endp */ /* Prohibited MPC towards a port-based signal endp */ /* subflow is a listener managed by the in-kernel PM */ /* a listener managed by the kernel PM? */No hurry, I guess we can send this patch later on.
I would opt for the multi-line comment.
/P
Matthieu Baerts
maintainerQuoted 14 lines · Paolo Abeni
Quoted 5 lines · Matthieu Baerts
Quoted 4 lines · On 10/7/24 20:22, Matthieu Baerts (NGI0) wrote:
Side note: Jakub still strongly prefers not exceeding the 80 chars per column. A couple of comments and the above line are now above such threshold.
Quoted 7 lines
Mmh, I think we mostly followed the default 100 chars max per line in our code. We don't abuse it though: we use more than 80 to improve the readability, e.g. when the opening parenthesis is "too close" to the end of the line, when each line needs a comment next to, most multilines comments are under 80 chars, etc. In other words, if we want to enforce the max of 80 chars per line, we might uniform that, but I don't think that's worth it. Or do you think we should?
Quoted 2 lines
My take is that we should avoid adding more lines exceeding 80 chars, when possible.
OK, I will try to find something to have the new lines under 80 chars, and keep the consistency with the current code style.
Quoted 7 lines
Quoted 7 lines
In this patch, only the comments are above 80 chars, but they are aligned with the ones just above and below. I can still reduce them I see:
/* Prohibited MPC attempted towards a port-based signal endp */ /* Prohibited MPC towards a port-based signal endp */
Quoted 6 lines
Quoted 4 lines
/* subflow is a listener managed by the in-kernel PM */ /* a listener managed by the kernel PM? */
No hurry, I guess we can send this patch later on.
I would opt for the multi-line comment.
OK!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts (NGI0)
maintainerPATCH v2 2/2 selftests: mptcp: join: add test-case for MPC attempt towards signl ep
In reply to Matthieu Baerts (NGI0)From: Paolo Abeni <[email protected]>
Explicitly verify that MPC connection attempts towards a port-based signal endpoint fail with a reset.
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 110 +++++++++++++++++++----- 1 file changed, 87 insertions(+), 23 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +87 -23
@@ -41,6 +41,7 @@ evts_ns2_pid=0 last_test_failed=0 last_test_skipped=0 last_test_ignored=1 +cappid="" declare -A all_tests declare -a only_tests_ids
@@ -887,6 +888,43 @@ check_cestab() fi } +cond_start_capture() +{ + local ns="$1" + + :> "$capout" + + if $capture; then + local capuser capfile + if [ -z $SUDO_USER ]; then + capuser="" + else + capuser="-Z $SUDO_USER" + fi + + capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "$ns") + + echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile" + ip netns exec "$ns" tcpdump -i any -s 65535 -B 32768 $capuser -w "$capfile" > "$capout" 2>&1 & + cappid=$! + + sleep 1 + fi +} + +cond_stop_capture() +{ + if $capture; then + sleep 1 + kill $cappid + fi +} + +get_port() +{ + echo "$((10000 + MPTCP_LIB_TEST_COUNTER - 1))" +} + do_transfer() { local listener_ns="$1"
@@ -895,32 +933,16 @@ do_transfer() local srv_proto="$4" local connect_addr="$5" - local port=$((10000 + MPTCP_LIB_TEST_COUNTER - 1)) - local cappid local FAILING_LINKS=${FAILING_LINKS:-""} local fastclose=${fastclose:-""} local speed=${speed:-"fast"} + local port + port=$(get_port) :> "$cout" :> "$sout" - :> "$capout" - if $capture; then - local capuser - if [ -z $SUDO_USER ] ; then - capuser="" - else - capuser="-Z $SUDO_USER" - fi - - capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "${listener_ns}") - - echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile" - ip netns exec ${listener_ns} tcpdump -i any -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & - cappid=$! - - sleep 1 - fi + cond_start_capture ${listener_ns} NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ nstat -n
@@ -1007,10 +1029,7 @@ do_transfer() wait $spid local rets=$? - if $capture; then - sleep 1 - kill $cappid - fi + cond_stop_capture NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ nstat | grep Tcp > /tmp/${listener_ns}.out
@@ -2873,6 +2892,32 @@ verify_listener_events() fail_test } +chk_mpc_endp_attempt() +{ + local ret=$1 + local attempts=$2 + + print_check "Connect" + + if [ ${ret} = 124 ]; then + fail_test "timeout on connect" + elif [ ${ret} = 0 ]; then + fail_test "unexpected successful connect" + else + print_ok + + print_check "Attempts" + count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPCapableEndpAttempt") + if [ -z "$count" ]; then + print_skip + elif [ "$count" != "$attempts" ]; then + fail_test "got ${count} MPC attempt[s] on port-based endpoint, expected $attempts" + else + print_ok + fi + fi +} + add_addr_ports_tests() { # signal address with port
@@ -2963,6 +3008,25 @@ add_addr_ports_tests() chk_join_nr 2 2 2 chk_add_nr 2 2 2 fi + + if reset "port-based signal endpoint must not accept mpc"; then + local port ret count + port=$(get_port) + + cond_start_capture ${ns1} + + pm_nl_add_endpoint ${ns1} 10.0.2.1 flags signal port ${port} + mptcp_lib_wait_local_port_listen ${ns1} ${port} + + timeout 1 ip netns exec ${ns2} \ + ./mptcp_connect -t ${timeout_poll} -p $port -s MPTCP 10.0.2.1 >/dev/null 2>&1 + ret=$? + + cond_stop_capture + cat "$capout" + + chk_mpc_endp_attempt ${ret} 1 + fi } syncookies_tests()
Signature · 1 line
2.45.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
Matthieu Baerts
maintainerRe: [PATCH mptcp-net v2 2/2] selftests: mptcp: join: add test-case for MPC attempt towards signl ep
Hi Paolo,
(I guess you dropped the MPTCP ML from Cc by mistake, re-adding it)
Quoted 10 lines · Paolo Abeni
Quoted 7 lines · On 10/7/24 20:22, Matthieu Baerts (NGI0) wrote:
From: Paolo Abeni <[email protected]>
Explicitly verify that MPC connection attempts towards a port-based signal endpoint fail with a reset.
Signed-off-by Paolo Abeni <[email protected]>Reviewed-by Matthieu Baerts (NGI0) <[email protected]>Please put your co-dev tag above.
Sure, thank you, I can add that when applying the patch.
Quoted 13 lines
[...]
Quoted 10 lines
(quoted diff) +0
-0@@ -895,32 +933,16 @@ do_transfer()local srv_proto="$4"
local connect_addr="$5"
- local port=$((10000 +MPTCP_LIB_TEST_COUNTER- 1)) - local cappid
local FAILING_LINKS=${FAILING_LINKS:-""} local fastclose=${fastclose:-""}
local speed=${speed:-"fast"}
+ local port
+ port=$(get_port)At this point I would respect the reverse xmas tree order ;)
:)
Yes, probably best to move 'local port' above. Just to fix a non-interesting warning from shellcheck.
Quoted 15 lines
(quoted diff) +0
-0@@ -2963,6 +3008,25 @@ add_addr_ports_tests()Quoted 14 lines
chk_join_nr2 2 2
chk_add_nr2 2 2
fitools/testing/selftests/net/mptcp/mptcp_join.sh +11
-0+ + if reset "port-based signal endpoint must not accept mpc"; then + local port ret count + port=$(get_port) + + cond_start_capture ${ns1} + + pm_nl_add_endpoint ${ns1} 10.0.2.1 flags signal port ${port} + mptcp_lib_wait_local_port_listen ${ns1} ${port} + + timeout 1 ip netns exec ${ns2} \
Quoted 8 lines
Quoted 6 lines
+ ./mptcp_connect -t ${timeout_poll} -p $port -s MPTCP 10.0.2.1 >/dev/null 2>&1
+ ret=$?
+
+cond_stop_capture
+ cat "$capout"Perhaps worthy to move cat "$capout" into
cond_stop_capture()
I should have mentioned that in the changelog: I wanted to, but then it would change the behaviour for the other cases in do_transfer() where 'cat "$capout"' is used in 3 different places. I can suggest a patch for net-next, not to add more complexity in this patch if that's OK.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Paolo Abeni
maintainerRe: [PATCH mptcp-net v2 2/2] selftests: mptcp: join: add test-case for MPC attempt towards signl ep
Quoted 24 lines · Matthieu Baerts
Quoted 15 lines
(quoted diff) +0
-0@@ -2963,6 +3008,25 @@ add_addr_ports_tests()Quoted 14 lines
chk_join_nr2 2 2
chk_add_nr2 2 2
fitools/testing/selftests/net/mptcp/mptcp_join.sh +11
-0+ + if reset "port-based signal endpoint must not accept mpc"; then + local port ret count + port=$(get_port) + + cond_start_capture ${ns1} + + pm_nl_add_endpoint ${ns1} 10.0.2.1 flags signal port ${port} + mptcp_lib_wait_local_port_listen ${ns1} ${port} + + timeout 1 ip netns exec ${ns2} \Quoted 8 lines
Quoted 6 lines
+ ./mptcp_connect -t ${timeout_poll} -p $port -s MPTCP 10.0.2.1 >/dev/null 2>&1
+ ret=$?
+
+cond_stop_capture
+ cat "$capout"Perhaps worthy to move cat "$capout" into
cond_stop_capture()
Quoted 3 lines
I should have mentioned that in the changelog: I wanted to, but then it would change the behaviour for the other cases in
do_transfer()where 'cat "$capout"' is used in 3 different places.
Why would that change the behavior? AFAICS the 'cat "$capout" statement happend onece per do_transfer() invocation, just before 'return'. Moving it into cond_stop_capture would just reduce code duplication.
/P
Matthieu Baerts
maintainerRe: [PATCH mptcp-net v2 2/2] selftests: mptcp: join: add test-case for MPC attempt towards signl ep
Quoted 25 lines · Paolo Abeni
Quoted 24 lines · Matthieu Baerts
Quoted 23 lines
(quoted diff) +0
-0@@ -2963,6 +3008,25 @@ add_addr_ports_tests()Quoted 15 lines
chk_join_nr2 2 2
chk_add_nr2 2 2
fitools/testing/selftests/net/mptcp/mptcp_join.sh +12
-0+ + if reset "port-based signal endpoint must not accept mpc"; then + local port ret count + port=$(get_port) + + cond_start_capture ${ns1} + + pm_nl_add_endpoint ${ns1} 10.0.2.1 flags signal port ${port} + mptcp_lib_wait_local_port_listen ${ns1} ${port} + + timeout 1 ip netns exec ${ns2} \ + ./mptcp_connect -t ${timeout_poll} -p $port -s MPTCPQuoted 5 lines
10.0.2.1 >/dev/null 2>&1
+ ret=$?
+
+cond_stop_capture
+ cat "$capout"Perhaps worthy to move cat "$capout" into
cond_stop_capture()
Quoted 7 lines
Quoted 3 lines
I should have mentioned that in the changelog: I wanted to, but then it would change the behaviour for the other cases in
do_transfer()where 'cat "$capout"' is used in 3 different places.Why would that change the behavior? AFAICS the 'cat "$capout" statement happend onece per
do_transfer()invocation, just before 'return'. Moving it intocond_stop_capturewould just reduce code duplication.
Yes, but the info about the capture will be printed earlier. Will tcpdump still have time to flush all the last info into this file, before the 'cat'? I guess that's not a big deal to do that, and if there are conflicts when doing backports, we can also drop the patch from the backports.
Also, talking about backports, should we add the same 'Fixes' tag as for the previous patch, and add this in the commit message?
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.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Hi Paolo,
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: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/11221914489
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/8f0ae8ed9298
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=896357
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-normalFor 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)