Skip to contentSkip to conversation

mptcp: update mptcp ack sequence from work queue

PATCH In review Florian Westphal 1 participant 8 messages Feb 20, 2020

Subsystems (3)
lore
Share & tools
lore

Florian Westphal

author
#0 lore raw

v3 cover mptcp: update mptcp ack sequence from work queue

V3. No changes since v2, I only updated commit messages in patches 1, 2, 3 and 6.

I think we should try to avoid needless squashing and keep these as-is for now. We can always condense some of this later on in case we need to reduce number of individual patches for some reason.

author
#1 lore raw

PATCH v3 1/6 mptcp: add and use mptcp_data_ready helper

allows us to schedule the work queue to drain the ssk receive queue in a followup patch.

This is needed to avoid sending all-to-pessimistic mptcp-level acknowledgements. At this time, the ack_seq is what was last read by userspace instead of the highest in-sequence number queued for reading.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c |  8 ++++++++
 net/mptcp/protocol.h |  1 +
 net/mptcp/subflow.c  | 14 ++++----------
 3 files changed, 13 insertions(+), 10 deletions(-)
net/mptcp/protocol.c +8 -0
index 47b3c4afdc87..84204129e1d3 100644
@@ -156,6 +156,14 @@ void mptcp_subflow_eof(struct sock *sk)
 		sock_hold(sk);
 }
 
+void mptcp_data_ready(struct sock *sk)
+{
+	struct mptcp_sock *msk = mptcp_sk(sk);
+
+	set_bit(MPTCP_DATA_READY, &msk->flags);
+	sk->sk_data_ready(sk);
+}
+
 static void mptcp_stop_timer(struct sock *sk)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
net/mptcp/protocol.h +1 -0
index 3fbb33deb764..95b0ade75771 100644
@@ -317,6 +317,7 @@ void mptcp_finish_connect(struct sock *sk);
 void mptcp_subflow_eof(struct sock *sk);
 bool mptcp_finish_join(struct sock *sk);
 void mptcp_data_acked(struct sock *sk);
+void mptcp_data_ready(struct sock *sk);
 
 int mptcp_token_new_request(struct request_sock *req);
 void mptcp_token_destroy_request(u32 token);
net/mptcp/subflow.c +4 -10
index 547d5ffef070..fbff5dc39575 100644
@@ -723,11 +723,8 @@ static void subflow_data_ready(struct sock *sk)
 		return;
 	}
 
-	if (mptcp_subflow_data_available(sk)) {
-		set_bit(MPTCP_DATA_READY, &mptcp_sk(parent)->flags);
-
-		parent->sk_data_ready(parent);
-	}
+	if (mptcp_subflow_data_available(sk))
+		mptcp_data_ready(parent);
 }
 
 static void subflow_write_space(struct sock *sk)
@@ -916,11 +913,8 @@ static void subflow_state_change(struct sock *sk)
 	 * a fin packet carrying a DSS can be unnoticed if we don't trigger
 	 * the data available machinery here.
 	 */
