All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] [PATCH RFC 1/6] protocol: add discard_one_skb helper
@ 2019-09-09 15:53 Florian Westphal
  0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2019-09-09 15:53 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]

This can be re-used in followup patch.

Signed-off-by: Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 266a1028c9fd..3eecd9ae0c77 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -384,6 +384,15 @@ static enum mapping_status mptcp_get_mapping(struct sock *ssk)
 	return ret;
 }
 
+static bool mptcp_discard_one_skb(struct sock *sk)
+{
+	read_descriptor_t rd = {
+		.count = SIZE_MAX,
+	};
+
+	return tcp_read_sock(sk, &rd, mptcp_flush_actor) >= 0;
+}
+
 static void mptcp_wait_data(struct sock *sk, long *timeo)
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
@@ -471,16 +480,9 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 			if (!subflow->map_valid) {
 				pr_debug("Mapping missing, trying next skb");
 
-				arg.msg = NULL;
-				desc.count = SIZE_MAX;
-
-				bytes_read = tcp_read_sock(ssk, &desc,
-							   mptcp_flush_actor);
-
-				if (bytes_read < 0)
-					break;
-
-				continue;
+				if (mptcp_discard_one_skb(ssk))
+					continue;
+				break;
 			}
 		} else if (status == MAPPING_EMPTY) {
 			goto wait_for_data;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-09 15:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 15:53 [MPTCP] [PATCH RFC 1/6] protocol: add discard_one_skb helper Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.