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
23
votes
4 answers

Can eBPF modify the return value or parameters of a syscall?

To simulate some behavior I would like to attach a probe to a syscall and modify the return value when certain parameters are passed. Alternatively, it would also be enough to modify the parameters of the function before they are processes. Is this…
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
14
votes
2 answers

who creates map in BPF

After reading man bpf and a few other sources of documentation, I was under impression that a map can be only created by user process. However the following small program seems to magically create bpf map: struct bpf_map_def SEC("maps") my_map = { …
Mark
  • 6,052
  • 8
  • 61
  • 129
10
votes
2 answers

How can I get the bpf_helpers.h header file for my Linux kernel?

I am developing an eBPF program on an Ubuntu machine: $ uname -a Linux ubuntu-bionic 4.18.0-16-generic #17~18.04.1-Ubuntu SMP Tue Feb 12 13:35:51 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux To do this I need both bpf.h for a number of definitions as…
dippynark
  • 2,743
  • 20
  • 58
9
votes
1 answer

Testing XDP vs DPDK

I do have some experience with DPDK but currently I'm reading many blogs about XDP. I am trying to compare both technologies and understand the differences between DPDK and XDP. This raises some questions. I hope someone can help me with the…
pjk
  • 107
  • 1
  • 5
9
votes
4 answers

Is it possible to intercept unencrypted HTTPS request body of local programs?

Is it possible to write a single general EBPF program that can read the unencrypted HTTPS request and response bodies of all user space programs? As I understand it, EBPF works with packets for layers 2, 3 and 4 of the network. HTTPS payloads are…
zino
  • 1,222
  • 2
  • 17
  • 47
9
votes
1 answer

Map sharing between different ebpf program types

Is it possible to share ebpf maps between different program types. I need to share a map between a tc-bpf program and a cgroup bpf program. This should be possible if the map is pinned to file system that act as global namespace. But, I haven't got…
user1727270
  • 303
  • 1
  • 3
  • 10
8
votes
1 answer

Why is having an userspace version of eBPF interesting?

I've seen that userspace version of ebpf (runtime, assembler, dissasembler) are being developped (uBPF, rbpf). Why is having an userspace version of eBPF interesting ? Do those alternatives focus on the same goal than the eBPF program types…
Hugo REYMOND
  • 329
  • 1
  • 11
8
votes
2 answers

How to use seccomp filter with ebpf?

I'm looking for an example of eBPF to write a seccomp filter, but I can't find none. Could someone tell me if is possible to use eBPF to write seccomp filter?
Maicake
  • 1,046
  • 10
  • 34
8
votes
2 answers

Are loops allowed in Linux's BPF programs?

I am thinking of a solution of replicating packets in the kernel and forward to 5 hosts (unicast). Planning to utilize eBPF/XDP for it. I am trying to loop for 5 times, and inside the loop I am planning to clone the packet, modify the DST IP…
Fernando
  • 163
  • 1
  • 9
7
votes
1 answer

Output from bpf_printk()

While running some examples from samples/bpf I noticed that bpf_printk output is prepended with some extra information, e.g. : telnet-470 [001] .N.. 419421.045894: 0x00000001: BPF command: 2 BPF command: 2 is actual string passed to bpf_printk in…
Mark
  • 6,052
  • 8
  • 61
  • 129
6
votes
1 answer

How do you compute the performance impact of a eBPF probe?

eBPF has become a prominent tool to easily and quickly monitor processes. However, I was not able to find how would one compute the impact of the probe itself on the performance. I'm sure if I hook every syscall and push some information in a map,…
Dominus
  • 808
  • 11
  • 25
6
votes
1 answer

Dynamically Change eBPF map size

In the kernel, eBPF maps can be defined as: struct bpf_map_def SEC("maps") my_map = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(uint32_t), .value_size = sizeof(struct task_prov_struct), .max_entries = 4096, }; If I do not know…
vanbastelaer
  • 368
  • 2
  • 15
6
votes
1 answer

implicit declaration of function ‘bpf’

I have been studying BPF recently, but it is not proceeding because of a very basic problem. I included linux/bpf.h as described in man bpf(2), but GCC can not find bpf function. This code is just for the test to make sure that GCC can find bpf…
R00T3D
  • 65
  • 4
5
votes
1 answer

Getting PID of the connection owner in BPF_PROG_TYPE_SK_LOOKUP

I found an eBPF sample which proxies requests, which filter which requests to filter based on the target port. I'm trying to filter by the process_id of the client instead of the target port and tried adding the bpf_get_current_pid_tgid() here.…
Shubham Jain
  • 431
  • 3
  • 13
5
votes
2 answers

Test that an integer is different from two other integers in eBPF without branch opcodes

I'm writing an eBPF kprobe that checks task UIDs, namely that the only permitted UID changes between calls to execve are those allowed by setuid(), seteuid() and setreuid() calls. Since the probe checks all tasks, it uses an unrolled loop that…
patraulea
  • 652
  • 2
  • 5
  • 26
1
2 3
42 43