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#include "bpf_misc.h"
7
8#define MAX_STACK (512 - 3 * 32)
9
10static __attribute__ ((noinline))
11int f0(int var, struct __sk_buff *skb)
12{
13	return skb->len;
14}
15
16__attribute__ ((noinline))
17int f1(struct __sk_buff *skb)
18{
19	volatile char buf[MAX_STACK] = {};
20
21	__sink(buf[MAX_STACK - 1]);
22
23	return f0(0, skb) + skb->len;
24}
25
26int f3(int, struct __sk_buff *skb, int);
27
28__attribute__ ((noinline))
29int f2(int val, struct __sk_buff *skb)
30{
31	return f1(skb) + f3(val, skb, 1);
32}
33
34__attribute__ ((noinline))
35int f3(int val, struct __sk_buff *skb, int var)
36{
37	volatile char buf[MAX_STACK] = {};
38
39	__sink(buf[MAX_STACK - 1]);
40
41	return skb->ifindex * val * var;
42}
43
44SEC("tc")
45__success
46int global_func2(struct __sk_buff *skb)
47{
48	return f0(1, skb) + f1(skb) + f2(2, skb) + f3(3, skb, 4);
49}
50