From patchwork Fri Jul 19 12:24:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737274 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 4837783CA1 for ; Fri, 19 Jul 2024 12:24:35 +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=1721391875; cv=none; b=gWpKMzRm9TO/Eb4der4Kyo4B9jcQVssik8zHKa3eD7pfZ01+0hPjJxDCudD4uORhKWGwqLHtPy4m5UI057de421kbrxxyivKb/qnqB+YefcrSJLdaNS4M5S6XNCOFJgu2TEqp1oyz2iko7PNp5hadPNp6i4mxkQgcLGTBJSnl60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391875; c=relaxed/simple; bh=lVYzLe5JrCLEvvxaysYG3kgQy2v6ncdEAEe/A6edulI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aZjb1uX9kSN09hIESpsI2dlQR7CnOg/vh8pxA5UWbSOyuObhrb2CNUG8RGAYV1W6mdFykkreI9a7rOx/sBIp0dUGg6yRc02CD48BcJdLThesT1JC8wEQkfLHKzfQMCdqmNu1+OPp+QsLEsULkvHn5v3VVMFkQDaCipPHUgIA6vg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t0+hsY0+; 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="t0+hsY0+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5FCC4AF0A; Fri, 19 Jul 2024 12:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391874; bh=lVYzLe5JrCLEvvxaysYG3kgQy2v6ncdEAEe/A6edulI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=t0+hsY0+lPtKQBZVBmM1DeYHiEpkBceAz4phE2USjVrwOp4qtDwqq6lmttt/HxJ3f QPLFxSsfJvsVB7j/3XFJiBhmAboweMKWNeBMOQkj8tk3m53RxRSFR5jdCarpanppiN dEkgGbg4w3rNAs6GkHyNwesaGdOJkhBeYGsOuVDYD6ZRKzwJGrUTcstlW2FCHNn2wr jP+BY0faNE87zqz5NurCwbO8ovfcVINLJ9jnphAsq9JRjB+cVTndh5oVjCVa0HoWfs ltqtMILGJ9K5RplqSiKmhin325MirTmmlue1aztsNyBcSZfwVu5Z4evOqLv1PvgK6S 35P3uD9hB/OLw== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:12 +0200 Subject: [PATCH mptcp-net v3 01/20] mptcp: fully established after ADD_ADDR echo on MPJ Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-1-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1655; i=matttbe@kernel.org; h=from:subject:message-id; bh=lVYzLe5JrCLEvvxaysYG3kgQy2v6ncdEAEe/A6edulI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/nt3aaCrUKmYcSue0ILOjyygt7FhRftky7 CKjXYDo/vKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c9ZqEACYdUYZcZmqQLszOTcHZiCf5qQ20eo3fE+/s/nVsQJA+w8Q/VFzqYb3T9Dr/HGTvk8k2bd mJOFPqP/sTZlEQne5aFwFY59C+Tx7sUoJZ68vYFDiHe0QptlQNSuwFTFrtcSfUdcgcQ553f24py Dk1bIFxVErsRNSdzluBZpC4xOTXk+VaUB1uNMTa6MJL2YAng+aQ+6cyDtaKnyPriaKkXV7rRIHV aNSpsOOxLJhReKcT+W4QXaMjReKXzbNh8faKmNgMVrXdUSod8UazzHGuVzQfKB3nvAH2LcyONqu Ohp0mTtsYbV0E6s0qsxkgawARr+1NGy9hLd/GwMnmvrAuoQ8vn967Masecg3F636Ep7M1glpK+6 x//Z1xxRPjdN1MG31gcLavMFqGA27CKJ2KRuOi+IwlROGU8+YGcbCo8HkxmXCj86jKTh8HrnPQc FV5lMoErv3Q8KAbkF5/DTmchfWScZdzSML9kA3bC6Bgk+B1FaXgqsaWp64wPsPcGL3rJuSW6aOw R/pMma5xHTUwgMrokW6A4YGEnNohKPLhcNAWGvHDYt27/OGLtkFbtIYd2jGCpSBMcFcVc92cKip Z/yLjWvQs6xSILlOfXW4SO5Spe2cityPVs3iq7Uxsob0/BEbVBc+3HMOb7LvSKAVAlHyYKDitxz ksweRU6FrRNpLDQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Before this patch, receiving an ADD_ADDR echo on the just connected MP_JOIN subflow -- initiator side, after the MP_JOIN 3WHS -- was resulting in an MP_RESET. That's because only ACKs with a DSS or ADD_ADDRs without the echo bit were allowed. Not allowing the ADD_ADDR echo after an MP_CAPABLE 3WHS makes sense, as we are not supposed to send an ADD_ADDR before because it requires to be in full established mode first. For the MP_JOIN 3WHS, that's different: the ADD_ADDR can be sent on a previous subflow, and the ADD_ADDR echo can be received on the recently created one. The other peer will already be in fully established, so it is allowed to send that. We can then relax the conditions here to accept the ADD_ADDR echo for MPJ subflows. Fixes: 67b12f792d5e ("mptcp: full fully established support after ADD_ADDR") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/options.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index c0832df3b0a3..4ee2e3605f5b 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -958,7 +958,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, if (subflow->remote_key_valid && (((mp_opt->suboptions & OPTION_MPTCP_DSS) && mp_opt->use_ack) || - ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) && !mp_opt->echo))) { + ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) && + (!mp_opt->echo || subflow->mp_join)))) { /* subflows are fully established as soon as we get any * additional ack, including ADD_ADDR. */ From patchwork Fri Jul 19 12:24:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737275 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 7C4A683CA1 for ; Fri, 19 Jul 2024 12:24:36 +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=1721391876; cv=none; b=ClfsBogbrISpfI+MvXm9qnSEbExmx/hZREOYW5SMUlLu03vEXR2HT0saJ4WfsOqxpQFk7Qvy6WRKPjVS0J81H/gP7PyP92lttyWzGySohv+kVgdqq/trJABi0f5OUDpO+ozlo/IXOvFaLbVlVZwFcvQWYoOcFrH2THhOL67tsKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391876; c=relaxed/simple; bh=VTCYuWArzYhunK5hbwYMqWdj9fMJvYLpw+Ge9TGDPd8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ptyWWfIuKjxYZ0scD4NZmteTKFxVxAJGY1oH3dCuvoaa5X3nA2NOquH3QU96q+YXQi/X/+8yEANfYyhpmLCtgHOF6rx51A7Ei1MGez18SovvxbOygGAQRWzdksu5YKwp8ZrR8CiakiRc4gbN7G/KjvX+Mxgxr59zjm9BU5a5tIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VXJdROZN; 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="VXJdROZN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 568CEC4AF09; Fri, 19 Jul 2024 12:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391876; bh=VTCYuWArzYhunK5hbwYMqWdj9fMJvYLpw+Ge9TGDPd8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VXJdROZNrkGpG9qcpNlquE6Ei2cbkP69MW6OcSqrn5wNF1Uxx+ydtOQ3cBZtiZzOL QJCMas88flCjPd0Rumdv5ofwUAIYXxxhf0JZTHOTPlsVo9dTVIDxxaTecCTezwvhfP 3ADyNfr455/ASM0Qc0fdZ2qsywYneD6859mJObOo6IdSuWfQ+EBtUVkkbunfnXn6PF KB3qfVRb3KUYMaXjZZJmk4/ELh8uHekfs1u3J9xFUnciIfu46X0b0E7Lq0gsCRJiXn Paae+8dBuj1T7HXLBlHxT7ThzNA/oxAtv0YCovfaS6/1UipaNTwR/uK6sgMyHxNRJf X0ZbhNOG/LP5Q== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:13 +0200 Subject: [PATCH mptcp-net v3 02/20] mptcp: pm: deny endp with signal + subflow + port Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-2-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1389; i=matttbe@kernel.org; h=from:subject:message-id; bh=VTCYuWArzYhunK5hbwYMqWdj9fMJvYLpw+Ge9TGDPd8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/x6RqjWS3G5qyCir1+EatO690YSKHtk2TE Qy2b1umLdSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c80bD/sEFNUdjJ7M4l5zvcDjAYu8wox3QHqM5oHb5B7f9Wj1NsuI6u0JgOZtYLPQ1Sb7UYYUefr Xxx6oH/JNfH43ss90KeWQUSrawphDSX+UT9yI1mcvuAubBpNiYnecgnBoh5DO8CEQAkJqyuKr/U sugGJY5dtIBoufInQ/3NrN0MA62lZnzo1s5+gSSRYP3vJsBh9wepYRsAWOrut0joC5BWcg0r1Xq YsiVQeoxMoZEhWwP6vDTx8GajUN0yxYTyL9UPjRMKgxZ1Y3YngSSE4A5n234URW+B4d1ijNzeRJ kwj67PXOy8HQGWxuczdSI1HF744gumkAb5Nkms9clomM88Y5OBvdK+iIomXxAu3/lSym4s+UYs1 ++j9qlmHMVDSdEbZjxbIfyWE6QdNRsCurs/WTZdD6PggUCtzjYAeXohw97r6wjwHuUJtJvjgXL7 92KocBWhNUBQJzngdasGm+rTG3YKpISIYjICTNEwqIxe+wwrwb0p6AHc7fp/5uovs2OJp8V7LiJ kDauX2IDqo/tKF35ndLiWA+RMuTJVmbYEcqRIVuHuCHIYncEYRRU1G67Iav5JFLO4+Fink7vqVJ J8VEariOhbM50n4IDcNUZs9FR1EHhCAt17ndFm1yW5tvFpVv/BEZrl6DHK4JnX5v7k2BGROzfma 2BGQK9F/rFxNulA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 As mentioned in the 'Fixes' commit, the port flag is only supported by the 'signal' flag, and not by the 'subflow' one. Then if both the 'signal' and 'subflow' flags are set, the problem is the same: the feature cannot work with the 'subflow' flag. Technically, if both the 'signal' and 'subflow' flags are set, it will be possible to create the listening socket, but not to establish a subflow using this source port. So better to explicitly deny it, not to create some confusions because the expected behaviour is not possible. Fixes: 09f12c3ab7a5 ("mptcp: allow to use port and non-signal in set_flags") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index f65831de5c1a..c44b0ae51cdf 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1311,8 +1311,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) if (ret < 0) return ret; - if (addr.addr.port && !(addr.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { - GENL_SET_ERR_MSG(info, "flags must have signal when using port"); + if (addr.addr.port && !address_use_port(&addr)) { + GENL_SET_ERR_MSG(info, "flags must have signal and not subflow when using port"); return -EINVAL; } From patchwork Fri Jul 19 12:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737276 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 95A4B83CA1 for ; Fri, 19 Jul 2024 12:24:37 +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=1721391877; cv=none; b=tGFwhzVQlJDZ3w7LQXDnmiaeSzemvb4ZZmazF1L3tC3Wi5x1CocaVGay3DmyU/D+It7fw6xhZcsx5D4cceHPEGx8gp+i0A/E9puRRTcc4MKe3yHlPONOXVzLfbu1wUYhWrbgIkxibJY7nP8FTEpl4JcgEbzGeTkrRzg3FtotJjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391877; c=relaxed/simple; bh=1jgdfRM0rWxjkBHjcFTDjH0KOPr1H9+0NK7hSE/rOyY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IuN8llRHg/CvAI3krhuBqhkqRU6a6snX0LvX0Qto/kY82/dpqTZfQTheG7DO71B48cCgDpb0aj1FnLIe5BlgrtnzGu35drKehEIV/0NKMTgYAIdNpl9sPrsFLHorIqQ++uFaIqr85HLCoWO3SniHH3tmvzy1NViQUQ98YIwnkK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HXYeGYEB; 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="HXYeGYEB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81227C4AF0A; Fri, 19 Jul 2024 12:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391877; bh=1jgdfRM0rWxjkBHjcFTDjH0KOPr1H9+0NK7hSE/rOyY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HXYeGYEBXYJp6wLm7PEbCh1sleAZm7FQmjDciKeeXhloJrXXTu8o/CHxSMEgKlE8n M9lDCPkdOGqvBn7YmLDe0Fm3y6CciX9OgcTQuPtyGBDGEaaG3xKQRLxI+y84tYNBDK MojfYAcpZmSiGmWYpKVoeJ0o2cfrVSWeGvSYOQegAMHKa7Sq4zwQaB1h5sF094Fjax 1RyEwEqKYdMoMHXGDVL+W5QgfeefBxpo/0wdfPfu1DYPZloRqHz1n4vSEcM2Ot2d0j mbFnU27Txe3pypUxvcODUggeZ5Loe8wcCdqxqmVtgrLB1LeJYhyEfzWBt3aOx4fvMd qWhSSg0R3ppPQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:14 +0200 Subject: [PATCH mptcp-net v3 03/20] mptcp: pm: reduce indentation blocks Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-3-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1379; i=matttbe@kernel.org; h=from:subject:message-id; bh=1jgdfRM0rWxjkBHjcFTDjH0KOPr1H9+0NK7hSE/rOyY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/xFatUMWs9pYtIA4YMkmEks0rW4Rj0ZOjQ R4YsUEdZP2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c8mHEACAq93RFrC3Zj9kZKSyKaRXfIPP5NhA10k8K/Uv2aQRtuVwJobZJNLI5d45ao0LnZGkUA2 22b7seRKspVqjEYWymR7GlqB/OP9lBiDtWqRe6ltaJeojA9x4jm39qhkx7MeOKrUHriOLn8lt4s Z0XmRookiyOfnLAA4gGVVT2OfP+H+u5DtMZH4LG7BF6zXY87Gp5PDTvS7ftmbcJZ15KRXxtYvu+ NHLIg9usfIatDAeKUqSgj9DflqBFQDCvjjpb8qdBPNpS7s5w4fY2pLwaemHT++Y5MnQw83uBtX+ UwpmyRrPmU1K6C7+FLvd8UtfP4aHd7R3///pgK3krovXG9E8pS1UTnhXQdU363TJevHLKjXY9kP cPUp/M1rO/s1pgkwyePCYXEAjtw1W+C0Xo9TD2qi0SSIUwp00DE2fDYzCx/5HYNExERtniN2acN lFE2ySr02TVe5pASetTeDNM2BFNbfzQTLNzloyPW3O+dDDalMAivzoi/fqNS0iA3i42+SalHNkn DBdkuCp02QJPlL59hSyDKDzuGKPegdpD9zheRfD4haL142XSQ301cm0zvDMpOwTskkfpbnifpYs fUi0Spv5IvgbwQfK52N4zmrIEmRoFhYmre9ORV4Jey213k65Um95f1/uA9tdDiN1rg/wPJWUnRy 4o3JtP8ozfBJ5fA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 That will simplify the following commits. No functional changes intended. Suggested-by: Paolo Abeni Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c44b0ae51cdf..adc0183b8d3f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -568,16 +568,19 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) if (msk->pm.addr_signal & BIT(MPTCP_ADD_ADDR_SIGNAL)) return; - if (local) { - if (mptcp_pm_alloc_anno_list(msk, &local->addr)) { - __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); - msk->pm.add_addr_signaled++; - mptcp_pm_announce_addr(msk, &local->addr, false); - mptcp_pm_nl_addr_send_ack(msk); - } - } + if (!local) + goto subflow; + + if (!mptcp_pm_alloc_anno_list(msk, &local->addr)) + goto subflow; + + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); + msk->pm.add_addr_signaled++; + mptcp_pm_announce_addr(msk, &local->addr, false); + mptcp_pm_nl_addr_send_ack(msk); } +subflow: /* check if should create a new subflow */ while (msk->pm.local_addr_used < local_addr_max && msk->pm.subflows < subflows_max) { From patchwork Fri Jul 19 12:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737277 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 DAA0F83CA1 for ; Fri, 19 Jul 2024 12:24:38 +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=1721391878; cv=none; b=G7CnlzYV13QSZRkkp1H0N1Ka6YppibRN2DeNR/eE5HDFXjp0QWb93tFV2TYl2IsuLYIzBvYaubF69DxsiSwSd/iF6u6Mvd38+YrQi2KUq4RWQQ6DebcL67BtkMCwmHZQb92o/dTSe2hWWEm+VEDPf6j2SbcbeI0Qk49G8czUxTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391878; c=relaxed/simple; bh=3bp0+EUTF1pd58//Srb/ytyXhrPRDQI38dewIb8zZ0I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aZDK9a6Mog2dszqg+NFMQ+rmwm7wSg4yWSmRtr3iNRHhTyI71G2WCU3JSixV3vQwu92oTDYLIAaJKH4yfduTU/GqOvXhzRIiUS3KIQ4pVI7aFcjjX2j5pZLZhSMo5smDIRSbH7Unb48L0jQ9xoFDA9OjEVrQk/IPMNbGboUKnNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lCoWemjF; 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="lCoWemjF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABFE1C32782; Fri, 19 Jul 2024 12:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391878; bh=3bp0+EUTF1pd58//Srb/ytyXhrPRDQI38dewIb8zZ0I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lCoWemjF3gtx18dnicRNcpOCsv8OeWjlkdoe/alY+ALyW/z6mQV+3OEsZADNilt2h zhztRfcWel9ikUe6mS50cGGsqSalsIMXmeCKaE6Cyjwgp0Mfg5nDmYmU1qvT0QD8Iy 2LSk+EWoRjkmGQhtn4AdE9fGZcai9XBaSqoZL5qn7p5cDbg0sYoirUQppXaoqngEjt EtS55pZ3bLW1Nr+4P3rfeM9yd2BuiA+hfpcLIhWGKLLG7kVWaAdvmliGbiFfRVj5Ns KKbZAxymHyGdsSM5w7nbqRM28tO5sbtG2NQX7gMdm3bymkltOySoSkYInRPaoVkpKG vLjHbQPi8xCMQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:15 +0200 Subject: [PATCH mptcp-net v3 04/20] mptcp: pm: don't try to create sf if alloc failed Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-4-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2161; i=matttbe@kernel.org; h=from:subject:message-id; bh=3bp0+EUTF1pd58//Srb/ytyXhrPRDQI38dewIb8zZ0I=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/XN+oxN0wFUNim3HxcfM8ygfB9p8dwb1KW QQ55lmRHQWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c0IoEACnPhYzPq550e8XvuY5qUpuCHl3LHJbJY5x3leXIzjPzZC/ZX4LzF4O6YK+offmtwFqa/8 LbhHmUzJc/ezBEi7FHMkUHeiyhyp9mzmlGpdh8com3ScF1py4GDCqJyeXZrm/uTSZSdC4F/ZeTF i2kAFcGAOG43RsLOOz42KIk+DjFp0oTBfh1mK8ZTi3zzSeeuoR1YazAorXKpllh2IycxhXDDZRY Jz8yHLSWXaUFI2C2kr3zBzROdhtzPpmZSw6P+UxnPHgLjDwjDk5bK0xtuWyUg3F2m5ZTTX1gP/L JvhHboJoEJTiAGTm4nF5H1hjl7gF+95GEpTuJlOY0V7FFZ6D3Y/Z4UOfRlrEr18qjE3kSIsNJb1 zM7ITiWQhGxlJ5OaxRKj6Of+nitVWC7pb0LC20KFJr8yJoUgGdmoi39Rq8wNTesQZTycfkVMSLJ CAUAQ9e4Jqi6Zc0HynJLVqjRn5MmtdE0iyKz3VK4V+EJ0btVPMO5ZqkcNddXsSQcTqcaVrD+6f0 szbk+8VP+l/btyjgzwmO40Pjs5ooW7xYEff8c0VrYXCil5SH+IWnULB/H/iBrRAcl3I5U6zhlWX uSJPQ6AaZNs0P+nEEGopigHKke2ot3usvFQilE53aX/a+NMzm8bhubT0DhFoNua8ObdgwMsFeP1 leNYsABCyef6ZNg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 It sounds better to avoid wasting cycles and / or put extreme memory pressure on the system by trying to create new subflows if it was not possible to add a new item in the announce list. While at it, a warning is now printed if the entry was already in the list as it should not happen with the in-kernel path-manager. With this PM, mptcp_pm_alloc_anno_list() should only fail in case of memory pressure. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Suggested-by: Paolo Abeni Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index adc0183b8d3f..0ca6b358ab51 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -348,7 +348,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, add_entry = mptcp_lookup_anno_list_by_saddr(msk, addr); if (add_entry) { - if (mptcp_pm_is_kernel(msk)) + if (WARN_ON_ONCE(mptcp_pm_is_kernel(msk))) return false; sk_reset_timer(sk, &add_entry->add_timer, @@ -556,8 +556,6 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) /* check first for announce */ if (msk->pm.add_addr_signaled < add_addr_signal_max) { - local = select_signal_address(pernet, msk); - /* due to racing events on both ends we can reach here while * previous add address is still running: if we invoke now * mptcp_pm_announce_addr(), that will fail and the @@ -568,11 +566,15 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) if (msk->pm.addr_signal & BIT(MPTCP_ADD_ADDR_SIGNAL)) return; + local = select_signal_address(pernet, msk); if (!local) goto subflow; + /* If the alloc fails, we are on memory pressure, not worth + * continuing, and trying to create subflows. + */ if (!mptcp_pm_alloc_anno_list(msk, &local->addr)) - goto subflow; + return; __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); msk->pm.add_addr_signaled++; From patchwork Fri Jul 19 12:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737278 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 F3E4D83CA1 for ; Fri, 19 Jul 2024 12:24:39 +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=1721391880; cv=none; b=ncHra7lwDpmRdLm0k7GxwxdHYHyfBolfOq5S9PuuD7DJOqycrLnfx6DpIP4KuUxYEZPoC/LviWmq6j2bbd6soJs//EAKoVqNGo62W0lSWFbaRV52rojJDrano9HKRk1lrHoU6MEgGZ0eeJShX93qG4cs5/P+mnzXS1q9tJl7hkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391880; c=relaxed/simple; bh=i77z9tOTtHs5P1x2DEPDtVt0aXpXalQv5SfvpCPktr0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XuSFd2vh8bAsb9rThonkm5x+G07HjxJ/9+Zg2+orE6ialcST2Qv4hC4QShyH5sNIJ+g8As46aGgY+RzMNY1tZKNpOAPo641FMQONX+oAjYkmh4Pag9Zfh4LS5schpiAlgfMFqKi8bYqXRInivFH7sHhFCBHKKHTHs4yisXehuGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OF5b8q7Z; 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="OF5b8q7Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6769C4AF09; Fri, 19 Jul 2024 12:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391879; bh=i77z9tOTtHs5P1x2DEPDtVt0aXpXalQv5SfvpCPktr0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OF5b8q7ZwkLpaoS5Q4BJ0c4kBcgTFYro7JrSg+5JN5x/IvGlsGvh0GgCENpxq0OkC K6x6+Gd4c+LhT7g9f1deh8wZtFrby8JqMeIWS8s3DyxJtQ4yrQGNr/hLls3KOHcZx1 AC4ZNAjeEBc/lVyAc/NHGtPe2Wu8dnekPICRfnubFkPv+vYCf/XzhxNH1/1ElPm3P4 N7XJXZ1jCR4TQafHdhUC2Q31wJmkEQjugtGwNsVY3J/nP0snpvfc5d3Z5Td80GOozV Wk2bTb+DxYEjFEkQCZ2jHOVTcLNeRibwgewEL+HXNuyedhuaMvlI1DCQiSJjzIBahH 0wFaHdaWD73tA== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:16 +0200 Subject: [PATCH mptcp-net v3 05/20] mptcp: pm: do not ignore 'subflow' if 'signal' flag is also set Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-5-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3907; i=matttbe@kernel.org; h=from:subject:message-id; bh=i77z9tOTtHs5P1x2DEPDtVt0aXpXalQv5SfvpCPktr0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/xHsih0kF7d7BonDcxQxAgeak2r7lGAL3H yIBBYwc22KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c2XvD/9l2PGUfYlbC23PevWrbvfYkf8CO79ULSIvYRB5H7M995vGdWhb8+AWCxN8FH0TTW36d4i xPxdy/iBzpXrgYGhrVVzoA6d93CHp0JVeyOClXSRiVwEMHb1OnKMXwpm3UE49ERV9oKFcH2YyRV RyoKB1ZLNFiIhfDaip8vwqFygsLOwZrLhQ7DdcfsOzx2tRRH6e11vsDsSkAlwA3QOHZ1pBaRcxp /3sU4CnXgBGxgKNOjSvWotJKYDH+cjakUVP938exUN8/M3EvaUf4Dky70DI0ryXI0koPtIiJ0pT uDbgrQAy3brCx2MpvY56Vxw7dX9JKcIJIac6ZLJGXhUUiSv3AP77vFOYDvMUJrB0M+9y8gtE+Da vMKBEsso1saBONGUEGtZoJa/0QEPu8Hm7uCqauodYa5W/7naEQxk2GooqXBHUND+UoKXOik5Kzf 3htVc/5b+ObBFVUIu3pbrzy0Sxo/U5zMH1Zim3OreGfA0wJRrUZ+Kpz1YgZbZ7bQWbv+vWfMZ3H m4uUb6keq6W0TNpZ6uZUKJ+HnYjvrQqxnILi1jW7NN5S44rQAO30noI3WDIU2ACZa0TK9ltKAwT y9leBq6vbXSKlygAucbnqINyMDy5CHaEQWg+xqmzXnQbAroQ/o1me2y0skMqncTu+G/xLQ4BwmC afCRU8geE9D0TbQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Up to the 'Fixes' commit, having an endpoint with both the 'signal' and 'subflow' flags, resulted in the creation of a subflow and an address announcement using the address linked to this endpoint. After this commit, only the address announcement was done, ignoring the 'subflow' flag. That's because the same bitmap is used for the two flags. It is OK to keep this single bitmap, the already selected local endpoint simply have to be re-used, but not via select_local_address() not to look at the just modified bitmap. Note that it is unusual to set the two flags together: creating a new subflow using a new local address will implicitly advertise it to the other peer. So in theory, no need to advertise it explicitly as well. Maybe there are use-cases -- the subflow might not reach the other peer that way, we can ask the other peer to try initiating the new subflow without delay -- or very likely the user is confused, and put both flags "just to be sure at least the right one is set". Still, if it is allowed, the kernel should do what has been asked: using this endpoint to announce the address and to create a new subflow from it. An alternative is to forbid the use of the two flags together, but that's probably too late, there are maybe use-cases, and it was working before. This patch will avoid people complaining subflows are not created using the endpoint they added with the 'subflow' and 'signal' flag. Note that with the current patch, the subflow might not be created in some corner cases, e.g. if the 'subflows' limit was reached when sending the ADD_ADDR, but changed later on. It is probably not worth splitting id_avail_bitmap per target ('signal', 'subflow'), which will add another large field to the msk "just" to track (again) endpoints. Anyway, currently when the limits are changed, the kernel doesn't check if new subflows can be created or removed, because we would need to keep track of the received ADD_ADDR, and more. It sounds OK to assume that the limits should be properly configured before establishing new connections. Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk") Suggested-by: Paolo Abeni Signed-off-by: Matthieu Baerts (NGI0) --- Notes: - v2: re-use the same bitmap instead of duplicating it for each target (Paolo) --- net/mptcp/pm_netlink.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 0ca6b358ab51..2e94f2a9f2a6 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -513,8 +513,8 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info) static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) { + struct mptcp_pm_addr_entry *local, *signal_and_subflow = NULL; struct sock *sk = (struct sock *)msk; - struct mptcp_pm_addr_entry *local; unsigned int add_addr_signal_max; unsigned int local_addr_max; struct pm_nl_pernet *pernet; @@ -580,6 +580,9 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) msk->pm.add_addr_signaled++; mptcp_pm_announce_addr(msk, &local->addr, false); mptcp_pm_nl_addr_send_ack(msk); + + if (local->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) + signal_and_subflow = local; } subflow: @@ -590,9 +593,14 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) bool fullmesh; int i, nr; - local = select_local_address(pernet, msk); - if (!local) - break; + if (signal_and_subflow) { + local = signal_and_subflow; + signal_and_subflow = NULL; + } else { + local = select_local_address(pernet, msk); + if (!local) + break; + } fullmesh = !!(local->flags & MPTCP_PM_ADDR_FLAG_FULLMESH); From patchwork Fri Jul 19 12:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737279 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 385AC83CA1 for ; Fri, 19 Jul 2024 12:24:40 +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=1721391881; cv=none; b=OdWwFGLHl3yMyHheEHSEEq5mEGsTIJ3kBPLNp62IYXmIkwIteT5hCY/8d1WugkDEtJbEzAVCnY6bNarHIPiE6RIwRRYSybYoDhW+6ZM07Od/j58Ll/w0BmlQTQwQSDxFC+2Fdz2HbMKRYwEG4ESDeD6iKPF8bl3RFnOpZv+7L0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391881; c=relaxed/simple; bh=NAhjnJLuFDq3Qif5cnScKlPlgz1s2euUXNeowcShoi8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VPepj3SDNf6LnQRhd5tPE6iNS3JIrLqvGt49XbIlgVfDPhProUfiLoEiD2OyS3uSWd0JkD/JViaUPXCNw10+xuKYnO2jjoezKSbKtvhMZ7Y7dYAezq+z4mON3ITtwxFnBFTy2zCDvceTV5HYp0P2V6XH29UUMlGVOBOFadAK638= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k+m1ynu6; 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="k+m1ynu6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DD71C32782; Fri, 19 Jul 2024 12:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391880; bh=NAhjnJLuFDq3Qif5cnScKlPlgz1s2euUXNeowcShoi8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=k+m1ynu6Pht5j1iXLc/ajvHp0d0hKaYWzQMSLnnDYEWXZPJs0LtU5rFevvwMhWT1J He8LFG5Xg7FWtZzP+P43QXgYJibsXpbnEr7y86kjAwC1ULxbd+GvPT6E8TGy+PBvGj iFwFG4jkHIAeIkcSFJlpfSXD7ux/x8upbVFw0Aj2LI3J09Uie9dA/ThcLwYFEEZZoR XrVMDSTENAvwnWmwICWf/TjMQkXz6zIG9F7Ae6p0E5z5RCg/17Q9JCl3FOreM5y63Z fRLZX4gyy2/n5QBq5Y80KUCzcDYTRaJn8ENmIuScwrJxVZjs551IC0MfkiZJkIqNXb UgghpZkZkMt1w== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:17 +0200 Subject: [PATCH mptcp-net v3 06/20] selftests: mptcp: join: ability to invert ADD_ADDR check Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-6-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4285; i=matttbe@kernel.org; h=from:subject:message-id; bh=NAhjnJLuFDq3Qif5cnScKlPlgz1s2euUXNeowcShoi8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/HmZwdrxp545HnECmitolTzDbJNnrHYCVI bEnd9QeUAOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c2J3EADLIDs58rCLSzyukFJy8X8v1B+NOlKS/SMs7envjLRC1BttUGcFHS9vDKY9IK6MTb5ffhn aISFY1O6yUbTrnnpXmTlhX/MFieV5wPytVTxtVXBAN/En79vNj7qEueyekwLlZmbQQA8pskxCV2 Uo/YMVrpOWsSYUi3LAbEG6Jdv7l1jJA2to9QX3RbPu0AOTO7UuUMJtQQifGHqr+3vXbByyZHzZ3 bwIZeg9soYcDkhY4UkSH1eJeqKWdGPYSKCoz+5KQR5f9x9yWNM6NkJc3rRRmoMJiqHxn6nY+cup RC79inf5EnlqV6YslVHFoEYumbuR3XqCWTa4JZIzz1glAtXIt7dKYgtw9+u+2TP5s1sOOUK27zw 8ModBKpDKA25l4Yexm06utDDJUK7UdBpFmZuh20py02QSuqAfneV8AddUbnlfcwLS3f40tDI/JI Al5iU07vC6gP7/tZd27Cf3+4U5CL8u0P6EVLWTXA5STNcWcutyJdHG3MMAA5EYH38ThtCz3RFfo 47ev71Mn9L/Fi/vSe2nYe0m0096WTwe2h28hwqe/UFPkgYJ/8Z2qegPMIy952K0r9zLuJmL0vXy rGKFHJGmdg5Cri+vGDEOYSdb41ME+LJYmamCp3mZ2saNra+JwuAHK5zgAzebq0GO4nvV59QrQAd J8I8dXiJ9L/FblQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 In the following commit, the client will initiate the ADD_ADDR, instead of the server. We need to way to verify the ADD_ADDR have been correctly sent. Note: the default expected counters for when the port number is given are never changed by the caller, no need to accept them as parameter then. 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. Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 40 ++++++++++++++++--------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 55d84a1bde15..55ccc4fdf18a 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -1415,18 +1415,28 @@ chk_add_nr() local add_nr=$1 local echo_nr=$2 local port_nr=${3:-0} - local syn_nr=${4:-$port_nr} - local syn_ack_nr=${5:-$port_nr} - local ack_nr=${6:-$port_nr} - local mis_syn_nr=${7:-0} - local mis_ack_nr=${8:-0} + local ns_invert=${4:-""} + local syn_nr=$port_nr + local syn_ack_nr=$port_nr + local ack_nr=$port_nr + local mis_syn_nr=0 + local mis_ack_nr=0 + local ns_tx=$ns1 + local ns_rx=$ns2 + local extra_msg="" local count local timeout - timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) + if [[ $ns_invert = "invert" ]]; then + ns_tx=$ns2 + ns_rx=$ns1 + extra_msg="invert" + fi + + timeout=$(ip netns exec ${ns_tx} sysctl -n net.mptcp.add_addr_timeout) print_check "add" - count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtAddAddr") + count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtAddAddr") if [ -z "$count" ]; then print_skip # if the test configured a short timeout tolerate greater then expected @@ -1438,7 +1448,7 @@ chk_add_nr() fi print_check "echo" - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtEchoAdd") + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtEchoAdd") if [ -z "$count" ]; then print_skip elif [ "$count" != "$echo_nr" ]; then @@ -1449,7 +1459,7 @@ chk_add_nr() if [ $port_nr -gt 0 ]; then print_check "pt" - count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtPortAdd") + count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtPortAdd") if [ -z "$count" ]; then print_skip elif [ "$count" != "$port_nr" ]; then @@ -1459,7 +1469,7 @@ chk_add_nr() fi print_check "syn" - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinPortSynRx") + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPJoinPortSynRx") if [ -z "$count" ]; then print_skip elif [ "$count" != "$syn_nr" ]; then @@ -1470,7 +1480,7 @@ chk_add_nr() fi print_check "synack" - count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx") + count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPJoinPortSynAckRx") if [ -z "$count" ]; then print_skip elif [ "$count" != "$syn_ack_nr" ]; then @@ -1481,7 +1491,7 @@ chk_add_nr() fi print_check "ack" - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinPortAckRx") + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPJoinPortAckRx") if [ -z "$count" ]; then print_skip elif [ "$count" != "$ack_nr" ]; then @@ -1492,7 +1502,7 @@ chk_add_nr() fi print_check "syn" - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMismatchPortSynRx") + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMismatchPortSynRx") if [ -z "$count" ]; then print_skip elif [ "$count" != "$mis_syn_nr" ]; then @@ -1503,7 +1513,7 @@ chk_add_nr() fi print_check "ack" - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMismatchPortAckRx") + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMismatchPortAckRx") if [ -z "$count" ]; then print_skip elif [ "$count" != "$mis_ack_nr" ]; then @@ -1513,6 +1523,8 @@ chk_add_nr() print_ok fi fi + + print_info "$extra_msg" } chk_add_tx_nr() From patchwork Fri Jul 19 12:24:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737280 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 4CCD483CA1 for ; Fri, 19 Jul 2024 12:24:42 +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=1721391882; cv=none; b=QP8+VeA6ztslfhFB8XYVonAwY1b0nOqLSq/qdgMgZW78dtzSzM6VctyNGsUavhrG36/rFTpnSscMpM3rPP2uaZGOMzcGwMRu87lfJlynaAN5WwHGBBanVF0p397sdYHtOyjocXzSCE8tMcntqp/qq3N+G2oMqYKx6PVG2gb2QEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391882; c=relaxed/simple; bh=Uk5krQmua1YGk0ItymKu1THhzRWDba0Om0yojxoq1YA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gKp1Nu0V3XVi1u62OzVfXftblhgTpFLK2dnxr8EV9ZxoTeKGEOmKOnAVBiTNLkXhCQysr49waVp7Gh227DvGAe/OKubeOQxv7eiVzux8U3LSGwNRP8gD+XyO9DhQ1Pk9/rBn8ysskCRZkxOTY2UI0CfJfqPw8FNWuQDIUSw2kSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=amtOf2N1; 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="amtOf2N1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D0AEC4AF0D; Fri, 19 Jul 2024 12:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391882; bh=Uk5krQmua1YGk0ItymKu1THhzRWDba0Om0yojxoq1YA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=amtOf2N1n4v3R0QFFiaUDI3Obr4AbrhTpTXyDZJZlu+rweawkYedBIv7bISDwEn24 IpfAOdwosfdAAy8YKTNmK4MbDw/ysYz+BklNaryZICuykINI7yPHV6uax0ts+ni0v7 PSzVvicifjU9IuknhqWfr+xTQ3ERj98huWWSm+oLZM/wQUZNvZEomwspEKqtXGalfl IogVpTaOYA6qYZ731UVOT5+PYXSCq0bVuP2VHE32gf+tO27oYhZCFE821JwsBo+y6B 1NNwX/J3Wrg3sQ8WqwkHsKmaCRUcpLlLtkc0TQ32s1pwyyjglMN9bBMlQONUh0ncE4 O90r62APjhmMw== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:18 +0200 Subject: [PATCH mptcp-net v3 07/20] selftests: mptcp: join: test both signal & subflow Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-7-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2396; i=matttbe@kernel.org; h=from:subject:message-id; bh=Uk5krQmua1YGk0ItymKu1THhzRWDba0Om0yojxoq1YA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/BgpdpFyEDjBa6nz2BH7hCRFkr1rqOG+W+ zH4M18SBTaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c5WMD/90aE5dS1f2CstS6t15NE4F3tKrzFWKqjWrK01PFOpyscqIoLY46kwNNfnCvkUCudGc6vp 3Iupzbsk8CUffxGBKYHELdCQruD4rLUujQdwrnRyTR3WxMhLQB4G8vyzp3a65s+ISTNRimWic52 gxCdyWyULT/HxKuLqa2jFpEBziB50sJqFjpxDWyox+YcZ1UE1DH22o6Jt41GeV73QPXc6Am/s0m fK1x3sd7DaPBWGi5Zw2D7Y4Pmi74+kQf+E3l/39tSRjK9PX3vL7S63gw8bnLVNJTiO0Vk9WZTft 5B51CY0RKOkVSI+26hSRNrwx7V7FxO6dop9Kw22T5+y3xue5elIR39QqwEf42WtOfP/Bd3HEq2v NgdDlPFyZV/qqJHEamp4kzlgpBQcY2t5FbggJCLEevd8s7kZEKBbn36tXeX/CzpKdCyVdtOyjnR HWa3TIcyMmDJquZwQqmumxTN+3e9ymHgA6ZqcDcxxCypQcXOAGPTjA4o7gkKpQYEz64GoLe69LV ipWhqKwrtxTr1jclQN71eIRpBB/KhukhA1hQRVgvtJaUx0m/nbB3T+k7Q4Kipk8RM1JVFBxPDaq onwW8rMAwYDi8+Ql4MqKP7PzNH6/iAOlllFSE/tJ5v6GaTNg3ea3JmlJ1VTNVfCAhaNPScu/uLv v5Vpy7CCPGR6/Gg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 It should be quite uncommon to set both the subflow and the signal flags: the initiator of the connection is typically the one creating new subflows, not the other peer, then no need to announce additional local addresses, and use it to create subflows. But some people might be confused about the flags, and set both "just to be sure at least the right one is set". To verify the previous fix, and avoid future regressions, this specific case is now validated: the client announces a new address, and initiates a new subflow from the same address. While working on this, another bug has been noticed, where the client reset the new subflow because an ADD_ADDR echo got received as the 3rd ACK: this new test also explicitly checks that no RST have been sent by the client and server. 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. Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 55ccc4fdf18a..d25ac561e050 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -1967,6 +1967,21 @@ signal_address_tests() chk_add_nr 1 1 fi + # uncommon: subflow and signal flags on the same endpoint + # or because the user wrongly picked both, but still expects the client + # to create additional subflows + if reset "subflow and signal together"; then + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 0 2 + pm_nl_add_endpoint $ns2 10.0.3.2 flags signal,subflow + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr 1 1 1 + chk_add_nr 1 1 0 invert # only initiated by ns2 + chk_add_nr 0 0 0 # none initiated by ns1 + chk_rst_nr 0 0 invert # no RST sent by the client + chk_rst_nr 0 0 # no RST sent by the server + fi + # accept and use add_addr with additional subflows if reset "multiple subflows and signal"; then pm_nl_set_limits $ns1 0 3 From patchwork Fri Jul 19 12:24:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737281 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 8467A83CA1 for ; Fri, 19 Jul 2024 12:24:43 +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=1721391883; cv=none; b=X1lzYrU16c+GhjEKlJnZAGX2aT4vnI1ZIF7sIajf3kHFdekhsJ1aBwOHxBJKhg6sV6qVMW2E/8dKeGjPRoUmKzGHDYMatmnTJFAUidLj0AtXXDDfSOFWVmqs+1flgWJYm7u7EleA6W5f/DizLAmBQPGQLfF1/INuWHYPQ0Jqtag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391883; c=relaxed/simple; bh=2I6vmk+jwCRqxKwCtsRxnsAvhqqiS5h3MAqfuPR50Z8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZtTijtux40B8ytq70MTuiK0afcWvHIpOm+luMS5RZo2+NGEzj39mZnmVVOfLZyYIBdSTObRM3AhSBX26LPhTxFMLAUYTFrVMz4Ld+I7VflVvDIU9pHTg9Lu5NfQHt59JaqkQOY9Uq+vAAHNwhkpFjnabI2nmmQ5LxfIna2HLiAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PyrXbgq/; 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="PyrXbgq/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6846AC4AF09; Fri, 19 Jul 2024 12:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391883; bh=2I6vmk+jwCRqxKwCtsRxnsAvhqqiS5h3MAqfuPR50Z8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PyrXbgq/0roTqHe3F7c6niKFbRYdXoq6feE5gKugNZF4BSTN+8MLzQwpBPYSTal5j N+SDKEpsDEqDktl9fZtTFCwYSXxlFErMdCiIlxU6985gjGA0CXzSUUzTz83lfsVlZM aPh5oL5gtI/+0ENsL0lwMMWu4o5k3Q+XDZ9WjT2VubLPSMv//w+8mztBTZiu2W1o4R rWnlF1RsSeGdeorUK2IIAjN2GUB5KCuXIllyNnCsgp/aTjvo28ZM3lFG+8XNk0pYz8 u5MK4VNwAvBo+/KxiEtN8heIjnmVTlzMtVkJyPQvry/hEqoQTGUyHsWTj9HkER1Eqo jDXEeHi8Hq+rw== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:19 +0200 Subject: [PATCH mptcp-net v3 08/20] mptcp: pm: re-using ID of unused removed ADD_ADDR Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-8-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=995; i=matttbe@kernel.org; h=from:subject:message-id; bh=2I6vmk+jwCRqxKwCtsRxnsAvhqqiS5h3MAqfuPR50Z8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/XS3QjNyxEGoYyOcwIhys5RFf1opKQXsjU uY09a+FFOeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c7EsD/9Qse6diF6flBXjB2TT967Jg8Xo12EXfB0oeFhBACSDoY0lZyMkE1XDz73DNUW2klTANYK HIqbBPgSx9qPn+HgWq6G5ZaNn4Vc33/HfzWD2vpR7B48+o0mJreGrOt/155JkZwT37iRPIo4wBY W5YwyRZM/ZFL9VFmt42P5MgopOKPEWQ68r0x2f1P6BFkb8EIrarIdB03igdDhe6C7E2qtllllp8 2Qke2lbYcLNSwjUzLK31+TJKFYZUAE0BkhmDu8JYXUt1pJl4AV5kNOGGaUL2pyqtHJv8EO6bD7H qCI+XHGIjR+qUZqbq6GoF0YVLhlyhvpcsUFaNtAiiSg7P/S2DHc00aZV5N4jfiHtrZubNLCJLB1 kOCxSVyYPKZeATjHsOg9edyWPS5+7Pz/c6YqmB4N1myy3yPMgp6BsJfiBdNBWfzzf/07zv/iTHv y8y7/qwvCyiRWM1Ju6rP3TUl3BQ9QaiVVmFu1NWCSn3YRaLgunxHFjGLmAhGl7T+dWlCCf3TTTJ 2hzJXQ76FMGhIU54TAnzc/8nxg1kIwHE90t7YaqEEet89vKA91DZDuMUdDsdpvPB5jjY8YDJn+D TRsaASWIXZ487YmvNY0YPvuscq4wwAw6KPVjimD0QTEvSlY97Y9wdc4Ha5LsCJovSa4bVIrEAiw K7wdrKoXDOWkWgw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If no subflow is attached to the 'signal' endpoint that is being removed, the addr ID will not be marked as available again. Mark the linked ID as available when removing the address entry from the list to cover this case. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 2e94f2a9f2a6..d44d318dce03 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1394,6 +1394,11 @@ static bool remove_anno_list_by_saddr(struct mptcp_sock *msk, entry = mptcp_pm_del_add_timer(msk, addr, false); if (entry) { + spin_lock_bh(&msk->pm.lock); + __set_bit(entry->addr.id ? : msk->mpc_endpoint_id, + msk->pm.id_avail_bitmap); + spin_unlock_bh(&msk->pm.lock); + list_del(&entry->list); kfree(entry); return true; From patchwork Fri Jul 19 12:24:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737282 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 C464E83CA1 for ; Fri, 19 Jul 2024 12:24:44 +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=1721391884; cv=none; b=biHAWIbdbiuekzIZYY38YwwvShY5W1iqX5JWYIUG2L0roL4iZs3O6IN1nQdt+xFGYTnubbX4TTLQTd9/Dkt4i4U3IkedYzL2MaZZm59xW5gO1IfFp4y/aP/zCMg7esXeKbYVQoQBoh33BxpogABRypkoOytFAhZFnhVbRBBxbGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391884; c=relaxed/simple; bh=IZLmMEPKaTI0ecetyxX+ZJUmzHaA8vdoxLN3U+l3uKA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oJOamUz4kLc4XDKuzfiRo8d70gsSnnpYhAZsnHskUJpoInHzWduimBr5/w+9VMeET+jTDokqo7pMLO3QpBHJNhEOvtNRw41xcWaAlpwrLA8P3oo7Fac5uBWBirBUy+yr5QSgmujnmKBsJ6P7QOlKeVUeKgqF1YGx2IOHEA9XVmA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XWrUUBr1; 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="XWrUUBr1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93913C32782; Fri, 19 Jul 2024 12:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391884; bh=IZLmMEPKaTI0ecetyxX+ZJUmzHaA8vdoxLN3U+l3uKA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XWrUUBr1of0GYzMEJs5T7H9iAdBhEfqEfmhshOMcRdLUjszkinhGFkk3oGzPpqcMl kK/4BXjT3FGHqTRIqDqDjqJoB3/6D8R/gonPHvzaN4GL3T/sl/pB//sZv07B3V6zBD tHRewWDSiZfAi+VOxB6vqG+ZInMUWO0+JSE2m7v4VZjzJq1weue4eV22MvX5hnZrRy TR4BLRIx7eu1rSWXDvILc4EfboJo1TJ4JkHkPE981ZHEwmbpUZED0rg/YRmueFMSPq cdL6Hr3TrviOHz6UI6dDMJ+aCOugdeFKxuvh6EcZzD5WRwEMvCxeQMdCqk7+2rkV38 jtTrPHWGyDlng== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:20 +0200 Subject: [PATCH mptcp-net v3 09/20] selftests: mptcp: join: check re-using ID of unused ADD_ADDR Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-9-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2591; i=matttbe@kernel.org; h=from:subject:message-id; bh=IZLmMEPKaTI0ecetyxX+ZJUmzHaA8vdoxLN3U+l3uKA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlr/l+JEJCbVcXEQjizd1qEuALB/oD4y/3jlA Uq/zIv1zamJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppa/wAKCRD2t4JPQmmg c6GZD/90eaaxpsz0OB8aNCI1NDuj4iwVEAb+YNBBEWVt2fRvmVxCb3bdt0dAfj3eqp3gffIPDAN iJHEvy6kNmj0IoYPpQsi2Ch1/TkqFgNMxOQhQAr9XbIT5ODSnQBtm50O9+7VZJxvTyr5nnQkMPb FyxoBo8lzuZBHv1Hvf0umBAv3ylOOEEeVeS25qbF7Pmagsb/yVlNuHwsEz8idYCCufXSyJmWxMU Q8tXWGlg2ZKC1CbVANkA/zL/z+nX1UJIyRXt5GqW7uXqwmaUaH2badnC+N18UIqtmPejx33xGi/ FFKeHsGQaZ/563wjbOVgcPGJAseF+tJFBhfcYM5dz3HOBBK8zJTe8lCJuFFHgHPWsDEh80mreiA L/iOu6kTAwCA0wgMmr35rTveMvftLwprzyXzX+kPkkA4QFXPpHyNnXl6nXgM7EMD+q1L0+PFfqt d559c1ssAumJJuBmy5elE55q6y9w2hIzbNL4m/+VktcTr1xdeZLvt6Pt48/2Krhs48iIqT4toNf nZan7am9SsjbAbrbMS4lhvTzmVj3s9zpSRre30anwPEu1dUFBqjKEwYOCeVnsp2vZV8Bla15ANm S1yTxqZZQ0qKfArHJRBCCFkA1XBGR2X9ij51/HW5CvYK5u7sQ4DVfNObdW3C0xBCGAKjAfTcThN ve1oLiRcVvwKrdQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This test extends "delete re-add signal" to validate the previous commit. An extra address is announced by the server, but this address cannot be used by the client. The result is that no subflow will be established to this address. Later, the server will delete this extra endpoint, and set a new one, with a valid address, but re-using the same ID. Before the previous commit, the server would not have been able to announce this new address. While at it, extra checks have been added to validate the expected numbers of MPJ, ADD_ADDR and RM_ADDR. 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. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index d25ac561e050..b4dc5f2772dc 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3557,9 +3557,11 @@ endpoint_tests() # remove and re-add if reset "delete re-add signal" && mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then - pm_nl_set_limits $ns1 1 1 - pm_nl_set_limits $ns2 1 1 + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal + # broadcast IP: no packet for this address will be received on ns1 + pm_nl_add_endpoint $ns1 224.0.0.1 id 2 flags signal test_linkfail=4 speed=20 \ run_tests $ns1 $ns2 10.0.1.1 & local tests_pid=$! @@ -3571,15 +3573,21 @@ endpoint_tests() chk_mptcp_info subflows 1 subflows 1 pm_nl_del_endpoint $ns1 1 10.0.2.1 + pm_nl_del_endpoint $ns1 2 224.0.0.1 sleep 0.5 chk_subflow_nr "after delete" 1 chk_mptcp_info subflows 0 subflows 0 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal + pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal wait_mpj $ns2 - chk_subflow_nr "after re-add" 2 - chk_mptcp_info subflows 1 subflows 1 + chk_subflow_nr "after re-add" 3 + chk_mptcp_info subflows 2 subflows 2 mptcp_lib_kill_wait $tests_pid + + chk_join_nr 3 3 3 + chk_add_nr 4 4 + chk_rm_nr 2 1 invert fi } From patchwork Fri Jul 19 12:24:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737283 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 9693183CA1 for ; Fri, 19 Jul 2024 12:24:45 +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=1721391885; cv=none; b=qvU6TQAiQdBJ88CQb29ho+IUyH5HP4dv5AkQA7uWb/9vFjHmezPQGr9LYw+RAMa3Kjx+XUIYYF7kc0UpbP+ABFpN/3Gz5fSm8HeUMACHYjuVwx0g6RtkzTRN2cGthYzTiuEsHhg49EJBYzBWcRY2Uhg+tKYGqn717sMVRQN5AmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391885; c=relaxed/simple; bh=oSnmMLYCpUNY0er7kFjeah3ZncChkhJj3qmtgH+CoJ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mttUn6v1tUwF2VrVfXf1aDlNfuA6kBIMY7q/Jjf2+lahm5e/rPp8LBRqzqcax5nI8I3t6UFe4BKzzJZYirRdS6D4syanZwAjeHm8G1p/HpcVZ1BYHgxVX+eJW5j3wjC5Wzu63NmNmpmNEqZH27RYOZLzmkIy8EAgLr/ADJlYgYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mmKfYCbK; 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="mmKfYCbK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0FA1C4AF0A; Fri, 19 Jul 2024 12:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391885; bh=oSnmMLYCpUNY0er7kFjeah3ZncChkhJj3qmtgH+CoJ4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mmKfYCbK0TAhHB4rQgWTP98v8+h8N2tGAgxXulkZsFTtD3xYrskv7XgvZv66V2jqg 1QH0A8zYJ2r+p0Yy0ECj5VrS2BE9LzHCkToUgzxax3zlQzjyhclw8cipvncABzO7Oy 5v+sxs6pFZGLH/FiEmtdH18wYRNJH6iNGjCTez9BT1Mfx6fnr5+Jbx4sfK6o+fL+Rx OkQoZz4SRJxp5hsneWB/WpUVhOLAOyIVaDWc1Br6E+oZDWx5965hqUnQFV9eZHr8ej Svrb+2QNTvRElDsJJc+ioq9FZuFJTnZplp44/d2JEfNx1c7oPPnnze54UXFnKIjW4K 92xZVbvAsF4Qg== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:21 +0200 Subject: [PATCH mptcp-net v3 10/20] mptcp: pm: re-using ID of unused removed subflows Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-10-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1606; i=matttbe@kernel.org; h=from:subject:message-id; bh=oSnmMLYCpUNY0er7kFjeah3ZncChkhJj3qmtgH+CoJ4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsAN8CLPBwNbU23zwczKQq7Z+GbB9JX5blZv z6efm8fBGWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg czYdD/kBlTtMm/qSGipWha7cETfcdDmckMkOQaGfLLlCVzL0eFQW9iELsgEz5roVTGzReHane5T PTZpYTuhMdDcoVIdNVdugmMD2jeoHwohf6WBMxqzbjFoAO911p7671h4MpbB6cQp5rTweEcqKgI +xF5AlWh74kNGvyzR5a2yhxMqITGBz6rOa1RSK1Pfn2HrQfW1d9Y7ghz2TPBs3JfDbLP56ucjMF +bDOWnDno16amP1yA0iC0PCJv7x/8RZyEd9vIphtLnP2XB2DcFRebRRPw2zL7XcAV8GwKcQr1Z1 fF4TxNX+y9nmrfgEpWQ5UH7x2PapPwCsUkO8GaloAumDrZui/cYPbhSKcQ0s1UknXd16zfDRqBF m5nEw2omQEiwmUQsAxcTOc3GXjjxlF9t2s5gNjsUSbkCzNV3dNDsk8MYGEjAULJWdsi8++zcJKo yTy6Du0Kmrj93A9Z3BxOW10zCix+VQdvpXk69QGUXBLgqQSRmeHI128A1qcd8LMqPWHjt1bAyuD vXWsSRw2UAzDLYULjX9+KQK6xZLl+J0ZxqBfEE5T4pIxD1nhiyrcQ/bZjGnNy+3djBmULW029eN 7kWSFDIrsouqjytItdrMBeavTgpW6AeuwfcTocNz1VxT43LKpemmkWrx07a1IBsWnTiaIJC5jwz 2Rku8Omy2qDzF9A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If no subflow is attached to the 'subflow' endpoint that is being removed, the addr ID will not be marked as available again. Mark the linked ID as available when removing the 'subflow' endpoint if no subflow is attached to it. While at it, the local_addr_used counter is decremented if the ID was marked as being used to reflect the reality, but also to allow adding new endpoints after that. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Signed-off-by: Matthieu Baerts (NGI0) --- Notes: - v3: - Add new line before 'if (remove_subflow) {' block. (Geliang) --- net/mptcp/pm_netlink.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d44d318dce03..bdbf27fe89e0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1454,8 +1454,17 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, remove_subflow = lookup_subflow_by_saddr(&msk->conn_list, addr); mptcp_pm_remove_anno_addr(msk, addr, remove_subflow && !(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT)); - if (remove_subflow) + + if (remove_subflow) { mptcp_pm_remove_subflow(msk, &list); + } else if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { + /* If the subflow has been used, but now closed */ + spin_lock_bh(&msk->pm.lock); + if (!__test_and_set_bit(entry->addr.id, msk->pm.id_avail_bitmap)) + msk->pm.local_addr_used--; + spin_unlock_bh(&msk->pm.lock); + } + release_sock(sk); next: From patchwork Fri Jul 19 12:24:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737284 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 08069129A74 for ; Fri, 19 Jul 2024 12:24:46 +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=1721391887; cv=none; b=tZS4hSf7/TFe2/hq1cQ3ktNCnVC720BxYVEXQEJPF3HKtBds+jRbnKC6Qv2Af39vCItmSIa4WLNOX19RCtLUpmgmDrDiuhOFPRSnhfx+dKdmy2JLfty1shjWYJ/0XMfWYW3PQlHF5iOLzFfqLcUvZI5lygHpILXwK+3hG5lrRqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391887; c=relaxed/simple; bh=u8qIDXTTzowhUR4HkW0eiXruuNaZM+rGz61FM/Q9y9Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UAEj4xApNyYN2cTP8bWon18IKhuLdlOEKC8uG6A1NOU87w+RKFrSAMa4ST1Q6IUlUIqRNYifjY/yo73nkkUmc3zLEW7RppmRvZNBX7uDX2o+MjC2PN7FR16WOfb7ik9v4UwSKGB8pWwf77PKa1QssVTWYbe605cZBGOel927XlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MOkn2Hlz; 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="MOkn2Hlz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB5B8C4AF09; Fri, 19 Jul 2024 12:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391886; bh=u8qIDXTTzowhUR4HkW0eiXruuNaZM+rGz61FM/Q9y9Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MOkn2HlzCZTguN65XebG77t3Tm8PUbWShKVf5nRK3L3KBvB1Rs2H91YxkzorVo7uI fSrFFseyqOnsZF562mrnnXBF8Cfo814CZ6ewxZnlOQvyDrLRYU37V/XKT7Vb7TpuFv wv40ERBJOld5yg9HkRqgquB1X5R0Rumrg50UO5BR8um5k2/fia3eif2DxcQPAbcHGq +87s1EQli604blKOJFk32CkiyQSz3PAqkTsrq+egyk0rMT1SMDRwSUgf15y46+ggoD cFCB79RpOrrqGGp94s+4ddrsXpgzvH6wYEEywRsterbHO2mp3P/pCXqU0laOLuKlNF Pi2H1i/Lug6IQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:22 +0200 Subject: [PATCH mptcp-net v3 11/20] selftests: mptcp: join: check re-using ID of closed subflow Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-11-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2972; i=matttbe@kernel.org; h=from:subject:message-id; bh=u8qIDXTTzowhUR4HkW0eiXruuNaZM+rGz61FM/Q9y9Y=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsA31vFyHPIJV8QXPZvOToF3f7OsZL3zRy83 mk9pbA2xyKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c2PxEADqAL6/Dl178kja6geiCS/rSWrEROC0g/U50j1AVTDGl0Xvg24VruT1ih9o+Y+49g9oKlc Lf79XLp0WDFiKTmAChWvsMNOQq4/kIpDXBRVXbZKiaLfWz+3IYhTxxxCUrtY/EUzxs5tLYxJjPy fCgoSPb52Dxbj+RVky0if9JnFZWN8K7+wt7+Qu5zEMiqRAqExb0SPyY6EaDQUoaw6vCPfaJus+8 NMiBQleyfUAexNtS6ieE+KIpN7h85z/xQA4J/P7WqPvrgcSUFAl0zOgxALFapaxjaG1ld4z8p9D DT3Q3+JI23xJeVxyLq1c0oWcQ3kEO6/HIEDATh+r0bMa8it8uN9NvmIFG0W9mR1jusF5lLefJfx fQN9nLceNWMiX9Joezax5L7WpU42Eso4ye09Iymn1Qn2eIs7gqNM6r+jGQcjwLJKpPyH8RnbDXC haFYeo2peM2hTZaMyD0MfT/jyTo/EyXiZVpdiAW8afTbw/o2bJ/Gqe4ey+NhfmdEP+tFqLvea8C p1VLpkmf0a9QIyWmZdemwK1O1zbEq4w1CeoON/wfW2HDV3IlJPRMXi26TCo8NcxFOEf0awcyKbP bYOSuRf9AmwgTGzPgdJ6O2BPzK1lfn7NRDj0AFimt0ZXysTDr9D+Dfds6tQyZpytrG+aLsWHyl0 cadCAy18YE1M7YQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This test extends "delete and re-add" to validate the previous commit. A new 'subflow' endpoint is added, but the subflow request will be rejected. The result is that no subflow will be established from this address. Later, the endpoint is removed and re-added after having cleared the firewall rule. Before the previous commit, the client would not have been able to create this new subflow. While at it, extra checks have been added to validate the expected numbers of MPJ and RM_ADDR. 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. Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 27 ++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index b4dc5f2772dc..c5aa745a36f5 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -436,9 +436,10 @@ reset_with_tcp_filter() local ns="${!1}" local src="${2}" local target="${3}" + local chain="${4:-INPUT}" if ! ip netns exec "${ns}" ${iptables} \ - -A INPUT \ + -A "${chain}" \ -s "${src}" \ -p tcp \ -j "${target}"; then @@ -3527,10 +3528,10 @@ endpoint_tests() mptcp_lib_kill_wait $tests_pid fi - if reset "delete and re-add" && + if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT && mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then - pm_nl_set_limits $ns1 1 1 - pm_nl_set_limits $ns2 1 1 + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 0 2 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow test_linkfail=4 speed=20 \ run_tests $ns1 $ns2 10.0.1.1 & @@ -3547,11 +3548,27 @@ endpoint_tests() chk_subflow_nr "after delete" 1 chk_mptcp_info subflows 0 subflows 0 - pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow + pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow wait_mpj $ns2 chk_subflow_nr "after re-add" 2 chk_mptcp_info subflows 1 subflows 1 + + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + wait_attempt_fail $ns2 + chk_subflow_nr "after new reject" 2 + chk_mptcp_info subflows 1 subflows 1 + + ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT + pm_nl_del_endpoint $ns2 3 10.0.3.2 + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + wait_mpj $ns2 + chk_subflow_nr "after no reject" 3 + chk_mptcp_info subflows 2 subflows 2 + mptcp_lib_kill_wait $tests_pid + + chk_join_nr 3 3 3 + chk_rm_nr 1 1 fi # remove and re-add From patchwork Fri Jul 19 12:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737285 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 EDC6984A4C for ; Fri, 19 Jul 2024 12:24:47 +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=1721391888; cv=none; b=Qd8Uu/WAxe9ZNxCIOA0OzHkKyA2sOPgERlknFDWAVGhbHWVwNt7yEs/BbqE/8pCCWb4rkPl8WoAkwUkgNaY34MDMoKQ4ipwOn6qG/HhOFWlKabGUan2TSRd+r2vQOQMx9joHeVZdGvw4up0a5HYIeoAyOAzGr7tV2HR0TSkW9OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391888; c=relaxed/simple; bh=GEkkHViB56dUWH56K7rwfK01aIrJJch4t8GMykQ7od8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d9jsFdRIFDnP6/nqb5Ps5DWz/6A4FYVOjUgETowqaXKSxcFmKV8gWyAnaSJMcb8SLHa6FqW+kmVioC7QrbbCClUHbNeG54GCO6pKC5Uij9MuoNYPivQmN78LwgYGJl+sn8pGorOfL1q8a7cetri+fLKNH4GCxzTYZXAh+zifT88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HRjFJt1/; 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="HRjFJt1/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22258C32782; Fri, 19 Jul 2024 12:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391887; bh=GEkkHViB56dUWH56K7rwfK01aIrJJch4t8GMykQ7od8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HRjFJt1//ILJRdcTolJb8CsFbyLK9Ti5KRhCIs1pKoGSwyRRq1kVV/A9ZPy8bL3dV v5Bw0JYYuDqghbvGtPHppkzEbG96k7u04ZlKCzToAlpQBO0PApNUzwHTzCxnrJstC/ KKFcjb1hTz7b9XJDJAXesmCn/u5yOr8hkLwGiUVZIf0K9nOd6XgfR4dlTZoumzar+x Yk6qnrAWIxgQqZyHhE+Dv3f6waaynbCBAVNTAWJ+1nmDr1SXwLIghjnM+bA3vy6rL0 sieP4OB4RQFwJAdFl+VwyXwhGUnlO42/hEIHUYf0P8GCK7+hCkkmHemryRfSN6tULa x9P60gQdIXC9w== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:23 +0200 Subject: [PATCH mptcp-net v3 12/20] mptcp: pm: re-using ID of unused flushed subflows Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-12-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2788; i=matttbe@kernel.org; h=from:subject:message-id; bh=GEkkHViB56dUWH56K7rwfK01aIrJJch4t8GMykQ7od8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsAOApfGeGnPS1nX5zxJQx5kbjON7HncCdMP rb7EbYDC/eJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c3tXEACv3uzCndPXG2SIhYWFE0vZK9TH8+Sz6dhmg868+Uha29skAl3YHxjTkqxlylJQSbdEXtq vTe6hxloFZYLTXmVQEBToX9BiIs42X9rAJsPLXjFLQ5S5Yva0nAYNdK0Ch8sgMhLmje7qQ4bMNU TdnMuj6/udrh/v7I6tK1EE0l2amz5VA6odwq2IWqz4O0Ij5JJBBiHvZiq4SUsPUpsKdS/BP8kr3 7btrkP2UQUdm1zELjfCJyEBPVn+QnVb+TIzJkPhBLO1fgJfGHcKj13nxF2lCYjg+A8zg/D0MH7i YPsmbFa4ABCa3+ZGUqm5pIffcSxZMpd91tzcJ2QCycTJ+WGwWws96zQmrnE8cOoFJ0UXxAjCLYs wfMa0mssWTalPKgAuJTc+/BCFJfUFdn6uge6pNi2DvYDl1jHO+KiRttyRbobkk76N6ByhqU3uXw mx7Itl6KG112I1FlsK1wlhUpHvpHIzmo1U2LDh5FbClWthmeonMrZZW/bZUKjz9awF/zKxTvF5c 3ojf96FtHLM50i+aZJ1kgeMVmWksB31vk1goqY/R6sOgHoW+wzhkPCvRiNEbzUFO1IVYLouGCxa ikuM09526kny+dg6YZUhf8k7ccOySf/dcctUmiOXYsNJYATl5faiccfleZAA4h3uAvXDi4HEF3+ z18i2ed99yTjk1A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If no subflows are attached to the 'subflow' endpoints that are being flushed, the corresponding addr IDs will not be marked as available again. Mark all ID as being available when flushing all the 'subflow' endpoints, and reset local_addr_used counter to cover these cases. While at it, renamed the helpers linked to the flushing operations to make it clear that the intention is to flush all created subflows, and remove all announced addresses, not just a "random" selection. Fixes: 06faa2271034 ("mptcp: remove multi addresses and subflows in PM") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index bdbf27fe89e0..4045e5cc6298 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1586,8 +1586,8 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) } } -static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, - struct list_head *rm_list) +static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk, + struct list_head *rm_list) { struct mptcp_rm_list alist = { .nr = 0 }, slist = { .nr = 0 }; struct mptcp_pm_addr_entry *entry; @@ -1608,12 +1608,19 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, mptcp_pm_remove_addr(msk, &alist); spin_unlock_bh(&msk->pm.lock); } + if (slist.nr) mptcp_pm_remove_subflow(msk, &slist); + + /* Reset counters: maybe some subflows have been removed before */ + spin_lock_bh(&msk->pm.lock); + bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + msk->pm.local_addr_used = 0; + spin_unlock_bh(&msk->pm.lock); } -static void mptcp_nl_remove_addrs_list(struct net *net, - struct list_head *rm_list) +static void mptcp_nl_flush_addrs_list(struct net *net, + struct list_head *rm_list) { long s_slot = 0, s_num = 0; struct mptcp_sock *msk; @@ -1626,7 +1633,7 @@ static void mptcp_nl_remove_addrs_list(struct net *net, if (!mptcp_pm_is_userspace(msk)) { lock_sock(sk); - mptcp_pm_remove_addrs_and_subflows(msk, rm_list); + mptcp_pm_flush_addrs_and_subflows(msk, rm_list); release_sock(sk); } @@ -1667,7 +1674,7 @@ int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) pernet->next_id = 1; bitmap_zero(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); spin_unlock_bh(&pernet->lock); - mptcp_nl_remove_addrs_list(sock_net(skb->sk), &free_list); + mptcp_nl_flush_addrs_list(sock_net(skb->sk), &free_list); synchronize_rcu(); __flush_addrs(&free_list); return 0; From patchwork Fri Jul 19 12:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737286 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 6634C84A4C for ; Fri, 19 Jul 2024 12:24:49 +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=1721391889; cv=none; b=JZOluwLSl0Dt4IaNBzacChLW/KBnV99ajdL96WP8SJgWyFvXTYKbdVFuXSUH0zA3CuqlON2Rqk5o961bOIpnpxA2FmpZo112B4kpdYpjMjtNH6L4vt/220lOlLz6kSAhuoUbF/ZJzHAbmWNHoMgSRoVjzbfm3PzjHlJrY8xj8IY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391889; c=relaxed/simple; bh=XkczOedmWFgLcnHwG5YodN3uumTEtKKu+YQSdFypLd4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=amTZq3vbOuj0SncZA3AgwpB3r0DHJNoZmYXxJ29MZPvvvIB+f0tClXxTBI3ExIXa4ybs30KPmqNMszW6oJ2DmfrBbIovkhMFop6fcR1MtTyLZ5zqhhLDeJ24RJa1TT+NaJTlrebXHG1RQjNxUE/DtSFoezWdatkyYUQyJVyhUAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vB4jpnIr; 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="vB4jpnIr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DA28C32782; Fri, 19 Jul 2024 12:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391889; bh=XkczOedmWFgLcnHwG5YodN3uumTEtKKu+YQSdFypLd4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vB4jpnIrNN0a/J4aMI30aaYxVyz1PmKvHKukoKK3rFZ34t/eFRdcX8dvLSA8Yq62H zvkdJItpS+IK+belij/+h3DI5qkVs7jFsmsT2ee7Ohvq5KN/9BZhmEFS7XIXuKen8r w4C79GnHkgNE/uN7Ms0QUWr0llunp0ulTfeBzL2+feuXfmhnqcuE6ErIUiMzeJ6a8S t8Y6eihv+H1wXv4YuWGSCyvqw+NylwQv12fRNUICr8qLMY3DNyuA4qLlAGnhw1D7UC bCzb9FSXRygQmccA/eGp+Kc2QlC+OlX9HBk1ovckdbD5JQP8Ce7t/hqAh5SGT8Vzcp h69uBZZkI+PSg== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:24 +0200 Subject: [PATCH mptcp-net v3 13/20] selftests: mptcp: join: test for flush/re-add endpoints Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-13-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2174; i=matttbe@kernel.org; h=from:subject:message-id; bh=XkczOedmWFgLcnHwG5YodN3uumTEtKKu+YQSdFypLd4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsA9pBfFYYBgYdfslFZJLrB5ksBw/WPoSewo OLiYhyDVu2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c3ikD/43KJG6sdoy9hYlMWzGU99Z9nD3lUGwo2ouVN5iQPU+eMeSY92QQdaR6ewrxNVZAT6KUKu R+1PwxlP35lTCqihAxygq3WynrgtCZPswkGeGrXE5BKeu9MzNXeCDmTyHUr27ITbTnmHIbrTtYU XJ7t2hCbJ8fui+kxTq5hSAnV+bXsx+1jJ7BgB47bbYpR5Oop3bnsFAHLTUHVnXCKTuKgcVEMbPB ARgWGZXwsZem9npDQzeWzTNOrzMu07pn5WCwTlwe81Fi3RSCOZHohZM+Uc3GMMXvYuqxhIEccO9 MsfXdCDj3AFV3RC8swYLqqvKeKpyxT4FbHXXCe9eSWya7Lg2I9B6halIg6v46IaEgzoTB+1VGo5 U/MABEVKtyyY8rRBt1LokeA4wIR+Jjmayz4FjAjtCIAjptACAUe4I6TbdYRT5aKNgEvbwJKA2kX nWGuXERr6p85a/eAvqLmLxcTeYLWxLwhLSkL8OWzCq7T5gd1HhSDoc+k3v3yaW1ahwOqJy4YM1i ltbhUoBD+xrU9IeraWjTCx3i9oG7sJqDGXPyQl5i03XlWUV/nsCKx1sEQAMWd4OH5RhWdHjPYRh ffYDzPG3vk6bk8TEPymiE2os81+7uTCCblyAAfCt1nu623KkIce1URYbvs7uJskLJsYMKhiCjUC EX1ElFHOmu2OTsg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After having flushed endpoints that didn't cause the creation of new subflows, it is important to check endpoints can be re-created, re-using previously used IDs. Before the previous commit, the client would not have been able to re-create the subflow that was previously rejected. 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. Fixes: 06faa2271034 ("mptcp: remove multi addresses and subflows in PM") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index c5aa745a36f5..3565d8b48125 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3607,6 +3607,36 @@ endpoint_tests() chk_rm_nr 2 1 invert fi + # flush and re-add + if reset_with_tcp_filter "flush re-add" ns2 10.0.3.2 REJECT OUTPUT && + mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 1 2 + # broadcast IP: no packet for this address will be received on ns1 + pm_nl_add_endpoint $ns1 224.0.0.1 id 2 flags signal + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + test_linkfail=4 speed=20 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + + wait_attempt_fail $ns2 + chk_subflow_nr "before flush" 1 + chk_mptcp_info subflows 0 subflows 0 + + pm_nl_flush_endpoint $ns2 + pm_nl_flush_endpoint $ns1 + wait_rm_addr $ns2 0 + ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT + pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow + wait_mpj $ns2 + pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal + wait_mpj $ns2 + mptcp_lib_kill_wait $tests_pid + + chk_join_nr 2 2 2 + chk_add_nr 2 2 + chk_rm_nr 1 0 invert + fi } # [$1: error message] From patchwork Fri Jul 19 12:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737287 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 5423A83CA1 for ; Fri, 19 Jul 2024 12:24:50 +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=1721391890; cv=none; b=ihj/iNImq3+NQv+WOsY3TVh6Y2nQSxykVMjBY1VEyDIeZTA7IW+q9EmCf0rK9A3/KRYbXpzoNnYYkVIxqZ6pv83lzmLHfVi9ejvfSGtsQOO6akentVFTWdmITyqNLnMxiB3F3/xJspeoSoPemrHWjf3BIYhG3BZ52nyuZVAjfOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391890; c=relaxed/simple; bh=DPCMP4eWODT9nHLLzAjsnvSTdaXqPhdwWCvENtknObE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c5l7fV93J+xhGt863C9RxAgvkWA/3kT2JO1dESvI7aPvhczY74bcOK5XRQ/w+4cSHyOaKx2pxpnvMoxH93+xnAd62YFoJoDeeS1tl11JSdBlUOe7aHskWhU0L4ZCm5Osvi33ik0sfEdHoayr6ctCYMZyZ/xnAbsZOGQkedoW/Lg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RVHxhs/V; 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="RVHxhs/V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 789C9C4AF09; Fri, 19 Jul 2024 12:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391890; bh=DPCMP4eWODT9nHLLzAjsnvSTdaXqPhdwWCvENtknObE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RVHxhs/VSWFCfsS+DJxB/9FnagM5tkqKbS8amCBf3qHHMGxBd9X21vM9WkhecCIX0 6vLF8RswzZmiVpidOZ1kQtZ7GOldTyy+8wH3AeIEwe2UZe8Tp14a8qYmELS6+Xyw0h DLBLwE+qor3vmS7NoGDMwDGnz3bdnj0pz+bOChQipmpFiAWCb8E8BsAYOaiS0So1+E M18hT9Bna9ckUolV7lXrqigOG2klmc7A2WR5y5a7GwUrzgn6n+d1k9+mEpRAL2ph0T EoKjnVkBX4Kd5rM3Q3htSyC8ho4nkdgMurMjCoYrxg0WFpT8zlhReRU18m20n6aNI+ Xu9Ny+DzJVi3Q== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:25 +0200 Subject: [PATCH mptcp-net v3 14/20] mptcp: pm: remove mptcp_pm_remove_subflow() Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-14-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4828; i=matttbe@kernel.org; h=from:subject:message-id; bh=DPCMP4eWODT9nHLLzAjsnvSTdaXqPhdwWCvENtknObE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsAyoqM4dmUPOe1pqH6oWFZjxcqq8bKpioBN /duwXK23JGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c/nCD/9XlX7zc6uLT9JCo8gVE+Qrib0+kSWUA5l0guywL2JJerGx1jFwpeLASxUJMZGEvPVgP6S Y1i+uSPjXDlLttZiF2AXEZ341cBBeq7j6u1cDTctNZZbVOKJyqJmq1IocYiJoh4MScVCOcArBAI 4AyNI7UA/3AvbC27SbSiQfXjGCyg2r5Ccm2jIElWBQ4M1rFOYHJDhjwQka8Lz7Rq3joemqYxYlG 06Vo6awlztxJuYoyG60ukevhwm7ZLUDSTmSrsnYh2loGuvZ/zITUOsPMvYxjQug4Nr1X7tLTZA5 LdWUFo+9n5/SUzZgCSQ/6bX5HtdvcfV5/RCsqCZlQmO/Yvcl/uW5nBk9rSrXg7d6MKUO2yWuU/7 o4K7ODy3scgwJ9/1f5quapraG3XLg5D7gp75fUce0QOKGb6dcX+pHVic9OuOu5enscQVG5y8IK+ W+OuyoDyvhbHEUqtLdU9dCYJ/poanNFmZMPOlMmNb0j/Xxjxfn0DsVFIdqHsjGoe7UQHuyNkaPd p5Ex8WDO0Pwy6oaiaTdGzw9v9YHPBdYI/soUtVktIBtopVBpbXOOaGCkRaBNLswTy1yHoZgEvVj lhOB2f24E+GBbINYgwNbUkuXmPCp/Bme3pkuUSBaZq+HYn/4YYg4Dq6hdTUbRw9lqkemMIgkugh uKE/CB0CUw+D3Vw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This helper is confusing. It is in pm.c, but it is specific to the in-kernel PM and it cannot be used by the userspace one. Also, it simply calls one in-kernel specific function with the PM lock, while the similar mptcp_pm_remove_addr() helper requires the PM lock. What's left is the pr_debug(), which is not that useful, because a similar one is present in the only function called by this helper: mptcp_pm_nl_rm_subflow_received() After these modifications, this helper can be marked as 'static', and the lock can be taken only once in mptcp_pm_flush_addrs_and_subflows(). Note that it is not a bug fix, but it will help backporting the following commits. Fixes: 0ee4261a3681 ("mptcp: implement mptcp_pm_remove_subflow") Signed-off-by: Matthieu Baerts (NGI0) --- Notes: - v3: - New line before 'if (remove_subflow) {' moved to patch 10 (Geliang) - One PM spin lock to remove address and subflows (Geliang) --- net/mptcp/pm.c | 10 ---------- net/mptcp/pm_netlink.c | 16 +++++++--------- net/mptcp/protocol.h | 3 --- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 55406720c607..1f1b2617d0f5 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -60,16 +60,6 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_ return 0; } -int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list) -{ - pr_debug("msk=%p, rm_list_nr=%d", msk, rm_list->nr); - - spin_lock_bh(&msk->pm.lock); - mptcp_pm_nl_rm_subflow_received(msk, rm_list); - spin_unlock_bh(&msk->pm.lock); - return 0; -} - /* path manager event handlers */ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 4045e5cc6298..a653ecc9e9ad 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -858,8 +858,8 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) mptcp_pm_nl_rm_addr_or_subflow(msk, &msk->pm.rm_list_rx, MPTCP_MIB_RMADDR); } -void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, - const struct mptcp_rm_list *rm_list) +static void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, + const struct mptcp_rm_list *rm_list) { mptcp_pm_nl_rm_addr_or_subflow(msk, rm_list, MPTCP_MIB_RMSUBFLOW); } @@ -1456,7 +1456,9 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, !(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT)); if (remove_subflow) { - mptcp_pm_remove_subflow(msk, &list); + spin_lock_bh(&msk->pm.lock); + mptcp_pm_nl_rm_subflow_received(msk, &list); + spin_unlock_bh(&msk->pm.lock); } else if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { /* If the subflow has been used, but now closed */ spin_lock_bh(&msk->pm.lock); @@ -1602,18 +1604,14 @@ static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk, alist.ids[alist.nr++] = entry->addr.id; } + spin_lock_bh(&msk->pm.lock); if (alist.nr) { - spin_lock_bh(&msk->pm.lock); msk->pm.add_addr_signaled -= alist.nr; mptcp_pm_remove_addr(msk, &alist); - spin_unlock_bh(&msk->pm.lock); } - if (slist.nr) - mptcp_pm_remove_subflow(msk, &slist); - + mptcp_pm_nl_rm_subflow_received(msk, &slist); /* Reset counters: maybe some subflows have been removed before */ - spin_lock_bh(&msk->pm.lock); bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); msk->pm.local_addr_used = 0; spin_unlock_bh(&msk->pm.lock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 19d60b6d5b45..f2eb5273d752 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1030,7 +1030,6 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool echo); int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); -int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_free_local_addr_list(struct mptcp_sock *msk); @@ -1134,8 +1133,6 @@ static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflo void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); -void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, - const struct mptcp_rm_list *rm_list); unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk); From patchwork Fri Jul 19 12:24:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737288 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 D10AB83CA1 for ; Fri, 19 Jul 2024 12:24:51 +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=1721391891; cv=none; b=qKBLdy80LzumNL55LXq8Q2afk0VAYt/QsjJcAXsCtcTqCV4ij9o7TzpkuLirl+TzrOeHh99hAIV6hsX6fJ17lWRO4dE0cnWoJHT+ky6Tmw1CQ9ntJwXukHkplxLE8OR1BnlTs08iS35FSS+86PWnmy9Ei16AC5AlejpaBe98FL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391891; c=relaxed/simple; bh=0xFMDS4qYHKOiwYm0etxgWoqfwa1KQQH9JL0qVq+ToY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PkeU0IsLPm2T6kl9r6R9ciIDhLgePkkJeyus40IRrXCwbdTBlZ6jfrQcoGFHAq7dIU7BDhPoqHuP44J9zKq0im4KudAqs4chH/L9HN0HIDlNaVRUBXCyP6yFyUvv+4qojCGvhnzinYGVlQZv3sv4nDRP7db0MOdr3gCb5jx/NdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hK7jsMGg; 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="hK7jsMGg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6570C4AF0D; Fri, 19 Jul 2024 12:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391891; bh=0xFMDS4qYHKOiwYm0etxgWoqfwa1KQQH9JL0qVq+ToY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hK7jsMGgvT24VnVJerpCyyfpGb7utiau2HbJGHUxjUjNgOT4f0pN0PY4NkgReApT8 qYvSArm6y6svIb6OIoLKQKhy+RCB+ExVVauNnMtpP8Y/VNv2LI4MaCdR/QNGu+j1Si KjUuxyDgb7EYIQrAa0sQWhE5IlgVugBg6xUn1Bp8Zla286O0k4vrLcCSICjRbSq4mR mPIaY62Xxsz6TMBp66SH2bsKRm6mFATYujlGB4fQmUZTDfEZuJ5OgSDwrSS35fFqvg DFPlT3DoGW07xbq+u2fAK2euMhVBjBfhD0eJ01WpkGaV5waMcScg3rfTU6mXAJMiJd MNdlHTwDVSugw== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:26 +0200 Subject: [PATCH mptcp-net v3 15/20] mptcp: pm: only mark 'subflow' endp as available Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-15-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4021; i=matttbe@kernel.org; h=from:subject:message-id; bh=0xFMDS4qYHKOiwYm0etxgWoqfwa1KQQH9JL0qVq+ToY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsA5YdgSfZiQIPpsche40jiPS6YNaMUDnZvU soIFsEUXeKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c1vKEACKc5H450TOd++KcBl3GDYwPrAckuvfwtBlpYawm9bfpJsKMFjn/vdyy6kHJklgYGSBmq1 bFV0WGmVLFJED1YkVcompKJ6PlswGMRAgShnKHVNkV8XbcMUAuIUBonUC/z97hoOpdPsWVmXEHU jEogu4LArY2EdTs2sSppcs+ESkuEWLg3UUryMlLvr6DNh9iaccjBgoi9TuSNIbZ73rARH27dBIC W4IJBE20dNS8ZJwY8bHNo6yL/+J8DuW6Zb0F084/Ie0GHtg5yvsbwA8RmC+Mf12+SqFzZShpXFS uPcrmuq7xS1IDykmfrdvTJrMiFjMA+JnUdFGvjH+9n+f/XkKt3bVZCSHKF7SaekK/QL4G3Lx7Jp 8Jh73zNxMjPmIb149px+cMeiKZG6y/oHBYTOCNjRuILnrXu1KQ6H5b2kvF/YTdaRtgLG8EKSShB /hhqBuENqzsgp8j2fQPrLtuq+BsaFta5qTZcErsqaM8ognfDJ7F9g0Uul3Drf+Vxrug7LmYdB39 mHZPLjJi3xYGPw2eFmJWdImzEv3OMZmmvc90pMcROutM3BjJVjzdW5KyPlqDRIRS42fudraDjkL Cnm+IjbiAp9aW6n710SFfTnZTa1nv3OD9Hp18y/an3oGcnv4luQbKMDLSXCn6mfmtkoNcKp+9bA Zm/ko43gI2mpH2Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Adding the following warning ... WARN_ON_ONCE(msk->pm.local_addr_used == 0) ... before decrementing the local_addr_used counter helped to find a bug when running the "remove single address" subtest from the mptcp_join.sh selftests. Removing a 'signal' endpoint will trigger the removal of all subflows linked to this endpoint via mptcp_pm_nl_rm_addr_or_subflow() with rm_type == MPTCP_MIB_RMSUBFLOW. This will decrement the local_addr_used counter, which is wrong in this case because this counter is linked to 'subflow' endpoints, and here it is a 'signal' endpoint that is being removed. Now, the counter is decremented, only if the ID is being used outside of mptcp_pm_nl_rm_addr_or_subflow(), only for 'subflow' endpoints, and if the ID is not 0 -- local_addr_used is not taking into account these ones. This marking of the ID as being available, and the decrement is done no matter if a subflow using this ID is currently available, because the subflow could have been closed before. Fixes: 06faa2271034 ("mptcp: remove multi addresses and subflows in PM") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a653ecc9e9ad..ea942c9f998f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -834,10 +834,10 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (rm_type == MPTCP_MIB_RMSUBFLOW) __MPTCP_INC_STATS(sock_net(sk), rm_type); } - if (rm_type == MPTCP_MIB_RMSUBFLOW) - __set_bit(rm_id ? rm_id : msk->mpc_endpoint_id, msk->pm.id_avail_bitmap); - else if (rm_type == MPTCP_MIB_RMADDR) + + if (rm_type == MPTCP_MIB_RMADDR) __MPTCP_INC_STATS(sock_net(sk), rm_type); + if (!removed) continue; @@ -847,8 +847,6 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (rm_type == MPTCP_MIB_RMADDR) { msk->pm.add_addr_accepted--; WRITE_ONCE(msk->pm.accept_addr, true); - } else if (rm_type == MPTCP_MIB_RMSUBFLOW) { - msk->pm.local_addr_used--; } } } @@ -1426,6 +1424,14 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, return ret; } +static void __mark_subflow_endp_available(struct mptcp_sock *msk, u8 id) +{ + /* If it was marked as used, and not ID 0, decrement local_addr_used */ + if (!__test_and_set_bit(id ? : msk->mpc_endpoint_id, msk->pm.id_avail_bitmap) && + id && !WARN_ON_ONCE(msk->pm.local_addr_used == 0)) + msk->pm.local_addr_used--; +} + static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, const struct mptcp_pm_addr_entry *entry) { @@ -1459,11 +1465,11 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, spin_lock_bh(&msk->pm.lock); mptcp_pm_nl_rm_subflow_received(msk, &list); spin_unlock_bh(&msk->pm.lock); - } else if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { - /* If the subflow has been used, but now closed */ + } + + if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { spin_lock_bh(&msk->pm.lock); - if (!__test_and_set_bit(entry->addr.id, msk->pm.id_avail_bitmap)) - msk->pm.local_addr_used--; + __mark_subflow_endp_available(msk, entry->addr.id); spin_unlock_bh(&msk->pm.lock); } @@ -1501,6 +1507,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, spin_lock_bh(&msk->pm.lock); mptcp_pm_remove_addr(msk, &list); mptcp_pm_nl_rm_subflow_received(msk, &list); + __mark_subflow_endp_available(msk, 0); spin_unlock_bh(&msk->pm.lock); release_sock(sk); @@ -1902,6 +1909,7 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); mptcp_pm_nl_rm_subflow_received(msk, &list); + __mark_subflow_endp_available(msk, addr->id); mptcp_pm_create_subflow_or_signal_addr(msk); spin_unlock_bh(&msk->pm.lock); } From patchwork Fri Jul 19 12:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737289 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 B6EA283CA1 for ; Fri, 19 Jul 2024 12:24:52 +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=1721391892; cv=none; b=fz4XJwQTWP0wU1HdWRW1esdrDZOtqOuhXX3v8nJkZgkbkvwg2KBu6N/+h6ugXorUaAbE6dshiRBHNTy300XHUn2zsX5gcB+hfyVAK/9Soi+FdjuduM1MElcdKym5ZhMejcczRLePc/iJhQGWs/agJjyc5T2cKTLWl8FBLSEJ82Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391892; c=relaxed/simple; bh=DeLnnNqaKgMl/0xcB+x46WxsWT6jNX6wQUj5lqlSQtY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uYgj/jvVpy8ZyzIPeqbxgWqRJLpOxeLFWdsZgagJTlIzZc9XpKBcFpagNaVAa26zFj44+KsX057CzVI0IQJvUoUJNVv9nw2h7ui2xyf5YxwyuHYUclshosICllLaezz1BByOYuJ1zZoLhniBPuyfG9QyAcIkPwJXomWHCXxls/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kv2hrj33; 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="kv2hrj33" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D297AC32782; Fri, 19 Jul 2024 12:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391892; bh=DeLnnNqaKgMl/0xcB+x46WxsWT6jNX6wQUj5lqlSQtY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kv2hrj33GnD7d/9TDZoi4KxMNe9KvtW2SP/nBCEmRWuxL8o1gAlbgyJK1TNmgmfk2 8YBIwMijohfR4yVXihGaVP8LPqskQNAZACttLNuxfcSlPmSm2ACmFspi9ZXDUzl14K 6Jsc9mTXrZwDTYHNcklXuONov0g55r6WRscFWUwWQclLBQZN0pPkvyyjzTK4QHhgJx bH0rmU2jK8ZleqkdNl5b5VzYMI3mHAq8VU7cGsKLSeZfjxoCaDCO6lukho7cx+oOop w61uVil00ZoV3xIAWyhJENXqtV3IVjZUGbzos8i/vzsKMR+h89GSpo2KXI7f9sFj12 mfveCVAGake+A== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:27 +0200 Subject: [PATCH mptcp-net v3 16/20] mptcp: pm: only decrement add_addr_accepted for MPJ req Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-16-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1961; i=matttbe@kernel.org; h=from:subject:message-id; bh=DeLnnNqaKgMl/0xcB+x46WxsWT6jNX6wQUj5lqlSQtY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsAiZ7MoDrA0+Hitu3TgvhHdiYcjISJJsAf4 KdOxlZH9W+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c9S3EACU++rg7KrBRuJrDsV1Zdpem8O8SdxIAwAPOAUSP00NroV6GM09UF85mVyssfE3VOJhN/l Q3da/dIsUaPoSjEQr0+fhv9pS9DnEJUFqx2q78cax7DGPCP69o9OPYiXC8gEVIylz5apcmVnTEc NPEE1VBseo4ki07rvIAXxDLrKWtIhMaeW6XImGVIVhJOUrdrc0ojXsoed5wl+WlZisa3R2J6pmK sXuCLVaYyyiwEtUbeAqkrHQEFAsVEUWY1dw8r8KBpqbrGutXFnM1eYY0hQhblWh/P78LLwiiTtS qGNOXbZoPf0pvw6hxua01I0rXz3QOvpijeN8WX4CnLjBx2XAiK+V/Dqx7IfUjOwQK8MtxmyGhzr 3oa7n6sbxCx22b+iwhPFIiW6xrky2zOJiApfXrYRxqj5saM8M5W70vWkVmD5qdcGW4cQIFNpI5E t5+B+uIRN1LuA0JEY9hdg2NJUKlqC+FsmSWhdaIpZ5TcIrtF178aReqCwnes9WGdEH0MhTnCfmJ PAY3UDco30zab6557GSbIOXXC/+HV0EVABePZuQpMIt1pi5VLUPPeesTnVXK1EP4vU/0zM39f5G Dk7WCp1ToFdp6x/V+FClXTcJP5pusO5Nn0bO+vFKR6Ys9Km92ktU5Ff2NW2GGCkojRvt4rhjjJg FAUKiPJpNSNij2w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Adding the following warning ... WARN_ON_ONCE(msk->pm.add_addr_accepted == 0) ... before decrementing the add_addr_accepted counter helped to find a bug when running the "remove single subflow" subtest from the mptcp_join.sh selftest. Removing a 'subflow' endpoint will first trigger a RM_ADDR, then the subflow closure. Before this patch, and upon the reception of the RM_ADDR, the other peer will then try to decrement this add_addr_accepted. That's not correct because the attached subflows have not been created upon the reception of an ADD_ADDR. A way to solve that is to decrement the counter only if the attached subflow was an MP_JOIN to a remote id that was not 0, and initiated by the host receiving the RM_ADDR. Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ea942c9f998f..d040cf8af412 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -830,7 +830,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, mptcp_close_ssk(sk, ssk, subflow); spin_lock_bh(&msk->pm.lock); - removed = true; + removed |= subflow->request_join; if (rm_type == MPTCP_MIB_RMSUBFLOW) __MPTCP_INC_STATS(sock_net(sk), rm_type); } @@ -844,7 +844,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, if (!mptcp_pm_is_kernel(msk)) continue; - if (rm_type == MPTCP_MIB_RMADDR) { + if (rm_type == MPTCP_MIB_RMADDR && rm_id && + !WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)) { + /* Note: if the subflow has been closed before, this + * add_addr_accepted counter will not be decremented. + */ msk->pm.add_addr_accepted--; WRITE_ONCE(msk->pm.accept_addr, true); } From patchwork Fri Jul 19 12:24:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737290 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 DAE9583CA1 for ; Fri, 19 Jul 2024 12:24:53 +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=1721391893; cv=none; b=QXR32MMMuA9KlX08CxGbL/vGgvA1Os/JCHmp4oD51lGVZsqBOzpiG+9xh8adFnigDbkRUFoPNGW2gWfVqtlJtR1/77SF001I62JTCq0ParcSwmIXiXYnc5AsorDIGr8wqEVXXmT1gZS4k0BE6gp+3nJrClk3tZj40vPxciKzpuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391893; c=relaxed/simple; bh=4X7QSjPZQ9mzFn+OP2ehOB27WgZnhWY1j3aQBdeEXgc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VqmfVKLmtE+NKlYum2Ajujosw5ja0IFPJ6ZgTzmV2hsxXJVPChe3r5Y9aXxKh5kuVDZzR/I9t3tNBUt40w8A7XxiACOQpwIyxM7an/b5TH4SwDTqVO3QzEt3FHT9c129YSNH0JNYELXOKrQ/NbImE75GNlpyTRVf1/d3+jXcg18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CKmk1Q6n; 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="CKmk1Q6n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E97AC4AF0D; Fri, 19 Jul 2024 12:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391893; bh=4X7QSjPZQ9mzFn+OP2ehOB27WgZnhWY1j3aQBdeEXgc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CKmk1Q6nR87tgFDNn02c8NZn38OHuxB+k82qH+lKyJLphay/sQRU4wXIGnmWkLIdy XuEgd5o19QXUj7ytlaTdeyAbbrPmDgrGk7Loff5CQj0Z5FChxapsWivPzcbPF4ZCOF uau6rGpSQnSp8SwOc7+RHqGQXE4osa3JbY/U5mv6JNofXaDkWAH/Ik3BVGzxPoQIN9 PoyjeACDNizk9Oq9Ots5kZoCTvJjpluPSsJTI8NQafdpfDdQHkuduxYXEPsy+sTY+x UGNLogLPSOKRlboN2qA6VUQdEcjw6kBEiBOATC/dOuOwIltEJB036A7UfN2cSlMJPs 4VuQUxjRwHCdA== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:28 +0200 Subject: [PATCH mptcp-net v3 17/20] mptcp: pm: check add_addr_accept_max before accepting new ADD_ADDR Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-17-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=926; i=matttbe@kernel.org; h=from:subject:message-id; bh=4X7QSjPZQ9mzFn+OP2ehOB27WgZnhWY1j3aQBdeEXgc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsASl/Qr+hjWrUht/q/sEqDGTlWXENwQBJti eCcwuF3OHWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg cwtDEADdL8IuCxWfM+cOGZCmblFvxM/vT3Z6eK932IMMtwgFp1NTDrVtThGvyC4Ii/3NMMxv2ln spZPOMN+Q5Dxpn066pMripe8fEg8Xn+TFc6smbNDla0BREsWz5BW1WZ3POXdbB6VZ7mWD0bjFBD gISC2t8+Z9GyWe8IpmyVYeWB0sdN/b7n600THaZ8O4dETF8qqmIHORYlfmoT9dL+htuSdJAXc2U wZbVa//DiuSw4ALreLEaWw0aLms2K4BLYyFQczS5IEe4m1g+sFiyLhVafp9KhgOQV2IuePx/wwe OsVZdesrorMNPlZd6FXQBpSDFeDQIa2WqMnN5tEqfFTDdx+BC53CTpaG9sXvrLnsAEiSCmbCxTc xJU9R/oNJkiYEpjUlIfqc2ZiMWQgOzGnJSq2QNVIi0FKvMDkfm18AyaWHVBXr22CNourq9x2Y1G dULh4ISjdAhsoqrm5PCCDzsLYmRlmXPv7qINu0sqSzB8GFit+aTUd2fqYORGFql9RH1QNSS4uBl OPlNvQLn5wdjuICB66BgtSm1lt+OKYXJfBDiKeRuhS1O99IgsDULq/W3vH0EkO8oZNIDhKi3I5Y BX0P2l1oqJNG+IAbF9avBQiLgu0KKP+wSDD1Mm0t/nIG/9apuAoXL3CMVs2GhO0AWOnPoF4eeeH WonZZQ4tIWiewnQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The limits might have changed in between, it is best to check them before accepting new ADD_ADDR. Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d040cf8af412..b6086e9c7fc8 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -849,8 +849,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, /* Note: if the subflow has been closed before, this * add_addr_accepted counter will not be decremented. */ - msk->pm.add_addr_accepted--; - WRITE_ONCE(msk->pm.accept_addr, true); + if (--msk->pm.add_addr_accepted < mptcp_pm_get_add_addr_accept_max(msk)) + WRITE_ONCE(msk->pm.accept_addr, true); } } } From patchwork Fri Jul 19 12:24:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737291 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 568AC83CA1 for ; Fri, 19 Jul 2024 12:24:55 +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=1721391895; cv=none; b=O8iCL/rjoKwhI63F7QNDapoJyZ9L7IQoVB3asPblUt8iNxXbo+Vi4v5vkY4busA23BeFXad0DxFst94o8OjvJ1REnh6uIC/DJgiM3noBYYfdsvKwhE1YEqUOAR0uPEP6qKYqE83FQjAK2a1bQ5sI0LTvW/gn95d/zAcfbxnjl0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391895; c=relaxed/simple; bh=TWpomIPCHdgqln4Z9R1XvaM1nsH19QkgyOXDZ5F+sDQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K5gSz02nJRQuEd4uTev+h+eVKJdF1Iw1ULevMDsJy9xWrD15PcCgSbff+LSXZk8Ky3PHO84yZDSUnY7WnrTi9vN/bgEoqSe/fNNEeZrweXowLktBYmD9THxFdTGlbb+mSYEhl+gmqoxgdjhMzq7pNPfPRklCthGsxPeEMHZ/zp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R+Hwz4DT; 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="R+Hwz4DT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B727C4AF0A; Fri, 19 Jul 2024 12:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391894; bh=TWpomIPCHdgqln4Z9R1XvaM1nsH19QkgyOXDZ5F+sDQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R+Hwz4DTNm4BuVSZXJZmbTqiVte79ebKOAhaa6EyADWJGFEO5/ZaBbgICCCDCpKsR t4jjt/UNEfIAnrjvnHOBxHHPQ6F06cElOiaJTJAXdKT75UXowlHB8Tryu6SToT0j2W XAwFSgM+jafa3fX0gpI1IAdEE+aCKvC24MmuVlwTxzOU84xnVf5N6cODr2g/oH0U5B WSAHwdgCpNSTvy93JGiDiLjN90otSZKq8rjSzba0AjMr5dDFzQ8PVXgW4o80JFHFir /FuENoBl2lJN5//pW1UXqeqwtlyBI8owKttGu+U1F5TMiFiM3Nzlg0L42E0w28PmDB RWvpUYCVQ/ujA== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:29 +0200 Subject: [PATCH mptcp-net v3 18/20] mptcp: pm: only in-kernel cannot have entries with ID 0 Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-18-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1493; i=matttbe@kernel.org; h=from:subject:message-id; bh=TWpomIPCHdgqln4Z9R1XvaM1nsH19QkgyOXDZ5F+sDQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsAe0SlkH9Y8ultj62cN+aMBN4+RkuGotQnZ u/1GVOe1cGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg cx8nEAC6Gc6aUNyQf0a6eK1jJhlFlHIbvrInKzNJrxnUX8+KIID7+y8QsoH9yTDSFnvzDuq6p08 YPJXUYDePRF7W9toFtGte9dVAyKozcNKkOouHriT40AfxssPdEQ92SvQJ+tmfbEhK7EgqIkItoZ 41YUvYdyAcFqj3wmaDH1By1fPXNTMuu70Pry/5kVdIOmaNGv9YLb4LK6VbWk2IVz0gKCELafzDk RMtHp46hzQWb1Z/9opSZrQLP0frl/VdDXjV+4hhXCWlR4gjruWobfrgrpzCTWyRo4soHrj1UVz5 lSbo7qwsj2CjCqkhrvLUxfioHtiF6yllyBG3XL/dXrpqiESkfvwj5u1EIbM2kP1ApvwqUf++8CG HPX4X1su6QKf6qFpFmCiVEXEQgMsD8/M59qI/si5aFFBwiLuYpdpS7JLbzgrv7BWcFr4Tn7RdUc rG1qtfH0wrrSoGNwt2jub9nGqf7I9vq7oAvrg2EcRN1wER/K2Kqa4enwQUN7hWGAgKNQbfDI6Xi u0a2Rdyy0qDnqecD+RgGroSaR97dRNmGINjHRr4yzv3zqwxKmyEmjEstBExppO1l3x2H8GsQ0g+ lR0OUM2WSDPGFublxxYUA9Jy+ww1mD4cBmJ8Zyn78wpAjR8o+9SyILvHs6on6A+k+W9B98MIh2J 40UUO00SWE+bTjQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The ID 0 is specific per MPTCP connections. The per netns entries cannot have this special ID 0 then. But that's different for the userspace PM where the entries are per connection, they can then use this special ID 0. Fixes: f40be0db0b76 ("mptcp: unify pm get_flags_and_ifindex_by_id") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 3 --- net/mptcp/pm_netlink.c | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 1f1b2617d0f5..ddad51210971 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -422,9 +422,6 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id *flags = 0; *ifindex = 0; - if (!id) - return 0; - if (mptcp_pm_is_userspace(msk)) return mptcp_userspace_pm_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index b6086e9c7fc8..ec23bb32862f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1378,6 +1378,10 @@ int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int struct sock *sk = (struct sock *)msk; struct net *net = sock_net(sk); + /* No entries with ID 0 */ + if (id == 0) + return 0; + rcu_read_lock(); entry = __lookup_addr_by_id(pm_nl_get_pernet(net), id); if (entry) { From patchwork Fri Jul 19 12:24:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737292 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 876E183CA1 for ; Fri, 19 Jul 2024 12:24:56 +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=1721391896; cv=none; b=dgk2g85qpDXO5+nt4grYf5zKVtNSYZu0d6faXHlzmpiBTq6SfttmzPgEzNZEbWNGTX4+OAof68Qd3o0Ba48GZfBmwWtj32oMTit2+W06f+se35sUL28OPTTMBb0Z6zdON9gsdrKc2wvodoosmvlrQfhDHIJBPLzfNJFqYQ8lyYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391896; c=relaxed/simple; bh=Gq19EVxp4y7fsbZBvTEyrGKHXIbKGlWR0Acz4Iq6Ix0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nxiuHfqU/ItCH0LbAU/dHwiZTX3zfVZ/Y04HvD5u1lvfUcFu02WvIjcWOIfi3GQoVXQtSArgV3jtKvHq7PfHSeVNlKzHjw2eUbHUVgHsyRO7ix/xwSnUPhdNtxVCb9T2IlSrLkXUjITXCgypCWW1MoQXHxNKCxX0hJx1n5fINfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P6ubquNn; 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="P6ubquNn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 674E2C32782; Fri, 19 Jul 2024 12:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391896; bh=Gq19EVxp4y7fsbZBvTEyrGKHXIbKGlWR0Acz4Iq6Ix0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P6ubquNngfhqq4qiBbevQNesd0e8J68P8nyb97qZ6WCBG2mZouJdZ/RL+k0J9QdFJ QIjy/Dm7JwRBQymX+fACfCDTl3E0IKZGos84uN+NG886ARIL9qOwsoeMPMx0TgHlMU Hl7eLn5FkltcZFBygugEcZf6F7VKv+2DT3DYzhDJlsu5ek3XhSDEA+n8Xbas6xVgs/ Tqy9t6i1KQaBKsAGGQlcrLHqPgG2/xGSF5YK4JQOZoHxz9h1ZwfDahmYnDHvUJku5m Z0DjWMqJZroeoa60QCDmAUP2BW0wVlGHlyutIM8OYIGbBuJkHPbTjhxEZoVr1Sf9Nn BvmzUFib7XA9Q== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:30 +0200 Subject: [PATCH mptcp-net v3 19/20] mptcp: pm: fullmesh: select the right ID later Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-19-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1807; i=matttbe@kernel.org; h=from:subject:message-id; bh=Gq19EVxp4y7fsbZBvTEyrGKHXIbKGlWR0Acz4Iq6Ix0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsA7Mo1VKxI6q8CkaHC9tLtGYxeo5LqehSzF 6Z+3Vnr1X2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg cz22D/9CXycSghLs5lon6EGoohB0Ug91rSOJYnidaNdnm7km6rrX6/fafcdPmR7tCLNRv4zZkej +ObhBuCV3omHIK3H/XZ+/yYk9B/MbRSt/rNC6ggVdwB/W5hjhlFYsMsM+2tT/ArhgdqZgfOJCio 6mqogqAy0CsuOKMTbu7eqQ1H0n6EDBvPqqG9ZCRtk6svUH68jEa/n2HVhYFSThtHCb/xRYYnGVc CnpD0/WQW76iwiWQ6lmaH0OiaXo5wqe/FoCyVi8USvAlz6fYAL2RwySvQWFvQdFa1nivr8/1xZj tLgDuFrdrlLgpFC2pOctRwIh5LuhmS294kl4X5q46Xy2ZVNfDejENVbFyaT/gi7TlSnCk6qw9MK QUQxD1tLx0sEmVNO4qAIK328l4yT02YK0WdUnc3P4YClZeiMo2Uz6ITlMJLmSe6uZiR93UK95kP /eQC3dYhVR7enY1g+VnUSgZJXqynIpkVFP78nLlGW2SGt/G3jXRDe4o6BfdQ29FlGl2/gHCJ+6a 6UrNkbp6ubz1BpwdhCu+70KGpu2hu9vSXbHANTuy4WUMVO4fgneH25EJyps+woZ/IOfR2h7RWup 1cTmO+tCgoZi+f4bYgtmIrCDSWPKABrPhqu+2qpY9HyvnSrJciQ+vpJjJoklnWYVBxgOG8YJVqx qeswkFc0TksG4cA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When reacting upon the reception of an ADD_ADDR, the in-kernel PM first looks for fullmesh endpoints. If there are some, it will pick them, using their entry ID. It should set the ID 0 when using the endpoint corresponding to the initial subflow, it is a special case imposed by the MPTCP specs. Note that msk->mpc_endpoint_id might not be set when receiving the first ADD_ADDR from the server. So better to compare the addresses. Fixes: 1a0d6136c5f0 ("mptcp: local addresses fullmesh") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ec23bb32862f..1b0e1617e90a 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -637,12 +637,14 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, { struct sock *sk = (struct sock *)msk; struct mptcp_pm_addr_entry *entry; + struct mptcp_addr_info mpc_addr; struct pm_nl_pernet *pernet; unsigned int subflows_max; int i = 0; pernet = pm_nl_get_pernet_from_msk(msk); subflows_max = mptcp_pm_get_subflows_max(msk); + mptcp_local_address((struct sock_common *)msk->first, &mpc_addr); rcu_read_lock(); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { @@ -654,7 +656,13 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, if (msk->pm.subflows < subflows_max) { msk->pm.subflows++; - addrs[i++] = entry->addr; + addrs[i] = entry->addr; + + /* Special case for ID0: set the correct endpoint */ + if (mptcp_addresses_equal(&entry->addr, &mpc_addr, entry->addr.port)) + addrs[i].id = 0; + + i++; } } rcu_read_unlock(); From patchwork Fri Jul 19 12:24:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13737293 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 B16EC83CA1 for ; Fri, 19 Jul 2024 12:24:57 +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=1721391897; cv=none; b=pxIfCVfwLmhmT5T8kcaj6p7GFUF8KAWhIXUqjoqurzShr42/gPceKiG9vHqt/9Ihmzhn6PwbrcoiCWt10f7s6EcNLk2tfRTdDAphOpWq2N4R2o77BZjlZCQlmr8H1LtN87oeODLAsucANcQkneSWgIVQg3iAzEAEk7LLWSfmPqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721391897; c=relaxed/simple; bh=tZmsTr4h7z/PWxZXsPVa1fhv9uKUkReD+8TToEemtVo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N5u0ka3el9krnda7qy4+bCBfhVrr97f6qJzr9FIwFp2SLXIdJzivEPgQt3aBNpQ1gxpcfqCJlsdB2l3n0KcG2/HdD6UYtXFDGve20xZ6nBXZGzPsIs4U7XJZ95iItmqFSJkwZXKCIuFPrmdXSnUwupG9mDnhnfajykA1RD1pbMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ugmxQqGL; 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="ugmxQqGL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91E81C4AF0D; Fri, 19 Jul 2024 12:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721391897; bh=tZmsTr4h7z/PWxZXsPVa1fhv9uKUkReD+8TToEemtVo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ugmxQqGLOh3KnovYSst9WkKBsIP14YNsYZrhPpXScGUagXL3bWWR2nLEjJuQ/eFJX KAHSB6vSwpBe6U6omCZvsQxMePCKR3fOVKTfXellIDKv0JJ0pDgqtT6MDIhqYGx1jU hU7KoZX73njqWbDYhQD7VqA4+tuaPOFb/FBo0mzl/w6merDbMWKiShh3KU4Xen5mOZ v0TfKH/2vEYIoGbGPBUDB583Zwg7CiRY+fxM6H/mxtne67wddKpV4odHHDfx0gspdm hE/1UgmNwZMjNtz/hH+pDtOYZxNdPGSVkjoZFz4XQ1XTtDfFOt2TZ1ylJ4LwM9Wfah znzNiScp7PhxA== From: "Matthieu Baerts (NGI0)" Date: Fri, 19 Jul 2024 14:24:31 +0200 Subject: [PATCH mptcp-net v3 20/20] selftests: mptcp: join: validate fullmesh endp on 1st sf Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240719-mptcp-pm-avail-v3-20-e96b5591ced3@kernel.org> References: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> In-Reply-To: <20240719-mptcp-pm-avail-v3-0-e96b5591ced3@kernel.org> To: mptcp@lists.linux.dev Cc: Paolo Abeni , "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1198; i=matttbe@kernel.org; h=from:subject:message-id; bh=tZmsTr4h7z/PWxZXsPVa1fhv9uKUkReD+8TToEemtVo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmmlsAH2+5tODIE8IMU4VvWPFx5M5lXCrSbWkmg vtruJDyNriJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZppbAAAKCRD2t4JPQmmg c06QD/4obBPKx9/DWrPcIHO4JXsa5Qy9EOnUfoX2gagmM6NFwXq9EN/ZxvkMXSnkH0dccP2z1yQ qwGN0SDZCoIJuZEF13J0MzWfW2cHKrWRLJ3ClqGFHFHhBgkE8clyH0+bx2EJSpKTq6bgUzrAbc+ Grj89/qZy1BasYvZgiE1hHt+bmPK2/L34TeOztKfFbNr7FGuVkcj5BfgXKews0bh9uyf0MUfKa+ gchzyWSMGwVleov/NaFyhSCGvjSIxfMDhzynnF95bf6wCLKKzXGsm8iNJZ72fU1Prj177MUw+RX 3xFoQ8XajYseVYutxzvFvfkQxC8wXZSVJtLcdsRqfZ33RN27JtXgTy0FBMCngr/NM5HNCtGe4aT 4rhBjBkFsfg+3Y8dJMs0xJxyM0AMRwo9ASSTL3XxmMHKJ38QBMOAs+eQ9g8yUUDFuHqJSwAl2/6 8I2KTecAJgGmmdzdsMr5iSjIbXDqJ2jGud7Y3zZGaO43Noub0pbwG/V4sAWUoSBpwsscGy2WA8H KUjKrhnPyX7SRUOAMwLb+IpdQ6DuFtFHfTl7sFwmZ8ArKxqWkAuz0AlXp/KkdFJaDfrxAZ/TJnE 33zM4YXbRgt6GNMByDkuweU4Aoo/VCeu3qiRRD9Y//FUU9GEksxDzqUSToZrFCp0QyQGyQptyxu /zgBMvE0eCAqPxw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This case was not covered, and the wrong ID was set before the previous commit. The rest is not modified, it is just that it will increase the code coverage. The right address ID can be verified by looking at the packet traces. We could automate that using Netfilter with some cBPF code for example, but that's always a bit cryptic. Packetdrill seems better fitted for that. Fixes: 4f49d63352da ("selftests: mptcp: add fullmesh testcases") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 3565d8b48125..c4bb390933d6 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3014,6 +3014,7 @@ fullmesh_tests() if reset "fullmesh test 1x1"; then pm_nl_set_limits $ns1 1 3 pm_nl_set_limits $ns2 1 3 + pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,fullmesh pm_nl_add_endpoint $ns1 10.0.2.1 flags signal fullmesh=1 speed=slow \ run_tests $ns1 $ns2 10.0.1.1