1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2020 Facebook */
3 #include <stddef.h>
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 
7 __attribute__ ((noinline))
8 int f1(struct __sk_buff *skb)
9 {
10 	return skb->len;
11 }
12 
13 __attribute__ ((noinline))
14 int f2(int val, struct __sk_buff *skb)
15 {
16 	return f1(skb) + val;
17 }
18 
19 __attribute__ ((noinline))
20 int f3(int val, struct __sk_buff *skb, int var)
21 {
22 	return f2(var, skb) + val;
23 }
24 
25 __attribute__ ((noinline))
26 int f4(struct __sk_buff *skb)
27 {
28 	return f3(1, skb, 2);
29 }
30 
31 __attribute__ ((noinline))
32 int f5(struct __sk_buff *skb)
33 {
34 	return f4(skb);
35 }
36 
37 __attribute__ ((noinline))
38 int f6(struct __sk_buff *skb)
39 {
40 	return f5(skb);
41 }
42 
43 __attribute__ ((noinline))
44 int f7(struct __sk_buff *skb)
45 {
46 	return f6(skb);
47 }
48 
49 #ifndef NO_FN8
50 __attribute__ ((noinline))
51 int f8(struct __sk_buff *skb)
52 {
53 	return f7(skb);
54 }
55 #endif
56 
57 SEC("classifier/test")
58 int test_cls(struct __sk_buff *skb)
59 {
60 #ifndef NO_FN8
61 	return f8(skb);
62 #else
63 	return f7(skb);
64 #endif
65 }
66