From: Matthieu Baerts <matttbe@kernel.org>
To: Kyuwon Cho <kyuwon.cho@skku.edu>
Cc: Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Kalpan Jani <kalpan.jani@mpiricsoftware.com>,
netdev@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH net] mptcp: pm: preserve the port when removing ID 0
Date: Fri, 4 Dec 2026 12:05:09 +0100 [thread overview]
Message-ID: <d021e6e0-1c96-40f0-8aca-e6096761eb85@kernel.org> (raw)
In-Reply-To: <179633974213.577499.3953204420789445318@skku.edu>
Hi Kyuwon,
Thank you for sharing this patch.
On 04/12/2026 06:11, Kyuwon Cho wrote:
> The ID 0 removal path copies the MPTCP socket's local address, then clears
> its port before looking for a pending ADD_ADDR. An ID 0 ADD_ADDR that was
> announced with a port is stored with that port
I think the root cause of your issue is there: an ID 0 ADD_ADDR
shouldn't be announced with a port: the ID0 is a bit special: it is
linked to the initial subflow IP address and port. It should then use
the "default" port (set to 0 then), the one linked to the msk, so the
initial one.
> so removal misses the
> entry. A later announcement of the same address finds the stale entry and
> warns:
>
> WARNING: net/mptcp/pm.c:451 at mptcp_pm_announced_alloc
> RIP: 0010:mptcp_pm_announced_alloc (net/mptcp/pm.c:451)
> Call Trace:
> mptcp_pm_create_subflow_or_signal_addr (net/mptcp/pm_kernel.c:377)
> mptcp_pm_nl_add_addr_doit
> (net/mptcp/pm_kernel.c:983 net/mptcp/pm_kernel.c:1049)
> genl_family_rcv_msg_doit (net/netlink/genetlink.c:1114)
>
> Use the port supplied with the removal request. Portless removals continue
> to use zero, while port-specific entries can now be found and removed.
>
> Fixes: 2ac7d6e62076 ("mptcp: pm: kernel: drop pending ADD_ADDR when removing ID0")
I started working on a fix when this patch was sent upstream. I was
doing that:
================================= 8< =================================
diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index d3014bf57bf3..cd9df9f56d96 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -314,6 +314,7 @@ static void mptcp_mpc_endpoint_setup(struct mptcp_sock *msk)
pernet = pm_nl_get_pernet_from_msk(msk);
mptcp_local_address((struct sock_common *)msk->first, &mpc_addr);
+ mpc_addr.port = 0; /* entries for ID0 don't have a specific port */
rcu_read_lock();
entry = __lookup_addr(pernet, &mpc_addr);
if (entry) {
@@ -368,7 +369,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
/* Special case for ID0: set the correct ID */
endp_id = local.addr.id;
- if (endp_id == msk->mpc_endpoint_id)
+ if (endp_id == msk->mpc_endpoint_id && local.addr.port == 0)
local.addr.id = 0;
/* If the alloc fails, we are on memory pressure, not worth
@@ -409,7 +410,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
__clear_bit(local.addr.id, msk->pm.id_avail_bitmap);
/* Special case for ID0: set the correct ID */
- if (local.addr.id == msk->mpc_endpoint_id)
+ if (local.addr.id == msk->mpc_endpoint_id && !local.addr.port)
local.addr.id = 0;
else /* local_addr_used is not decr for ID 0 */
msk->pm.local_addr_used++;
@@ -975,6 +976,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net,
/* if the endp linked to the init sf is re-added with a != ID */
mptcp_local_address((struct sock_common *)msk, &mpc_addr);
+ mpc_addr.port = 0; /* entries for ID0 don't have a port */
lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
================================= 8< =================================
Could that help for your case? (Note: not tested, it might break
selftests / packetdrill tests: you might want to validate the whole
test suite with: https://github.com/multipath-tcp/mptcp-upstream-virtme-docker)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2026-12-04 11:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 5:11 [PATCH net] mptcp: pm: preserve the port when removing ID 0 Kyuwon Cho
2026-12-04 6:38 ` MPTCP CI
2026-12-04 11:05 ` Matthieu Baerts [this message]
2026-12-05 1:47 ` Kyuwon Cho
2026-12-05 5:11 ` sashiko-bot
2026-12-05 5:48 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d021e6e0-1c96-40f0-8aca-e6096761eb85@kernel.org \
--to=matttbe@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kalpan.jani@mpiricsoftware.com \
--cc=kuba@kernel.org \
--cc=kyuwon.cho@skku.edu \
--cc=martineau@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.