-	if (parent && subflow->mp_capable && mptcp_subflow_data_available(sk)) {
-		set_bit(MPTCP_DATA_READY, &mptcp_sk(parent)->flags);
-
-		parent->sk_data_ready(parent);
-	}
+	if (parent && subflow->mp_capable && mptcp_subflow_data_available(sk))
+		mptcp_data_ready(parent);
 
 	if (parent && !(parent->sk_shutdown & RCV_SHUTDOWN) &&
 	    !subflow->rx_eof && subflow_is_done(sk)) {
Signature · 1 line
2.24.1
author
#2 lore raw

PATCH v3 2/6 mptcp: update mptcp ack sequence from work queue

In reply to Florian Westphal

This adds a new worker flag to indicate when the work queue should drain a subflow socket.

skbs on the subflow socket are then placed on the mptcp socket receive queue (which was not used so far).
This allows us to announce the correct mptcp ack sequence in the tcp acks that we send back to the peer, even when the application does not call recv() on the mptcp socket for some time.

We still wake userspace tasks waiting for POLLIN immediately:
If the mptcp level receive queue is empty (because the work queue is still pending) it can be filled from in-sequence subflow sockets at recv time.

Without this, when userspace is not reading data, all the mptcp-level acks contain the ack_seq from the last time userspace read data rather than the most recent in-sequence value. This causes pointless retransmissions for data that is already queued.

The skb_orphan when moving skbs from subflow to mptcp level is needed, because the destructor (sock_rfree) relies on skb->sk (ssk!) lock being taken.

Followup patch will add needed rmem accouting for the moved skbs.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 231 ++++++++++++++++++++++++++++++-------------
 net/mptcp/protocol.h |   1 +
 2 files changed, 164 insertions(+), 68 deletions(-)
net/mptcp/protocol.c +163 -68
index 84204129e1d3..85d7f73ca804 100644
@@ -34,6 +34,12 @@ struct mptcp6_sock {
 
 static struct percpu_counter mptcp_sockets_allocated;
 
+struct mptcp_skb_cb {
+	u32 offset;
+};
+
+#define MPTCP_SKB_CB(__skb)	((struct mptcp_skb_cb *)&((__skb)->cb[0]))
+
 /* If msk has an initial subflow socket, and the MP_CAPABLE handshake has not
  * completed yet or has failed, return the subflow socket.
  * Otherwise return NULL.
@@ -162,6 +168,13 @@ void mptcp_data_ready(struct sock *sk)
 
 	set_bit(MPTCP_DATA_READY, &msk->flags);
 	sk->sk_data_ready(sk);
+
+	if (test_and_set_bit(MPTCP_WORK_DATA_READY, &msk->flags))
+		return;
+
+	sock_hold(sk);
+	if (!schedule_work(&msk->rtx_work))
+		sock_put(sk);
 }
 
 static void mptcp_stop_timer(struct sock *sk)
@@ -641,19 +654,134 @@ static void mptcp_wait_data(struct sock *sk, long *timeo)
 	remove_wait_queue(sk_sleep(sk), &wait);
 }
 
+static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
+				struct msghdr *msg,
+				size_t len)
+{
+	struct sock *sk = (struct sock *)msk;
+	struct sk_buff *skb;
+	int copied = 0;
+
+	while ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) {
+		u32 offset = MPTCP_SKB_CB(skb)->offset;
+		u32 data_len = skb->len - offset;
+		u32 count = min_t(size_t, len - copied, data_len);
+		int err;
+
+		err = skb_copy_datagram_msg(skb, offset, msg, count);
+		if (unlikely(err < 0)) {
+			if (!copied)
+				return err;
+			break;
+		}
+
+		copied += count;
+
+		if (count < data_len) {
+			MPTCP_SKB_CB(skb)->offset += count;
+			break;
+		}
+
+		__skb_unlink(skb, &sk->sk_receive_queue);
+		__kfree_skb(skb);
+
+		if (copied >= len)
+			break;
+	}
+
+	return copied;
+}
+
+static void __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
+			     struct sk_buff *skb,
+			     unsigned int offset, size_t copy_len)
+{
+	struct sock *sk = (struct sock *)msk;
+
+	__skb_unlink(skb, &ssk->sk_receive_queue);
+	skb_orphan(skb);
+	__skb_queue_tail(&sk->sk_receive_queue, skb);
+
+	msk->ack_seq += copy_len;
+	MPTCP_SKB_CB(skb)->offset = offset;
+}
+
+static bool __mptcp_move_skbs(struct mptcp_sock *msk)
+{
+	struct sock *sk = &msk->sk.icsk_inet.sk;
+	unsigned int moved = 0;
+	bool done = false;
+
+	do {
+		struct mptcp_subflow_context *subflow;
+		struct sock *ssk;
+		bool more_data_avail;
+		struct tcp_sock *tp;
+
+		ssk = mptcp_subflow_recv_lookup(msk);
+		if (!ssk)
+			break;
+
+		subflow = mptcp_subflow_ctx(ssk);
+
+		lock_sock(ssk);
+
+		tp = tcp_sk(ssk);
+		do {
+			u32 map_remaining, offset;
+			u32 seq = tp->copied_seq;
+			struct sk_buff *skb;
+			bool fin;
+
+			/* try to move as much data as available */
+			map_remaining = subflow->map_data_len -
+					mptcp_subflow_get_map_offset(subflow);
+
+			skb = skb_peek(&ssk->sk_receive_queue);
+			if (!skb)
+				break;
+
+			offset = seq - TCP_SKB_CB(skb)->seq;
+			fin = TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN;
+			if (fin) {
+				done = true;
+				seq++;
+			}
+
+			if (offset < skb->len) {
+				size_t len = skb->len - offset;
+
+				if (tp->urg_data)
+					done = true;
+
+				__mptcp_move_skb(msk, ssk, skb, offset, len);
+				seq += len;
+				moved += len;
+
+				if (WARN_ON_ONCE(map_remaining < len))
+					break;
+			} else {
+				WARN_ON_ONCE(!fin);
+				sk_eat_skb(sk, skb);
+				done = true;
+			}
+
+			WRITE_ONCE(tp->copied_seq, seq);
+			more_data_avail = mptcp_subflow_data_available(ssk);
+		} while (more_data_avail);
+
+		release_sock(ssk);
+	} while (!done);
+
+	return moved > 0;
+}
+
+
 static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 			 int nonblock, int flags, int *addr_len)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
