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

Kprobe BPF programs execution order

Is there a reliable way to explicitly specify BPF kprobe programs execution order (without kretprobes). For example, when I name programs like kprobe___1 and kprobe___2 I get an execution order like kprobe___2 -> kprobe___1,…
Tim
  • 25
  • 2
2
votes
1 answer

Elements incorrectly evicted from eBPF LRU hash map

I observe that elements are incorrectly evicted in an eBPF LRU hash map (BPF_MAP_TYPE_LRU_HASH). In the following code I insert into an LRU hash map of size 8 and print its contents every second: package main import ( "fmt" …
user2233706
  • 6,148
  • 5
  • 44
  • 86
2
votes
1 answer

How to create slice of LPM trie record for IPs/CIDRs

I am trying to use the BatchUpdate and BatchDelete API from https://github.com/cilium/ebpf/blob/master/map.go#L952-L1038. from my understanding, I need to create slice of LPM trie of IPs/CIRDs, for example: if I have denyIPs :=…
99Linux
  • 176
  • 1
  • 2
  • 12
2
votes
1 answer

How to get bpftool to attach a program to a tracepoint?

I have the following simple eBPF program: #include "vmlinux.h" #include struct sys_enter_execve_ctx { unsigned short common_type; unsigned char common_flags; unsigned char common_preempt_count; int common_pid; int…
2
votes
0 answers

How can I attach sock_ops bpf prog to cgroup v1?

For cgroup v2, I can attach sock_ops to unified cgroup via following command bpftool cgroup attach "/sys/fs/cgroup/unified/" sock_ops pinned "/sys/fs/bpf/bpf_sockops" Is it possible that sock_ops is attached to cgroup v1? How can I attach sock_ops…
2
votes
1 answer

Can I use eBPF to replace a kernel function?

Can I use eBPF to reimplement a kernel function and jump to the reimplemented function when the original function is called, skipping the original function altogether? For example, there is a kernel function A: void A() { xxx; } Can I use eBPF…
ray
  • 43
  • 3
2
votes
0 answers

How to emulate network failures (chaos testing) on clusters with cilium

Could you please provide me the information about the available tools for emulating network failures on Cilium/eBPF-based Service Mesh solutions? Previously I used Chaos Mesh https://chaos-mesh.org/ but emulating network-related issues (packet delay…
hoozgo
  • 21
  • 4
2
votes
1 answer

bpftrace single-line commands are not working in wsl ubuntu

I am new to eBPF, kernel tracing, etc. I really just wanted a simple intro to eBPF while learning Rust / Aya eBPF tools / Solana blockchain. My Windows version: Version 10.0.19043 Build 19043 Output of "wsl -l -v" is: NAME STATE …
ecorrales
  • 137
  • 11
2
votes
1 answer

why eBPF programs need some passes to get jited code?

I'm new to eBPF, I am reading the source code from linux kernel tree arch/x86/net/bpf_jit_comp.c. I noticed there are some passes needed for the final jited image. I'm very confused about this. Toturial says JITed image shrinks with every pass and…
Nicholas
  • 127
  • 1
  • 11
2
votes
0 answers

Tracepoints not available from network namespace

I want to use the linux tracepoints for a bpf application. However when I enter a network namespace no tracepoints/tracing events are available, e.g. ls /sys/kernel/tracing is empty. Why is that and how can I access them from a network…
marxlaml
  • 321
  • 2
  • 11
2
votes
1 answer

What is the difference between BPF and eBPF?

I'm new to eBPF, and there are a lot of tutorials saying eBPF is just the extended BPF, but I cannot understand what extended mean? So what is the difference between BPF and eBPF? Are the samples resides in Linux source file [root]/samples/bpf…
Nicholas
  • 127
  • 1
  • 11
2
votes
2 answers

ebpf tail call didn't work even bpf code is loaded successfully

#include "bpf/bpf_helpers.h" #include char _license[] SEC("license") = "GPL"; struct bpf_map_def SEC("maps") jump_table = { .type = BPF_MAP_TYPE_PROG_ARRAY, .key_size = sizeof(__u32), .value_size = sizeof(__u32), …
2
votes
0 answers

got unknown stack while capturing go binary exit point with bpftrace

I want to practice bpftrace tracing go program exit point, such as, runtime.gopanic and os.Exit, but I'm confused with the result: [root@localhost trace-go-func]# bpftrace -c "./binary -mode exit -code 2" trace.bt Attaching 2 probes... mode=exit,…
yeqown
  • 21
  • 4
2
votes
1 answer

What is the difference between syscalls openat and sys_enter_openat?

I see for python BCC implementation the syscall __x64_sys_openat is used to attach a kprobe, however in libbpf implementation a kprobe is attached to sys_enter_openat. It seems both capture openat() syscall, I tested it with cat file.txt. What is…
phoxd
  • 1,546
  • 3
  • 12
  • 26
2
votes
1 answer

Unable to initialize BPF_MAP_TYPE_PERCPU_ARRAY

Here's how I'm trying to initialize a BPF_MAP_TYPE_PERCPU_ARRAY of structs to a default value. The array contains counters the user space program will read. #include #include struct xdp_stats_t { __u64…
user2233706
  • 6,148
  • 5
  • 44
  • 86