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