-	struct mptcp_subflow_context *subflow;
-	bool more_data_avail = false;
-	struct mptcp_read_arg arg;
-	read_descriptor_t desc;
-	bool wait_data = false;
 	struct socket *ssock;
-	struct tcp_sock *tp;
-	bool done = false;
-	struct sock *ssk;
 	int copied = 0;
 	int target;
 	long timeo;
@@ -671,66 +799,27 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		return copied;
 	}
 
-	arg.msg = msg;
-	desc.arg.data = &arg;
-	desc.error = 0;
-
 	timeo = sock_rcvtimeo(sk, nonblock);
 
 	len = min_t(size_t, len, INT_MAX);
 	target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
 	__mptcp_flush_join_list(msk);
 
-	while (!done) {
-		u32 map_remaining;
+	while (len > (size_t)copied) {
 		int bytes_read;
 
-		ssk = mptcp_subflow_recv_lookup(msk);
-		pr_debug("msk=%p ssk=%p", msk, ssk);
-		if (!ssk)
-			goto wait_for_data;
+		bytes_read = __mptcp_recvmsg_mskq(msk, msg, len - copied);
+		if (unlikely(bytes_read < 0)) {
+			if (!copied)
+				copied = bytes_read;
+			goto out_err;
+		}
 
-		subflow = mptcp_subflow_ctx(ssk);
-		tp = tcp_sk(ssk);
+		copied += bytes_read;
 
-		lock_sock(ssk);
-		do {
-			/* try to read as much data as available */
-			map_remaining = subflow->map_data_len -
-					mptcp_subflow_get_map_offset(subflow);
-			desc.count = min_t(size_t, len - copied, map_remaining);
-			pr_debug("reading %zu bytes, copied %d", desc.count,
-				 copied);
-			bytes_read = tcp_read_sock(ssk, &desc,
-						   mptcp_read_actor);
-			if (bytes_read < 0) {
-				if (!copied)
-					copied = bytes_read;
-				done = true;
-				goto next;
-			}
-
-			pr_debug("msk ack_seq=%llx -> %llx", msk->ack_seq,
-				 msk->ack_seq + bytes_read);
-			msk->ack_seq += bytes_read;
-			copied += bytes_read;
-			if (copied >= len) {
-				done = true;
-				goto next;
-			}
-			if (tp->urg_data && tp->urg_seq == tp->copied_seq) {
-				pr_err("Urgent data present, cannot proceed");
-				done = true;
-				goto next;
-			}
-next:
-			more_data_avail = mptcp_subflow_data_available(ssk);
-		} while (more_data_avail && !done);
-		release_sock(ssk);
-		continue;
-
-wait_for_data:
-		more_data_avail = false;
+		if (skb_queue_empty(&sk->sk_receive_queue) &&
+		    __mptcp_move_skbs(msk))
+			continue;
 
 		/* only the master socket status is relevant here. The exit
 		 * conditions mirror closely tcp_recvmsg()
@@ -771,26 +860,25 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		}
 
 		pr_debug("block timeout %ld", timeo);
-		wait_data = true;
 		mptcp_wait_data(sk, &timeo);
 		if (unlikely(__mptcp_tcp_fallback(msk)))
 			goto fallback;
 	}
 
-	if (more_data_avail) {
-		if (!test_bit(MPTCP_DATA_READY, &msk->flags))
-			set_bit(MPTCP_DATA_READY, &msk->flags);
-	} else if (!wait_data) {
+	if (skb_queue_empty(&sk->sk_receive_queue)) {
+		/* entire backlog drained, clear DATA_READY. */
 		clear_bit(MPTCP_DATA_READY, &msk->flags);
 
-		/* .. race-breaker: ssk might get new data after last
-		 * data_available() returns false.
+		/* .. race-breaker: ssk might have gotten new data
+		 * after last __mptcp_move_skbs() returned false.
 		 */
-		ssk = mptcp_subflow_recv_lookup(msk);
-		if (unlikely(ssk))
+		if (unlikely(__mptcp_move_skbs(msk)))
 			set_bit(MPTCP_DATA_READY, &msk->flags);
+	} else if (unlikely(!test_bit(MPTCP_DATA_READY, &msk->flags))) {
+		/* data to read but mptcp_wait_data() cleared DATA_READY */
+		set_bit(MPTCP_DATA_READY, &msk->flags);
 	}
-
+out_err:
 	release_sock(sk);
 	return copied;
 }
