aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/changes_pkt_data.c
diff options
context:
space:
mode:
authorEduard Zingerman <[email protected]>2024-12-12 07:07:11 +0000
committerAlexei Starovoitov <[email protected]>2024-12-12 19:38:36 +0000
commit04789af756a4a43e72986185f66f148e65b32fed (patch)
treeedaa01678aefab27827d8a95c8d1a24884676621 /tools/testing/selftests/bpf/progs/changes_pkt_data.c
parentbpf: fix null dereference when computing changes_pkt_data of prog w/o subprogs (diff)
downloadkernel-04789af756a4a43e72986185f66f148e65b32fed.tar.gz
kernel-04789af756a4a43e72986185f66f148e65b32fed.zip
selftests/bpf: extend changes_pkt_data with cases w/o subprograms
Extend changes_pkt_data tests with test cases freplacing the main program that does not have subprograms. Try four combinations when both main program and replacement do and do not change packet data. Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/changes_pkt_data.c')
-rw-r--r--tools/testing/selftests/bpf/progs/changes_pkt_data.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/testing/selftests/bpf/progs/changes_pkt_data.c b/tools/testing/selftests/bpf/progs/changes_pkt_data.c
index f87da8e9d6b3..43cada48b28a 100644
--- a/tools/testing/selftests/bpf/progs/changes_pkt_data.c
+++ b/tools/testing/selftests/bpf/progs/changes_pkt_data.c
@@ -4,22 +4,35 @@
#include <bpf/bpf_helpers.h>
__noinline
-long changes_pkt_data(struct __sk_buff *sk, __u32 len)
+long changes_pkt_data(struct __sk_buff *sk)
{
- return bpf_skb_pull_data(sk, len);
+ return bpf_skb_pull_data(sk, 0);
}
__noinline __weak
-long does_not_change_pkt_data(struct __sk_buff *sk, __u32 len)
+long does_not_change_pkt_data(struct __sk_buff *sk)
{
return 0;
}
-SEC("tc")
-int dummy(struct __sk_buff *sk)
+SEC("?tc")
+int main_with_subprogs(struct __sk_buff *sk)
+{
+ changes_pkt_data(sk);
+ does_not_change_pkt_data(sk);
+ return 0;
+}
+
+SEC("?tc")
+int main_changes(struct __sk_buff *sk)
+{
+ bpf_skb_pull_data(sk, 0);
+ return 0;
+}
+
+SEC("?tc")
+int main_does_not_change(struct __sk_buff *sk)
{
- changes_pkt_data(sk, 0);
- does_not_change_pkt_data(sk, 0);
return 0;
}