1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/bpf.h> 4 #include <bpf/bpf_helpers.h> 5 #include <bpf/bpf_tracing.h> 6 7 char _license[] SEC("license") = "GPL"; 8 9 int test_1_result = 0; 10 11 SEC("struct_ops/test_1") 12 int BPF_PROG(test_1) 13 { 14 test_1_result = 42; 15 return 0; 16 } 17 18 SEC("struct_ops/test_1") 19 int BPF_PROG(test_2) 20 { 21 return 0; 22 } 23 24 struct bpf_testmod_ops___v1 { 25 int (*test_1)(void); 26 }; 27 28 struct bpf_testmod_ops___v2 { 29 int (*test_1)(void); 30 int (*does_not_exist)(void); 31 }; 32 33 SEC(".struct_ops.link") 34 struct bpf_testmod_ops___v1 testmod_1 = { 35 .test_1 = (void *)test_1 36 }; 37 38 SEC(".struct_ops.link") 39 struct bpf_testmod_ops___v2 testmod_2 = { 40 .test_1 = (void *)test_1, 41 .does_not_exist = (void *)test_2 42 }; 43 44 SEC("?.struct_ops") 45 struct bpf_testmod_ops___v1 optional_map = { 46 .test_1 = (void *)test_1, 47 }; 48 49 SEC("?.struct_ops.link") 50 struct bpf_testmod_ops___v1 optional_map2 = { 51 .test_1 = (void *)test_1, 52 }; 53