Skip to contentSkip to conversation

mptcp: fix stale subflow->writeable caching

PATCH In review Florian Westphal 3 participants 3 messages Aug 21, 2020 – Aug 28, 2020

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author
#0 lore raw

PATCH 1/1 mptcp: fix stale subflow->writeable caching

Even with fixed subflow_write_space(), we may still indicate EPOLLOUT even if no subflow is writeable.

We need to re-check the last ssk that was used after the final tcp_push(). tcp_push() can allocate new skbs that get charged to the subflow sk which may bring it above the wmem limit.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +4 -1
index ad91f4588216..4dd5d35a8f39 100644
@@ -1239,7 +1239,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 		msk->snd_burst -= ret;
 		copied += ret;
 
-		if (!sk_stream_memory_free(ssk))
+		if (!sk_stream_is_writeable(ssk))
 			WRITE_ONCE(subflow->writable, false);
 
 		tx_ok = msg_data_left(msg);
@@ -1294,6 +1294,9 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 		/* start the timer, if it's not pending */
 		if (!mptcp_timer_pending(sk))
 			mptcp_reset_timer(sk);
+
+		if (!sk_stream_is_writeable(ssk))
+			WRITE_ONCE(mptcp_subflow_ctx(ssk)->writable, false);
 	}
 
 	release_sock(ssk);
Signature · 1 line
2.26.2
#1 lore raw
Quoted 37 lines · Florian Westphal

Even with fixed subflow_write_space(), we may still indicate EPOLLOUT even if no subflow is writeable.

We need to re-check the last ssk that was used after the final tcp_push(). tcp_push() can allocate new skbs that get charged to the subflow sk which may bring it above the wmem limit.

Signed-off-by Florian Westphal <fw(a)strlen.de>

---
net/mptcp/protocol.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +4 -1
index ad91f4588216..4dd5d35a8f39 100644
@@ -1239,7 +1239,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 		msk->snd_burst -= ret;
 		copied += ret;
 
-		if (!sk_stream_memory_free(ssk))
+		if (!sk_stream_is_writeable(ssk))
 			WRITE_ONCE(subflow->writable, false);
 
 		tx_ok = msg_data_left(msg);
@@ -1294,6 +1294,9 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 		/* start the timer, if it's not pending */
 		if (!mptcp_timer_pending(sk))
 			mptcp_reset_timer(sk);
+
+		if (!sk_stream_is_writeable(ssk))
+			WRITE_ONCE(mptcp_subflow_ctx(ssk)->writable, false);
 	}
 
 	release_sock(ssk);
Signature · 1 line
2.26.2

Thanks Florian. All three patches look good to me.

--
Mat Martineau
Intel

#2 lore raw

Hi Florian, Mat,

Quoted 5 lines · Mat Martineau
Quoted 3 lines · Florian Westphal

Even with fixed subflow_write_space(), we may still indicate EPOLLOUT even if no subflow is writeable.

Quoted 8 lines
Quoted 6 lines

We need to re-check the last ssk that was used after the final tcp_push().
tcp_push() can allocate new skbs that get charged to the subflow sk which may bring it above the wmem limit.

Signed-off-by Florian Westphal <fw(a)strlen.de>

Thanks Florian. All three patches look good to me.

Thank you for the patch and the review!

Applied at the end of the series.

Tests + export are in progress!

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net