diff mbox series

[v2] mptcp: call tcp_cleanup_rbuf on subflows

Message ID 90b277657a8e3bb69267f0cc902bf0d34bf32417.1599734019.git.pabeni@redhat.com
State Accepted, archived
Commit bef7797391292b1210d0ecd4b4a90483e5747e05
Delegated to: Matthieu Baerts
Headers show
Series [v2] mptcp: call tcp_cleanup_rbuf on subflows | expand

Commit Message

Paolo Abeni Sept. 10, 2020, 10:33 a.m. UTC
That is needed to let the subflows announce promply when new
space is available in the receive buffer.

tcp_cleanup_rbuf() is currently a static function, drop the
scope modifier and add a declaration in the TCP header.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
--
should be inserted just before "mptcp: simult flow self-tests"

v1 -> v2:
 - move tcp_cleanup_rbuf() declaration inside the headers
---
 include/net/tcp.h    | 2 ++
 net/ipv4/tcp.c       | 2 +-
 net/mptcp/protocol.c | 6 ++++++
 net/mptcp/subflow.c  | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)

Comments

Mat Martineau Sept. 10, 2020, 11:31 p.m. UTC | #1
On Thu, 10 Sep 2020, Paolo Abeni wrote:

> That is needed to let the subflows announce promply when new
> space is available in the receive buffer.
>
> tcp_cleanup_rbuf() is currently a static function, drop the
> scope modifier and add a declaration in the TCP header.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> --
> should be inserted just before "mptcp: simult flow self-tests"
>
> v1 -> v2:
> - move tcp_cleanup_rbuf() declaration inside the headers
> ---

v2 looks good for the export branch, thanks Paolo.

--
Mat Martineau
Intel
Matthieu Baerts Sept. 11, 2020, 10:53 a.m. UTC | #2
Hi Paolo, Mat,

On 11/09/2020 01:31, Mat Martineau wrote:
> 
> On Thu, 10 Sep 2020, Paolo Abeni wrote:
> 
>> That is needed to let the subflows announce promply when new
>> space is available in the receive buffer.
>>
>> tcp_cleanup_rbuf() is currently a static function, drop the
>> scope modifier and add a declaration in the TCP header.
>>
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>> -- 
>> should be inserted just before "mptcp: simult flow self-tests"
>>
>> v1 -> v2:
>> - move tcp_cleanup_rbuf() declaration inside the headers
>> ---
> 
> v2 looks good for the export branch, thanks Paolo.

Thank you for the patch and the review!

This patch has been added just before: t/mptcp-simult-flow-self-tests

- 341c313c53a5..2e7e0cdd7acd: result

Tests + export are in progress!

Cheers,
Matt
diff mbox series

Patch

diff --git a/include/net/tcp.h b/include/net/tcp.h
index e85d564446c6..852f0d71dd40 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1414,6 +1414,8 @@  static inline int tcp_full_space(const struct sock *sk)
 	return tcp_win_from_space(sk, READ_ONCE(sk->sk_rcvbuf));
 }
 
+void tcp_cleanup_rbuf(struct sock *sk, int copied);
+
 /* We provision sk_rcvbuf around 200% of sk_rcvlowat.
  * If 87.5 % (7/8) of the space has been consumed, we want to override
  * SO_RCVLOWAT constraint, since we are receiving skbs with too small
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 57a568875539..d3781b6087cb 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1527,7 +1527,7 @@  static int tcp_peek_sndq(struct sock *sk, struct msghdr *msg, int len)
  * calculation of whether or not we must ACK for the sake of
  * a window update.
  */
-static void tcp_cleanup_rbuf(struct sock *sk, int copied)
+void tcp_cleanup_rbuf(struct sock *sk, int copied)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	bool time_to_ack = false;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7469e89b3d7a..2abfe998ed05 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -527,6 +527,8 @@  static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk,
 	} while (more_data_avail);
 
 	*bytes += moved;
+	if (moved)
+		tcp_cleanup_rbuf(ssk, moved);
 
 	return done;
 }
@@ -1439,10 +1441,14 @@  static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
 			 */
 			mptcp_for_each_subflow(msk, subflow) {
 				struct sock *ssk;
+				bool slow;
 
 				ssk = mptcp_subflow_tcp_sock(subflow);
+				slow = lock_sock_fast(ssk);
 				WRITE_ONCE(ssk->sk_rcvbuf, rcvbuf);
 				tcp_sk(ssk)->window_clamp = window_clamp;
+				tcp_cleanup_rbuf(ssk, 1);
+				unlock_sock_fast(ssk, slow);
 			}
 		}
 	}
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index e31900ff0c56..c3073c400d6c 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -823,6 +823,8 @@  static void mptcp_subflow_discard_data(struct sock *ssk, struct sk_buff *skb,
 		sk_eat_skb(ssk, skb);
 	if (mptcp_subflow_get_map_offset(subflow) >= subflow->map_data_len)
 		subflow->map_valid = 0;
+	if (incr)
+		tcp_cleanup_rbuf(ssk, incr);
 }
 
 static bool subflow_check_data_avail(struct sock *ssk)