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
1
vote
1 answer

How to use XDP_REDIRECT in egress path?

How to use xdp_redirect in egress path? I know how use it by TC_ACT_REDIRECT but dont know by XDP_REDIRECT?
gbsec
  • 23
  • 4
1
vote
1 answer

Why dont bpf redirect work correctly?(XDP)

I write a simple Program Like this: SEC("tc_redirect") int _egress_redirect(struct __sk_buff *skb){ return bpf_redirect(5,0); // redirect all egress packets to interface 5 } # tc filter add dev (4) egress prio 1 handle 1 bpf da obj x.o sec…
gbsec
  • 23
  • 4
1
vote
1 answer

Failed to load XDP program inside a QEMU VM with custom (bridged) tap device

I'm recently trying to load XDP program inside a QEMU VM (with virtio-net-pci as NIC driver, and tap device as the backend). It seems that by doing so my NIC is required to features vCPU*2 of queues, which can be done by declaring it at QEMU startup…
Feng. Ma
  • 121
  • 8
1
vote
0 answers

Modify UDP packet payload with XDP, extending beyond received size

I'm wanting to use XDP_TX to re-transmit a packet received, whilst also modifying the packets content. I have swapped the dst and src ip address around so it successfully gets sent back to the sender, that's all working perfect. I however would like…
user1447762
  • 13
  • 1
  • 5
1
vote
1 answer

AF-XDP - How does `XDP_USE_NEED_WAKEUP` work e.g. "How to reduce ksoftirqd load"?

I try to maximize throughput on a single RX-Queue of my network card. My current setup is utilizing the Shared Umem feature by setting up multiple sockets on the same RX-Queue, each with a reference to the same Umem. My Kernel XDP-Program then…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
1
vote
1 answer

AF-XDP: Is there a bug regarding small packets?

Is there a known (or maybe unknown) bug regarding the size of packets in the AF-XDP socket framework (+ libbpf)? I am experiencing a strange packet loss for my application: IPv4/UDP/RTP packet stream with all packets being the same size (1442…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
1
vote
0 answers

how to capture packets sent by XDP user space program

Say I have XDP kernel and user programs. Kernel code examines ingress packets and "forwards" them to XDP user space program. XDP user space program then does some processing and sends packets out (could be same NIC or other one). For controlling…
Que0Le
  • 84
  • 5
1
vote
1 answer

AF_XDP: No packets for socket with queue-id 0 even though every packet is redirect

I am based on this tutorial: https://github.com/xdp-project/xdp-tutorial/tree/master/advanced03-AF_XDP I create a socket with Queue-ID 0 in userspace. In my kernel af-xdp program I filter for UDP-packets and redirect them to the userspace socket via…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
1
vote
0 answers

AF-XDP: Load kernel program only once but distribute access to xsks-map to multiple processes

As far as I understand there can only be one AF-XDP kernel program per network interface. I want to distribute packet processing from multiple multicast-addresses from a single network interface to several processes. I have written a…
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
1
vote
1 answer

How to properly utilize masks to send index information to perf event output?

According to the documentation for bpf_perf_event_output found here: http://man7.org/linux/man-pages/man7/bpf-helpers.7.html "The flags are used to indicate the index in map for which the value must be put, masked with BPF_F_INDEX_MASK." In the…
1
vote
0 answers

Get PID of XDP hook in userspace

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

How to get XDP program into kernel with iproute2?

I am using "ip link" command to put xdp program into kernel, in my virtual machine(kernel-version:4.18) command like this: ip link set dev ens33 xdp obj xdpsock_kern.o sec .text but after this command, the error said: No ELF library support…
Vector
  • 67
  • 1
  • 5
0
votes
1 answer

eBPF: Properly passing fixed length strings from userspace using eBPF array maps

I have a BPF_MAP_TYPE_ARRAY map that stores instances of this struct: struct target_d_name { unsigned long int len; char name[PID_LEN_MAX]; //PID_LEN_MAX = 8, it is a macro }; Here is the map definition: struct { …
vykt
  • 3
  • 2
0
votes
0 answers

Port.rx drop in Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+

I am currently working on writing an application on AF_XDP sockets. My goal was to reach line rate. The application is written using the cndp library (https://github.com/CloudNativeDataPlane/cndp) This is my setup for testing purpose. Server1 is the…
Gour DEV
  • 21
  • 4
0
votes
1 answer

Tap interface injected packet not received by application

I have written an application using AF_XDP sockets on eth0, currently all packets are received on the interface are received by the AF_XDP application (single queue nic). The application filters packet of specific port number all other packet are…
Gour DEV
  • 21
  • 4