Skip to content

Commit d82809b

Browse files
matttbePaolo Abeni
authored andcommitted
mptcp: avoid duplicated SUB_CLOSED events
The initial subflow might have already been closed, but still in the connection list. When the worker is instructed to close the subflows that have been marked as closed, it might then try to close the initial subflow again. A consequence of that is that the SUB_CLOSED event can be seen twice: # ip mptcp endpoint 1.1.1.1 id 1 subflow dev eth0 2.2.2.2 id 2 subflow dev eth1 # ip mptcp monitor & [ CREATED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9 [ ESTABLISHED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9 [ SF_ESTABLISHED] remid=0 locid=2 saddr4=2.2.2.2 daddr4=9.9.9.9 # ip mptcp endpoint delete id 1 [ SF_CLOSED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9 [ SF_CLOSED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9 The first one is coming from mptcp_pm_nl_rm_subflow_received(), and the second one from __mptcp_close_subflow(). To avoid doing the post-closed processing twice, the subflow is now marked as closed the first time. Note that it is not enough to check if we are dealing with the first subflow and check its sk_state: the subflow might have been reset or closed before calling mptcp_close_ssk(). Fixes: b911c97 ("mptcp: add netlink event support") Cc: stable@vger.kernel.org Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent d397d72 commit d82809b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

net/mptcp/protocol.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,12 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
25082508
void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
25092509
struct mptcp_subflow_context *subflow)
25102510
{
2511+
/* The first subflow can already be closed and still in the list */
2512+
if (subflow->close_event_done)
2513+
return;
2514+
2515+
subflow->close_event_done = true;
2516+
25112517
if (sk->sk_state == TCP_ESTABLISHED)
25122518
mptcp_event(MPTCP_EVENT_SUB_CLOSED, mptcp_sk(sk), ssk, GFP_KERNEL);
25132519

net/mptcp/protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ struct mptcp_subflow_context {
524524
stale : 1, /* unable to snd/rcv data, do not use for xmit */
525525
valid_csum_seen : 1, /* at least one csum validated */
526526
is_mptfo : 1, /* subflow is doing TFO */
527-
__unused : 10;
527+
close_event_done : 1, /* has done the post-closed part */
528+
__unused : 9;
528529
bool data_avail;
529530
bool scheduled;
530531
u32 remote_nonce;

0 commit comments

Comments
 (0)