Alexei Starovoitov | b061017 | 2019-06-15 12:12:24 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // Copyright (c) 2019 Facebook |
| 3 | #include <linux/sched.h> |
| 4 | #include <linux/ptrace.h> |
| 5 | #include <stdint.h> |
| 6 | #include <stddef.h> |
| 7 | #include <stdbool.h> |
| 8 | #include <linux/bpf.h> |
Toke Høiland-Jørgensen | 3e68914 | 2020-01-20 14:06:45 +0100 | [diff] [blame] | 9 | #include <bpf/bpf_helpers.h> |
| 10 | #include <bpf/bpf_tracing.h> |
Alexei Starovoitov | b061017 | 2019-06-15 12:12:24 -0700 | [diff] [blame] | 11 | |
| 12 | char _license[] SEC("license") = "GPL"; |
| 13 | |
| 14 | SEC("raw_tracepoint/consume_skb") |
Andrii Nakryiko | 70bc793 | 2022-01-06 12:51:56 -0800 | [diff] [blame] | 15 | int while_true(struct pt_regs *ctx) |
Alexei Starovoitov | b061017 | 2019-06-15 12:12:24 -0700 | [diff] [blame] | 16 | { |
Andrii Nakryiko | 70bc793 | 2022-01-06 12:51:56 -0800 | [diff] [blame] | 17 | volatile __u64 i = 0, sum = 0; |
Alexei Starovoitov | b061017 | 2019-06-15 12:12:24 -0700 | [diff] [blame] | 18 | do { |
| 19 | i++; |
Ilya Leoshkevich | af3c24e | 2019-07-11 16:29:30 +0200 | [diff] [blame] | 20 | sum += PT_REGS_RC(ctx); |
Alexei Starovoitov | b061017 | 2019-06-15 12:12:24 -0700 | [diff] [blame] | 21 | } while (i < 0x100000000ULL); |
| 22 | return sum; |
| 23 | } |