Re: [PATCH bpf 2/2] bpf: selftests: Add non function pointer test to struct_ops
From: Martin KaFai Lau <hidden>
Date: 2021-02-10 21:18:42
Also in:
bpf
On Wed, Feb 10, 2021 at 12:27:38PM -0800, Andrii Nakryiko wrote:
On Tue, Feb 9, 2021 at 12:11 PM Martin KaFai Lau [off-list ref] wrote:quoted
This patch adds a "void *owner" member. The existing bpf_tcp_ca test will ensure the bpf_cubic.o and bpf_dctcp.o can be loaded. Signed-off-by: Martin KaFai Lau <redacted> ---Acked-by: Andrii Nakryiko <andrii@kernel.org> What will happen if BPF code initializes such non-func ptr member? Will libbpf complain or just ignore those values? Ignoring initialized members isn't great.
The latter. libbpf will ignore non-func ptr member. The non-func ptr member stays zero when it is passed to the kernel. libbpf can be changed to copy this non-func ptr value. The kernel will decide what to do with it. It will then be consistent with int/array member like ".name" and ".flags" where the kernel will verify the value. I can spin v2 to do that.
quoted
tools/testing/selftests/bpf/bpf_tcp_helpers.h | 1 + 1 file changed, 1 insertion(+)diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h index 6a9053162cf2..91f0fac632f4 100644 --- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h +++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h@@ -177,6 +177,7 @@ struct tcp_congestion_ops { * after all the ca_state processing. (optional) */ void (*cong_control)(struct sock *sk, const struct rate_sample *rs); + void *owner; }; #define min(a, b) ((a) < (b) ? (a) : (b)) --2.24.1