netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/1] tcp: Honor the eor bit in tcp_mtu_probe
@ 2018-02-07 13:13 Ilya Lesokhin
  2018-02-08 19:37 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Ilya Lesokhin @ 2018-02-07 13:13 UTC (permalink / raw)
  To: netdev, davem, eric.dumazet, kafai; +Cc: borisp, Ilya Lesokhin

Avoid SKB coalescing if eor bit is set in one of the relevant
SKBs.

Fixes: c134ecb87817 ("tcp: Make use of MSG_EOR in tcp_sendmsg")
Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
---
 net/ipv4/tcp_output.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e9f985e42405..33988058e07f 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2027,6 +2027,25 @@ static inline void tcp_mtu_check_reprobe(struct sock *sk)
 	}
 }
 
+static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len)
+{
+	struct sk_buff *skb, *next;
+
+	skb = tcp_send_head(sk);
+	tcp_for_write_queue_from_safe(skb, next, sk)
+	{
+		if (len <= skb->len)
+			break;
+
+		if (unlikely(TCP_SKB_CB(skb)->eor))
+			return false;
+
+		len -= skb->len;
+	}
+
+	return true;
+}
+
 /* Create a new MTU probe if we are ready.
  * MTU probe is regularly attempting to increase the path MTU by
  * deliberately sending larger packets.  This discovers routing
@@ -2099,6 +2118,9 @@ static int tcp_mtu_probe(struct sock *sk)
 			return 0;
 	}
 
+	if (!tcp_can_coalesce_send_queue_head(sk, probe_size))
+		return -1;
+
 	/* We're allowed to probe.  Build it now. */
 	nskb = sk_stream_alloc_skb(sk, probe_size, GFP_ATOMIC, false);
 	if (!nskb)
@@ -2134,6 +2156,10 @@ static int tcp_mtu_probe(struct sock *sk)
 			/* We've eaten all the data from this skb.
 			 * Throw it away. */
 			TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags;
+			/* If this is the last SKB we copy and eor is set
+			 * we need to propagate it to the new skb.
+			 */
+			TCP_SKB_CB(nskb)->eor = TCP_SKB_CB(skb)->eor;
 			tcp_unlink_write_queue(skb, sk);
 			sk_wmem_free_skb(sk, skb);
 		} else {
-- 
Changes from v2:                                                                 
- Initialize SKB before tcp_for_write_queue_from_safe                            
- Move new logic to its own function
- Add comment about eor propagation
                                                                                 
Changes from v1:                                                                 
- Propagate eor when consuming the old SKB 
2.15.0.317.g14c63a9

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 1/1] tcp: Honor the eor bit in tcp_mtu_probe
  2018-02-07 13:13 [PATCH v3 1/1] tcp: Honor the eor bit in tcp_mtu_probe Ilya Lesokhin
@ 2018-02-08 19:37 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-02-08 19:37 UTC (permalink / raw)
  To: ilyal; +Cc: netdev, eric.dumazet, kafai, borisp

From: Ilya Lesokhin <ilyal@mellanox.com>
Date: Wed,  7 Feb 2018 15:13:11 +0200

> +static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len)
> +{
> +	struct sk_buff *skb, *next;
> +
> +	skb = tcp_send_head(sk);
> +	tcp_for_write_queue_from_safe(skb, next, sk)
> +	{

Please format tcp_for_write_queue_from_safe() uses like a real for loop,
meaning that the openning curly braces go on the same line as the
tcp_for_write_queue_from_safe() statement.

Thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-08 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-07 13:13 [PATCH v3 1/1] tcp: Honor the eor bit in tcp_mtu_probe Ilya Lesokhin
2018-02-08 19:37 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).