]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mptcp: schedule worker when subflow is closed
authorFlorian Westphal <fw@strlen.de>
Fri, 12 Feb 2021 23:59:56 +0000 (15:59 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Feb 2021 00:31:45 +0000 (16:31 -0800)
When remote side closes a subflow we should schedule the worker to
dispose of the subflow in a timely manner.

Otherwise, SF_CLOSED event won't be generated until the mptcp
socket itself is closing or local side is closing another subflow.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mptcp/protocol.c
net/mptcp/subflow.c

index 3fd8aef979a33c2f4671bcfcfb581bfd41378ccc..267c5521692d7a03644dd6b82b0af0e8524263d4 100644 (file)
@@ -2170,6 +2170,10 @@ static void __mptcp_close_subflow(struct mptcp_sock *msk)
                if (inet_sk_state_load(ssk) != TCP_CLOSE)
                        continue;
 
+               /* 'subflow_data_ready' will re-sched once rx queue is empty */
+               if (!skb_queue_empty_lockless(&ssk->sk_receive_queue))
+                       continue;
+
                mptcp_close_ssk((struct sock *)msk, ssk, subflow);
        }
 }
index 280da418d60b6898de7cdb4cd9755f52403374da..36b15726f85112cc1c34f6fe58bb91ce50b573a2 100644 (file)
@@ -953,6 +953,22 @@ static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb,
                subflow->map_valid = 0;
 }
 
+/* sched mptcp worker to remove the subflow if no more data is pending */
+static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ssk)
+{
+       struct sock *sk = (struct sock *)msk;
+
+       if (likely(ssk->sk_state != TCP_CLOSE))
+               return;
+
+       if (skb_queue_empty(&ssk->sk_receive_queue) &&
+           !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) {
+               sock_hold(sk);
+               if (!schedule_work(&msk->work))
+                       sock_put(sk);
+       }
+}
+
 static bool subflow_check_data_avail(struct sock *ssk)
 {
        struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
@@ -991,11 +1007,11 @@ static bool subflow_check_data_avail(struct sock *ssk)
                }
 
                if (status != MAPPING_OK)
-                       return false;
+                       goto no_data;
 
                skb = skb_peek(&ssk->sk_receive_queue);
                if (WARN_ON_ONCE(!skb))
-                       return false;
+                       goto no_data;
 
                /* if msk lacks the remote key, this subflow must provide an
                 * MP_CAPABLE-based mapping
@@ -1029,6 +1045,9 @@ static bool subflow_check_data_avail(struct sock *ssk)
        }
        return true;
 
+no_data:
+       subflow_sched_work_if_closed(msk, ssk);
+       return false;
 fatal:
        /* fatal protocol error, close the socket */
        /* This barrier is coupled with smp_rmb() in tcp_poll() */
@@ -1413,6 +1432,8 @@ static void subflow_state_change(struct sock *sk)
        if (mptcp_subflow_data_available(sk))
                mptcp_data_ready(parent, sk);
 
+       subflow_sched_work_if_closed(mptcp_sk(parent), sk);
+
        if (__mptcp_check_fallback(mptcp_sk(parent)) &&
            !subflow->rx_eof && subflow_is_done(sk)) {
                subflow->rx_eof = 1;