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
2 answers

Difference in eBPF XDP mode and Socket Filter Mode when parsing a packet header information

I was wondering if there's a difference between eBPF XDP and eBPF socket filter mode when parsing a packet header information. Say I want to retrieve a destination IP address and a source IP address from a packet header using eBPF. If there's no…
Rosè
  • 345
  • 2
  • 13
0
votes
1 answer

is it possible to build fragmented Ipv4 packet, and detect tear drop atack in xdp / ebpf program?

Well, i'm trying to realize tear drop atack packet filtering based on the eBPF and xdp driver. And i dont know how to do it... Is it possible to detect ipv4 fragment overlaping by using these instruments?
Ivan Kamynin
  • 51
  • 1
  • 6
0
votes
0 answers

samples/bpf/xdpsock_user.c:xsk_configure_socket:331: errno: 1/"Operation not permitted"

I have a similar issue to XDP program ip link error: Prog section rejected: Operation not permitted, except on Linux 5.4.0. I am able to run some XDP eBPF programs, but not AF_XDP: ➜ uname -r 5.4.0 ➜ sudo strace -e bpf ./xdpsock -i eth0 -t -q1…
akn320
  • 573
  • 4
  • 13
0
votes
2 answers

BPF cgroup device controller program problem with map

I want to pass data between user/kernel side with BPF_PROG_TYPE_CGROUP_DEVICE I have defined map as: struct bpf_map_def SEC("maps") my_map = { .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(int), .value_size = sizeof(int), …
0
votes
0 answers

Is there a way to lookup for a specific value in the entire BPF map?

Hi I'm doing some experiments with eBPF. I need to iterate through all the values in the BPF map and check if such value exists in the map from the kernel space. However, to my understanding eBPF verifier wouldn't load programs into the kernel if it…
Rosè
  • 345
  • 2
  • 13
0
votes
1 answer

How to drop skb_buff use ebpf/bcc?

I am running the bcc example /http_filter/http-parse-simple.c, in which a comment explains: /* eBPF program. Filter IP and TCP packets, having payload not empty and containing "HTTP", "GET", "POST" ... as first bytes of payload if the…
Vector
  • 67
  • 1
  • 5
0
votes
0 answers

EBPF probe for compiled inlined function

Id like to create an EBPF program for Golang that records when a function is entered and returns. Some issues I have: A. Functions are inlined. B. Closures are anonymous. C. Reading Golang structs. Questions: A. In my case its not possible to…
zino
  • 1,222
  • 2
  • 17
  • 47
0
votes
0 answers

stdio.h header not working with eBPF kernel program

I'm trying to see if I can use stdio.h with a simple XDP code that blocks every packet. #include #include int main() { return XDP_DROP; } This code works without stdio.h but it wouldn't compile…
Rosè
  • 345
  • 2
  • 13
0
votes
1 answer

How to account for VFS operations at the block device layer?

I want to measure how much could be gained by placing some of a filesystem data on a fast device, vs regular spinning disks. As an example, measure extended attribute (xattr) operations, vs regular reads and writes. I started with the "bpftrace"…
0
votes
1 answer

libseccomp patch for hash maps

Has this patch been merged or rejected? Or the discussion has just ended without evolving? Maybe the fact that seccomp filters can be rewritten as binary trees is enough to don't add hash maps support for…
Maicake
  • 1,046
  • 10
  • 34
0
votes
2 answers

Does BPF_PROG_RUN implements the fallback ebpf interpreter?

https://github.com/torvalds/linux/blob/33920f1ec5bf47c5c0a1d2113989bdd9dfb3fae9/include/linux/filter.h#L556-L571 is this the implementation of the ebpf fallback interpreter?
Maicake
  • 1,046
  • 10
  • 34
0
votes
1 answer

net/core/filter.c and linux/bpf/verifier.c

If I understood well initially the cBPF verifier and interpreter were both within net/core/fiter.c for example sk_run_filter here https://elixir.bootlin.com/linux/v3.2/source/net/core/filter.c#L112 just convert the cBPF instructions applying them on…
Maicake
  • 1,046
  • 10
  • 34
0
votes
1 answer

Why load_half is defined in bpf_helpers but it doesn't appear in filter.c?

If I understood "well" within tools/testing/selftests/bpf/bpf_helpers.h bpf heleprs prototypes are defined. If I want to now which helpers are usable with a specific program type I need to search within the results of 'func_proto(enum bpf_func_id…
Maicake
  • 1,046
  • 10
  • 34
0
votes
1 answer

Can't access correctly to tracepoint context struct fields

GOAL: write in the trace_pipe only if openat is called with O_RDONLY flag. I've build the struct looking the format contained here /sys/kernel/debug/tracing/events/syscalls/sys_enter_open/format PROBLEM I think I'm not accessing to the flags field …
Maicake
  • 1,046
  • 10
  • 34
0
votes
1 answer

tracepoint/syscalls/sys_enter doesn't trigger bpf_trace_printk

GOAL: print Hello every time a system call is executed. CODE: _kern.c #include #include "bpf_helpers.h" SEC("tracepoint/syscalls/sys_enter") int bpf_sys(struct syscalls_enter_open_args *ctx) { char fmt[] = "Hello\n"; …
Maicake
  • 1,046
  • 10
  • 34