@@ -921,6 +1009,9 @@ static void mptcp_worker(struct work_struct *work)
 	lock_sock(sk);
 	mptcp_clean_una(sk);
 
+	if (test_and_clear_bit(MPTCP_WORK_DATA_READY, &msk->flags))
+		__mptcp_move_skbs(msk);
+
 	if (test_and_clear_bit(MPTCP_WORK_EOF, &msk->flags))
 		mptcp_check_for_eof(msk);
 
@@ -1085,6 +1176,8 @@ static void mptcp_close(struct sock *sk, long timeout)
 
 	mptcp_cancel_work(sk);
 
+	__skb_queue_purge(&sk->sk_receive_queue);
+
 	sk_common_release(sk);
 }
 
@@ -1755,6 +1848,8 @@ void mptcp_proto_init(void)
 		panic("Failed to register MPTCP proto.\n");
 
 	inet_register_protosw(&mptcp_protosw);
+
+	BUILD_BUG_ON(sizeof(struct mptcp_skb_cb) > sizeof_field(struct sk_buff, cb));
 }
 
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
net/mptcp/protocol.h +1 -0
index 95b0ade75771..d676b7b6bbd3 100644
@@ -82,6 +82,7 @@
 #define MPTCP_SEND_SPACE	BIT(1)
 #define MPTCP_WORK_RTX		BIT(2)
 #define MPTCP_WORK_EOF		BIT(3)
