Split-off PT_REGS-related helpers into bpf_tracing.h header. Adjust selftests and samples to include it where necessary. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Song Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20191008175942.1769476-5-andriin@fb.com
30 lines
501 B
C
30 lines
501 B
C
// 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"
|
|
#include "bpf_tracing.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;
|
|
}
|