Questions tagged [xdp-bpf]

XDP/BPF and AF_XDP. XDP (eXpress Data Path) is a component of the Linux kernel working in collaboration with the networking stack to enable fast packet processing. It can be used to run BPF programs on packets at the driver level, just as they exit the NIC and before they reach the stack. Or, as AF_XDP sockets, it can be use to efficiently filter and drive packets to user space applications.

XDP (eXpress Data Path) is a component of the Linux kernel working in collaboration with the networking stack to enable fast packet processing. It can be used to run BPF programs on packets at the driver level, just as they exit the NIC (Network Interface Card) and before they reach the stack. Or, as AF_XDP sockets, it can be used to efficiently filter and drive packets to user space applications.

XDP itself mostly consists in hooks for BPF programs in network card drivers. BPF is documented in the Linux kernel documentation or as part of the Cilium documentation. There is also a tutorial to get started with XDP.

Documentation on AF_XDP can be found within the Linux kernel documentation. Assistance can also be found in the xdp-newbies mailing list.

151 questions
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
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
4
votes
0 answers

How to share BPF maps between two kernel space BPF programs?

Before I present my matter; I have read this Map sharing between different ebpf program types previously asked question which does not seem to answer my question. Now, what I am doing is, I have two BPF programs, one for XDP and other for TC (No…
Zarrar
  • 63
  • 3
4
votes
1 answer

bpf_xdp_adjust_meta() returns errcode -13 (permission denied)

Problem: bpf_xdp_adjust_meta(ctx, -delta); is returning error code -13 (permission denied) when delta > 32. But BPF and XDP Reference Guide states that there are 256 bytes headroom for metadata. So did I misunderstand something or how can I use 256…
n1kb3rt
  • 111
  • 1
  • 8
3
votes
1 answer

Thread safe operations on XDP

I was able to confirm from the documentation that bpf_map_update_elem is an atomic operation if done on HASH_MAPs. Source (https://man7.org/linux/man-pages/man2/bpf.2.html). [Cite: map_update_elem() replaces existing elements atomically] My question…
Rishab
  • 73
  • 4
3
votes
1 answer

eBPF: 'bpf_map_update()' returns the 'invalid indirect read from stack' error

I have an eBPF program with the following map definitions: struct bpf_map_def SEC("maps") servers = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(struct ip_key), .value_size = sizeof(struct dest_info), .max_entries =…
Ferrar
  • 65
  • 7
3
votes
1 answer

BPF verifier says program exceeds 1M instruction

For the following program I get an error from the verifier saying that it exceeds 1M instructions, even though it shouldn't. The program finds the hostname of a HTTP packet. #include #include struct server_name { …
user2233706
  • 6,148
  • 5
  • 44
  • 86
3
votes
1 answer

BPF verification error when trying to extract SNI from TLS packet

I am trying to get the server name from the SNI extension of a TLS hello packet in a XDP program. When I try to load it, I get the following error from the BPF verifier: math between pkt pointer and register with unbounded min value is not…
user2233706
  • 6,148
  • 5
  • 44
  • 86
3
votes
1 answer

bpf_prog_test_run() causes unexpected packet data

I try to perform a test run for an XDP BPF program. The BPF program uses the bpf_xdp_adjust_meta() helper, to adjust the meta data. I tried: to run bpf_prog_test_run() to run bpf_prog_test_run_xattr() 1. bpf_prog_test_run() (The first time I…
n1kb3rt
  • 111
  • 1
  • 8
3
votes
1 answer

Low throughput with XDP_TX in comparison with XDP_DROP/REDIRECT

I have developed a XDP program that filters packets based on some specific rules and then either drops them (XDP_DROP) or redirects them (xdp_redirect_map) to another interface. This program was well able to process a synthetic load of ~11Mpps…
Marcus Wichelmann
  • 762
  • 1
  • 6
  • 18
3
votes
1 answer

How to share a ebpf map between interfaces

Is it possible to share an ebpf Map between two network interfaces. I want to write an XDP program and hook it on two devices namely eth0 and eth1. The implementation requires that they both use the same map. Is it possible to load the same program,…
WIOUW
  • 113
  • 1
  • 2
  • 7
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
2 answers

XDP/BPF: Is there an user-space alternative to `bpf_ktime_get_ns`?

I want to insert a timestamp into the packets I receive in my XDP program. The only way I know how to get a timestamp is by calling bpf_ktime_get_ns. But what would be the user-space equivalent function which creates comparable timestamps? As far as…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
3
votes
1 answer

how to forward packet between NIC and WIFI using XDP

I am trying to redirect the traffic between NIC and WIFI. I am trying to forwards packets from eth0, to send even packets through wlan0 and odd packets through wlan1. I have not been able to successfully redirect packets from one interface to…
Gef
  • 73
  • 8
3
votes
1 answer

XDP program ip link error: Prog section rejected: Operation not permitted

I try to get into XDP, for this I have this very small program: // SPDX-License-Identifier: GPL-2.0 #include #include "bpf/bpf_helpers.h" #include "xdpsock.h" struct { __uint(type, BPF_MAP_TYPE_ARRAY); __uint(max_entries,…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
1
2 3
9 10