+#define MPTCP_WORK_DATA_READY	BIT(4)
 
 static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
 {
Signature · 1 line
2.24.1
author
#3 lore raw

PATCH v3 3/6 mptcp: add rmem queue accounting

In reply to Florian Westphal

If userspace never drains the receive buffers we must stop draining the subflow socket(s) at some point.

This adds the needed rmem accouting for this.
If the threshold is reached, we stop draining the subflows.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +15 -1
index 85d7f73ca804..ac81283d5ec3 100644
@@ -172,6 +172,10 @@ void mptcp_data_ready(struct sock *sk)
 	if (test_and_set_bit(MPTCP_WORK_DATA_READY, &msk->flags))
 		return;
 
+	/* don't schedule if mptcp sk is (still) over limit */
+	if (atomic_read(&sk->sk_rmem_alloc) > READ_ONCE(sk->sk_rcvbuf))
+		return;
+
 	sock_hold(sk);
 	if (!schedule_work(&msk->rtx_work))
 		sock_put(sk);
@@ -699,7 +703,7 @@ static void __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
 	struct sock *sk = (struct sock *)msk;
 
 	__skb_unlink(skb, &ssk->sk_receive_queue);
-	skb_orphan(skb);
+	skb_set_owner_r(skb, sk);
 	__skb_queue_tail(&sk->sk_receive_queue, skb);
 
 	msk->ack_seq += copy_len;
@@ -717,6 +721,7 @@ static bool __mptcp_move_skbs(struct mptcp_sock *msk)
 		struct sock *ssk;
 		bool more_data_avail;
 		struct tcp_sock *tp;
+		int rcvbuf;
 
 		ssk = mptcp_subflow_recv_lookup(msk);
 		if (!ssk)
@@ -726,6 +731,10 @@ static bool __mptcp_move_skbs(struct mptcp_sock *msk)
 
 		lock_sock(ssk);
 
+		rcvbuf = max(ssk->sk_rcvbuf, sk->sk_rcvbuf);
+		if (rcvbuf > sk->sk_rcvbuf)
+			sk->sk_rcvbuf = rcvbuf;
+
 		tp = tcp_sk(ssk);
 		do {
 			u32 map_remaining, offset;
@@ -741,6 +750,11 @@ static bool __mptcp_move_skbs(struct mptcp_sock *msk)
 			if (!skb)
 				break;
 
+			if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
+				done = true;
+				break;
+			}
+
 			offset = seq - TCP_SKB_CB(skb)->seq;
 			fin = TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN;
 			if (fin) {
Signature · 1 line
2.24.1
author
#4 lore raw

PATCH v3 4/6 mptcp: remove mptcp_read_actor

In reply to Florian Westphal

Only used to discard stale data from the subflow, so move it where needed.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 27 ---------------------------
 net/mptcp/protocol.h |  7 -------
 net/mptcp/subflow.c  | 18 +++++++++++++-----
 3 files changed, 13 insertions(+), 39 deletions(-)
net/mptcp/protocol.c +0 -27
index ac81283d5ec3..75ae03931963 100644
@@ -616,33 +616,6 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	return ret;
 }
 
-int mptcp_read_actor(read_descriptor_t *desc, struct sk_buff *skb,
-		     unsigned int offset, size_t len)
-{
-	struct mptcp_read_arg *arg = desc->arg.data;
-	size_t copy_len;
-
-	copy_len = min(desc->count, len);
-
-	if (likely(arg->msg)) {
-		int err;
-
-		err = skb_copy_datagram_msg(skb, offset, arg->msg, copy_len);
-		if (err) {
-			pr_debug("error path");
-			desc->error = err;
-			return err;
-		}
-	} else {
-		pr_debug("Flushing skb payload");
-	}
-
-	desc->count -= copy_len;
-
-	pr_debug("consumed %zu bytes, %zu left", copy_len, desc->count);
-	return copy_len;
-}
-
 static void mptcp_wait_data(struct sock *sk, long *timeo)
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
net/mptcp/protocol.h +0 -7
index d676b7b6bbd3..c6f955f0fd0b 100644
@@ -304,13 +304,6 @@ void mptcp_proto_init(void);
 int mptcp_proto_v6_init(void);
 #endif
 
-struct mptcp_read_arg {
-	struct msghdr *msg;
-};
-
-int mptcp_read_actor(read_descriptor_t *desc, struct sk_buff *skb,
-		     unsigned int offset, size_t len);
-
 void mptcp_get_options(const struct sk_buff *skb,
 		       struct tcp_options_received *opt_rx);
 
net/mptcp/subflow.c +13 -5
index fbff5dc39575..da984f2af7ac 100644
@@ -577,6 +577,18 @@ static enum mapping_status get_mapping_status(struct sock *ssk)
 	return MAPPING_OK;
 }
 
