Re: [RFC PATCH bpf-next 7/9] selftests/bpf: add CO-RE relo test for TYPE_ID_LOCAL/TYPE_ID_TARGET

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 04, 2020 at 11:24:07AM -0700, Andrii Nakryiko wrote:
> +
> +SEC("raw_tracepoint/sys_enter")
> +int test_core_type_id(void *ctx)
> +{
> +	struct core_reloc_type_id_output *out = (void *)&data.out;
> +
> +	out->local_anon_struct = bpf_core_type_id_local(struct { int marker_field; });
> +	out->local_anon_union = bpf_core_type_id_local(union { int marker_field; });
> +	out->local_anon_enum = bpf_core_type_id_local(enum { MARKER_ENUM_VAL = 123 });
> +	out->local_anon_func_proto_ptr = bpf_core_type_id_local(_Bool(*)(int));
> +	out->local_anon_void_ptr = bpf_core_type_id_local(void *);
> +	out->local_anon_arr = bpf_core_type_id_local(_Bool[47]);
> +
> +	out->local_struct = bpf_core_type_id_local(struct a_struct);
> +	out->local_union = bpf_core_type_id_local(union a_union);
> +	out->local_enum = bpf_core_type_id_local(enum an_enum);
> +	out->local_int = bpf_core_type_id_local(int);
> +	out->local_struct_typedef = bpf_core_type_id_local(named_struct_typedef);
> +	out->local_func_proto_typedef = bpf_core_type_id_local(func_proto_typedef);
> +	out->local_arr_typedef = bpf_core_type_id_local(arr_typedef);
> +
> +	out->targ_struct = bpf_core_type_id_kernel(struct a_struct);
> +	out->targ_union = bpf_core_type_id_kernel(union a_union);
> +	out->targ_enum = bpf_core_type_id_kernel(enum an_enum);
> +	out->targ_int = bpf_core_type_id_kernel(int);
> +	out->targ_struct_typedef = bpf_core_type_id_kernel(named_struct_typedef);
> +	out->targ_func_proto_typedef = bpf_core_type_id_kernel(func_proto_typedef);
> +	out->targ_arr_typedef = bpf_core_type_id_kernel(arr_typedef);

bpf_core_type_id_kernel() returns btf_id of the type in vmlinux BTF or zero,
so what is the point of above tests? All targ_* will be zero.
Should the test find a type that actually exists in the kernel?
What am I missing?



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux