summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/loop2.c
blob: 9b2f808a2863732f7a3648ed6a875c1a93b57425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019 Facebook
#include <linux/sched.h>
#include <linux/ptrace.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <linux/bpf.h>
#include "bpf_helpers.h"

char _license[] SEC("license") = "GPL";

SEC("raw_tracepoint/consume_skb")
int while_true(volatile struct pt_regs* ctx)
{
	int i = 0;

	while (true) {
		if (PT_REGS_RC(ctx) & 1)
			i += 3;
		else
			i += 7;
		if (i > 40)
			break;
	}

	return i;
}