+static int subflow_read_actor(read_descriptor_t *desc,
+			      struct sk_buff *skb,
+			      unsigned int offset, size_t len)
+{
+	size_t copy_len = min(desc->count, len);
+
+	desc->count -= copy_len;
+
+	pr_debug("flushed %zu bytes, %zu left", copy_len, desc->count);
+	return copy_len;
+}
+
 static bool subflow_check_data_avail(struct sock *ssk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
@@ -651,16 +663,12 @@ static bool subflow_check_data_avail(struct sock *ssk)
 		pr_debug("discarding %zu bytes, current map len=%d", delta,
 			 map_remaining);
 		if (delta) {
-			struct mptcp_read_arg arg = {
-				.msg = NULL,
-			};
 			read_descriptor_t desc = {
 				.count = delta,
-				.arg.data = &arg,
 			};
 			int ret;
 
-			ret = tcp_read_sock(ssk, &desc, mptcp_read_actor);
+			ret = tcp_read_sock(ssk, &desc, subflow_read_actor);
 			if (ret < 0) {
 				ssk->sk_err = -ret;
 				goto fatal;
Signature · 1 line
2.24.1
author
#5 lore raw

PATCH v3 5/6 mptcp: protocol: re-check dsn before reading from subflow

In reply to Florian Westphal

mptcp_subflow_data_available() is commonly called via ssk->sk_data_ready(), in this case the mptcp socket lock cannot be acquired.

Therefore, while we can safely discard subflow data that was already received up to msk->ack_seq, we cannot be sure that 'subflow->data_avail' will still be valid at the time userspace wants to read the data -- a previous read on a different subflow might have carried this data already.

In that (unlikely) event, msk->ack_seq will have been updated and will be ahead of the subflow dsn.

We can check for this condition and skip/resync to the expected sequence number.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +18 -2
index 75ae03931963..02aba8b31f1f 100644
@@ -205,8 +205,24 @@ static struct sock *mptcp_subflow_recv_lookup(const struct mptcp_sock *msk)
 	sock_owned_by_me(sk);
 
 	mptcp_for_each_subflow(msk, subflow) {
-		if (subflow->data_avail)
-			return mptcp_subflow_tcp_sock(subflow);
+		if (subflow->data_avail) {
+			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+			u64 dsn = mptcp_subflow_get_mapped_dsn(subflow);
+
+			/* revalidate data sequence number.
+			 *
+			 * mptcp_subflow_data_available() is usually called
+			 * without msk lock.  Its unlikely (but possible)
+			 * that msk->ack_seq has been advanced since the last
+			 * call found in-sequence data.
+			 */
+			if (likely(dsn == msk->ack_seq))
+				return ssk;
+
+			subflow->data_avail = 0;
+			if (mptcp_subflow_data_available(ssk))
+				return ssk;
+		}
 	}
 
 	return NULL;
Signature · 1 line
2.24.1
author
#6 lore raw

PATCH v3 6/6 mptcp: send acks when moving skbs to mptcp receive queue

In reply to Florian Westphal

This isn't strictly required, however, without this we will punish flows that don't do bluk transmits as they will lag behind in their window updates sent to peer.

Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 include/net/tcp.h    | 1 +
 net/ipv4/tcp.c       | 2 +-
 net/mptcp/protocol.c | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)
include/net/tcp.h +1 -0
index a5ea27df3c2b..454ecab0df8b 100644
@@ -650,6 +650,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
 
 /* tcp.c */
 void tcp_get_info(struct sock *, struct tcp_info *);
+void tcp_cleanup_rbuf(struct sock *sk, int copied);
 
 /* Read 'sendfile()'-style from a TCP socket */
 int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
net/ipv4/tcp.c +1 -1
index 1b685485a5b5..62362885a518 100644
@@ -1517,7 +1517,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;
net/mptcp/protocol.c +3 -0
index 02aba8b31f1f..93963bf3f9fe 100644
@@ -773,6 +773,9 @@ static bool __mptcp_move_skbs(struct mptcp_sock *msk)
 			more_data_avail = mptcp_subflow_data_available(ssk);
 		} while (more_data_avail);
 
+		if (moved > 0)
+			tcp_cleanup_rbuf(ssk, moved);
+
 		release_sock(ssk);
 	} while (!done);
 
Signature · 1 line
2.24.1
author
#7 lore raw
In reply to Florian Westphal
Quoted 7 lines · Florian Westphal

V3. No changes since v2, I only updated commit messages in patches 1, 2, 3 and 6.

I think we should try to avoid needless squashing and keep these as-is for now. We can always condense some of this later on in case we need to reduce number of individual patches for some reason.

As per yesterdays meeting, I've rebased this on top of net-next:

https://git.breakpoint.cc/cgit/fw/net-next.git/log/?h=mptcp_ssk_drain_01

Paolo, I extracted the parts that add the work queue from your retrans patch, I renamed the work queue because 'rtx_work' doesn't makse sense if its not related to retransmits.

The patch is rather tiny so I wonder if it should be merged with the main patch (mptcp: update mptcp ack sequence from work queue).

Let me know.

Also, I would propose to drop
"mptcp: protocol: re-check dsn before reading from subflow" before sending this to netdev since that patch isn't related to the rest of the patches.

It should probably be part of the batch after this, at the latest it needs to go in when MP_JOIN support is added.

WDYT?

I can't post it to netdev yet anyway because I need to wait for net -> net-next merge to avoid a small conflict in protocol.h, so you can take your time with reviewing this.