Skip to content

Commit 2948d0a

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: factor out __mptcp_retrans helper()
Will simplify the following patch, no functional change intended. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c8fe62f commit 2948d0a

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

net/mptcp/protocol.c

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,59 +2261,23 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
22612261
mptcp_close_wake_up(sk);
22622262
}
22632263

2264-
static void mptcp_worker(struct work_struct *work)
2264+
static void __mptcp_retrans(struct sock *sk)
22652265
{
2266-
struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
2267-
struct sock *ssk, *sk = &msk->sk.icsk_inet.sk;
2266+
struct mptcp_sock *msk = mptcp_sk(sk);
22682267
struct mptcp_sendmsg_info info = {};
22692268
struct mptcp_data_frag *dfrag;
22702269
size_t copied = 0;
2271-
int state, ret;
2272-
2273-
lock_sock(sk);
2274-
state = sk->sk_state;
2275-
if (unlikely(state == TCP_CLOSE))
2276-
goto unlock;
2277-
2278-
mptcp_check_data_fin_ack(sk);
2279-
__mptcp_flush_join_list(msk);
2280-
2281-
mptcp_check_fastclose(msk);
2282-
2283-
if (msk->pm.status)
2284-
mptcp_pm_nl_work(msk);
2285-
2286-
if (test_and_clear_bit(MPTCP_WORK_EOF, &msk->flags))
2287-
mptcp_check_for_eof(msk);
2288-
2289-
__mptcp_check_send_data_fin(sk);
2290-
mptcp_check_data_fin(sk);
2291-
2292-
/* There is no point in keeping around an orphaned sk timedout or
2293-
* closed, but we need the msk around to reply to incoming DATA_FIN,
2294-
* even if it is orphaned and in FIN_WAIT2 state
2295-
*/
2296-
if (sock_flag(sk, SOCK_DEAD) &&
2297-
(mptcp_check_close_timeout(sk) || sk->sk_state == TCP_CLOSE)) {
2298-
inet_sk_state_store(sk, TCP_CLOSE);
2299-
__mptcp_destroy_sock(sk);
2300-
goto unlock;
2301-
}
2302-
2303-
if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
2304-
__mptcp_close_subflow(msk);
2305-
2306-
if (!test_and_clear_bit(MPTCP_WORK_RTX, &msk->flags))
2307-
goto unlock;
2270+
struct sock *ssk;
2271+
int ret;
23082272

23092273
__mptcp_clean_una(sk);
23102274
dfrag = mptcp_rtx_head(sk);
23112275
if (!dfrag)
2312-
goto unlock;
2276+
return;
23132277

23142278
ssk = mptcp_subflow_get_retrans(msk);
23152279
if (!ssk)
2316-
goto reset_unlock;
2280+
goto reset_timer;
23172281

23182282
lock_sock(ssk);
23192283

@@ -2339,9 +2303,52 @@ static void mptcp_worker(struct work_struct *work)
23392303
mptcp_set_timeout(sk, ssk);
23402304
release_sock(ssk);
23412305

2342-
reset_unlock:
2306+
reset_timer:
23432307
if (!mptcp_timer_pending(sk))
23442308
mptcp_reset_timer(sk);
2309+
}
2310+
2311+
static void mptcp_worker(struct work_struct *work)
2312+
{
2313+
struct mptcp_sock *msk = container_of(work, struct mptcp_sock, work);
2314+
struct sock *sk = &msk->sk.icsk_inet.sk;
2315+
int state;
2316+
2317+
lock_sock(sk);
2318+
state = sk->sk_state;
2319+
if (unlikely(state == TCP_CLOSE))
2320+
goto unlock;
2321+
2322+
mptcp_check_data_fin_ack(sk);
2323+
__mptcp_flush_join_list(msk);
2324+
2325+
mptcp_check_fastclose(msk);
2326+
2327+
if (msk->pm.status)
2328+
mptcp_pm_nl_work(msk);
2329+
2330+
if (test_and_clear_bit(MPTCP_WORK_EOF, &msk->flags))
2331+
mptcp_check_for_eof(msk);
2332+
2333+
__mptcp_check_send_data_fin(sk);
2334+
mptcp_check_data_fin(sk);
2335+
2336+
/* There is no point in keeping around an orphaned sk timedout or
2337+
* closed, but we need the msk around to reply to incoming DATA_FIN,
2338+
* even if it is orphaned and in FIN_WAIT2 state
2339+
*/
2340+
if (sock_flag(sk, SOCK_DEAD) &&
2341+
(mptcp_check_close_timeout(sk) || sk->sk_state == TCP_CLOSE)) {
2342+
inet_sk_state_store(sk, TCP_CLOSE);
2343+
__mptcp_destroy_sock(sk);
2344+
goto unlock;
2345+
}
2346+
2347+
if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
2348+
__mptcp_close_subflow(msk);
2349+
2350+
if (test_and_clear_bit(MPTCP_WORK_RTX, &msk->flags))
2351+
__mptcp_retrans(sk);
23452352

23462353
unlock:
23472354
release_sock(sk);

0 commit comments

Comments
 (0)