Skip to content

Commit c21ca44

Browse files
committed
selftests/bpf: Add test for detachment on empty mprog entry
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-427.18.1.el9_4 commit-author Daniel Borkmann <[email protected]> commit 21ce6ab Add a detachment test case with miniq present to assert that with and without the miniq we get the same error. # ./test_progs -t tc_opts ctrliq#244 tc_opts_after:OK ctrliq#245 tc_opts_append:OK ctrliq#246 tc_opts_basic:OK ctrliq#247 tc_opts_before:OK ctrliq#248 tc_opts_chain_classic:OK ctrliq#249 tc_opts_delete_empty:OK ctrliq#250 tc_opts_demixed:OK ctrliq#251 tc_opts_detach:OK ctrliq#252 tc_opts_detach_after:OK ctrliq#253 tc_opts_detach_before:OK ctrliq#254 tc_opts_dev_cleanup:OK ctrliq#255 tc_opts_invalid:OK ctrliq#256 tc_opts_mixed:OK ctrliq#257 tc_opts_prepend:OK ctrliq#258 tc_opts_replace:OK ctrliq#259 tc_opts_revision:OK Summary: 16/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]> (cherry picked from commit 21ce6ab) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 8285ab7 commit c21ca44

File tree

1 file changed

+31
-0
lines changed
  • tools/testing/selftests/bpf/prog_tests

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,3 +2237,34 @@ void serial_test_tc_opts_detach_after(void)
22372237
test_tc_opts_detach_after_target(BPF_TCX_INGRESS);
22382238
test_tc_opts_detach_after_target(BPF_TCX_EGRESS);
22392239
}
2240+
2241+
static void test_tc_opts_delete_empty(int target, bool chain_tc_old)
2242+
{
2243+
LIBBPF_OPTS(bpf_tc_hook, tc_hook, .ifindex = loopback);
2244+
LIBBPF_OPTS(bpf_prog_detach_opts, optd);
2245+
int err;
2246+
2247+
assert_mprog_count(target, 0);
2248+
if (chain_tc_old) {
2249+
tc_hook.attach_point = target == BPF_TCX_INGRESS ?
2250+
BPF_TC_INGRESS : BPF_TC_EGRESS;
2251+
err = bpf_tc_hook_create(&tc_hook);
2252+
ASSERT_OK(err, "bpf_tc_hook_create");
2253+
__assert_mprog_count(target, 0, true, loopback);
2254+
}
2255+
err = bpf_prog_detach_opts(0, loopback, target, &optd);
2256+
ASSERT_EQ(err, -ENOENT, "prog_detach");
2257+
if (chain_tc_old) {
2258+
tc_hook.attach_point = BPF_TC_INGRESS | BPF_TC_EGRESS;
2259+
bpf_tc_hook_destroy(&tc_hook);
2260+
}
2261+
assert_mprog_count(target, 0);
2262+
}
2263+
2264+
void serial_test_tc_opts_delete_empty(void)
2265+
{
2266+
test_tc_opts_delete_empty(BPF_TCX_INGRESS, false);
2267+
test_tc_opts_delete_empty(BPF_TCX_EGRESS, false);
2268+
test_tc_opts_delete_empty(BPF_TCX_INGRESS, true);
2269+
test_tc_opts_delete_empty(BPF_TCX_EGRESS, true);
2270+
}

0 commit comments

Comments
 (0)