Skip to content

Commit e1cebd8

Browse files
fomichevAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix a couple of broken test_btf cases
Commit 51c39bb ("bpf: Introduce function-by-function verification") introduced function linkage flag and changed the error message from "vlen != 0" to "Invalid func linkage" and broke some fake BPF programs. Adjust the test accordingly. AFACT, the programs don't really need any arguments and only look at BTF for maps, so let's drop the args altogether. Before: BTF raw test[103] (func (Non zero vlen)): do_test_raw:3703:FAIL expected err_str:vlen != 0 magic: 0xeb9f version: 1 flags: 0x0 hdr_len: 24 type_off: 0 type_len: 72 str_off: 72 str_len: 10 btf_total_size: 106 [1] INT (anon) size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [2] INT (anon) size=4 bits_offset=0 nr_bits=32 encoding=(none) [3] FUNC_PROTO (anon) return=0 args=(1 a, 2 b) [4] FUNC func type_id=3 Invalid func linkage BTF libbpf test[1] (test_btf_haskv.o): libbpf: load bpf program failed: Invalid argument libbpf: -- BEGIN DUMP LOG --- libbpf: Validating test_long_fname_2() func#1... Arg#0 type PTR in test_long_fname_2() is not supported yet. processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 libbpf: -- END LOG -- libbpf: failed to load program 'dummy_tracepoint' libbpf: failed to load object 'test_btf_haskv.o' do_test_file:4201:FAIL bpf_object__load: -4007 BTF libbpf test[2] (test_btf_newkv.o): libbpf: load bpf program failed: Invalid argument libbpf: -- BEGIN DUMP LOG --- libbpf: Validating test_long_fname_2() func#1... Arg#0 type PTR in test_long_fname_2() is not supported yet. processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 libbpf: -- END LOG -- libbpf: failed to load program 'dummy_tracepoint' libbpf: failed to load object 'test_btf_newkv.o' do_test_file:4201:FAIL bpf_object__load: -4007 BTF libbpf test[3] (test_btf_nokv.o): libbpf: load bpf program failed: Invalid argument libbpf: -- BEGIN DUMP LOG --- libbpf: Validating test_long_fname_2() func#1... Arg#0 type PTR in test_long_fname_2() is not supported yet. processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 libbpf: -- END LOG -- libbpf: failed to load program 'dummy_tracepoint' libbpf: failed to load object 'test_btf_nokv.o' do_test_file:4201:FAIL bpf_object__load: -4007 Fixes: 51c39bb ("bpf: Introduce function-by-function verification") Signed-off-by: Stanislav Fomichev <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent dfc55ac commit e1cebd8

File tree

4 files changed

+16
-40
lines changed

4 files changed

+16
-40
lines changed

tools/testing/selftests/bpf/progs/test_btf_haskv.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,12 @@ struct bpf_map_def SEC("maps") btf_map = {
2020

2121
BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
2222

23-
struct dummy_tracepoint_args {
24-
unsigned long long pad;
25-
struct sock *sock;
26-
};
27-
2823
__attribute__((noinline))
29-
int test_long_fname_2(struct dummy_tracepoint_args *arg)
24+
int test_long_fname_2(void)
3025
{
3126
struct ipv_counts *counts;
3227
int key = 0;
3328

34-
if (!arg->sock)
35-
return 0;
36-
3729
counts = bpf_map_lookup_elem(&btf_map, &key);
3830
if (!counts)
3931
return 0;
@@ -44,15 +36,15 @@ int test_long_fname_2(struct dummy_tracepoint_args *arg)
4436
}
4537

4638
__attribute__((noinline))
47-
int test_long_fname_1(struct dummy_tracepoint_args *arg)
39+
int test_long_fname_1(void)
4840
{
49-
return test_long_fname_2(arg);
41+
return test_long_fname_2();
5042
}
5143

5244
SEC("dummy_tracepoint")
53-
int _dummy_tracepoint(struct dummy_tracepoint_args *arg)
45+
int _dummy_tracepoint(void *arg)
5446
{
55-
return test_long_fname_1(arg);
47+
return test_long_fname_1();
5648
}
5749

5850
char _license[] SEC("license") = "GPL";

tools/testing/selftests/bpf/progs/test_btf_newkv.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,12 @@ struct {
2828
__type(value, struct ipv_counts);
2929
} btf_map SEC(".maps");
3030

31-
struct dummy_tracepoint_args {
32-
unsigned long long pad;
33-
struct sock *sock;
34-
};
35-
3631
__attribute__((noinline))
37-
int test_long_fname_2(struct dummy_tracepoint_args *arg)
32+
int test_long_fname_2(void)
3833
{
3934
struct ipv_counts *counts;
4035
int key = 0;
4136

42-
if (!arg->sock)
43-
return 0;
44-
4537
counts = bpf_map_lookup_elem(&btf_map, &key);
4638
if (!counts)
4739
return 0;
@@ -57,15 +49,15 @@ int test_long_fname_2(struct dummy_tracepoint_args *arg)
5749
}
5850

5951
__attribute__((noinline))
60-
int test_long_fname_1(struct dummy_tracepoint_args *arg)
52+
int test_long_fname_1(void)
6153
{
62-
return test_long_fname_2(arg);
54+
return test_long_fname_2();
6355
}
6456

6557
SEC("dummy_tracepoint")
66-
int _dummy_tracepoint(struct dummy_tracepoint_args *arg)
58+
int _dummy_tracepoint(void *arg)
6759
{
68-
return test_long_fname_1(arg);
60+
return test_long_fname_1();
6961
}
7062

7163
char _license[] SEC("license") = "GPL";

tools/testing/selftests/bpf/progs/test_btf_nokv.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@ struct bpf_map_def SEC("maps") btf_map = {
1717
.max_entries = 4,
1818
};
1919

20-
struct dummy_tracepoint_args {
21-
unsigned long long pad;
22-
struct sock *sock;
23-
};
24-
2520
__attribute__((noinline))
26-
int test_long_fname_2(struct dummy_tracepoint_args *arg)
21+
int test_long_fname_2(void)
2722
{
2823
struct ipv_counts *counts;
2924
int key = 0;
3025

31-
if (!arg->sock)
32-
return 0;
33-
3426
counts = bpf_map_lookup_elem(&btf_map, &key);
3527
if (!counts)
3628
return 0;
@@ -41,15 +33,15 @@ int test_long_fname_2(struct dummy_tracepoint_args *arg)
4133
}
4234

4335
__attribute__((noinline))
44-
int test_long_fname_1(struct dummy_tracepoint_args *arg)
36+
int test_long_fname_1(void)
4537
{
46-
return test_long_fname_2(arg);
38+
return test_long_fname_2();
4739
}
4840

4941
SEC("dummy_tracepoint")
50-
int _dummy_tracepoint(struct dummy_tracepoint_args *arg)
42+
int _dummy_tracepoint(void *arg)
5143
{
52-
return test_long_fname_1(arg);
44+
return test_long_fname_1();
5345
}
5446

5547
char _license[] SEC("license") = "GPL";

tools/testing/selftests/bpf/test_btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,7 @@ static struct btf_raw_test raw_tests[] = {
28542854
.value_type_id = 1,
28552855
.max_entries = 4,
28562856
.btf_load_err = true,
2857-
.err_str = "vlen != 0",
2857+
.err_str = "Invalid func linkage",
28582858
},
28592859

28602860
{

0 commit comments

Comments
 (0)