When setting RTO through BPF program, SYN ACK packets were unaffected and
continued to use TCP_TIMEOUT_INIT constant. This patch makes SYN ACK
retransmits use tcp_timeout_init() function instead.
Signed-off-by: Akhmat Karakotov <redacted>
---
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_minisocks.c | 4 ++--
net/ipv4/tcp_timer.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
From: Eric Dumazet <hidden> Date: 2021-10-25 16:54:16
On 10/25/21 5:12 AM, Akhmat Karakotov wrote:
When setting RTO through BPF program, SYN ACK packets were unaffected and
continued to use TCP_TIMEOUT_INIT constant. This patch makes SYN ACK
retransmits use tcp_timeout_init() function instead.
I do not think we want this, this will break existing BPF programs
that did not expect this risky change of behavior.
Please next time you send controversial TCP patches, add TCP experts/maintainers
in CC.
From: Alexander Azimov <hidden> Date: 2021-10-25 19:28:13
Hi Eric,
Can you please clarify why do you think that SYN RTO should be accessible through BPF and SYN ACK RTO should be bound to TCP_TIMEOUT_INIT constant?
I can't see the reason for such asymmetry, please advise.
I also wonder what kind of existing BPF programs can suffer from these changes. Please give us your insights.
ps: this is a copy of the original message, hope this one will come in a plain text
From: Eric Dumazet <hidden> Date: 2021-10-25 20:48:16
On 10/25/21 12:26 PM, Alexander Azimov wrote:
Hi Eric,
Can you please clarify why do you think that SYN RTO should be accessible through BPF and SYN ACK RTO should be bound to TCP_TIMEOUT_INIT constant?
I can't see the reason for such asymmetry, please advise.
I also wonder what kind of existing BPF programs can suffer from these changes. Please give us your insights.
ps: this is a copy of the original message, hope this one will come in a plain text
When commit 8550f328f45db6d37981eb2041bc465810245c03
("bpf: Support for per connection SYN/SYN-ACK RTOs")
was added, tcp_timeout_init() (and potential eBPF prog)
would be called from tcp_conn_request() and tcp_connect_init()
So some users are now using this eBPF program, expecting
it to have an effect only from these call sites.
If you are adding more call sites, suddenly the behavior
of TCP stack for these users will change. You have to
document if bad things could happen for them, like unexpected
max acceptable delays for connection establishment being severely reduced.
In any case, I would prefer adding a new @timeout field
in struct request_sock to carry the base timeout
instead of calling a BPF program all the times,
otherwise we could have weird behavior (eg PAWS checks)
if the return from eBPF program is variable for one 5-tuple.
Also, have you checked if TCP syn cookies would still work
if tcp_timeout_init() returns a small value like 5ms ?
tcp_check_req()
...
tmp_opt.ts_recent_stamp = ktime_get_seconds() - ((tcp_timeout_init((struct sock *)req)/HZ)<<req->num_timeout);
-> tmp_opt.ts_recent_stamp = ktime_get_seconds()
From: Martin KaFai Lau <hidden> Date: 2021-10-25 21:55:22
On Mon, Oct 25, 2021 at 01:48:12PM -0700, Eric Dumazet wrote:
On 10/25/21 12:26 PM, Alexander Azimov wrote:
quoted
Hi Eric,
Can you please clarify why do you think that SYN RTO should be accessible through BPF and SYN ACK RTO should be bound to TCP_TIMEOUT_INIT constant?
quoted
I can't see the reason for such asymmetry, please advise.
In tcp_conn_request(), tcp_timeout_init() is used, so the very
first SYN-ACK RTO should work?
iiuc, this patch's changes in reqsk_timer_handler() only affects the
later RTOs (e.g. 2nd RTOs). For this particular
function (reqsk_timer_handler()), it looks like an overlook
in the original bpf's tcp_timeout_init() implementation.
quoted
I also wonder what kind of existing BPF programs can suffer from these changes. Please give us your insights.
ps: this is a copy of the original message, hope this one will come in a plain text
When commit 8550f328f45db6d37981eb2041bc465810245c03
("bpf: Support for per connection SYN/SYN-ACK RTOs")
was added, tcp_timeout_init() (and potential eBPF prog)
would be called from tcp_conn_request() and tcp_connect_init()
So some users are now using this eBPF program, expecting
it to have an effect only from these call sites.
If you are adding more call sites, suddenly the behavior
of TCP stack for these users will change. You have to
document if bad things could happen for them, like unexpected
max acceptable delays for connection establishment being severely reduced.
In any case, I would prefer adding a new @timeout field
in struct request_sock to carry the base timeout
instead of calling a BPF program all the times,
otherwise we could have weird behavior (eg PAWS checks)
if the return from eBPF program is variable for one 5-tuple.
Seems like a good idea. This field can be set to
the timeout-value returned by the bpf prog.
On Oct 25, 2021, at 23:48, Eric Dumazet [off-list ref] wrote:
Also, have you checked if TCP syn cookies would still work
if tcp_timeout_init() returns a small value like 5ms ?
tcp_check_req()
...
tmp_opt.ts_recent_stamp = ktime_get_seconds() - ((tcp_timeout_init((struct sock *)req)/HZ)<<req->num_timeout);
-> tmp_opt.ts_recent_stamp = ktime_get_seconds()
I may have overlooked this. As long as I remember TCP SYN cookies worked
but I will recheck this place again. Also could you please tell in what way exactly
does this relate to syn cookies? I may have misunderstood what the code does.
Excuse me for lots of duplicate messages. I couldn't get default client
to consistently send plain text messages and delivery system kept rejecting
them. I forgot to remove everyone from cc when tried again.
On Oct 29, 2021, at 19:19, Akhmat Karakotov [off-list ref] wrote:
quoted
On Oct 25, 2021, at 23:48, Eric Dumazet [off-list ref] wrote:
Also, have you checked if TCP syn cookies would still work
if tcp_timeout_init() returns a small value like 5ms ?
tcp_check_req()
...
tmp_opt.ts_recent_stamp = ktime_get_seconds() - ((tcp_timeout_init((struct sock *)req)/HZ)<<req->num_timeout);
-> tmp_opt.ts_recent_stamp = ktime_get_seconds()
I may have overlooked this. As long as I remember TCP SYN cookies worked
but I will recheck this place again. Also could you please tell in what way exactly
does this relate to syn cookies? I may have misunderstood what the code does.
From: Eric Dumazet <hidden> Date: 2021-10-29 16:30:19
On 10/29/21 9:19 AM, Akhmat Karakotov wrote:
quoted
On Oct 25, 2021, at 23:48, Eric Dumazet [off-list ref] wrote:
Also, have you checked if TCP syn cookies would still work
if tcp_timeout_init() returns a small value like 5ms ?
tcp_check_req()
...
tmp_opt.ts_recent_stamp = ktime_get_seconds() - ((tcp_timeout_init((struct sock *)req)/HZ)<<req->num_timeout);
-> tmp_opt.ts_recent_stamp = ktime_get_seconds()
I may have overlooked this. As long as I remember TCP SYN cookies worked
but I will recheck this place again. Also could you please tell in what way exactly
does this relate to syn cookies? I may have misunderstood what the code does.
This was badly written.
This should have been two different questions.
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
On Tue, Nov 2, 2021 at 11:33 AM Akhmat Karakotov [off-list ref] wrote:
quoted hunk
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
From: Eric Dumazet <hidden> Date: 2021-11-02 22:06:37
On 11/2/21 11:32 AM, Akhmat Karakotov wrote:
quoted hunk
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
I wonder how much time it will take to syzbot to trigger an overflow here and
other parts.
(Not sure BPF_SOCK_OPS_TIMEOUT_INIT has any sanity checks)
Maybe take the opportunity of this patch to use wider type
timeo = min_t(unsigned long,
(unsigned long)req->timeout << req->num_timeout,
TCP_RTO_MAX);
Overall, your patch looks good to me, thanks.
From: Martin KaFai Lau <hidden> Date: 2021-11-02 23:17:59
On Tue, Nov 02, 2021 at 03:06:31PM -0700, Eric Dumazet wrote:
On 11/2/21 11:32 AM, Akhmat Karakotov wrote:
quoted
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
On Nov 3, 2021, at 02:17, Martin KaFai Lau [off-list ref] wrote:
On Tue, Nov 02, 2021 at 03:06:31PM -0700, Eric Dumazet wrote:
quoted
On 11/2/21 11:32 AM, Akhmat Karakotov wrote:
quoted
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
From: Martin KaFai Lau <hidden> Date: 2021-11-03 17:22:22
On Wed, Nov 03, 2021 at 12:31:46PM +0300, Akhmat Karakotov wrote:
quoted
On Nov 3, 2021, at 02:17, Martin KaFai Lau [off-list ref] wrote:
On Tue, Nov 02, 2021 at 03:06:31PM -0700, Eric Dumazet wrote:
quoted
On 11/2/21 11:32 AM, Akhmat Karakotov wrote:
quoted
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
include/net/tcp.h | 2 +-
net/ipv4/inet_connection_sock.c | 4 +++-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 12 +++++++++---
5 files changed, 20 insertions(+), 8 deletions(-)
From: Eric Dumazet <hidden> Date: 2021-11-03 20:54:43
On 11/3/21 1:46 PM, Akhmat Karakotov wrote:
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
include/net/tcp.h | 2 +-
net/ipv4/inet_connection_sock.c | 4 +++-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 12 +++++++++---
5 files changed, 20 insertions(+), 8 deletions(-)
SGTM, thanks.
Reviewed-by: Eric Dumazet <edumazet@google.com>
On Wed, Nov 3, 2021 at 1:46 PM Akhmat Karakotov [off-list ref] wrote:
quoted hunk
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
include/net/tcp.h | 2 +-
net/ipv4/inet_connection_sock.c | 4 +++-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 12 +++++++++---
5 files changed, 20 insertions(+), 8 deletions(-)
On Wed, Nov 3, 2021 at 5:23 PM Yuchung Cheng [off-list ref] wrote:
On Wed, Nov 3, 2021 at 1:46 PM Akhmat Karakotov [off-list ref] wrote:
quoted
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
include/net/tcp.h | 2 +-
net/ipv4/inet_connection_sock.c | 4 +++-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 12 +++++++++---
5 files changed, 20 insertions(+), 8 deletions(-)
would it make sense to have a helper tcp_timeout_max() to reduce
clutter? but that can be done by a later refactor patch
I like Yuchung's idea to have a helper function (perhaps
reqsk_timeout() to go with reqsk_timer_handler()?) to calculate the
timeout value, since there are 3 of these non-trivial expressions.
Otherwise this looks good to me.
thanks,
neal
From: Martin KaFai Lau <hidden> Date: 2021-11-04 01:06:58
On Wed, Nov 03, 2021 at 11:46:07PM +0300, Akhmat Karakotov wrote:
quoted hunk
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
include/net/tcp.h | 2 +-
net/ipv4/inet_connection_sock.c | 4 +++-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 12 +++++++++---
5 files changed, 20 insertions(+), 8 deletions(-)
Dear David,
We got the patch acked couple of weeks ago, please let us know what further steps are required before merge.
Thanks, Akhmat.
On Nov 4, 2021, at 04:06, Martin KaFai Lau [off-list ref] wrote:
On Wed, Nov 03, 2021 at 11:46:07PM +0300, Akhmat Karakotov wrote:
quoted
When setting RTO through BPF program, some SYN ACK packets were unaffected
and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout
option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT
and is reassigned through BPF using tcp_timeout_init call. SYN ACK
retransmits now use newly added timeout option.
Signed-off-by: Akhmat Karakotov <redacted>
---
include/net/request_sock.h | 2 ++
include/net/tcp.h | 2 +-
net/ipv4/inet_connection_sock.c | 4 +++-
net/ipv4/tcp_input.c | 8 +++++---
net/ipv4/tcp_minisocks.c | 12 +++++++++---
5 files changed, 20 insertions(+), 8 deletions(-)