|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
Shared per-interface BPF objects for the AF_XDP driver: one XSKMAP plus redirect-filter program plus link per ifindex, shared by every per-queue XSK socket (wired_srvxdp). More...
#include "common/platform/sys/syscall.h"Go to the source code of this file.
Data Structures | |
| struct | wired_srvxdpbpf |
| The three kernel objects backing one interface's redirect filter. More... | |
Macros | |
| #define | WIRED_SRVXDPBPF_MAP_ENTRIES 64u |
| Max XSKMAP entries = max NIC queues servable per interface. | |
Functions | |
| i64 | wired_srvxdpbpf_open (wired_srvxdpbpf *b, u32 ifindex, u16 port, u32 attach_flags) |
| Create the XSKMAP (WIRED_SRVXDPBPF_MAP_ENTRIES slots), build and load the redirect-filter program around it (xdpbpf_prog_build, dport == port), and attach it to the interface with a BPF link. | |
| i64 | wired_srvxdpbpf_register (wired_srvxdpbpf *b, u32 queue_id, u32 xsk_fd) |
| Point the map's queue_id slot at an XSK socket fd, so frames arriving on that NIC queue are redirected to that socket. | |
| void | wired_srvxdpbpf_close (wired_srvxdpbpf *b) |
| Close the link, program and map fds in that order (negative fds are skipped) and reset each to -1. | |
Shared per-interface BPF objects for the AF_XDP driver: one XSKMAP plus redirect-filter program plus link per ifindex, shared by every per-queue XSK socket (wired_srvxdp).
The kernel allows only one XDP link per interface (a second BPF_LINK_CREATE is -EBUSY), so multi-queue servers open this object once per interface and register each queue's XSK socket into its map; the program already redirects by rx_queue_index.
| void wired_srvxdpbpf_close | ( | wired_srvxdpbpf * | b | ) |
Close the link, program and map fds in that order (negative fds are skipped) and reset each to -1.
Safe to call repeatedly.
| b | shared BPF objects to tear down |
| i64 wired_srvxdpbpf_open | ( | wired_srvxdpbpf * | b, |
| u32 | ifindex, | ||
| u16 | port, | ||
| u32 | attach_flags ) |
Create the XSKMAP (WIRED_SRVXDPBPF_MAP_ENTRIES slots), build and load the redirect-filter program around it (xdpbpf_prog_build, dport == port), and attach it to the interface with a BPF link.
On any failure, everything already built is closed in reverse order and every fd is left at -1.
| b | output; all three fds valid on success, -1 on failure |
| ifindex | network interface to attach to |
| port | UDP destination port the filter redirects |
| attach_flags | 0 = native XDP, XDP_FLAGS_SKB_MODE(2) = generic/veth |
| i64 wired_srvxdpbpf_register | ( | wired_srvxdpbpf * | b, |
| u32 | queue_id, | ||
| u32 | xsk_fd ) |
Point the map's queue_id slot at an XSK socket fd, so frames arriving on that NIC queue are redirected to that socket.
| b | open shared BPF objects for the socket's interface |
| queue_id | NIC RX queue index (key into the XSKMAP) |
| xsk_fd | AF_XDP socket fd bound to that queue |