<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/ipv4/tcp_timer.c, branch linux-6.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-09-13T07:48:04Z</updated>
<entry>
<title>net: tcp: fix unexcepted socket die when snd_wnd is 0</title>
<updated>2023-09-13T07:48:04Z</updated>
<author>
<name>Menglong Dong</name>
</author>
<published>2023-08-11T02:55:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9bb4becae5cf125a9ebe83aef9d5dfc60182f5d5'/>
<id>urn:sha1:9bb4becae5cf125a9ebe83aef9d5dfc60182f5d5</id>
<content type='text'>
[ Upstream commit e89688e3e97868451a5d05b38a9d2633d6785cd4 ]

In tcp_retransmit_timer(), a window shrunk connection will be regarded
as timeout if 'tcp_jiffies32 - tp-&gt;rcv_tstamp &gt; TCP_RTO_MAX'. This is not
right all the time.

The retransmits will become zero-window probes in tcp_retransmit_timer()
if the 'snd_wnd==0'. Therefore, the icsk-&gt;icsk_rto will come up to
TCP_RTO_MAX sooner or later.

However, the timer can be delayed and be triggered after 122877ms, not
TCP_RTO_MAX, as I tested.

Therefore, 'tcp_jiffies32 - tp-&gt;rcv_tstamp &gt; TCP_RTO_MAX' is always true
once the RTO come up to TCP_RTO_MAX, and the socket will die.

Fix this by replacing the 'tcp_jiffies32' with '(u32)icsk-&gt;icsk_timeout',
which is exact the timestamp of the timeout.

However, "tp-&gt;rcv_tstamp" can restart from idle, then tp-&gt;rcv_tstamp
could already be a long time (minutes or hours) in the past even on the
first RTO. So we double check the timeout with the duration of the
retransmission.

Meanwhile, making "2 * TCP_RTO_MAX" as the timeout to avoid the socket
dying too soon.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lore.kernel.org/netdev/CADxym3YyMiO+zMD4zj03YPM3FBi-1LHi6gSD2XT8pyAMM096pg@mail.gmail.com/
Signed-off-by: Menglong Dong &lt;imagedong@tencent.com&gt;
Reviewed-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: fix the RTO timer retransmitting skb every 1ms if linear option is enabled</title>
<updated>2023-08-23T15:32:56Z</updated>
<author>
<name>Jason Xing</name>
</author>
<published>2023-08-11T02:37:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b237550e1f1bd1bd5f5e76af7a426e79c83fe71a'/>
<id>urn:sha1:b237550e1f1bd1bd5f5e76af7a426e79c83fe71a</id>
<content type='text'>
commit e4dd0d3a2f64b8bd8029ec70f52bdbebd0644408 upstream.

In the real workload, I encountered an issue which could cause the RTO
timer to retransmit the skb per 1ms with linear option enabled. The amount
of lost-retransmitted skbs can go up to 1000+ instantly.

The root cause is that if the icsk_rto happens to be zero in the 6th round
(which is the TCP_THIN_LINEAR_RETRIES value), then it will always be zero
due to the changed calculation method in tcp_retransmit_timer() as follows:

icsk-&gt;icsk_rto = min(icsk-&gt;icsk_rto &lt;&lt; 1, TCP_RTO_MAX);

Above line could be converted to
icsk-&gt;icsk_rto = min(0 &lt;&lt; 1, TCP_RTO_MAX) = 0

Therefore, the timer expires so quickly without any doubt.

I read through the RFC 6298 and found that the RTO value can be rounded
up to a certain value, in Linux, say TCP_RTO_MIN as default, which is
regarded as the lower bound in this patch as suggested by Eric.

Fixes: 36e31b0af587 ("net: TCP thin linear timeouts")
Suggested-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: Jason Xing &lt;kernelxing@tencent.com&gt;
Reviewed-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tcp: fix mishandling when the sack compression is deferred.</title>
<updated>2023-06-01T11:15:12Z</updated>
<author>
<name>fuyuanli</name>
</author>
<published>2023-05-31T08:01:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=30c6f0bf9579debce27e45fac34fdc97e46acacc'/>
<id>urn:sha1:30c6f0bf9579debce27e45fac34fdc97e46acacc</id>
<content type='text'>
In this patch, we mainly try to handle sending a compressed ack
correctly if it's deferred.

Here are more details in the old logic:
When sack compression is triggered in the tcp_compressed_ack_kick(),
if the sock is owned by user, it will set TCP_DELACK_TIMER_DEFERRED
and then defer to the release cb phrase. Later once user releases
the sock, tcp_delack_timer_handler() should send a ack as expected,
which, however, cannot happen due to lack of ICSK_ACK_TIMER flag.
Therefore, the receiver would not sent an ack until the sender's
retransmission timeout. It definitely increases unnecessary latency.

