Skip to content

Commit fb8d0bc

Browse files
matttbekuba-moo
authored andcommitted
mptcp: pm: avoid sending RM_ADDR over same subflow
RM_ADDR are sent over an active subflow, the first one in the subflows list. There is then a high chance the initial subflow is picked. With the in-kernel PM, when an endpoint is removed, a RM_ADDR is sent, then linked subflows are closed. This is done for each active MPTCP connection. MPTCP endpoints are likely removed because the attached network is no longer available or usable. In this case, it is better to avoid sending this RM_ADDR over the subflow that is going to be removed, but prefer sending it over another active and non stale subflow, if any. This modification avoids situations where the other end is not notified when a subflow is no longer usable: typically when the endpoint linked to the initial subflow is removed, especially on the server side. Fixes: 8dd5efb ("mptcp: send ack for rm_addr") Cc: stable@vger.kernel.org Reported-by: Frank Lorenz <lorenz-frank@web.de> Closes: multipath-tcp/mptcp_net-next#612 Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260303-net-mptcp-misc-fixes-7-0-rc2-v1-2-4b5462b6f016@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8c09412 commit fb8d0bc

File tree

1 file changed

+43
-12
lines changed

1 file changed

+43
-12
lines changed

net/mptcp/pm.c

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,24 @@ void mptcp_pm_send_ack(struct mptcp_sock *msk,
212212
spin_lock_bh(&msk->pm.lock);
213213
}
214214

215-
void mptcp_pm_addr_send_ack(struct mptcp_sock *msk)
215+
static bool subflow_in_rm_list(const struct mptcp_subflow_context *subflow,
216+
const struct mptcp_rm_list *rm_list)
217+
{
218+
u8 i, id = subflow_get_local_id(subflow);
219+
220+
for (i = 0; i < rm_list->nr; i++) {
221+
if (rm_list->ids[i] == id)
222+
return true;
223+
}
224+
225+
return false;
226+
}
227+
228+
static void
229+
mptcp_pm_addr_send_ack_avoid_list(struct mptcp_sock *msk,
230+
const struct mptcp_rm_list *rm_list)
216231
{
217-
struct mptcp_subflow_context *subflow, *alt = NULL;
232+
struct mptcp_subflow_context *subflow, *stale = NULL, *same_id = NULL;
218233

219234
msk_owned_by_me(msk);
220235
lockdep_assert_held(&msk->pm.lock);
@@ -224,19 +239,35 @@ void mptcp_pm_addr_send_ack(struct mptcp_sock *msk)
224239
return;
225240

226241
mptcp_for_each_subflow(msk, subflow) {
227-
if (__mptcp_subflow_active(subflow)) {
228-
if (!subflow->stale) {
229-
mptcp_pm_send_ack(msk, subflow, false, false);
230-
return;
231-
}
242+
if (!__mptcp_subflow_active(subflow))
243+
continue;
232244

233-
if (!alt)
234-
alt = subflow;
245+
if (unlikely(subflow->stale)) {
246+
if (!stale)
247+
stale = subflow;
248+
} else if (unlikely(rm_list &&
249+
subflow_in_rm_list(subflow, rm_list))) {
250+
if (!same_id)
251+
same_id = subflow;
252+
} else {
253+
goto send_ack;
235254
}
236255
}
237256

238-
if (alt)
239-
mptcp_pm_send_ack(msk, alt, false, false);
257+
if (same_id)
258+
subflow = same_id;
259+
else if (stale)
260+
subflow = stale;
261+
else
262+
return;
263+
264+
send_ack:
265+
mptcp_pm_send_ack(msk, subflow, false, false);
266+
}
267+
268+
void mptcp_pm_addr_send_ack(struct mptcp_sock *msk)
269+
{
270+
mptcp_pm_addr_send_ack_avoid_list(msk, NULL);
240271
}
241272

242273
int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
@@ -470,7 +501,7 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_
470501
msk->pm.rm_list_tx = *rm_list;
471502
rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
472503
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
473-
mptcp_pm_addr_send_ack(msk);
504+
mptcp_pm_addr_send_ack_avoid_list(msk, rm_list);
474505
return 0;
475506
}
476507

0 commit comments

Comments
 (0)