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
0
votes
0 answers

Using in prog_kern.c ebpf

I've seen that instead of using #include to have access to offsetof macro, ebpf programs conditionally define the macro inside the prog_kern.c file. Is it wrong to include stddef.h in prog_kern.c? If yes, why should I avoid it?
Maicake
  • 1,046
  • 10
  • 34
0
votes
1 answer

Ebpf:undefined symbol for helpers

I run an up to date debian testing (with kernel 4.19). Helpers are not found on my system (but they exist in the header, Qt jumps to them) #include "bpf/bpf.h" int main (){ int r = bpf_create_map(BPF_MAP_TYPE_ARRAY,1,1,1,0); return…
Larry
  • 1,735
  • 1
  • 18
  • 46
0
votes
2 answers

Exception: Failed to attach BPF to kprobe when executing sudo opensnoop-bpfcc

When I try to execute sudo opensnoop-bpfcc I get this message: In file included from /virtual/main.c:4: In file included from include/linux/sched.h:14: In file included from include/linux/pid.h:5: In file included from…
Maicake
  • 1,046
  • 10
  • 34
0
votes
1 answer

Error compiling eBPF C code out of kernel tree

I'm trying to build a BPF program written in C into the bpf bytecode needed to load it. I used this post to try to start me off: https://blogs.oracle.com/linux/notes-on-bpf-4 I do not want to use BCC due to the library dependency. I'm using ubuntu…
shaddow
  • 405
  • 1
  • 4
  • 19
0
votes
1 answer

Tried to learn eBPF tail call, fails to attach kprobe

Hi I'm trying to learn how to use eBPF maps so I tried to run the simple code I found on BCC document. import os import socket import time import logging import signal import sys import zmq import json import yaml import netifaces as ni from bcc…
Rosè
  • 345
  • 2
  • 13
0
votes
3 answers

Error trying to run XDP on my device driver

I'm trying to figure out how to run a XDP code: #include int main() { return XDP_PASS; } I'm trying to have XDP drop all the packets. So I compiled it as : clang -target bpf -c xdp.c -o xdp.o and my interface name is enp5s0. So I…
Rosè
  • 345
  • 2
  • 13
0
votes
0 answers

eBPF(BCC) destination IP address from kernel space and user space doesn't match

I'm using eBPF and BCC to print out IP addresses of the packets I'm receiving. For the kernel, I've programmed a code to print out from ip_t -> dst; which I assume it's an address of the destination. For the user space, I've programmed a code to…
Rosè
  • 345
  • 2
  • 13
0
votes
1 answer

eBPF / XDP fails to compile on Ubuntu 16.04.6

After upgrading Ubuntu 16.04, it's no longer possible to compile eBPF. The bpf.h file is missing key structs and the uapi headers don't seem to be installed. Sample code: #include int main() { return XDP_DROP; } Compiled with…
Ben Hall
  • 1,927
  • 5
  • 25
  • 39
0
votes
1 answer

EBPF Newbie: Need Help, facing an error while loading a EBF code

I wrote a bpf code and compiled with clang, while trying to load, I face an error. I am not able to understand why and how to resolve it, need experts advice. I am running this code in a VM OS : Ubuntu 18.04.2 Kernel : Linux 4.18.0-15-generic…
Fernando
  • 163
  • 1
  • 9
0
votes
0 answers

Why does adding an established TCP socket to a BPF_MAP_TYPE_SOCKMAP map break SSL?

I have the following BPF program: #include #include #include "bpf_helpers.h" #include "bpf_map.h" struct bpf_map_def SEC("maps/sock_ops") sock_ops = { .type = BPF_MAP_TYPE_SOCKMAP, .key_size =…
dippynark
  • 2,743
  • 20
  • 58
0
votes
1 answer

How can I work out the meaning of the return codes for BPF helper functions?

I am writing a BPF_PROG_TYPE_SOCKET_OPS program and I am seeing the following in /sys/kernel/debug/tracing/trace_pipe: <...>-12586 [001] .... 6972.409111: 0: update err: -95 when I load it due to the following snippet: ret =…
dippynark
  • 2,743
  • 20
  • 58
0
votes
1 answer

headers not working at a kernel level on eBPF code

So I'm developing something on eBPF. I needed to use the unistd.h header because I wanted to use sleep function. However, I realized that when I type in #include these headers don't get included and I would get an error saying: warning…
Rosè
  • 345
  • 2
  • 13
0
votes
1 answer

bpf/bcc reports error when trying to access `struct rq`

This is my bpf program to profile a kernel function pick_next_task_fiar. #include #include #include #include struct rq; // forward declaration struct val_t { …
Chen Wei
  • 392
  • 2
  • 12
0
votes
1 answer

Always get 0 session ID in BPF program

I am trying to write a BPF program that examines the session ID of any process that calls the tty_write kernel function. I am trying to do this by retrieving a field from the current task_struct struct. My code is as follows:…
dippynark
  • 2,743
  • 20
  • 58
0
votes
1 answer

fail to attach eBPF blob

I've just compiled BPF examples from kernel tools/testing/selftests/bpf and tried to load as explained in http://cilium.readthedocs.io/en/v0.10/bpf/: % tc filter add dev enp0s1 ingress bpf \ object-file…
Mark
  • 6,052
  • 8
  • 61
  • 129