diff mbox series

[net-next,v2,1/3] Add new args for cong_control in tcp_congestion_ops

Message ID 20240501074338.362361-1-miaxu@meta.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2,1/3] Add new args for cong_control in tcp_congestion_ops | expand

Checks

Context Check Description
netdev/series_format warning Series does not have a cover letter
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1831 this patch: 1831
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff fail author Signed-off-by missing
netdev/deprecated_api success None detected
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: 1867 this patch: 1867
netdev/checkpatch warning WARNING: line length of 95 exceeds 80 columns WARNING: line length of 98 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-05-01--09-00 (tests: 1001)

Commit Message

Miao Xu May 1, 2024, 7:43 a.m. UTC
This patch adds two new arguments for cong_control of struct
tcp_congestion_ops:
 - ack
 - flag
These two arguments are inherited from the caller tcp_cong_control in
tcp_intput.c. One use case of them is to update cwnd and pacing rate
inside cong_control based on the info they provide. For example, the
flag can be used to decide if it is the right time to raise or reduce a
sender's cwnd.

Reviewed-by: Eric Dumazet <edumazet@google.com>
--
Changes in v2:
* Split the v1 patch into 2 separate patches. In particular, spin out
bpf_tcp_ca.c as a separate patch because it is bpf specific.

Signed-off-by: Miao Xu <miaxu@meta.com>
---
 include/net/tcp.h     | 2 +-
 net/ipv4/bpf_tcp_ca.c | 3 ++-
 net/ipv4/tcp_bbr.c    | 2 +-
 net/ipv4/tcp_input.c  | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski May 1, 2024, 1:26 p.m. UTC | #1
On Wed, 1 May 2024 00:43:36 -0700 Miao Xu wrote:
> This patch adds two new arguments for cong_control of struct
> tcp_congestion_ops:
>  - ack
>  - flag
> These two arguments are inherited from the caller tcp_cong_control in
> tcp_intput.c. One use case of them is to update cwnd and pacing rate
> inside cong_control based on the info they provide. For example, the
> flag can be used to decide if it is the right time to raise or reduce a
> sender's cwnd.
> 
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> --

three dashes here ---

> Changes in v2:
> * Split the v1 patch into 2 separate patches. In particular, spin out
> bpf_tcp_ca.c as a separate patch because it is bpf specific.
> 
> Signed-off-by: Miao Xu <miaxu@meta.com>

This goes after Eric's review tag.

Looks like you need to adjust one of the BPF selftests:

Error: #29/14 bpf_tcp_ca/tcp_ca_kfunc
  Error: #29/14 bpf_tcp_ca/tcp_ca_kfunc
  libbpf: extern (func ksym) 'bbr_main': func_proto [213] incompatible with vmlinux [48152]
  libbpf: failed to load object 'tcp_ca_kfunc'
  libbpf: failed to load BPF skeleton 'tcp_ca_kfunc': -22
  test_tcp_ca_kfunc:FAIL:tcp_ca_kfunc__open_and_load unexpected error: -22
diff mbox series

Patch

diff --git a/include/net/tcp.h b/include/net/tcp.h
index fe98fb01879b..7294da8fb780 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1172,7 +1172,7 @@  struct tcp_congestion_ops {
 	/* call when packets are delivered to update cwnd and pacing rate,
 	 * after all the ca_state processing. (optional)
 	 */
-	void (*cong_control)(struct sock *sk, const struct rate_sample *rs);
+	void (*cong_control)(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs);
 
 
 	/* new value of cwnd after loss (required) */
diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
index 7f518ea5f4ac..6bd7f8db189a 100644
--- a/net/ipv4/bpf_tcp_ca.c
+++ b/net/ipv4/bpf_tcp_ca.c
@@ -307,7 +307,8 @@  static u32 bpf_tcp_ca_min_tso_segs(struct sock *sk)
 	return 0;
 }
 
-static void bpf_tcp_ca_cong_control(struct sock *sk, const struct rate_sample *rs)
+static void bpf_tcp_ca_cong_control(struct sock *sk, u32 ack, int flag,
+				    const struct rate_sample *rs)
 {
 }
 
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index 7e52ab24e40a..760941e55153 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -1024,7 +1024,7 @@  static void bbr_update_model(struct sock *sk, const struct rate_sample *rs)
 	bbr_update_gains(sk);
 }
 
-__bpf_kfunc static void bbr_main(struct sock *sk, const struct rate_sample *rs)
+__bpf_kfunc static void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs)
 {
 	struct bbr *bbr = inet_csk_ca(sk);
 	u32 bw;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 53e1150f706f..23ccfc7b1d3c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3541,7 +3541,7 @@  static void tcp_cong_control(struct sock *sk, u32 ack, u32 acked_sacked,
 	const struct inet_connection_sock *icsk = inet_csk(sk);
 
 	if (icsk->icsk_ca_ops->cong_control) {
-		icsk->icsk_ca_ops->cong_control(sk, rs);
+		icsk->icsk_ca_ops->cong_control(sk, ack, flag, rs);
 		return;
 	}