Skip to contentSkip to conversation

tcp: inherit timestamp on mtu probe

PATCH In review Willem de Bruijn 3 participants 7 messages Aug 27, 2019 – Aug 28, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: inherit timestamp on mtu probe

From: Willem de Bruijn <[email protected]>

TCP associates tx timestamp requests with a byte in the bytestream. If merging skbs in tcp_mtu_probe, migrate the tstamp request.

Similar to MSG_EOR, do not allow moving a timestamp from any segment in the probe but the last. This to avoid merging multiple timestamps.

Tested with the packetdrill script at
https://github.com/wdebruij/packetdrill/commits/mtu_probe-1

Fixes 4ed2d765dfac ("net-timestamp: TCP timestamping")
---
 net/ipv4/tcp_output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp_output.c +2 -1
index 5c46bc4c7e8d..42abc9bd687a 100644
@@ -2053,7 +2053,7 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len)
 		if (len <= skb->len)
 			break;
 
-		if (unlikely(TCP_SKB_CB(skb)->eor))
+		if (unlikely(TCP_SKB_CB(skb)->eor) || tcp_has_tx_tstamp(skb))
 			return false;
 
 		len -= skb->len;
@@ -2170,6 +2170,7 @@ static int tcp_mtu_probe(struct sock *sk)
 			 * we need to propagate it to the new skb.
 			 */
 			TCP_SKB_CB(nskb)->eor = TCP_SKB_CB(skb)->eor;
+			tcp_skb_collapse_tstamp(nskb, skb);
 			tcp_unlink_write_queue(skb, sk);
 			sk_wmem_free_skb(sk, skb);
 		} else {
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#1 lore raw
Quoted 33 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

TCP associates tx timestamp requests with a byte in the bytestream. If merging skbs in tcp_mtu_probe, migrate the tstamp request.

Similar to MSG_EOR, do not allow moving a timestamp from any segment in the probe but the last. This to avoid merging multiple timestamps.

Tested with the packetdrill script at
https://github.com/wdebruij/packetdrill/commits/mtu_probe-1

Fixes 4ed2d765dfac ("net-timestamp: TCP timestamping")
---
 net/ipv4/tcp_output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
index 5c46bc4c7e8d..42abc9bd687a 100644
@@ -2053,7 +2053,7 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len)
                if (len <= skb->len)
                        break;
 
-               if (unlikely(TCP_SKB_CB(skb)->eor))
+               if (unlikely(TCP_SKB_CB(skb)->eor) || tcp_has_tx_tstamp(skb))
                        return false;
 
                len -= skb->len;

net/ipv4/tcp_output.c static int tcp_mtu_probe(struct sock *sk) · line 2173

Quoted 4 lines
net/ipv4/tcp_output.c +1 -0
@@ -2170,6 +2170,7 @@ static int tcp_mtu_probe(struct sock *sk)
                         * we need to propagate it to the new skb.
                         */
                        TCP_SKB_CB(nskb)->eor = TCP_SKB_CB(skb)->eor;
+                       tcp_skb_collapse_tstamp(nskb, skb);

nit: maybe rename tcp_skb_collapse_tstamp() to tcp_skb_tstamp_copy() or something ?

Its name came from the fact that it was only used from tcp_collapse_retrans(), but it will no
longer be the case after your fix.

Quoted 6 lines
net/ipv4/tcp_output.c +0 -1
                        tcp_unlink_write_queue(skb, sk);
                        sk_wmem_free_skb(sk, skb);
                } else {
--

2.23.0.187.g17f5b7556c-goog

#2 lore raw
Quoted 44 lines · Eric Dumazet
Quoted 33 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

TCP associates tx timestamp requests with a byte in the bytestream. If merging skbs in tcp_mtu_probe, migrate the tstamp request.

Similar to MSG_EOR, do not allow moving a timestamp from any segment in the probe but the last. This to avoid merging multiple timestamps.

Tested with the packetdrill script at
https://github.com/wdebruij/packetdrill/commits/mtu_probe-1

Fixes 4ed2d765dfac ("net-timestamp: TCP timestamping")
---
 net/ipv4/tcp_output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
index 5c46bc4c7e8d..42abc9bd687a 100644
@@ -2053,7 +2053,7 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len)
                if (len <= skb->len)
                        break;
 
-               if (unlikely(TCP_SKB_CB(skb)->eor))
+               if (unlikely(TCP_SKB_CB(skb)->eor) || tcp_has_tx_tstamp(skb))
                        return false;
 
                len -= skb->len;

net/ipv4/tcp_output.c static int tcp_mtu_probe(struct sock *sk) · line 2173

Quoted 4 lines
net/ipv4/tcp_output.c +1 -0
@@ -2170,6 +2170,7 @@ static int tcp_mtu_probe(struct sock *sk)
                         * we need to propagate it to the new skb.
                         */
                        TCP_SKB_CB(nskb)->eor = TCP_SKB_CB(skb)->eor;
+                       tcp_skb_collapse_tstamp(nskb, skb);

nit: maybe rename tcp_skb_collapse_tstamp() to tcp_skb_tstamp_copy() or something ?

Quoted 3 lines

Its name came from the fact that it was only used from tcp_collapse_retrans(), but it will no
longer be the case after your fix.

Sure, that's more descriptive.

One caveat, the function is exposed in a header, so it's a bit more churn. If you don't mind that, I'll send the v2.

#3 lore raw
Quoted 4 lines · Willem de Bruijn

Sure, that's more descriptive.

One caveat, the function is exposed in a header, so it's a bit more churn. If you don't mind that, I'll send the v2.

Oh right it is also used from tcp_shifted_skb() after Martin KaFai Lau fix ...

#4 lore raw
Quoted 10 lines · Eric Dumazet
Quoted 4 lines · Willem de Bruijn

Sure, that's more descriptive.

One caveat, the function is exposed in a header, so it's a bit more churn. If you don't mind that, I'll send the v2.

Oh right it is also used from tcp_shifted_skb() after Martin KaFai Lau fix ...

Leave as is then?

#5 lore raw
Quoted 6 lines · Willem de Bruijn
Quoted 4 lines · Eric Dumazet

On Tue, Aug 27, 2019 at 10:54 PM Willem de Bruijn
<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Sure, that's more descriptive.

One caveat, the function is exposed in a header, so it's a bit more churn. If you don't mind that, I'll send the v2.

Oh right it is also used from tcp_shifted_skb() after Martin KaFai Lau fix ...

Leave as is then?

Not a big deal really ;)

maintainer
#6 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Tue, 27 Aug 2019 15:09:33 -0400

Quoted 8 lines

From: Willem de Bruijn <[email protected]>

TCP associates tx timestamp requests with a byte in the bytestream. If merging skbs in tcp_mtu_probe, migrate the tstamp request.

Similar to MSG_EOR, do not allow moving a timestamp from any segment in the probe but the last. This to avoid merging multiple timestamps.

Quoted 6 lines

Tested with the packetdrill script at
https://github.com/wdebruij/packetdrill/commits/mtu_probe-1

Fixes 4ed2d765dfac ("net-timestamp: TCP timestamping")

Applied and queued up for -stable.