Skip to content

Commit c1c385d

Browse files
Paolo Abenismb49
authored andcommitted
mptcp: use mptcp_schedule_work instead of open-coding it
BugLink: https://bugs.launchpad.net/bugs/2023328 commit a5cb752 upstream. 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: [email protected] Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Luke Nowakowski-Krijger <[email protected]>
1 parent 303ded3 commit c1c385d

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
@@ -1156,9 +1156,8 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
11561156
*/
11571157
if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) {
11581158
if (mp_opt.data_fin && mp_opt.data_len == 1 &&
1159-
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64) &&
1160-
schedule_work(&msk->work))
1161-
sock_hold(subflow->conn);
1159+
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
1160+
mptcp_schedule_work((struct sock *)msk);
11621161

11631162
return true;
11641163
}

net/mptcp/subflow.c

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

361361
tcp_send_active_reset(ssk, GFP_ATOMIC);
362362
tcp_done(ssk);
363-
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) &&
364-
schedule_work(&mptcp_sk(sk)->work))
365-
return; /* worker will put sk for us */
363+
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags))
364+
mptcp_schedule_work(sk);
366365

367366
sock_put(sk);
368367
}
@@ -1010,8 +1009,8 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
10101009
skb_ext_del(skb, SKB_EXT_MPTCP);
10111010
return MAPPING_OK;
10121011
} else {
1013-
if (updated && schedule_work(&msk->work))
1014-
sock_hold((struct sock *)msk);
1012+
if (updated)
1013+
mptcp_schedule_work((struct sock *)msk);
10151014

10161015
return MAPPING_DATA_FIN;
10171016
}
@@ -1114,17 +1113,12 @@ static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb,
11141113
/* sched mptcp worker to remove the subflow if no more data is pending */
11151114
static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct sock *ssk)
11161115
{
1117-
struct sock *sk = (struct sock *)msk;
1118-
11191116
if (likely(ssk->sk_state != TCP_CLOSE))
11201117
return;
11211118

11221119
if (skb_queue_empty(&ssk->sk_receive_queue) &&
1123-
!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) {
1124-
sock_hold(sk);
1125-
if (!schedule_work(&msk->work))
1126-
sock_put(sk);
1127-
}
1120+
!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
1121+
mptcp_schedule_work((struct sock *)msk);
11281122
}
11291123

11301124
static bool subflow_can_fallback(struct mptcp_subflow_context *subflow)

0 commit comments

Comments
 (0)