mptcp: avoid duplicated SUB_CLOSED events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>

commit d82809b6c5f2676b382f77a5cbeb1a5d91ed2235 upstream.

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: b911c97c7dc7 ("mptcp: add netlink event support")
Cc: stable@xxxxxxxxxxxxxxx
Tested-by: Arınç ÜNAL <arinc.unal@xxxxxxxxxx>
Reviewed-by: Mat Martineau <martineau@xxxxxxxxxx>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 net/mptcp/protocol.c |    6 ++++++
 net/mptcp/protocol.h |    3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2508,6 +2508,12 @@ out:
 void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 		     struct mptcp_subflow_context *subflow)
 {
+	/* The first subflow can already be closed and still in the list */
+	if (subflow->close_event_done)
+		return;
+
+	subflow->close_event_done = true;
+
 	if (sk->sk_state == TCP_ESTABLISHED)
 		mptcp_event(MPTCP_EVENT_SUB_CLOSED, mptcp_sk(sk), ssk, GFP_KERNEL);
 
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -519,7 +519,8 @@ struct mptcp_subflow_context {
 		stale : 1,	    /* unable to snd/rcv data, do not use for xmit */
 		valid_csum_seen : 1,        /* at least one csum validated */
 		is_mptfo : 1,	    /* subflow is doing TFO */
-		__unused : 10;
+		close_event_done : 1,       /* has done the post-closed part */
+		__unused : 9;
 	bool	data_avail;
 	bool	scheduled;
 	u32	remote_nonce;


Patches currently in stable-queue which might be from matttbe@xxxxxxxxxx are

queue-6.10/selftests-mptcp-join-cannot-rm-sf-if-closed.patch
queue-6.10/mptcp-pm-fix-rm_addr-id-for-the-initial-subflow.patch
queue-6.10/mptcp-pm-fix-id-0-endp-usage-after-multiple-re-creations.patch
queue-6.10/mptcp-pm-skip-connecting-to-already-established-sf.patch
queue-6.10/mptcp-pm-reuse-id-0-after-delete-and-re-add.patch
queue-6.10/mptcp-avoid-duplicated-sub_closed-events.patch
queue-6.10/mptcp-pm-add_addr-0-is-not-a-new-address.patch
queue-6.10/mptcp-pm-do-not-remove-already-closed-subflows.patch
queue-6.10/mptcp-pm-send-ack-on-an-active-subflow.patch
queue-6.10/mptcp-pm-reset-mpc-endp-id-when-re-added.patch
queue-6.10/mptcp-close-subflow-when-receiving-tcp-fin.patch
queue-6.10/selftests-mptcp-join-check-re-re-adding-id-0-endp.patch
queue-6.10/selftests-mptcp-join-no-extra-msg-if-no-counter.patch
queue-6.10/mptcp-pr_debug-add-missing-n-at-the-end.patch
queue-6.10/selftests-mptcp-join-check-removing-id-0-endpoint.patch
queue-6.10/mptcp-sched-check-both-backup-in-retrans.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux