Skip to content

Commit a5cb752

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: use mptcp_schedule_work instead of open-coding it
Beyond reducing code duplication this also avoids scheduling the mptcp_worker on a closed socket on some edge scenarios. The addressed issue is actually older than the blamed commit below, but this fix needs it as a pre-requisite. Fixes: ba8f48f ("mptcp: introduce mptcp_schedule_work") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5b7be2d commit a5cb752

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

net/mptcp/options.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,8 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
11921192
*/
11931193
if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) {
11941194
if (mp_opt.data_fin && mp_opt.data_len == 1 &&
1195-
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64) &&
1196-
schedule_work(&msk->work))
1197-
sock_hold(subflow->conn);
1195+
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
1196+
mptcp_schedule_work((struct sock *)msk);
11981197

11991198
return true;
12001199
}

net/mptcp/subflow.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,8 @@ void mptcp_subflow_reset(struct sock *ssk)
408408

409409
tcp_send_active_reset(ssk, GFP_ATOMIC);
410410
tcp_done(ssk);
411-
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) &&
412-
schedule_work(&mptcp_sk(sk)->work))
413-
return; /* worker will put sk for us */
411+
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags))
412+
mptcp_schedule_work(sk);
414413

415414
sock_put(sk);
416415
}
@@ -1118,8 +1117,8 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
11181117
skb_ext_del(skb, SKB_EXT_MPTCP);
11191118
return MAPPING_OK;
11201119
} else {
1121-
if (updated && schedule_work(&msk->work))
1122-
sock_hold((struct sock *)msk);
1120+
if (updated)
1121+
mptcp_schedule_work((struct sock *)msk);
11231122

11241123
return MAPPING_DATA_FIN;
11251124
}
@@ -1222,17 +1221,12 @@ static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb,
12221221
/* sched mptcp worker to remove the subflow if no more data is pending */
12231222
static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ssk)
12241223
{
1225-
struct sock *sk = (struct sock *)msk;
1226-
12271224
if (likely(ssk->sk_state != TCP_CLOSE))
12281225
return;
12291226

12301227
if (skb_queue_empty(&ssk->sk_receive_queue) &&
1231-
!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) {
1232-
sock_hold(sk);
1233-
if (!schedule_work(&msk->work))
1234-
sock_put(sk);
1235-
}
1228+
!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
1229+
mptcp_schedule_work((struct sock *)msk);
12361230
}
12371231

12381232
static bool subflow_can_fallback(struct mptcp_subflow_context *subflow)

0 commit comments

Comments
 (0)