diff options
author | Toke Høiland-Jørgensen <toke@redhat.com> | 2022-01-07 23:11:15 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-01-11 18:44:06 +0100 |
commit | 036a05f50bd777134b1955f400e8d24c0149fef4 (patch) | |
tree | c128bcf26d072175917ad3dbe484207c6780a5b3 /tools | |
parent | bpf/selftests: convert xdp_link test to ASSERT_* macros (diff) | |
download | linux-036a05f50bd777134b1955f400e8d24c0149fef4.tar.xz linux-036a05f50bd777134b1955f400e8d24c0149fef4.zip |
bpf/selftests: Add check for updating XDP bpf_link with wrong program type
Add a check to the xdp_link selftest that the kernel rejects replacing an
XDP program with a different program type on link update.
v2:
- Split this out into its own patch.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20220107221115.326171-3-toke@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/xdp_link.c | 5 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_xdp_link.c | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_link.c b/tools/testing/selftests/bpf/prog_tests/xdp_link.c index eec0bf83546b..b2b357f8c74c 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_link.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_link.c @@ -127,6 +127,11 @@ void serial_test_xdp_link(void) ASSERT_EQ(link_info.prog_id, id1, "link_prog_id"); ASSERT_EQ(link_info.xdp.ifindex, IFINDEX_LO, "link_ifindex"); + /* updating program under active BPF link with different type fails */ + err = bpf_link__update_program(link, skel1->progs.tc_handler); + if (!ASSERT_ERR(err, "link_upd_invalid")) + goto cleanup; + err = bpf_link__detach(link); if (!ASSERT_OK(err, "link_detach")) goto cleanup; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_link.c b/tools/testing/selftests/bpf/progs/test_xdp_link.c index ee7d6ac0f615..64ff32eaae92 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_link.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_link.c @@ -10,3 +10,9 @@ int xdp_handler(struct xdp_md *xdp) { return 0; } + +SEC("tc") +int tc_handler(struct __sk_buff *skb) +{ + return 0; +} |