From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309525; b=ZoS617FmaTSkWc6BS4lx13n1kwHSavfJzihAwUUC5OJtB3CqwRNtIUSXJ3EorV1zSrlo VVlP63hxI3RgTJ1ph2WmdQ1PMY3Bpkvmn8za/K44BdrFX6aUkdrzKPVze3yUnOFIpZGvn 7AxQl1FPRPj7LnSEDVWwoNWkPwoUs0LiGowUJaSOxeyUgIUhtEhoHPk0dov5QVyncL4P+ sMUI9W7Zo/NcDX44yTHAtFAhlqGrfNaVFL7VsGx7sVfW3Ib8MyPbcgiCd5PLIfFJnqeXf mLwos/iAbShOHBHDVK6vn2+abS9Dulla4GaWs2VJaDXIRwr7kHZOVMGGNsJm5ovpH+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309525; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=B4LbqVo3QeneFeEYmPSvr8gQGLicNhzg9OBydPl+Egk=; b=RYbmfDwbSyricibWPlMi5S5ZCSZmpYtH32B+20Hrl5+RoV0w2Mi+SEPGtInIDPj12biO 36Bb0ijKk98vZ6yfCAki/bwNpIrEoHrQZ55o41IVm9YmYQXTkkC93ShscE5mCu7f7WfL/ 0J9kH2VotW7b3CLMyrISGH5Ud+x4RR8PpHNVFlPKnvexEnUz0hr2E34bxMlJsODqFWYV2 XrmtnVNGTVVjYAOuZqk1ZtUUNFEWtU7qPOPLERUC8xUHjZUkgzmaWGzaHucXJ3Ti2gH1d W8vDnPp9EC8g6QvGxVFOpBY+qwP/w6b/CBX6//pR5BQcWDc/XQcZCxaNJcFmZtJGUPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wkto1Pd4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C8F4606A31A for ; Thu, 29 Oct 2026 21:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wkto1Pd4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87CA91F01824; Thu, 29 Oct 2026 21:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309525; bh=B4LbqVo3QeneFeEYmPSvr8gQGLicNhzg9OBydPl+Egk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Wkto1Pd4E4ntt1YPBM85AAxeEDZtMARLaPo5I+YE917MPeuFeOmyhg/rIqKOe3Jd0 kwTTQGAG/EMuCtWjlkeAQS5ERZqHjNO1psx52UGiGETKKrGFw4qXxV9BNrs5OkM9qE T6Omd/iXXPFbXtoYhifej1F6HKHIq1Ya4gVr9OZdOaHcmr32E/i/T6qeCwbi4IlC0W DpbWltgBmZMUKWYp7Ms7Hzk5aft6go82EKwYAUyoBD/RxzIDQdML7xqpIVKJ1IEejt wvZoVJrP2sDL7ccjHuuMfjYoT9ziFE2QezZwkKQjis4e/LTtfKINo96v3DUyqDXOyM qHn2wDTZ5mU6g== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:46 +0100 Subject: [PATCH mptcp-net v4 1/8] mptcp: pm: userspace: properly handle the ID0 case X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-1-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4374; i=matttbe@kernel.org; h=from:subject:message-id; bh=SRwTaM446K8mDGBD/UsF8m7DGDI+XPF8uQj62FHVKYQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7/ZTSpbKvPhm38O1n9adnMB7+eGLev9P/9O+qqWZa GtVpNiUdZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEzEZwHD//Dmh0ev1epdviS/ aJUb38u/B7atvuCq/1vs8AreS4nvODsZ/ruJyPB/ODXdUaSjoS76pE3lSfcyofAvst5KYiyx4WW FbAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 In MPTCP, the local address and port used by the initial subflow has the ID "0". It means that when this address and port are used for some operations -- e.g. creating a new subflow -- they should be linked to the ID0, and no other addresses and ports can get this special ID while the initial IP address and port is used. So far, the ID0 case was handled as an exception: each operation dealing with the ID0 had to be handled differently. Except that this was done in some places like removing the ID0, but not everywhere the list of local addresses was iterated. This way of handling the ID0 is prone to bugs and harder to maintain. Instead, the initial local address corresponding to ID0 can be added to the list when a connection is created, and the number of exceptions can be dramatically reduced, handling this case like any others with existing local address. The existing exceptions are going to be removed in the following patches. The main downside of this is that each connection will now have one allocated entry added the list, possibly one more than before. But that seems OK to do that with the userspace PM where the path management is done per connection, with many Netlink messages sent back and forth. Adding a few more bytes per connections on such setup seems acceptable. Fixes: 4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs") Signed-off-by: Matthieu Baerts (NGI0) --- sashiko: check the next patches before pointing at existing issues. v2: - List new exceptions in the commit message. - Handle local_addr_used with the ID0 case properly. (Sashiko) - Handle needs_id where the addrs don't match, but the IDs (0) does. (S) v3: - Split local_addr_used case: that's fixing another commit. - Set port to 0 (msk) instead of adding exceptions in lookups. --- net/mptcp/pm.c | 4 ++++ net/mptcp/pm_userspace.c | 20 ++++++++++++++++++++ net/mptcp/protocol.h | 1 + 3 files changed, 25 insertions(+) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index d7c5b50b34cc..e9a538296200 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -551,6 +551,10 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, c= onst struct sock *ssk, int pr_debug("msk=3D%p, token=3D%u side=3D%d\n", msk, READ_ONCE(msk->token), = server_side); =20 WRITE_ONCE(pm->server_side, server_side); + + if (mptcp_pm_is_userspace(msk)) + mptcp_pm_userspace_created(msk, ssk); + mptcp_event(MPTCP_EVENT_CREATED, msk, ssk, GFP_ATOMIC); } =20 diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index f723a134356f..45faee894ac3 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -707,6 +707,26 @@ int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm= _addr_entry *addr, return ret; } =20 +/* Add the initial local address (ID0) to the local list: easier that way = */ +void mptcp_pm_userspace_created(struct mptcp_sock *msk, const struct sock = *ssk) +{ + struct mptcp_pm_addr_entry *entry; + + entry =3D sock_kmalloc((struct sock *)msk, sizeof(*entry), GFP_ATOMIC); + /* Fine not to handle the ID0 case in memory pressure */ + if (!entry) + return; + + memset(entry, 0, sizeof(*entry)); + mptcp_local_address((struct sock_common *)ssk, &entry->addr); + entry->addr.port =3D 0; /* msk port */ + + spin_lock_bh(&msk->pm.lock); + list_add_tail_rcu(&entry->list, &msk->pm.userspace_pm_local_addr_list); + /* The initial address ID doesn't increment local_addr_used */ + spin_unlock_bh(&msk->pm.lock); +} + static struct mptcp_pm_ops mptcp_pm_userspace =3D { .get_local_id =3D mptcp_pm_userspace_get_local_id, .get_priority =3D mptcp_pm_userspace_get_priority, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3be60da12924..8c219fabfc9f 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1260,6 +1260,7 @@ void __init mptcp_pm_userspace_register(void); void __init mptcp_pm_nl_init(void); void mptcp_pm_worker(struct mptcp_sock *msk); void __mptcp_pm_kernel_worker(struct mptcp_sock *msk); +void mptcp_pm_userspace_created(struct mptcp_sock *msk, const struct sock = *ssk); u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk); u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk); u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk); --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309526; b=dGVEEQpPTmKim6UpTXf+m4lvn5Ogt5UkvwTRlRrOtkbqHoqqtV2+YV4OubrWrhxoc19G nInKViL9vARQuPM32plCeEJbPqU4yLqJv41lhnqokooqSnITg+SVYwkyV8EgzK6syGap5 UKZ3DLTSYa2x/Xdisx9tBPPsQ5wg9GgoCdEUfVGIivjpLNxIS+srh0mNCN0P/f3KPfROU iPmGN5+7UZa0sfTPyba0OHqUnsHVEsAcSU5JY7EnPIpjjv5ZAJNKLYoV0DltH98GpYTE4 QAqxgUUBszOBiVlXrp8eK8gm4iaJYxg0QjNAQF8zIEOXTZdYXDxZPpy2pTBLY3SOdeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309526; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ZZmuKTW7XKXUQS+6KITY8s4On/f8/H/VjPkQtBEwcf4=; b=PcmnjaE2FVQD1vTuedoPwaVdBsEqaQjvqN33V2mukSuySfANulJont/JxvJDlgaGrTwz Z/PGR/Xnbnwzf5NIWs6NVCKu3ws1ENvj+n8IAwGM5Dy6YeHb9RUG35sMjJgvS03gQOH8M ziqAWqw9GPHCR6gWinoNDSgOZ4T6cGBkMs/gZx8LztGsv41zPdgQUDihjGB/rR7tRb/8N huKf5zmtJjgBwhzCISJCKQvAn2xcPXJHyNGLL8/quFOImks9Me2pIm/bVZYmvAC+dycJO suyo/qRNMH/xKqDy+i0e+DV//b5CTBtsgIwfSSb4DCl0QTcsfIc/CpuwB3Yg0XCtXSQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dgTrFd8c; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF74606A31A for ; Thu, 29 Oct 2026 21:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dgTrFd8c Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B82A1F01829; Thu, 29 Oct 2026 21:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309525; bh=ZZmuKTW7XKXUQS+6KITY8s4On/f8/H/VjPkQtBEwcf4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=dgTrFd8c/85taKwmGZ5Fk/vvLVNdbFdNOdiUgaTW1NsnMkovD9MYVFLwe+htMvVlW givOGvTbr0TNV6WcYPrWOYrNC5hYgwXPeizvnDt3SoQIfrskIOGCirnbcaDrFXDQGi jUpploNnsRjApDuCzur33Mw1f3cACDNZ4QhzB1wQh51bwurQX3YwTcUR5y5e62pUwH PUfjz6MZoyHW5GaRqn9/cTr68jTkzHBItvPBJEPtKBl7LwN4vTyAz5dev4aMy1aCi7 6IXFcRZBSGXxMAB8AlrxMEN3uVenLtEq81qzaD868ioNULKgGyD7O7qBIZK3DTHPnO P+jhrhYhBSGzA== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:47 +0100 Subject: [PATCH mptcp-net v4 2/8] mptcp: pm: userspace: lookup: match port in priority X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-2-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1954; i=matttbe@kernel.org; h=from:subject:message-id; bh=bZTk4zIjYz5FTkERHuVw9fjxQCzWhYHnS6D1nDyKyPM=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7/a76D85zfSqd37uJcvEu9nfFM9Nm/17mZ0vp+jZD Q9KjuZM6ChlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZhIkwAjQ9OsmnP+glOcuma3 nDUy4torErzzVucOuT1GYpt+fJcoY2D4pyS2ZM/5M2pan1N3723VnRKq6BAk5SRz+lmg2Z/YJ3s ecQIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 In the local address list, there can be entries with the port set to 0 -- corresponding to the source port used by the initial subflow -- and others with a specific port. When performing a lookup, it is important to compare the ports to pick the right entry: when a specific port is given, then try to match it first. If no match is found, try to find entries with the port set to 0. We need to handle the case where a subflow got created without forcing the source port: we used the same ID as another entry, and we still need to match it, even if here the source port is likely not the same as the msk one (or a subflow attached to the same ID), but that's OK. Fixes: 24430f8bf516 ("mptcp: add address into userspace pm list") Signed-off-by: Matthieu Baerts (NGI0) --- sashiko: check the next patches before pointing at existing issues. - v3: new (Sashiko) - v4: avoid 2 loops (Geliang) --- net/mptcp/pm_userspace.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 45faee894ac3..68a02b15a4c5 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -31,13 +31,19 @@ static struct mptcp_pm_addr_entry * mptcp_userspace_pm_lookup_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr) { - struct mptcp_pm_addr_entry *entry; + struct mptcp_pm_addr_entry *entry, *wildcard =3D NULL; =20 mptcp_for_each_userspace_pm_addr(msk, entry) { - if (mptcp_addresses_equal(&entry->addr, addr, false)) - return entry; + if (mptcp_addresses_equal(&entry->addr, addr, false)) { + if (addr->port =3D=3D entry->addr.port) + return entry; + + if (!wildcard && (!addr->port || !entry->addr.port)) + wildcard =3D entry; + } } - return NULL; + + return wildcard; } =20 static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309527; b=l98hbuMF0lfmId1HMfb20TN2Md6omQKMPxUQPrWEb4CX30WLQs9hcBnG1fy/D6e5m4YX t33hjNE/KCmlsxSIsZOLDRWrdBAbNOSzGjCs2c2UEnPxWv8b881MiPhTMgNQT5OwgTvO9 IPKTYDl4xNXBFhHeAzARaGED2HC8/8Cb3aTqj0qZPbVV5sM5Fql4TbX+2xn/8wbqTkpqB TrlbssMy4TxCRv0hl8cVUym7Sg6qIwXnUOLH0vzklcUolHXSQ9fY0BK3Bm8eoTKBFQiTa xCUYhSrk091ZotAMMGueYY41mB8uILk7AqAl3YyXw6W6jSJtq3dC4tN3G3aucHZLPpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309527; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=o1xzL/rAqWXRY5gnIvTD/rPCVClM4/ctORTZ/ieUWXI=; b=ifiKMuH3IkfzkHmgZkbwYhO8YwvxXEWm9Oi15VBzWc7b5JxznxaFqc5i6ucaTE2tTYWS ihTPsAkY93zl8NmTaS2tsgvy8mgTFe5QvfMZM1mMGII7ypoygTluCJR2ZTCTch0OdG9OA oYSvnRxyLTpI00hD43GW96D0/ec2hH1AghaVfgNGUU/OGZ53wctfiNvwCkP+1IUHsv9Qw WefYybvk0i0xYhor2SFtkwPh+AVlE67EbxYjqPATVz1t53DKYxl1Zy/a5gYbZ+n+uWfRa j+5v7j+c0cf+leuYqxFHXnl57ikRa+nm3FlZSZPGu2IVHv0mYs2zweFXAFrTY1Tschw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eyzEjvbW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6F82606A31A for ; Thu, 29 Oct 2026 21:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eyzEjvbW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ECF51F01816; Thu, 29 Oct 2026 21:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309526; bh=o1xzL/rAqWXRY5gnIvTD/rPCVClM4/ctORTZ/ieUWXI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=eyzEjvbW13wnkz+hwgSZtM9Exijr6eM27IGaTFcjDkhk+H0ctWM6Mbo9iRXUbpHCn aIvDL1OilEfbf5nJU3GEcOUyL8Y270ej0cIeNwhTr+tcZFdBH2KQc2Ah0cWPq1KEeh M5qi/C0DetGNNhqUPhUqcI/SROThM+iZDjIDo2sbGzGHgyzMMHCA8KlMmtJEMQj0Mb H1cpoyatoLL8JmY3SV8FfnMWRCly8zmhvry6fDQXh891NorJG/dyO1AgVkk439VEiY iPIEEVCdJxTdGkggYpwnCBBQtxBCc4Wuih647gQwHIIpHZXszHFubrkOaCFiyZt66x mJkS1yPRwcQQQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:48 +0100 Subject: [PATCH mptcp-net v4 3/8] mptcp: pm: userspace: ID0 is not part of local_addr_used X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-3-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2282; i=matttbe@kernel.org; h=from:subject:message-id; bh=MJF5UucRTSbdz1A4jWZ4kEervi6VoRbLTIqZ4JN4ZAA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7/b/4KCXsHh5hM5Tk9PBexduPmuumcD7Z/8q5eO/v 6Xezlc/01HKwiDGxSArpsgi3RaZP/N5FW+Jl58FzBxWJpAhDFycAjCR9dwM/+O73O/P3m32/pjN fY6GkG75w8wGv5W2nVu6RXXjVu6tDu4M/4x9JJ5/28trtSva7d12wSPtC5uFJX1XTJe4HNwiEPi 6hxUA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The PM's local_addr_used counter doesn't take into account the ID0, similar to what is done with the in-kernel PM. When deleting a local address, only decrement the counter if it is not linked to the (initial) ID0. Similarly, do not increment it when re-adding the exact same entry. Fixes: 77e4b94a3de6 ("mptcp: update userspace pm infos") Signed-off-by: Matthieu Baerts (NGI0) --- sashiko: check the next patches before pointing at existing issues. v3: - split from patch 1. - do the same check when incrementing it to avoid a "leak". (Sashiko) - use a new dedicated helper, clearer. v4: move to one line when declaring is_init_id0. (Geliang) --- net/mptcp/pm_userspace.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 68a02b15a4c5..74969b86fb81 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -27,6 +27,11 @@ void mptcp_userspace_pm_free_local_addr_list(struct mptc= p_sock *msk) } } =20 +static bool is_init_id0(struct mptcp_pm_addr_entry *entry) +{ + return entry->addr.id =3D=3D 0 && entry->addr.port =3D=3D 0; +} + static struct mptcp_pm_addr_entry * mptcp_userspace_pm_lookup_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr) @@ -99,7 +104,9 @@ static int mptcp_userspace_pm_append_new_local_addr(stru= ct mptcp_sock *msk, =20 e->addr.id =3D id; list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list); - msk->pm.local_addr_used++; + /* Just to avoid this counter not to decrease when deleted */ + if (!is_init_id0(e)) + msk->pm.local_addr_used++; ret =3D e->addr.id; } else if (addr_match && id_match) { ret =3D entry->addr.id; @@ -125,12 +132,15 @@ static int mptcp_userspace_pm_delete_local_addr(struc= t mptcp_sock *msk, if (!entry) return -EINVAL; =20 + /* The initial address ID doesn't increment local_addr_used */ + if (!is_init_id0(entry)) + msk->pm.local_addr_used--; + /* TODO: a refcount is needed because the entry can * be used multiple times (e.g. fullmesh mode). */ list_del_rcu(&entry->list); sock_kfree_s(sk, entry, sizeof(*entry)); - msk->pm.local_addr_used--; return 0; } =20 --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309528; b=xY+liuh8y8ZN50HBYlHirNhHcngdNPIqAaoTD1ywJiA7cbLOXblfr5lOLVey+SPjJ4zA jmbNVzwvBJZacK3+iAyxX3/QsQO99UTt8yubK1sV2suK50jEV4i7mTbiKWIyWCF0kDc3v PDntXTRpmOUlKpVpJia3JbOjXT/dLVkT1Sr2s8oP8/uqsaWjnhbxsefP+8/PNyNxItOPs 0+9smlIfAV8famLlTUWHVS1TQPhWd02xHLxPgizPKhe71R3776FgLfLka1BBR+WUrNAQC FxclDUCQTte4nA9ILQ8wBNmnUOIX/7xxWIttrDZRlDDXM8qCplBD0wmVOsAlLJ3J0lg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309528; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=YiCK5Jj4VRRHy/fecTbn6QsuOjg25bt0JwD4qMhkTJc=; b=FTcL4KI14IyF6H3RcepzoJfKQwxeFhzyfQEu9djjFIaJ1gzG/N+mhL+WIpvlUfN8uBZZ IK37Hna7Z6bGAagk8JFSc54XPWusnjJRus9hHLSbKeUFTQvU08bf9ZaPyXNGP8XvqIqPa 1g+bjeEIWxK4nY7QTO+8Pk03PEW5pFTrH3pL3rHs6EKTAB2gTrmheIh3gwyW25TRWVzKA MtB/U4VpnzEXhBnldgqoAjDkju0UGAoLavpeRfSJTfr4Rk0j/cz4/DfSlpo/IbQlX4kZx hkR57GL5kyuvBbu+KXnvoHmbGNg1TeVFk76wEvaxDadx5dCgMn5FE5PURgB3Qi2CfWQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FL+KJZHq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6EF1606A31A for ; Thu, 29 Oct 2026 21:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FL+KJZHq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 021921F031E0; Thu, 29 Oct 2026 21:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309527; bh=YiCK5Jj4VRRHy/fecTbn6QsuOjg25bt0JwD4qMhkTJc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FL+KJZHqVlBZ/kCL24c/xGT50mETWZ1k6HG43FDMHgHdH+HthGGsw+s+0cCz95+gN OZrSzpLUzjzs9w0a5N4+QaHGpPucDvElCjojf+3ho+NFIDdZl70Pw6OQw0VkPrDIis GEusY3lA3YAZZq0ITh74k5e7a1K/deoOfrbBL14hwmX8+jW1jnIw0tpt6kjCYGKrmF SkEH8r/RGQtk7FUqfAW+FsHo4Zk3NJSTImH1HK/O1UqrakL8BU1HPt5rWzzH9xJrvr VXnoBSLWb0WkQLwsKdbFbflr/xpIvBD24OJsHe61UM86tP0/eZBm9wZSZhmI2t5Xof 5npMMpSMlnRHA== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:49 +0100 Subject: [PATCH mptcp-net v4 4/8] mptcp: pm: userspace: allow announcing ID0 addr X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-4-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1788; i=matttbe@kernel.org; h=from:subject:message-id; bh=RhvRsmm764l/fbDteakqbdBfWAuivqGjDaDiK0dm4QA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7w74K788atJhJ0Oz8BaJB7E+Bxd6aX0PLc9/cU9Zn mnZ7qPnO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACaiocXwP2PWXP6rm2M+6u44 t9TrlueUJF5D7yj7K2GRSyXPuDM9aWdkmH/8lnvvu9p39WrPHq1euOZmV+JZxTylut61JwwzTCs 9GQE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 It is valid to announce an address with the ID0, the in-kernel PM allows to do that when re-announcing the initial IP address after having been deleted. So no need to have such exception. If the ID is set to 0, but the address doesn't match with the existing one, an error will be returned by mptcp_userspace_pm_append_new_local_addr(). Note that once removed, the ID0 entry could be replaced by another IP address. The RFC8684 doesn't specify this specific case with ID0, but it says [1]: "A host wishing to replace an existing Address ID MUST first remove the existing one". In these unclear conditions, better to let the responsibility to the userspace daemon to pick the same IP or another one, similar to what was in place before. Fixes: 9ab4807c84a4 ("mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE") Link: https://datatracker.ietf.org/doc/html/rfc8684#section-3.4.1-13 [1] Signed-off-by: Matthieu Baerts (NGI0) --- sashiko: check the next patches before pointing at existing issues. v2: Add note about re-using the ID0 with another address (Sashiko) --- net/mptcp/pm_userspace.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 74969b86fb81..66dbf67fd6d8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -239,12 +239,6 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, str= uct genl_info *info) if (err < 0) goto announce_err; =20 - if (addr_val.addr.id =3D=3D 0) { - NL_SET_ERR_MSG_ATTR(info->extack, addr, "invalid addr id"); - err =3D -EINVAL; - goto announce_err; - } - if (!(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { NL_SET_ERR_MSG_ATTR(info->extack, addr, "invalid addr flags"); err =3D -EINVAL; --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309528; b=YLikJVj2DJY6aXCSdf9JE+5uFgLBeAvHobKkDz6S7JULgYpPQ6o0FI+UTET3P9psBwfD I4fUmOE/frpi9R2EsQXAqmjqegomlRnKbGQstZdSdmaztNyQFQOfTopEz3wPlkNNULSu8 nNX0jyNwTVyBn80oAokxsc5rul2p8+WaZ7Te67sVETf6r2tigdliu0j51LRWA+qj8Ee7B tJV1iTVDZAGWwyYSzgZ3PhoDaEnkr5fBzK/2h8BDx+sFM4M/3usxNicBQtV3JnOsEjCAj Zcnhh1ZhoIXlqwO/68+18uviJi1eUvUWQcQ1MWw832dQScSPhZlKBuyIJ69pLPr9mhA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309528; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=Od2tPKuv1TQzeyQyL8AQjofU0DeelE7sF28PcMdR2PE=; b=FE52o2DcfD+v4xOkwhhtFcn3b0hjth3N4jqacr0tLqMRS9v2VOrc76AtpfjMvNqN1CLs FUCa41CCptsVBqIBBTo/HF6jOKfNjxAypZPu+c4de4xtHd8C11C56mDtWTi+OlJbsFfMi WkH9cJ/f8YArFeRUSnvDZklA6P/0USD1O1YZklcrv1KdC9rnUnW9QvHG6WyfI5YSkQF6B oWbOAitBtoO5xT4fHxttGTNjCqFBmIYVUauZ0Hu/ieNemRipadMBe3Ql5McSfOaatCPG5 b5h4Olq61Owk+jfd3N0Of0LiZc+I4nSTAMkaE32k+ELXHUE+tCXiegTJFourcL5tuGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JT42+eyY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96DFD606A323 for ; Thu, 29 Oct 2026 21:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JT42+eyY Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9A971F031E2; Thu, 29 Oct 2026 21:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309528; bh=Od2tPKuv1TQzeyQyL8AQjofU0DeelE7sF28PcMdR2PE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=JT42+eyYkdnZ1HM+kY4LYoVJFKltoAvQfYt2oQSCBqhWoxYqArhsAbBMZwOlUMTN3 yNgI+TjlSxdJc+VacYBiUNkQoV7/CuJ9N3ZgSll9K5hgxgVWE9e4/Fpg1kTyM4CK6A 30he/886FXOgDCNnHz4b6w2BihVoxNfM7mYB7kmVhltQ8/tPCS3JAJraJwEQ59z/XE ridydKvG3SU6mORdpISrHpbqfpDxg/C7upLF2uJQB6fNk0kMnY4wfvziCoW4YX/rKO xUKadPSS9+wnSXlVV8NgH+09z+PNbqprb0FtlhBjGrEoRqMxUzxKnBoen9HP+XWt5X WshfqAgDJse7w== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:50 +0100 Subject: [PATCH mptcp-net v4 5/8] mptcp: pm: userspace: no ID0 exception for RM_ADDR X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-5-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1915; i=matttbe@kernel.org; h=from:subject:message-id; bh=El5xT2TsNQOMhZRToG0KbPg5mFoN9Q7bDbD2OLNSAY8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7w5Q+dT7UDdH9ljNmrqoygdFUafOLauJSr9+nbf7w 64rFa9ndpSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExkvTrDH75zR4LnTH2Xltw6 R95lYcDrK7JKBRHOT1aVbTKc3f0/w4mR4f2eevGKvrhq61IHjrSTnXaSeod3/fD/kL+/7Oafree bOQE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After the first patch of this series, the initial ID0 address is present in the local addr list when the connection has been created. Then, no need to have an exception to delete ID0, this can be done like with other IDs. Fixes: 84c531f54ad9 ("mptcp: userspace pm send RM_ADDR for ID 0") Signed-off-by: Matthieu Baerts (NGI0) --- sashiko: check the next patches before pointing at existing issues. --- net/mptcp/pm_userspace.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 66dbf67fd6d8..0f6400bc3bf8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -270,37 +270,6 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, str= uct genl_info *info) return err; } =20 -static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *ms= k) -{ - struct mptcp_rm_list list =3D { .nr =3D 0 }; - struct mptcp_subflow_context *subflow; - struct sock *sk =3D (struct sock *)msk; - bool has_id_0 =3D false; - int err =3D -EINVAL; - - lock_sock(sk); - mptcp_for_each_subflow(msk, subflow) { - if (READ_ONCE(subflow->local_id) =3D=3D 0) { - has_id_0 =3D true; - break; - } - } - if (!has_id_0) - goto remove_err; - - list.ids[list.nr++] =3D 0; - - spin_lock_bh(&msk->pm.lock); - mptcp_pm_remove_addr(msk, &list); - spin_unlock_bh(&msk->pm.lock); - - err =3D 0; - -remove_err: - release_sock(sk); - return err; -} - static void mptcp_userspace_pm_remove_addr_entry(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry) @@ -343,11 +312,6 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struc= t genl_info *info) =20 sk =3D (struct sock *)msk; =20 - if (id_val =3D=3D 0) { - err =3D mptcp_userspace_pm_remove_id_zero_address(msk); - goto out; - } - lock_sock(sk); =20 spin_lock_bh(&msk->pm.lock); --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309529; b=H4M8E9ul+gIvcjMSAc2le2E2wpjhi0m4+1C9cRCpLGQjJ6F71rex5TJ7WGsihr7vxdPX lM+nhKDTLefDGFXXc6w8MoBjNR8BVUEq4ckCypPpoCcPvKQhEGb6cGzlBnNdzf/RWdfi+ Pf/NVCEeOG4s6bvuw7BKkGz1AO+L2j5GM65tx6gjrVn8P5ecNAwX8hkio0SX2QglD35pB brAXYhbn62/mjkf5BK8OJhu5tKmALNSJV6VTZXnadKKJFrWaDVyEZZxgMRwTIngdSfhbx knljON8ILjyXbyBUQ721ohk/4jTyOm2qSw+R7ipglE3Fa5lDcuUb23/k+TWBTiRlxXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309529; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=+g4RFGtSy5CWrGKx9+HjfymvAu3uC40VGEsx0URqY0A=; b=X1/p5XqNlWZgM5XD+KaTZcku+XRPFTVTPLeL2JrtBxQnKoT4rRXP6NTI6nc57GDXSgDL rYWxl2/G7C0DDbEX61A+HtMFdp6C0CGQnDZhm1y+VKUS/uB5Y7ukikc5fuYjb/sUvXfr2 J5tVutpheS+KnUr3PQ44/yPs8RR08sTqSPvHiFf05zN20TpKDCilrtA7o2XvgWjNUMvvB XilfakN7mgtKg94JkZpPrH2NwIwEjKKmLuboCNzp3p6SXgR1+1vHrpqRU9RTEUUtlQmRT jqJCMsbWoFj4AX3PpGgrZJOFQs/qD9kRGn9NydPFMzI6xtJVSsY4JgffiorTjya+aYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="FW0H/CXN"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3175F606A323 for ; Thu, 29 Oct 2026 21:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FW0H/CXN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CE3C1F031E4; Thu, 29 Oct 2026 21:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309529; bh=+g4RFGtSy5CWrGKx9+HjfymvAu3uC40VGEsx0URqY0A=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FW0H/CXNxax/ktBKy8QdNaWBuVsQwJUM3ERX8JpW3DUOjoKxiaFxe70FOv6+KfsI2 vvppEK8EcM38aRwCYJjOiv8/qzrOYzS7jQZmZquCDskEUYCbMnnAgauHdQaSbpp2Wd 03BEC1BhFsSE3+q3Ec4DO4mumQK9sq48LvjH4Yz2kGwZ/HRzK/Z6E6UFEljq5kN60n R3mDlGPpUWsH8YYUvonbhPFgUN7L5Jqh3JqBsf61qsMXVvy5cERn9y+o/66QIEQu/6 eeXjNcwpWEsLz4t5QoUFwHVD7wqhMa0fo5vMGQ+79ohpyEOvCp6T272ZHrl7PtH8xt 1fXWWcy/Gu0DA== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:51 +0100 Subject: [PATCH mptcp-net v4 6/8] mptcp: pm: userspace: don't dump initial ID0 X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-6-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1301; i=matttbe@kernel.org; h=from:subject:message-id; bh=O9fq+md9qsKr8mR0OARhWigCaB7dJ18A2xoaGRrhi2k=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7w68UHVYd7Xp0kUtVx9c0z7L/Hrmqi0LOV4+CJVau SfjUpCOXUcpC4MYF4OsmCKLdFtk/sznVbwlXn4WMHNYmUCGMHBxCsBEVu9j+O/AW+Dh3XYu7d3l 6Y/8k8tWX1uV9FBRUuPo1RclMspTnOYwMixefMLB/daKoNOmojdUEm8mf1Rc8uv1uw3MqXdZWo/ 0iPMCAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After the first patch of this series, the initial ID0 address is present in the local addr list when the connection has been created. Not to change the previous behaviour, but also to have a similar behaviour than what is done with the in-kernel PM, the initial ID0 address is not dumped with the rest. If the address is removed, then re-added later with a new subflow, it can be dumped. Fixes: 34e74a5cf3b7 ("mptcp: implement mptcp_userspace_pm_dump_addr") Signed-off-by: Matthieu Baerts (NGI0) --- v3: - use is_init_id0() helper, to check the port and not the flags (prev workaround, but doesn't work if modified later) --- net/mptcp/pm_userspace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 0f6400bc3bf8..282d7f57c32a 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -637,7 +637,7 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, lock_sock(sk); spin_lock_bh(&msk->pm.lock); mptcp_for_each_userspace_pm_addr(msk, entry) { - if (test_bit(entry->addr.id, bitmap->map)) + if (is_init_id0(entry) || test_bit(entry->addr.id, bitmap->map)) continue; =20 if (mptcp_pm_genl_fill_addr(msg, cb, entry) < 0) --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309530; b=tix1YiT0+rkGFfjT2QPnp+NYjadgdAUranVKcJXdsewvpkz8DNoFdvS/I6sz56i9GjZe xUSYFseR8CGju7x6DahHWyxvePJsAtyHSs+fk51TandEgiFhy/nSqx00DXeEGy5jrMtF8 XlpontVCUGWM7pAgXKVRBzfK/6yURLTi4PobJu4TIHKv3z8qAhKPr+CDCQzGZxRDkQM3y eJxtvy6NZqHFpeotOR/JrWKEuUJmSdbgBvuuYtgNlo4/4imOlfRoep7gpte0IpK8CX8sm lXM8hl/F+un9EVaSvvXGtI93kJeKaI1SCA2L31XrNqetdNN4Hv3SzVf95BCYv3obVZw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309530; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=+rG8wjd7/UcmCF/VguBwrEnXTtMjx98c96s01QDltmY=; b=HfTQmIKaHjLSHoXrx63bb+NHpqFtmWZ6HIpEjnViqQzN9GeAFD1lJOHKKbtGE77c2hDh GJDwHLzYkUrWKRGzAbDmTWXg2nBNen2xp9U7XJXVmSTDgFLcWde52JYT10mDME8PZHmXd HKOAK7Wwk7JJq6J/6UNh6gihDpA+F63rgTeRRw+eb/ExoodSt7Mc4QZmMuHXBt5w9/yFT HkkuPWp1P8qjxx0xKNyqFovASbEj02DmpjSOlKeS6cZeGQ/G7G4q8Ixv0iqRhsRRKIrTg k6nesi0h0fJE2HLNRbRHkx9eoZ7oIlyXFjTXUf9Kt3NAZYLF5qRPsqTnka1XM6/3drA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N122CMb2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54BB4606A323 for ; Thu, 29 Oct 2026 21:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N122CMb2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 707EF1F031E0; Thu, 29 Oct 2026 21:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309529; bh=+rG8wjd7/UcmCF/VguBwrEnXTtMjx98c96s01QDltmY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=N122CMb2lcSY3PJrRO6Y45WkXUqClmXBbUWj2fcauKQ4v72ZZ4499Tg0DTkHwTh9L PdVH6ltKaYBELqAF1Ms83Q/IBRn14ZaYMhT5ZGWvX7DivyE7pWrPNJBrDriw/NAnC8 KTwdJRH8d+QLThf9FwfPT7pBFe/agSCW/pSGyAgT8vx2zRu+Xn+LKo/9uGadzizDGL VbPHhobltpM/9+odZkRMdsaew4se+YrEwWMvhivZw5PVtS3BQgglhij16Qg1ebG9F4 arZue0Aa/Ry1oeQN8hvkAUERaEkYuPaEu7FOc8P5FbYR4J2CzIALUcchaaic+hW29X AWtUNezl2eNcg== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:52 +0100 Subject: [PATCH mptcp-net v4 7/8] selftests: mptcp: join: new ID0 subflow from the right IP X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-7-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2087; i=matttbe@kernel.org; h=from:subject:message-id; bh=YxXsgCeXsbOpzwfySAeESEZiUb0qKlMc1QOIqafF2WQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7w6KE/o+4VOacPme+NkRqpp3dp+f0rzEuL9A7rq6d 6/61Uq9jlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgImUqDD8012d1r5JWnxnUfo2 s/8t/sXdLFWBVyvuOAdHvxKXtyv6wchwVsridtdpXePrtkyyiTtstcXZLx8Wv37mUAFvWuMNuRM 8AA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 In MPTCP, the local address and port used by the initial subflow has the ID "0". It means that when this address and port are used for some operations -- e.g. creating a new subflow -- they should be linked to the ID0, and no other addresses and ports can get this special ID while the initial IP address and port is used. Hence, this is not correct here to try to create a subflow with the ID "0", but from a different IP address. With the first patch of this series, this action now returns an error. Instead of simply using the right IP address, continue to also use the wrong one to check that the kernel is correctly not allowing the creation of an ID0 subflow with the wrong IP address. While at it, fix the dumped address: the initial address is not supposed to be dumped, similar to what is being done with the in-kernel PM. So no "extra" addresses should be printed there. Fixes: b2e2248f365a ("selftests: mptcp: userspace pm create id 0 subflow") Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index c3ccce96b45b..190ab48acbc6 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -4214,10 +4214,11 @@ userspace_tests() wait_event ns2 MPTCP_LIB_EVENT_ESTABLISHED 1 chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1 - userspace_pm_add_sf $ns2 10.0.3.2 0 + # from an IP not linked to ID0: failure expected, no new MPJ + userspace_pm_add_sf $ns2 10.0.3.2 0 2>/dev/null + userspace_pm_add_sf $ns2 10.0.1.2 0 wait_event ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 1 - userspace_pm_chk_dump_addr "${ns2}" \ - "id 0 flags subflow 10.0.3.2" "id 0 subflow" + userspace_pm_chk_dump_addr "${ns2}" "" "id 0 subflow" chk_join_nr 1 1 1 chk_mptcp_info subflows 1 subflows 1 chk_subflows_total 2 2 --=20 2.55.0 From nobody Thu Nov 5 07:28:36 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793309531; b=0sPtXZHZQYLFaSDruMHD0w/4joKbRKrZp0f+ZOTwSZfVEG/srq33qPs/Z3jcW4gRJ0CU xLSmLndhi0yJFBl+HxQEm4E8NXATi/5BNjfOFhgAsNWLucwm22cEDwA0W/rXAoyha9u67 dbiXZNQesgIulFQZo3UMSpmYMlRNuqAE5yejH0W+aepB04tLaiWmLN9SRfgZqCR6ApXmO rY342jgOEs6891bYxZ8SMfv/WcvdXct4BXifAHN1bQyz1JeWzWi+AZ6WT2qM3wBUDHcTd QmRUQ+OQj0Xf2bTZ/HXUk+lminWcPOOMy192BKYB4vHtnyychGWJvpqpZAa5+INPCbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793309531; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=J8OP1AgPoS4WTqXuXScJbnPXQz5Zf4VA39eDwTViHT4=; b=uXsWlxYzmWF0y4b/tcwoC0Ns0rDH0zCpu4uTYGOExBSRw0NvW49IAFz3jCqi5iA2gGae XzrZxSfqdEYyj152SQiHnr1NOC37wYIIxG1MdUyHiklHHx2vLNbxAEXlkvmroef8cNaZ7 6eB18tQCi/2b0mtshlGlS4piP4TLlplTQhYjCZeB3DZJBAqP6rvEKIEH48EHrXU98o8gl mSu4kK98I5UdD6J1nEFJYa31oQqUUSDVUa1isnlR0pUITjGgZXsBeHDh1jLCf1o2vslr1 UqF8j40BWr7ZhzZ4lpJNlbH3tFXh8CStC3shnl/GGjpc0dliyKMVRst/LMbtTT3k+YA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XnwpR1VH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4CD5606A322 for ; Thu, 29 Oct 2026 21:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XnwpR1VH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4429B1F031E7; Thu, 29 Oct 2026 21:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793309530; bh=J8OP1AgPoS4WTqXuXScJbnPXQz5Zf4VA39eDwTViHT4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=XnwpR1VHaX5qWzM5oDznGyuedlFlDiW6noR5JphTYYHdMD/ncO/vQAOPF0tREOoLB 3NylDYkokd9bLGbhPlN9fAXf+LJZxej50mh2UiXA4TWiqU/MSuBdc42aSU2G0ftLeL 8ktqptyKhMOqgquDs5YF+EoHXsPOEliHkMhgVaB1fpSCX0j6cKlVEhIjENgaGW703J UsWFA053SADQfWy6I0F+jZjZ/0q+7Ggx67w9jyhOlRccty16e7HtauyhgUWsOUpX52 TdEVuMEGVOMPDWby3rTkGl+q0Wrk9WTCYxOzTjvuNVJMtkAkRDMrSxvEdW3u2YVW6m XGEYiMZnpLmsQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Oct 2026 22:31:53 +0100 Subject: [PATCH mptcp-net v4 8/8] mptcp: pm: restrict in-kernel worker actions to this PM X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261029-mptcp-pm-userspace-id0-case-v4-8-555066fa4292@kernel.org> References: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> In-Reply-To: <20261029-mptcp-pm-userspace-id0-case-v4-0-555066fa4292@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=784; i=matttbe@kernel.org; h=from:subject:message-id; bh=3wbB6SYDfiS8i/VXCGY8UmLShVG2KSA0hX60WgoHtc8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIe7w5+auC7uZRhUpj7o7fVVZ17vPkPXL20z9/gQLqmZ 4r4R2fujlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIl4NzMy9K6R3fP5T/68RqHA K4eezL+9suy/4cOdt3cp1nXMfNLy4TIjw5+PzpXCFc87T038NamXb3JUu5H0gp7M4u0xFw4lW67 ezAoA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 No need to check them for the userspace PM. Fixes: a49eb8ae95b8 ("mptcp: pm: worker: split in-kernel and common tasks") Signed-off-by: Matthieu Baerts (NGI0) --- v3: use !mptcp_pm_is_userspace(), to handle WIP BPF MPTCP PM --- net/mptcp/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index e9a538296200..e38fe835abc0 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -1154,7 +1154,9 @@ void mptcp_pm_worker(struct mptcp_sock *msk) pm->status &=3D ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); mptcp_pm_rm_addr_recv(msk); } - __mptcp_pm_kernel_worker(msk); + + if (!mptcp_pm_is_userspace(msk)) + __mptcp_pm_kernel_worker(msk); =20 spin_unlock_bh(&msk->pm.lock); } --=20 2.55.0