diff mbox series

[net-next] tcp: Make SYN ACK RTO tunable by BPF programs with TFO

Message ID 20220815202900.3961097-1-jmeng@fb.com (mailing list archive)
State Accepted
Commit 8ea731d4c2ce721a29b17c7a1ee82c28b80f00ba
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tcp: Make SYN ACK RTO tunable by BPF programs with TFO | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 427 this patch: 427
netdev/cc_maintainers warning 4 maintainers not CCed: dsahern@kernel.org pabeni@redhat.com yoshfuji@linux-ipv6.org davem@davemloft.net
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 427 this patch: 427
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jie Meng Aug. 15, 2022, 8:29 p.m. UTC
Instead of the hardcoded TCP_TIMEOUT_INIT, this diff calls tcp_timeout_init
to initiate req->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 < S 0:0(0) win 32792 <mss 1000,sackOK,FO TFO_COOKIE>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
   +.01 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
   +.02 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
   +.04 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
   +.01 < . 1:1(0) ack 1 win 32792

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

Signed-off-by: Jie Meng <jmeng@fb.com>
---
 net/ipv4/tcp_fastopen.c | 3 ++-
 net/ipv4/tcp_timer.c    | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Neal Cardwell Aug. 16, 2022, 1:36 p.m. UTC | #1
On Mon, Aug 15, 2022 at 8:30 PM Jie Meng <jmeng@fb.com> wrote:
>
> Instead of the hardcoded TCP_TIMEOUT_INIT, this diff calls tcp_timeout_init
> to initiate req->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 < S 0:0(0) win 32792 <mss 1000,sackOK,FO TFO_COOKIE>
>    +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.01 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.02 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.04 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.01 < . 1:1(0) ack 1 win 32792
>
>    +0 accept(3, ..., ...) = 4
>
> Signed-off-by: Jie Meng <jmeng@fb.com>
> ---
>  net/ipv4/tcp_fastopen.c | 3 ++-
>  net/ipv4/tcp_timer.c    | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
> index 825b216d11f5..45cc7f1ca296 100644
> --- a/net/ipv4/tcp_fastopen.c
> +++ b/net/ipv4/tcp_fastopen.c
> @@ -272,8 +272,9 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk,
>          * The request socket is not added to the ehash
>          * because it's been added to the accept queue directly.
>          */
> +       req->timeout = tcp_timeout_init(child);
>         inet_csk_reset_xmit_timer(child, ICSK_TIME_RETRANS,
> -                                 TCP_TIMEOUT_INIT, TCP_RTO_MAX);
> +                                 req->timeout, TCP_RTO_MAX);
>
>         refcount_set(&req->rsk_refcnt, 2);
>
> diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
> index b4dfb82d6ecb..cb79127f45c3 100644
> --- a/net/ipv4/tcp_timer.c
> +++ b/net/ipv4/tcp_timer.c
> @@ -428,7 +428,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req)
>         if (!tp->retrans_stamp)
>                 tp->retrans_stamp = tcp_time_stamp(tp);
>         inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
> -                         TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX);
> +                         req->timeout << req->num_timeout, TCP_RTO_MAX);
>  }
>
>
> --

Looks good to me. Thanks for the feature!

Acked-by: Neal Cardwell <ncardwell@google.com>