Fixes: 5d9f4262b7ea ("tcp: add SACK compression")
Suggested-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: fuyuanli &lt;fuyuanli@didiglobal.com&gt;
Signed-off-by: Jason Xing &lt;kerneljasonxing@gmail.com&gt;
Link: https://lore.kernel.org/netdev/20230529113804.GA20300@didi-ThinkCentre-M920t-N000/
Reviewed-by: Eric Dumazet &lt;edumazet@google.com&gt;
Link: https://lore.kernel.org/r/20230531080150.GA20424@didi-ThinkCentre-M920t-N000
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
</content>
</entry>
<entry>
<title>tcp: annotate lockless access to sk-&gt;sk_err</title>
<updated>2023-03-17T08:25:05Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-15T20:57:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e13ec3da05d130f0d10da8e1fbe1be26dcdb0e27'/>
<id>urn:sha1:e13ec3da05d130f0d10da8e1fbe1be26dcdb0e27</id>
<content type='text'>
tcp_poll() reads sk-&gt;sk_err without socket lock held/owned.

We should used READ_ONCE() here, and update writers
to use WRITE_ONCE().

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tcp: annotate lockless accesses to sk-&gt;sk_err_soft</title>
<updated>2023-03-17T08:25:05Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-15T20:57:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cee1af825d65b8122627fc2efbc36c1bd51ee103'/>
<id>urn:sha1:cee1af825d65b8122627fc2efbc36c1bd51ee103</id>
<content type='text'>
This field can be read/written without lock synchronization.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tcp: Make SYN ACK RTO tunable by BPF programs with TFO</title>
<updated>2022-08-17T09:19:22Z</updated>
<author>
<name>Jie Meng</name>
</author>
<published>2022-08-15T20:29:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8ea731d4c2ce721a29b17c7a1ee82c28b80f00ba'/>
<id>urn:sha1:8ea731d4c2ce721a29b17c7a1ee82c28b80f00ba</id>
<content type='text'>
Instead of the hardcoded TCP_TIMEOUT_INIT, this diff calls tcp_timeout_init
to initiate req-&gt;timeout like the non TFO SYN ACK case.

Tested using the following packetdrill script, on a host with a BPF
program that sets the initial connect timeout to 10ms.

`../../common/defaults.sh`

// Initialize connection
    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_TCP, TCP_FASTOPEN, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

   +0 &lt; S 0:0(0) win 32792 &lt;mss 1000,sackOK,FO TFO_COOKIE&gt;
   +0 &gt; S. 0:0(0) ack 1 &lt;mss 1460,nop,nop,sackOK&gt;
   +.01 &gt; S. 0:0(0) ack 1 &lt;mss 1460,nop,nop,sackOK&gt;
   +.02 &gt; S. 0:0(0) ack 1 &lt;mss 1460,nop,nop,sackOK&gt;
   +.04 &gt; S. 0:0(0) ack 1 &lt;mss 1460,nop,nop,sackOK&gt;
   +.01 &lt; . 1:1(0) ack 1 win 32792

   +0 accept(3, ..., ...) = 4

Signed-off-by: Jie Meng &lt;jmeng@fb.com&gt;
Acked-by: Neal Cardwell &lt;ncardwell@google.com&gt;
Acked-by: Yuchung Cheng &lt;ycheng@google.com&gt;
Acked-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net</title>
<updated>2022-07-21T20:03:39Z</updated>
<author>
<name>Jakub Kicinski</name>
</author>
<published>2022-07-21T20:03:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6e0e846ee2ab01bc44254e6a0a6a6a0db1cba16d'/>
<id>urn:sha1:6e0e846ee2ab01bc44254e6a0a6a6a0db1cba16d</id>
<content type='text'>
No conflicts.

Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts.</title>
<updated>2022-07-20T09:14:50Z</updated>
<author>
<name>Kuniyuki Iwashima</name>
</author>
<published>2022-07-18T17:26:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7c6f2a86ca590d5187a073d987e9599985fb1c7c'/>
<id>urn:sha1:7c6f2a86ca590d5187a073d987e9599985fb1c7c</id>
<content type='text'>
While reading sysctl_tcp_thin_linear_timeouts, it can be changed
concurrently.  Thus, we need to add READ_ONCE() to its reader.

Fixes: 36e31b0af587 ("net: TCP thin linear timeouts")
Signed-off-by: Kuniyuki Iwashima &lt;kuniyu@amazon.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tcp: Fix data-races around some timeout sysctl knobs.</title>
<updated>2022-07-18T11:21:54Z</updated>
<author>
<name>Kuniyuki Iwashima</name>
</author>
<published>2022-07-15T17:17:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=39e24435a776e9de5c6dd188836cf2523547804b'/>
<id>urn:sha1:39e24435a776e9de5c6dd188836cf2523547804b</id>
<content type='text'>
While reading these sysctl knobs, they can be changed concurrently.
Thus, we need to add READ_ONCE() to their readers.

  - tcp_retries1
  - tcp_retries2
  - tcp_orphan_retries
  - tcp_fin_timeout

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima &lt;kuniyu@amazon.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>tcp: Fix data-races around sysctl_tcp_syn(ack)?_retries.</title>
<updated>2022-07-18T11:21:54Z</updated>
<author>
<name>Kuniyuki Iwashima</name>
</author>
<published>2022-07-15T17:17:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=20a3b1c0f603e8c55c3396abd12dfcfb523e4d3c'/>
<id>urn:sha1:20a3b1c0f603e8c55c3396abd12dfcfb523e4d3c</id>
<content type='text'>
While reading sysctl_tcp_syn(ack)?_retries, they can be changed
concurrently.  Thus, we need to add READ_ONCE() to their readers.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima &lt;kuniyu@amazon.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
