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

AF_XDP: Set `SO_TIMESTAMP` not supported for `SO_XDP`: Protocol not available

Why is setting SO_TIMESTAMP not supported for an AF_XDP socket? The user manual of my driver (mlnx 5.0) states that Incoming packets are time-stamped before they are distributed on the PCI depending on the congestion in the PCI buffers. To my…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
2
votes
1 answer

AF_XDP: `BPF_MAP_TYPE_XSKMAP` only has entries with `Operation not supported`

This is all my XDP / BPF kernel code: struct bpf_map_def SEC("maps") xsks_map = { .type = BPF_MAP_TYPE_XSKMAP, .key_size = sizeof(int), .value_size = sizeof(int), .max_entries = 64, /* Assume netdev has no more than 64 queues…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
2
votes
0 answers

How to set the number of cores/threads a XDP hook uses?

I am using a multi-producer single-consumer implementation on the user side to handle incoming data from a eBPF map from an XDP hook. However, in order to do this, I need to limit the number of cores the XDP hook can use to send information to the…
1
vote
1 answer

Output from trace pipe and perf_output are different

Im trying to get the IHL and Version fields from an IP header using XDP, and when I output these values to the trace pipe using bpf_trace_printk the values appear correct but using perf_output i get invalid values such as IPV = 0, IHL = 69. Code is…
1
vote
1 answer

PERCPU map performance gains when only reading from XDP

I write to eBPF maps of type BPF_MAP_TYPE_HASH and BPF_MAP_TYPE_ARRAY in user space and read the maps from an XDP program. Would I get performance improvements in the XDP program if I use BPF_MAP_TYPE_PERCPU_HASH and BPF_MAP_TYPE_PERCPU_ARRAY? In…
user2233706
  • 6,148
  • 5
  • 44
  • 86
1
vote
0 answers

Does NLM_F_DUMP on AF_XDP support filtering?

I'm issuing a SOCK_DIAG_BY_FAMILY DLM_F_DUMP on a NETLINK_INET_DIAG netlink socket for the AF_XDP family. I successfully get back a dump of the currently open XSKs. So I think I got the basics correct it seems. Now I want to query in some situations…
TheDiveO
  • 2,183
  • 2
  • 19
  • 38
1
vote
0 answers

bpf helpers: how to convert struct sock *sk to struct xdp_sock *?

Given a struct socket *sock I basically try to do the following: struct sock { struct sock_common __sk_common; } __attribute__((preserve_access_index)); struct socket { struct sock *sk; // sic! a pointer }…
TheDiveO
  • 2,183
  • 2
  • 19
  • 38
1
vote
1 answer

Sharing maps between same eBPF programs loaded onto different interfaces with libbpf

I want to load the same eBPF program for XDP hook onto different interfaces of a switch and all the programs should share the same map. I have gone through the post (exactly my target) post 1 and post 2. However, I could not get things up and…
1
vote
0 answers

Combined stack size too large error while loading eBPF program

I am trying to collect simple flow level statistics using eBPF program. I define a map as follows: struct { __uint(type, BPF_MAP_TYPE_HASH); __type(key, struct network_tuple_xdp); __type(value, struct flow_state_xdp); …
1
vote
1 answer

XDP driver mode on VM interface

Is driver mode available for an interface on a VM? On Virtualbox I could only load my XDP program in generic mode. Is this the case in general for all VMs? Since XDP driver mode support depends on whether the driver supports it, I'm wondering if…
user2233706
  • 6,148
  • 5
  • 44
  • 86
1
vote
1 answer

libbpf: map 'hash_map': unknown field 'values' in hash_map with struct as value

So I am compiling xdp program with hash map having struct in value struct hash_elem { int cnt; struct bpf_spin_lock lock; }; struct { __uint(type, BPF_MAP_TYPE_HASH); __uint(max_entries, 100); __uint(key_size, sizeof(__u32)); …
user786
  • 3,902
  • 4
  • 40
  • 72
1
vote
2 answers

kernel compilation error when CONFIG_DEBUG_INFO_BTF is enabled

FAILED: load BTF from vmlinux: No such file or directory make: *** [Makefile:1164: vmlinux] Error 255 make: *** Deleting file 'vmlinux' root@akb:/home/akb/SRC/net/net-next# I have to enable BTF for my BPF xdp program to work. Environment :on…
1
vote
1 answer

Linux Kernel 5.10 verifier rejects eBPF XDP program that is fine for kernel 5.13

I am writing some eBPF programs in Rust using redBPF and I've encountered some issue with the verifier that only appears on some kernels. This is a minimal reproducer XDP probe that shows the issue: #[xdp] unsafe fn xdp_test(ctx: XdpContext) ->…
Nummer378
  • 13
  • 2
1
vote
1 answer

Offloaded XDP program to Netronome Smart NIC unsupported function

I'm trying to offload a small EBPF program to the NIC that uses a map. I can lookup elements in the hash map, but when I add the command bpf_map_update_elem I get back an error when I attempt to load. 14: (85) call bpf_map_update_elem#2 [nfp]…
Thomas
  • 13
  • 2
1
vote
1 answer

Unable to fetch data using bpf_map_lookup_elem()

I am trying to write a code for XDP where a user space program will populate a bpf map and then later the Kernel will look into the map. For creating the map I have added a SEC(".maps") in the bpf_obj file that will get loaded into the kernel.…
Rishab
  • 73
  • 4
1 2
3
9 10