Skip to content

Commit

Permalink
selftests/bpf: Check bpf_cubic_acked() is called via struct_ops
Browse files Browse the repository at this point in the history
Test bpf_tcp_ca (in test_progs) checks multiple tcp_congestion_ops.
However, there isn't a test that verifies functions in the
tcp_congestion_ops is actually called. Add a check to verify that
bpf_cubic_acked is actually called during the test.

Suggested-by: Martin KaFai Lau <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Acked-by: Ilya Leoshkevich <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
liu-song-6 authored and Alexei Starovoitov committed Sep 19, 2023
1 parent cf094ba commit 48f5e7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ static void test_cubic(void)

do_test("bpf_cubic", NULL);

ASSERT_EQ(cubic_skel->bss->bpf_cubic_acked_called, 1, "pkts_acked called");

bpf_link__destroy(link);
bpf_cubic__destroy(cubic_skel);
}
Expand Down
3 changes: 3 additions & 0 deletions tools/testing/selftests/bpf/progs/bpf_cubic.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,16 @@ static __always_inline void hystart_update(struct sock *sk, __u32 delay)
}
}

int bpf_cubic_acked_called = 0;

void BPF_STRUCT_OPS(bpf_cubic_acked, struct sock *sk,
const struct ack_sample *sample)
{
const struct tcp_sock *tp = tcp_sk(sk);
struct bictcp *ca = inet_csk_ca(sk);
__u32 delay;

bpf_cubic_acked_called = 1;
/* Some calls are for duplicates without timetamps */
if (sample->rtt_us < 0)
return;
Expand Down

0 comments on commit 48f5e7d

Please sign in to comment.