FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
xdp_datagram_source.hpp File Reference

AF_XDP datagram source (ADR-0015, section 3): one XDP socket per (interface, RX queue), each with its own UMEM, fill and RX rings (the completion ring exists because bind requires it). More...

#include "fastmm/core/config_macros.hpp"
#include "fastmm/core/time.hpp"
#include "fastmm/net/datagram_source.hpp"
#include "fastmm/net/udp_frame.hpp"
#include "fastmm/net/xdp_program.hpp"
#include <sys/socket.h>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  fastmm::net::XdpSubscription
 
struct  fastmm::net::XdpInterfaceQueues
 
struct  fastmm::net::XdpConfig
 
struct  fastmm::net::XdpStats
 
struct  fastmm::net::XdpSocketStats
 XDP_STATISTICS of one socket, as of the last refresh_stats(). More...
 
struct  fastmm::net::XdpInterfaceStatus
 
class  fastmm::net::XdpFilter
 The BPF objects of one interface: subscription hash map, XSKMAP, per-CPU fallback counter and the program, plus its XDP link once attached. More...
 
class  fastmm::net::XdpDatagramSource
 

Namespaces

namespace  fastmm
 
namespace  fastmm::net
 

Enumerations

enum class  fastmm::net::XdpMode : std::uint8_t { fastmm::net::Auto , fastmm::net::ZeroCopy , fastmm::net::NativeCopy , fastmm::net::Generic }
 Attach and bind mode. More...
 

Functions

constexpr std::string_view fastmm::net::to_string (XdpMode m) noexcept
 
std::string fastmm::net::xdp_capability_error ()
 "" when the process has CAP_NET_ADMIN, CAP_NET_RAW, CAP_BPF (or CAP_SYS_ADMIN) and CAP_IPC_LOCK in its effective set; otherwise names the missing ones and the setcap command.
 
std::string fastmm::net::xdp_kernel_error ()
 "" on Linux 5.11 or later; otherwise the reason.
 

Detailed Description

AF_XDP datagram source (ADR-0015, section 3): one XDP socket per (interface, RX queue), each with its own UMEM, fill and RX rings (the completion ring exists because bind requires it).

A BPF program per interface, loaded and attached over raw bpf(2) calls, redirects UDP datagrams for the subscribed (group, port) pairs to the sockets and passes everything else to the kernel. A kernel UDP socket per multicast subscription joins the group so IGMP reports go out; it reads nothing. A unicast subscription is a local address (no join). Linux 5.11 or later; needs CAP_NET_ADMIN, CAP_NET_RAW, CAP_BPF and CAP_IPC_LOCK.

Single-threaded: open, poll and the stats calls belong to the net thread. poll() allocates nothing and returns every RX descriptor it took to the fill ring before it returns, so payload spans are valid only inside the handler call.