xref: /linux/tools/testing/selftests/bpf/progs/loop2.c (revision 07fdad3a93756b872da7b53647715c48d0f4a2d0)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
3 #include "vmlinux.h"
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
6 
7 char _license[] SEC("license") = "GPL";
8 
9 SEC("raw_tracepoint/consume_skb")
10 int while_true(volatile struct pt_regs* ctx)
11 {
12 	int i = 0;
13 
14 	while (true) {
15 		if (PT_REGS_RC(ctx) & 1)
16 			i += 3;
17 		else
18 			i += 7;
19 		if (i > 40)
20 			break;
21 	}
22 
23 	return i;
24 }
25