diff options
author | Martin KaFai Lau <kafai@fb.com> | 2021-08-24 10:30:26 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-08-25 17:40:35 -0700 |
commit | 574ee209286755ae57449196bfa11a90d2d724e5 (patch) | |
tree | cad9561b3fc80ffe9254a66bcf36159a0d5141c8 /tools/testing/selftests/bpf/progs/bpf_dctcp_release.c | |
parent | 3d7789831df9bda0941bda41cface6687b7c3e04 (diff) | |
download | linux-574ee209286755ae57449196bfa11a90d2d724e5.tar.bz2 |
bpf: selftests: Add dctcp fallback test
This patch makes the bpf_dctcp test to fallback to cubic by
using setsockopt(TCP_CONGESTION) when the tcp flow is not
ecn ready.
It also checks setsockopt() is not available to release().
The settimeo() from the network_helpers.h is used, so the local
one is removed.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210824173026.3979130-1-kafai@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bpf_dctcp_release.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/bpf_dctcp_release.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/bpf_dctcp_release.c b/tools/testing/selftests/bpf/progs/bpf_dctcp_release.c new file mode 100644 index 000000000000..d836f7c372f0 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bpf_dctcp_release.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2021 Facebook */ + +#include <stddef.h> +#include <linux/bpf.h> +#include <linux/types.h> +#include <linux/stddef.h> +#include <linux/tcp.h> +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> +#include "bpf_tcp_helpers.h" + +char _license[] SEC("license") = "GPL"; +const char cubic[] = "cubic"; + +void BPF_STRUCT_OPS(dctcp_nouse_release, struct sock *sk) +{ + bpf_setsockopt(sk, SOL_TCP, TCP_CONGESTION, + (void *)cubic, sizeof(cubic)); +} + +SEC(".struct_ops") +struct tcp_congestion_ops dctcp_rel = { + .release = (void *)dctcp_nouse_release, + .name = "bpf_dctcp_rel", +}; |