From patchwork Wed Apr 2 02:53:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14035512 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6AAD1F5EA for ; Wed, 2 Apr 2025 02:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743562398; cv=none; b=IGNSH4ksKuYOijsMmDH67Ui7bdYnxgkK9iH1Mbg2K0mQQRNWRJF16Y2mTkW8Wpar1LFuJXIUDmwlB8WznFp4Ydj4Ol2PcXYR45NvPzshGJELlY7MMBLOMD7TcK2aqQnbwJ5QMLRNWAgj831iLI5N5rCOMiU0xkcHL22x1B4PYBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743562398; c=relaxed/simple; bh=ixbxNcyIEzcBesSmeq4VBPB/qbiTpd1kzfZOphjwPsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KN1qvANPHwJGJvUfknb7IvVQaT6XMf9nUB2nUQuyC5Fk415FE0B2vxc3ePjeYTNMz9s5jtA3LvbeLFjv8TQ+fa3+a0iLzCcCqL7VKrushYXI8K7rDiM+5q4qDfpytZjpuimZnOywQC+OCQYWm5swXwiD4zi5LAs5+AMe5p+ZssM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SYBZyNT3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SYBZyNT3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32981C4CEE8; Wed, 2 Apr 2025 02:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743562396; bh=ixbxNcyIEzcBesSmeq4VBPB/qbiTpd1kzfZOphjwPsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYBZyNT3W0Sp/wxkXr0hoNQ+g+8BZfU9QQjjvvUU+wr8lruTM6GzZJngpTuVg2nQf P/FUjdnyuonW/B0eaaLDGniwAr+Df1cXzBJmSRHC3xPjugwaXb0xRfFwXb97wAQMOV 9mONrm6W7GrJz3/FD3kNp254ezLOErqMHT6tuuT3m72UMTsclshRml/mRBlomQiRgI cbWikYNOOAfhW6zgSHV6WWJNxhojJu8jEOKlBQNeskXEPL0Dm8ozvm+tNXZXTTzRCY c1epCtKYKJo+9/wcgCM5QeXXAN5my2+cfesPyxfWT7t4AdR4sQwydBxkmCm6hJUp2N s+XmJrM/QOKAg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 1/3] mptcp: pm: userspace: local_addr_used-- after sending REMOVE_ADDR Date: Wed, 2 Apr 2025 10:53:07 +0800 Message-ID: <4f0b16c622b2714069acf8607de0d4e7f0c013ea.1743562290.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Address entries are removed from local_addr_list when sending a REMOVE_ADDR by the userspace PM, the local_addr_used counter of PM should also be decremented accordingly. Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE") Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 7fc19b844384..db471eb836b3 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -331,6 +331,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) } list_del_rcu(&match->list); + msk->pm.local_addr_used--; spin_unlock_bh(&msk->pm.lock); mptcp_pm_remove_addr_entry(msk, match); From patchwork Wed Apr 2 02:53:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14035513 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFB951B7F4 for ; Wed, 2 Apr 2025 02:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743562399; cv=none; b=RmRMk6fd1M3E0LkTM3SpeP7H74Q0akHMfom5Gv9fIdRkpLmnuVKLYQRT9YWGiJA0oGjJgnxIV1c1a0i7Q39vBxRvmAvjzlO+HoXiJd5JJvAP3zErt6LT+6hh1jCVKD8JZ9mXQeQ/Tz2iI6SyqSiTU9ypMEO2QoUSs70qV2Y/pEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743562399; c=relaxed/simple; bh=G5E9/HlwhUJ14XucItH8hBrV6zJAQ4p5TWKjV8Re1I4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=moCElmW4ZsHA4oKoNmGB4zqpfC6VpmdobHMDDSrUIQqWdVyxaZs78z/VA9dY/TibPy5r16JT9J3osUCfibOumOL7KJbgRVwznf9nukbLRmZ2ivgLSbckiOlG0fCPBAsKfS7tfCzuo5pkMge+bD6it3bT5dXOLFgKT28HJzyGzQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FHdFTEAN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FHdFTEAN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8849C4CEE4; Wed, 2 Apr 2025 02:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743562398; bh=G5E9/HlwhUJ14XucItH8hBrV6zJAQ4p5TWKjV8Re1I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FHdFTEANVgiIqnbeWAFstzo9lD2kk4n4SeesRvaqr2LxSqFLOhksnsoBggJV69Afp u+80znoX+99t+rpYaGMT9yriGk3cq6E1/SxHVzRZ1ejxYsx4vfOXi565IiAJqFyk+I tnCVK8VYZMKdwKjfnHB7kvoBcZBkRZmw2Da1eCCvST9NCKSpO6yPu0KLiRZcGBzQx+ Re8+x4PXYWmU5uSMld4NNfXFIB9HBBSO9pw8Jk+Di1tHdP1AL1RjLO4vREi1lAv3zK jK9gEamDzOB0XmdnW446J6P2PAmljcL/5f0uBalsfuMwh3Can6IKBKzbiFWrkACGJP Tz744VzaIdpgQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 2/3] mptcp: pm: userspace: drop delete_local_addr helper Date: Wed, 2 Apr 2025 10:53:08 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Address entries should not be removed from local_addr_list when a subflow is deleted by the userspace PM, should only be removed when sending a REMOVE_ADDR. So mptcp_userspace_pm_delete_local_addr() helper shouldn't be called in mptcp_pm_nl_subflow_create_doit() and mptcp_pm_nl_subflow_destroy_doit(). Since this helper is open-coding in mptcp_pm_nl_remove_doit(), it can be dropped now. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/403 Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index db471eb836b3..3824b4165421 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -90,30 +90,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, return ret; } -/* If the subflow is closed from the other peer (not via a - * subflow destroy command then), we want to keep the entry - * not to assign the same ID to another address and to be - * able to send RM_ADDR after the removal of the subflow. - */ -static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *addr) -{ - struct sock *sk = (struct sock *)msk; - struct mptcp_pm_addr_entry *entry; - - entry = mptcp_userspace_pm_lookup_addr(msk, &addr->addr); - if (!entry) - return -EINVAL; - - /* TODO: a refcount is needed because the entry can - * be used multiple times (e.g. fullmesh mode). - */ - list_del_rcu(&entry->list); - sock_kfree_s(sk, entry, sizeof(*entry)); - msk->pm.local_addr_used--; - return 0; -} - static struct mptcp_pm_addr_entry * mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) { @@ -409,14 +385,13 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) err = __mptcp_subflow_connect(sk, &local, &addr_r); release_sock(sk); - if (err) + if (err) { GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err); + goto create_err; + } spin_lock_bh(&msk->pm.lock); - if (err) - mptcp_userspace_pm_delete_local_addr(msk, &entry); - else - msk->pm.subflows++; + msk->pm.subflows++; spin_unlock_bh(&msk->pm.lock); create_err: @@ -535,9 +510,6 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info goto release_sock; } - spin_lock_bh(&msk->pm.lock); - mptcp_userspace_pm_delete_local_addr(msk, &addr_l); - spin_unlock_bh(&msk->pm.lock); mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN | SEND_SHUTDOWN); mptcp_close_ssk(sk, ssk, mptcp_subflow_ctx(ssk)); MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW); From patchwork Wed Apr 2 02:53:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14035514 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 248691B7F4 for ; Wed, 2 Apr 2025 02:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743562400; cv=none; b=Z+eu+NzIoiBUBawVQWtYsO8p+zemGFiSNq4SoFT5xx+vgXVK2JNHE0Trp5ZlQ/SnCTO+9KEdYVn6zrvpKlaMQSktyCMWJa1z2NUb9fAGk0zKDEZZq48JVG2Jdftx63MTddHQIkJZAzOvnDMZz2suzHB09a0QgtSo4QLBCo19SM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743562400; c=relaxed/simple; bh=X4dT8D1hIN7DnSRAzJ8z0FXhAaUlQJmFiZ4YWZfnzGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mCf5QW8EezHjHp9+tUDai2RpZudpnZn2TZh01lY4ZOjqYa4g9RUc87lpj1/TuMLnJoR86568C35j082NPgaGlbmGFugADmDIbHX2HHnRxGPmGKSBuDvSVYc6eTt2ztElWiK5mlnOePruWL1o3x7pFI/CTCN2ELjFF8nEXAvyVdw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RSU9EgQU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RSU9EgQU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA855C4CEE8; Wed, 2 Apr 2025 02:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743562400; bh=X4dT8D1hIN7DnSRAzJ8z0FXhAaUlQJmFiZ4YWZfnzGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RSU9EgQUZEtWjObRAVoh5sLj7CGPQr7ChOS6bjg0ySI2bzt/SREnQfYP5E4GzyWvG XLSTI8rAUJ41u41LvBDeORKCzsaCSu/Ddus1FJoRyP+xwEgyNjY9Jem2Qg7PhddJrg fkR0Fm5dWZPL7Aj0nH8SQRPs5u4MDxkr+G3+bITLmdt6uebW2AqfWeSzVoK8gj4jor lLBGCZOPqVMKv+O6TLv6SVQHxj+PDmexrvlAmcurzSGj1qUBWaA4JheO97zya1ax6W DZmnjln6vJmMFrN4athEEbPazTW5454I85rBb+vLpQLEJ1I/DrrXYb9totaGiGwwFb 9fLcnyhmsxNOA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 3/3] selftests: mptcp: send REMOVE_ADDR after subflow is deleted Date: Wed, 2 Apr 2025 10:53:09 +0800 Message-ID: <6e9b7365c7b951d9addc8e9f208eeb9739fab28e.1743562290.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Now address entries only be removed from local_addr_list when sending a REMOVE_ADDR by the userspace PM, they're no longer removed when a subflow is deleted. To make the original userspace PM selftests pass, this patch always sends a REMOVE_ADDR when a subflow is deleted. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 +++- tools/testing/selftests/net/mptcp/userspace_pm.sh | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index b8af65373b3a..c138b4913ad8 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3624,11 +3624,12 @@ userspace_tests() userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1" userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1" userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $MPTCP_LIB_EVENT_SUB_ESTABLISHED + userspace_pm_rm_addr $ns1 10 userspace_pm_chk_dump_addr "${ns1}" \ "id 20 flags signal 10.0.3.1" "after rm_sf 10" userspace_pm_rm_addr $ns1 20 userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20" - chk_rm_nr 1 1 invert + chk_rm_nr 2 1 invert chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1 kill_events_pids @@ -3653,6 +3654,7 @@ userspace_tests() "subflow" userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2" userspace_pm_rm_sf $ns2 10.0.3.2 $MPTCP_LIB_EVENT_SUB_ESTABLISHED + userspace_pm_rm_addr $ns2 20 userspace_pm_chk_dump_addr "${ns2}" \ "" \ "after rm_sf 20" diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 333064b0b5ac..c16465c9c2ca 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -628,6 +628,7 @@ test_subflows() :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip dead:beef:2::1 lport "$sport" rip\ dead:beef:2::2 rport "$client6_port" token "$server6_token" + ip netns exec "$ns1" ./pm_nl_ctl rem id 23 token "$server6_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server6_token" "$AF_INET6"\ "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ @@ -667,6 +668,7 @@ test_subflows() :>"$server_evts" ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\ $new4_port token "$server4_token" + ip netns exec "$ns1" ./pm_nl_ctl rem id 23 token "$server4_token" sleep 0.5 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\ "10.0.2.2" "$new4_port" "23" "$client_addr_id" "ns1" "ns2" @@ -705,6 +707,7 @@ test_subflows() :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ $app4_port token "$client4_token" + ip netns exec "$ns2" ./pm_nl_ctl rem id 23 token "$client4_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\ "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" @@ -744,6 +747,7 @@ test_subflows() :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip dead:beef:2::2 lport "$sport" rip\ dead:beef:2::1 rport $app6_port token "$client6_token" + ip netns exec "$ns2" ./pm_nl_ctl rem id 23 token "$client6_token" sleep 0.5 verify_subflow_events $client_evts $SUB_CLOSED $client6_token $AF_INET6 "dead:beef:2::2"\ "dead:beef:2::1" "$app6_port" "23" "$server_addr_id" "ns2" "ns1" @@ -781,6 +785,7 @@ test_subflows() :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ $new4_port token "$client4_token" + ip netns exec "$ns2" ./pm_nl_ctl rem id 23 token "$client4_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\ "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" @@ -827,6 +832,7 @@ test_subflows_v4_v6_mix() :>"$client_evts" ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ $app6_port token "$client6_token" + ip netns exec "$ns2" ./pm_nl_ctl rem id 23 token "$client6_token" sleep 0.5 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client6_token" \ "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\