Questions tagged [ebpf]

eBPF (from “extended Berkeley Packet Filter”) is a subsystem introduced in Linux and allowing to load user programs into the kernel, to verify them for safety, possibly to JIT (Just-In-Time) compile them, and to attach them to hook points, where they run on certain events. eBPF's performance and flexibility make it suitable for a wide range of use cases, the most prominent being network packet processing, system monitoring, and security enforcement.

eBPF (from “extended Berkeley Packet Filter”) is a subsystem allowing to load user programs into the kernel, to verify them for safety, possibly to JIT (Just-In-Time) compile them, and to attach them to hook points, where they run on certain events. eBPF's performance and flexibility make it suitable for a wide range of use cases, the most prominent being network packet processing, system monitoring, and security enforcement. Introduced in Linux, eBPF gained support to varying degrees on other systems, including Windows or FreeBSD.

See also https://ebpf.io/ for a more detailed introduction and for additional resources. More assistance can also be found at the following locations:

When submitting questions related to a specific eBPF piece of code, please consider including a full stand-alone reproducer, it helps a lot for debugging the issues.

Related tags include bpf, bcc-bpf, or xdp-bpf.

641 questions
2
votes
1 answer

which kprobe hooks can I attach eBPF programs to?

I am learning about eBPF and I understand that I can attach my eBPF programs to kprobes, uprobes, tracepoints and more. I see that there is a list of for tracepoints under /sys/kernel/debug/tracing/events/ where I can attach eBPF programs to.…
user3267989
  • 299
  • 3
  • 18
2
votes
3 answers

ebpf: drop ICMP packet in socket filter program on lo interface

Consider a very simple ebpf code of BPF_PROG_TYPE_SOCKET_FILTER type: struct bpf_insn prog[] = { BPF_MOV64_IMM(BPF_REG_0, -1), BPF_EXIT_INSN(), }; The code snippets below from net/core/filter.c and net/core/sock/c show how the filter will be…
Mark
  • 6,052
  • 8
  • 61
  • 129
2
votes
1 answer

Keep getting bpf: Failed to load program: Permission denied when trying to run eBPF code

Sorry, I am really new to writing eBPF code, so I came upon an error that I can't seem to shake off. Running in sudo does not seem to help. And I wrote a slower crc32 program that compiles but this one does not want to execute no matter what. I am…
Zarif Rahman
  • 79
  • 1
  • 8
2
votes
1 answer

ebpf: where verifier prints its messages?

Where does the verifier print its messages? I have a simple code embedded in struct bpf_insn which I load and attach as BPF_PROG_TYPE_SOCKET_FILTER type: struct bpf_insn prog[] = { BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), BPF_EXIT_INSN(), }; This…
Mark
  • 6,052
  • 8
  • 61
  • 129
2
votes
1 answer

ebpf: bpf_prog_load() vs bpf_object__load()

I have not used libbpf in a while. Now, when I'm looking at the source code and examples, it looks to me that all API now is built around bpf_object while before it was based on program FD (at least on the user-facing level). I believe that fd is…
Mark
  • 6,052
  • 8
  • 61
  • 129
2
votes
0 answers

Instrument functions called in eBPF program using eBPF

I would like to write an eBPF program in order to track the functions being called in a separate running eBPF program. Also, I would like to count the number of times the respective functions have been called. Is this possible? And if so, could…
b0gd4n
  • 39
  • 2
2
votes
1 answer

Debugging bpf and bpf jit

I wrote some bpf programs. I've enabled echo "2" > /proc/sys/net/core/bpf_jit_enable so it outputs the generated jitted code in logs, but I don't have bpf_jit_disasm inside the qemu environment in which I generated the jitted code. The qemu…
user40061
  • 85
  • 2
  • 5
2
votes
1 answer

Using bcc python to detach probe

I am searching for a counterpart function with attach_kprobe(), which can detach the probe we insert previously. If it doesn't exist, are there any possible to detach inserted probe in same program using Python? Any suggestion will be appreciated!
Steven
  • 811
  • 4
  • 23
2
votes
1 answer

What should I do if "sudo /usr/share/bcc/tools/execsnoop" fails after build BCC from source?

After building BCC from source and running the test "sudo /usr/share/bcc/tools/execsnoop", I got the following output: Traceback (most recent call last): File "/usr/share/bcc/tools/execsnoop", line 21, in from bcc import BPF ImportError: No module…
SuperSim135
  • 135
  • 1
  • 10
2
votes
2 answers

How to modify userspace memory using eBPF?

I'm trying to write a sample code and see how it works practically. As said here and discussed here. If everything is correct the output should be: $ cat foo1 this is foo1 content $ cat foo2 this is foo2 content $ sudo bcc_mangle_open.py & [1]…
avsr
  • 143
  • 3
  • 15
2
votes
1 answer

Attaching eBPF to KPROBE?

I wrote a simple program to attach to execve system call with a kprobe, but I am unable to see the relevant output. Here is my one.c (BPF program): #include #include #include #include #include…
avsr
  • 143
  • 3
  • 15
2
votes
1 answer

bpf how to inspect syscall arguments

trace_output_kern.c traces sys_write syscall and prints the pid in userland: #include #include #include #include "bpf_helpers.h" struct bpf_map_def SEC("maps") my_map = { .type =…
struggling_learner
  • 1,214
  • 15
  • 29
2
votes
1 answer

ebpf program loading error: unknown func bpf_l4_csum_replace#11

I am testing a nat program using ebpf. But the ebpf prog loader throws a error message: 221: (85) call bpf_l4_csum_replace#11 unknown func bpf_l4_csum_replace#11 What does it mean ? How to solve it ? Thanks.
lrouter
  • 349
  • 1
  • 5
  • 20
2
votes
1 answer

How can I redirect traffic from one port to another in the same interface?

I need the traffic that gets into the docker container to a specific port to be redirected to another container, the ip of which I know, to another port using xdp. For this, I change the checksum of the iphdr structure: // Backup old dest address …
2
votes
1 answer

eBPF tools - skb_network_header crashes in a BPF Kernel trace function

I am looking to trace ip_forward_finish. The intent is to trace latency of all TCP connections going through a linux based gateway router. Hence thought of tracing ip_forward_finish kernel function. And capture the time-stamp of SYN, SYN-ACK and…
Vignesh
  • 21
  • 1