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
3
votes
1 answer

BPF Ring Buffer Invalid Argument (-22)?

I wanted to use eBPF's latest map, BPF_MAP_TYPE_RINGBUF, but I can't find much information online on how I can use it, so I am just doing some trial-and-error here. I defined and used it like this: struct bpf_map_def SEC("maps") r_buf = { .type…
vanbastelaer
  • 368
  • 2
  • 15
3
votes
4 answers

how xdp ebpf change checksum tcphdr after update dest port

how xdp ebpf change checksum tcphdr after update dest port ? // Check tcp header size struct tcphdr *tcph = data + nh_off; nh_off += sizeof(struct tcphdr); if (data + nh_off > data_end) { return XDP_PASS; } tcph->dest = bpf_ntohs(5555); // ...…
3
votes
0 answers

bpftrace under VirtualBox

I'd like to run bpftrace under Ubuntu on VirtualBox. Unfortunately, I get $ sudo bpftrace -e 'tracepoint:syscalls:sys_enter_open { printf("%s %s\n", comm, str(args->filename)); }' Kernel lockdown is enabled and set to 'confidentiality'. Lockdown…
Yoric
  • 3,348
  • 3
  • 19
  • 26
3
votes
2 answers

How to trace a fix process’s wakeup latency?

I want to use ftrace to trace a fix process’s wakeup latency. But, ftrace will only record the max latency. And, set_ftrace_pid is useless. Does anybody know how to do that? Thank you very much.
Jams.Liu
  • 493
  • 1
  • 4
  • 13
3
votes
1 answer

Generate a executable from bcc python script

bcc uses python to compile ebpf programs, is there any convenient way to generate a executable file from these python scripts so that I can run these tracing programs on servers where clang and llvm environment are not installed?
Cauchy Schwarz
  • 747
  • 3
  • 10
  • 27
3
votes
1 answer

How to trace a go function with BPF (BCC)

I have some go-code (myclient). It looks somehow like this (here only the mypackage is relevant): package mypackage import ( ... func (o *Client) CreateUser(ctx context.Context, user *User, ...) (User, error) { ... if err != nil ... …
x4k3p
  • 1,598
  • 2
  • 22
  • 42
3
votes
1 answer

How to read stack trace kernelside in ebpf?

I would like to filter my ebpf with address in stack, by example if stack trace contain the address of _do_fork then write to map. I seen this https://www.kernel.org/doc/html/latest/bpf/bpf_design_QA.html#q-can-bpf-programs-access-stack-pointer…
LeChatP
  • 33
  • 5
3
votes
1 answer

golang, ebpf and functions duration

I'm playing with gobpf and have got an issue with calculating a duration of traced user-space function. I use bpf_ktime_get_ns() to read time and then trying to calculate delta, but got enormous numbers, though traced function sleeps just 1…
lesovsky
  • 326
  • 2
  • 14
3
votes
1 answer

eBPF implicit declaration of BPF Helper

I'm having an issue with compiling an eBPF program that I'm installing with TC. At the moment, it is only performing some basic mangling, which requires recalculating the IP checksum. I noticed in the BPF helpers, there is a function…
gsm
  • 389
  • 2
  • 10
3
votes
1 answer

Linux TC eBPF and concurency

Is there a limit to how much instances of an eBPF programs the kernel can run simultaneously on several CPUs (similar to the python GIL problem) In particular can eBPF tc programs work on multiple CPU simultaneously? How is locking of kernel…
Eric
  • 1,138
  • 11
  • 24
3
votes
1 answer

ebpf: intercepting function calls

I am reading about kprobes BPF program type, and am wondering if it is possible to not just intercept a function call for tracing purposes or collect some low-level information (registers, stack etc.), but substitute a call and execute instead of…
Mark
  • 6,052
  • 8
  • 61
  • 129
2
votes
1 answer

How to release a BPF map that was created by the bpftool?

I am a complete novice at anything ebpf but trying out some random ideas to get some knowledge. I've built the libbpf library downloaded from (https://github.com/libbpf/libbpf-bootstrap) and test bpftool at first. And then I tried to create a map by…
Leo Lang
  • 21
  • 1
2
votes
1 answer

How to debug an eBPF program that uses cilium/ebpf to write a go user program?

Thanks to those who came to check it out. Now I'm having some problems. The ebpf program I was facing was an eBPF program written in go's cilium/ebpf library. There was no problem compiling, but there was a problem with the runtime and the bpf…
2
votes
0 answers

How can I intercept HTTPS calls from Go with eBPF?

Existing solutions like openssl-tracer and sslsniff work by intercepting calls to shared libraries like openssl and nss. But Go has its own SSL library, so those solutions do not work for programs written in Go. How can I intercept calls from Go…
Evan Rolfe
  • 151
  • 1
  • 10
2
votes
0 answers

use atomic operations fail in ebpf

My environment: aarch64-linux-5.15.7 bpf compile tools: clang-11 bpf compile param: clang -g -target bpf -Wall -O2 -g3 -g -DBPF_CODE -ggdb -std=gnu99 -D__TARGET_ARCH_arm64 -Wno-compare-distinct-pointer-types Using libbpf…
Jefen
  • 21
  • 2