summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/struct_ops_detach.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/bpf/progs/struct_ops_detach.c')
-rw-r--r--tools/testing/selftests/bpf/progs/struct_ops_detach.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/struct_ops_detach.c b/tools/testing/selftests/bpf/progs/struct_ops_detach.c
index 56b787a898761..d7fdcabe7d905 100644
--- a/tools/testing/selftests/bpf/progs/struct_ops_detach.c
+++ b/tools/testing/selftests/bpf/progs/struct_ops_detach.c
@@ -6,5 +6,17 @@
char _license[] SEC("license") = "GPL";
+/*
+ * This subprogram validates that libbpf handles the situation in which BPF
+ * object has subprograms in .text section, but has no entry BPF programs.
+ * At some point that was causing issues due to legacy logic of treating such
+ * subprogram as entry program (with unknown program type, which would fail).
+ */
+int dangling_subprog(void)
+{
+ /* do nothing, just be here */
+ return 0;
+}
+
SEC(".struct_ops.link")
struct bpf_testmod_ops testmod_do_detach;