Commit 29f38ca3 authored by Martin KaFai Lau's avatar Martin KaFai Lau
Browse files

Merge branch 'Add new args into tcp_congestion_ops' cong_control'



Miao Xu says:

====================
This patchset attempts to add two new arguments into the hookpoint
cong_control in tcp_congestion_ops. The new arguments are inherited
from the caller tcp_cong_control and can be used by any bpf cc prog
that implements its own logic inside this hookpoint.

Please review. Thanks a lot!

Changelog
=====
v2->v3:
  - Fixed the broken selftest caused by the new arguments.
  - Renamed the selftest file name and bpf prog name.

v1->v2:
  - Split the patchset into 3 separate patches.
  - Added highlights in the selftest prog.
  - Removed the dependency on bpf_tcp_helpers.h.
====================

Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parents f8c423d1 96c3490d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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) */
+5 −1
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ static int bpf_tcp_ca_btf_struct_access(struct bpf_verifier_log *log,
	case offsetof(struct tcp_sock, snd_cwnd_cnt):
		end = offsetofend(struct tcp_sock, snd_cwnd_cnt);
		break;
	case offsetof(struct tcp_sock, snd_cwnd_stamp):
		end = offsetofend(struct tcp_sock, snd_cwnd_stamp);
		break;
	case offsetof(struct tcp_sock, snd_ssthresh):
		end = offsetofend(struct tcp_sock, snd_ssthresh);
		break;
@@ -307,7 +310,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)
{
}

+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}

+24 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include "tcp_ca_incompl_cong_ops.skel.h"
#include "tcp_ca_unsupp_cong_op.skel.h"
#include "tcp_ca_kfunc.skel.h"
#include "bpf_cc_cubic.skel.h"

#ifndef ENOTSUPP
#define ENOTSUPP 524
@@ -452,6 +453,27 @@ static void test_tcp_ca_kfunc(void)
	tcp_ca_kfunc__destroy(skel);
}

static void test_cc_cubic(void)
{
	struct bpf_cc_cubic *cc_cubic_skel;
	struct bpf_link *link;

	cc_cubic_skel = bpf_cc_cubic__open_and_load();
	if (!ASSERT_OK_PTR(cc_cubic_skel, "bpf_cc_cubic__open_and_load"))
		return;

	link = bpf_map__attach_struct_ops(cc_cubic_skel->maps.cc_cubic);
	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
		bpf_cc_cubic__destroy(cc_cubic_skel);
		return;
	}

	do_test("bpf_cc_cubic", NULL);

	bpf_link__destroy(link);
	bpf_cc_cubic__destroy(cc_cubic_skel);
}

void test_bpf_tcp_ca(void)
{
	if (test__start_subtest("dctcp"))
@@ -482,4 +504,6 @@ void test_bpf_tcp_ca(void)
		test_link_replace();
	if (test__start_subtest("tcp_ca_kfunc"))
		test_tcp_ca_kfunc();
	if (test__start_subtest("cc_cubic"))
		test_cc_cubic();
}
Loading