2019-06-15 19:12:24 +00:00
|
|
|
// 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>
|
2020-01-20 13:06:45 +00:00
|
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
#include <bpf/bpf_tracing.h>
|
2019-06-15 19:12:24 +00:00
|
|
|
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
|
|
|
|
SEC("raw_tracepoint/consume_skb")
|
|
|
|
int while_true(volatile struct pt_regs* ctx)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (true) {
|
2019-07-11 14:29:30 +00:00
|
|
|
if (PT_REGS_RC(ctx) & 1)
|
2019-06-15 19:12:24 +00:00
|
|
|
i += 3;
|
|
|
|
else
|
|
|
|
i += 7;
|
|
|
|
if (i > 40)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|