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

BPF / XDP: 'bpftool batch file' returns 'Error: reading batch file failed: Operation not permitted'

I have a docker container with an XDP program loaded on it. I also have a batch file for the bpftool to run. When I run bpftool batch file tmp_bpftool.txt, I get Error: reading batch file failed: Operation not permitted. I am the root in the…
Ferrar
  • 65
  • 7
1
vote
1 answer

xdpoffload attach failed: Invalid argument

When I try to attach a BPF program in XDP offload mode, I get Invalid argument. I get the same error if attach through code or by using bpftool. Here's how I'm attaching using netlink: err = netlink.LinkSetXdpFdWithFlags(link,…
user2233706
  • 6,148
  • 5
  • 44
  • 86
1
vote
2 answers

Invalid access to packet even though check made before access

I get invalid access to packet from the eBPF verifier even though I'm performing a check before accessing a byte from a packet. The offset is stored in a BPF_MAP_TYPE_ARRAY. The number of loop iterations don't matter because this problem happens…
user2233706
  • 6,148
  • 5
  • 44
  • 86
1
vote
2 answers

BPF verifier fails because of invalid access to 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: invalid access to packet struct server_name { char…
user2233706
  • 6,148
  • 5
  • 44
  • 86
1
vote
1 answer

XDP program not capturing all ingress packets

The following XDP program does not capture all ingress XDP packets. I store the source IP in a hash table as the key and value as the number of times that IP is seen. #include #include #include…
user2233706
  • 6,148
  • 5
  • 44
  • 86
1
vote
1 answer

how exactly bpf redirect with BPF_MAP_TYPE_CPUMAP array?

i have a question about how exactly bpf redirect working BPF_MAP_TYPE_CPUMAP array, i saw it's a new feture on xdp-project repo and read are adding ability to run another (2nd) XDP-prog on the remote CPU the XDP packets is getting redirected to, i…
walid barakat
  • 455
  • 1
  • 6
  • 17
1
vote
1 answer

XDP alternate to bpf_get_current_pid

How do I fetch current process id in xdp my program: #include #include #include #include #include #include #include #include…
zexapod
  • 45
  • 6
1
vote
1 answer

What is the event that XDP socket is attached to?

I am developing a kernel module that registers to the receive handler like this: rx_handler_result_t rxhPacketIn(struct sk_buff **ppkt) However, when I tried to use this kernel module program with XDP program from XDP-tutorial 1, the kernel module…
Que0Le
  • 84
  • 5
1
vote
0 answers

How to assign value from string to struct in6_addr inside ebpf (XDP) kernel program?

I am trying to assign value to struct in6_addr from inside my XDP program. From user space it can be done using struct in6_addr in6 = {}; inet_pton(AF_INET6, "fc00:dead:cafe:2::1", &in6); But it seems inet_pton is not available inside eBPF. Is…
Vikas.Maurya
  • 50
  • 1
  • 6
1
vote
4 answers

Detect VLAN tagged packets using XDP eBPF

I am trying to detect packets with a VLAN tag. I have some PCAP files to containing VLAN tagged packets to test. A Wireshark screenshot of a sample packet: After reading some tutorials, I wrote the following code: #include #include…
a5hk
  • 7,532
  • 3
  • 26
  • 40
1
vote
0 answers

Redirect between taps using XDP

I am trying to use xdp to redirect network traffic between VM taps. I notice that when I load the xdp program, the network is much slower (130 Mbits/sec) from when I am loading the same code on the vmbr (4.5 Gbits/sec). I cannot understand what…
Lidorelias3
  • 27
  • 1
  • 10
1
vote
1 answer

XDP and sk_buff

I started coding in ebpf and XDP. I am using python bcc to load the XDP program to the NICs. I am trying to work with __sk_buff structure, but when I am trying to access any filed of skb the verifier failed to load the program. int xdp_test(struct…
Lidorelias3
  • 27
  • 1
  • 10
1
vote
0 answers

Can AF_XDP reinject data packets to the kernel?

I am a newcomer to ebpf and I am learning af_xdp recently. It was found that AF_XDP can efficiently capture data packets from kernelspace to userspace, but no relevant information was found to describe AF_XDP can reinject data to kernelspace. There…
1
vote
0 answers

XDP and eBPF performance with AMD EPYC CPU

I'm always running XDP applications on servers with Intel Xeon Gold CPU's, performance was always good and was not a problem - up to 125Mpps with 100 GbE MCX515A-CCAT network card and 2 CPU's inside 1U server. Today I was trying to make it work on…
1
vote
0 answers

Unicast/multicast packet using xdp/tc eBPF

I am trying to design a load balancer using ebpf. I want to transmit the incoming packet to different destinations (devices connected in the same network). Although I have used the clone_bpf_redirect() helper function to redirect the packet to…
Linux baby
  • 21
  • 1
  • 5