Commit d440a4e2 authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

mptcp: annotate lockless access for the tx path

The mptcp-level TX path info (write_seq, bytes_sent, snd_nxt) are under
the msk socket lock protection, and are accessed lockless in a few spots.

Always mark the write operations with WRITE_ONCE, read operations
outside the lock with READ_ONCE and drop the annotation for read
under such lock.

To simplify the annotations move mptcp_pending_data_fin_ack() from
__mptcp_data_acked() to __mptcp_clean_una(), under the msk socket
lock, where such call would belong.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1c09d7cb
...@@ -1060,7 +1060,7 @@ static void ack_update_msk(struct mptcp_sock *msk, ...@@ -1060,7 +1060,7 @@ static void ack_update_msk(struct mptcp_sock *msk,
msk->wnd_end = new_wnd_end; msk->wnd_end = new_wnd_end;
/* this assumes mptcp_incoming_options() is invoked after tcp_ack() */ /* this assumes mptcp_incoming_options() is invoked after tcp_ack() */
if (after64(msk->wnd_end, READ_ONCE(msk->snd_nxt))) if (after64(msk->wnd_end, snd_nxt))
__mptcp_check_push(sk, ssk); __mptcp_check_push(sk, ssk);
if (after64(new_snd_una, old_snd_una)) { if (after64(new_snd_una, old_snd_una)) {
......
...@@ -1033,13 +1033,15 @@ static void __mptcp_clean_una(struct sock *sk) ...@@ -1033,13 +1033,15 @@ static void __mptcp_clean_una(struct sock *sk)
msk->recovery = false; msk->recovery = false;
out: out:
if (snd_una == READ_ONCE(msk->snd_nxt) && if (snd_una == msk->snd_nxt && snd_una == msk->write_seq) {
snd_una == READ_ONCE(msk->write_seq)) {
if (mptcp_rtx_timer_pending(sk) && !mptcp_data_fin_enabled(msk)) if (mptcp_rtx_timer_pending(sk) && !mptcp_data_fin_enabled(msk))
mptcp_stop_rtx_timer(sk); mptcp_stop_rtx_timer(sk);
} else { } else {
mptcp_reset_rtx_timer(sk); mptcp_reset_rtx_timer(sk);
} }
if (mptcp_pending_data_fin_ack(sk))
mptcp_schedule_work(sk);
} }
static void __mptcp_clean_una_wakeup(struct sock *sk) static void __mptcp_clean_una_wakeup(struct sock *sk)
...@@ -1499,7 +1501,7 @@ static void mptcp_update_post_push(struct mptcp_sock *msk, ...@@ -1499,7 +1501,7 @@ static void mptcp_update_post_push(struct mptcp_sock *msk,
*/ */
if (likely(after64(snd_nxt_new, msk->snd_nxt))) { if (likely(after64(snd_nxt_new, msk->snd_nxt))) {
msk->bytes_sent += snd_nxt_new - msk->snd_nxt; msk->bytes_sent += snd_nxt_new - msk->snd_nxt;
msk->snd_nxt = snd_nxt_new; WRITE_ONCE(msk->snd_nxt, snd_nxt_new);
} }
} }
...@@ -3200,8 +3202,8 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, ...@@ -3200,8 +3202,8 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,
if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD) if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD)
WRITE_ONCE(msk->csum_enabled, true); WRITE_ONCE(msk->csum_enabled, true);
msk->write_seq = subflow_req->idsn + 1; WRITE_ONCE(msk->write_seq, subflow_req->idsn + 1);
msk->snd_nxt = msk->write_seq; WRITE_ONCE(msk->snd_nxt, msk->write_seq);
msk->snd_una = msk->write_seq; msk->snd_una = msk->write_seq;
msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd;
msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq; msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq;
...@@ -3303,9 +3305,6 @@ void __mptcp_data_acked(struct sock *sk) ...@@ -3303,9 +3305,6 @@ void __mptcp_data_acked(struct sock *sk)
__mptcp_clean_una(sk); __mptcp_clean_una(sk);
else else
__set_bit(MPTCP_CLEAN_UNA, &mptcp_sk(sk)->cb_flags); __set_bit(MPTCP_CLEAN_UNA, &mptcp_sk(sk)->cb_flags);
if (mptcp_pending_data_fin_ack(sk))
mptcp_schedule_work(sk);
} }
void __mptcp_check_push(struct sock *sk, struct sock *ssk) void __mptcp_check_push(struct sock *sk, struct sock *ssk)
......
...@@ -402,7 +402,7 @@ static inline struct mptcp_data_frag *mptcp_rtx_head(struct sock *sk) ...@@ -402,7 +402,7 @@ static inline struct mptcp_data_frag *mptcp_rtx_head(struct sock *sk)
{ {
struct mptcp_sock *msk = mptcp_sk(sk); struct mptcp_sock *msk = mptcp_sk(sk);
if (msk->snd_una == READ_ONCE(msk->snd_nxt)) if (msk->snd_una == msk->snd_nxt)
return NULL; return NULL;
return list_first_entry_or_null(&msk->rtx_queue, struct mptcp_data_frag, list); return list_first_entry_or_null(&msk->rtx_queue, struct mptcp_data_frag, list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment