Skip to content

Commit d2aa993

Browse files
Pu LehuiMartin KaFai Lau
authored andcommitted
selftests/bpf: Adapt cgroup effective query uapi change
The attach flags is meaningless for effective query and its value will always be set as 0 during effective query. Root cg's effective progs is always its attached progs, so we use non-effective query to get its progs count and attach flags. And we don't need the remain attach flags check. Fixes: b79c9fc ("bpf: implement BPF_PROG_QUERY for BPF_LSM_CGROUP") Signed-off-by: Pu Lehui <pulehui@huawei.com> Link: https://lore.kernel.org/r/20220921104604.2340580-4-pulehui@huaweicloud.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
1 parent bdcee1b commit d2aa993

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tools/testing/selftests/bpf/prog_tests/cgroup_link.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ void serial_test_cgroup_link(void)
7171

7272
ping_and_check(cg_nr, 0);
7373

74-
/* query the number of effective progs and attach flags in root cg */
74+
/* query the number of attached progs and attach flags in root cg */
7575
err = bpf_prog_query(cgs[0].fd, BPF_CGROUP_INET_EGRESS,
76-
BPF_F_QUERY_EFFECTIVE, &attach_flags, NULL,
77-
&prog_cnt);
76+
0, &attach_flags, NULL, &prog_cnt);
7877
CHECK_FAIL(err);
7978
CHECK_FAIL(attach_flags != BPF_F_ALLOW_MULTI);
8079
if (CHECK(prog_cnt != 1, "effect_cnt", "exp %d, got %d\n", 1, prog_cnt))
@@ -85,17 +84,15 @@ void serial_test_cgroup_link(void)
8584
BPF_F_QUERY_EFFECTIVE, NULL, NULL,
8685
&prog_cnt);
8786
CHECK_FAIL(err);
88-
CHECK_FAIL(attach_flags != BPF_F_ALLOW_MULTI);
8987
if (CHECK(prog_cnt != cg_nr, "effect_cnt", "exp %d, got %d\n",
9088
cg_nr, prog_cnt))
9189
goto cleanup;
9290

9391
/* query the effective prog IDs in last cg */
9492
err = bpf_prog_query(cgs[last_cg].fd, BPF_CGROUP_INET_EGRESS,
95-
BPF_F_QUERY_EFFECTIVE, &attach_flags,
96-
prog_ids, &prog_cnt);
93+
BPF_F_QUERY_EFFECTIVE, NULL, prog_ids,
94+
&prog_cnt);
9795
CHECK_FAIL(err);
98-
CHECK_FAIL(attach_flags != BPF_F_ALLOW_MULTI);
9996
if (CHECK(prog_cnt != cg_nr, "effect_cnt", "exp %d, got %d\n",
10097
cg_nr, prog_cnt))
10198
goto cleanup;

0 commit comments

Comments
 (0)