neal
Yuchung Cheng Aug. 16, 2022, 4:11 p.m. UTC | #2
On Tue, Aug 16, 2022 at 6:37 AM Neal Cardwell <ncardwell@google.com> wrote:
>
> On Mon, Aug 15, 2022 at 8:30 PM Jie Meng <jmeng@fb.com> wrote:
> >
> > Instead of the hardcoded TCP_TIMEOUT_INIT, this diff calls tcp_timeout_init
> > to initiate req->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 < S 0:0(0) win 32792 <mss 1000,sackOK,FO TFO_COOKIE>
> >    +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
> >    +.01 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
> >    +.02 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
> >    +.04 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
> >    +.01 < . 1:1(0) ack 1 win 32792
> >
> >    +0 accept(3, ..., ...) = 4
> >
> > Signed-off-by: Jie Meng <jmeng@fb.com>
> > ---
> >  net/ipv4/tcp_fastopen.c | 3 ++-
> >  net/ipv4/tcp_timer.c    | 2 +-
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
> > index 825b216d11f5..45cc7f1ca296 100644
> > --- a/net/ipv4/tcp_fastopen.c
> > +++ b/net/ipv4/tcp_fastopen.c
> > @@ -272,8 +272,9 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk,
> >          * The request socket is not added to the ehash
> >          * because it's been added to the accept queue directly.
> >          */
> > +       req->timeout = tcp_timeout_init(child);
> >         inet_csk_reset_xmit_timer(child, ICSK_TIME_RETRANS,
> > -                                 TCP_TIMEOUT_INIT, TCP_RTO_MAX);
> > +                                 req->timeout, TCP_RTO_MAX);
> >
> >         refcount_set(&req->rsk_refcnt, 2);
> >
> > diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
> > index b4dfb82d6ecb..cb79127f45c3 100644
> > --- a/net/ipv4/tcp_timer.c
> > +++ b/net/ipv4/tcp_timer.c
> > @@ -428,7 +428,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req)
> >         if (!tp->retrans_stamp)
> >                 tp->retrans_stamp = tcp_time_stamp(tp);
> >         inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
> > -                         TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX);
> > +                         req->timeout << req->num_timeout, TCP_RTO_MAX);
> >  }
> >
> >
> > --
>
> Looks good to me. Thanks for the feature!
>
> Acked-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Would be great to have a companion patch on SYN timeout as well.

>
> neal
Martin KaFai Lau Aug. 16, 2022, 4:59 p.m. UTC | #3
On Mon, Aug 15, 2022 at 01:29:00PM -0700, Jie Meng wrote:
> Instead of the hardcoded TCP_TIMEOUT_INIT, this diff calls tcp_timeout_init
> to initiate req->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 < S 0:0(0) win 32792 <mss 1000,sackOK,FO TFO_COOKIE>
>    +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.01 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.02 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.04 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK>
>    +.01 < . 1:1(0) ack 1 win 32792
> 
>    +0 accept(3, ..., ...) = 4
Acked-by: Martin KaFai Lau <kafai@fb.com>
patchwork-bot+netdevbpf@kernel.org Aug. 17, 2022, 9:30 a.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 15 Aug 2022 13:29:00 -0700 you wrote:
> Instead of the hardcoded TCP_TIMEOUT_INIT, this diff calls tcp_timeout_init
> to initiate req->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`
> 
> [...]

Here is the summary with links:
  - [net-next] tcp: Make SYN ACK RTO tunable by BPF programs with TFO
    https://git.kernel.org/netdev/net-next/c/8ea731d4c2ce

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 825b216d11f5..45cc7f1ca296 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -272,8 +272,9 @@  static struct sock *tcp_fastopen_create_child(struct sock *sk,
 	 * The request socket is not added to the ehash
 	 * because it's been added to the accept queue directly.
 	 */
+	req->timeout = tcp_timeout_init(child);
 	inet_csk_reset_xmit_timer(child, ICSK_TIME_RETRANS,
-				  TCP_TIMEOUT_INIT, TCP_RTO_MAX);
+				  req->timeout, TCP_RTO_MAX);
 
 	refcount_set(&req->rsk_refcnt, 2);
 
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index b4dfb82d6ecb..cb79127f45c3 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -428,7 +428,7 @@  static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req)
 	if (!tp->retrans_stamp)
 		tp->retrans_stamp = tcp_time_stamp(tp);
 	inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
-			  TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX);
+			  req->timeout << req->num_timeout, TCP_RTO_MAX);
 }