xref: /linux/tools/testing/selftests/bpf/progs/kfunc_module_order.c (revision 3d5ad2d4eca337e80f38df77de89614aa5aaceb9)
1*f91b2566SSimon Sundberg // SPDX-License-Identifier: GPL-2.0
2*f91b2566SSimon Sundberg #include <linux/bpf.h>
3*f91b2566SSimon Sundberg #include <bpf/bpf_helpers.h>
4*f91b2566SSimon Sundberg 
5*f91b2566SSimon Sundberg extern int bpf_test_modorder_retx(void) __ksym;
6*f91b2566SSimon Sundberg extern int bpf_test_modorder_rety(void) __ksym;
7*f91b2566SSimon Sundberg 
8*f91b2566SSimon Sundberg SEC("classifier")
call_kfunc_xy(struct __sk_buff * skb)9*f91b2566SSimon Sundberg int call_kfunc_xy(struct __sk_buff *skb)
10*f91b2566SSimon Sundberg {
11*f91b2566SSimon Sundberg 	int ret1, ret2;
12*f91b2566SSimon Sundberg 
13*f91b2566SSimon Sundberg 	ret1 = bpf_test_modorder_retx();
14*f91b2566SSimon Sundberg 	ret2 = bpf_test_modorder_rety();
15*f91b2566SSimon Sundberg 
16*f91b2566SSimon Sundberg 	return ret1 == 'x' && ret2 == 'y' ? 0 : -1;
17*f91b2566SSimon Sundberg }
18*f91b2566SSimon Sundberg 
19*f91b2566SSimon Sundberg SEC("classifier")
call_kfunc_yx(struct __sk_buff * skb)20*f91b2566SSimon Sundberg int call_kfunc_yx(struct __sk_buff *skb)
21*f91b2566SSimon Sundberg {
22*f91b2566SSimon Sundberg 	int ret1, ret2;
23*f91b2566SSimon Sundberg 
24*f91b2566SSimon Sundberg 	ret1 = bpf_test_modorder_rety();
25*f91b2566SSimon Sundberg 	ret2 = bpf_test_modorder_retx();
26*f91b2566SSimon Sundberg 
27*f91b2566SSimon Sundberg 	return ret1 == 'y' && ret2 == 'x' ? 0 : -1;
28*f91b2566SSimon Sundberg }
29*f91b2566SSimon Sundberg 
30*f91b2566SSimon Sundberg char _license[] SEC("license") = "GPL";
31