Support for syscalls required for AF_XDP
arctic-alpaca opened this issue · 1 comments
arctic-alpaca commented
Hi,
I'm experimenting with AF_XDP and would love to use rustix
instead of libc
. For the BPF side of things, I use aya
, so only the non-BPF related syscalls remain. Some syscalls are already supported like mmap
and socket
but others would need to be implemented or expanded/modified. I created a list of missing syscalls, constants and structs. Most of the syscalls, etc were added in 4.18 with some additions and modifications in later kernel versions.
Syscalls:
- setsockopt
-
setsockopt(fd, SOL_XDP, XDP_UMEM_REG, umem_reg, sizeof(umem_reg))
,umem_reg
see structs -
setsockopt(fs, SOL_XDP, XDP_UMEM_FILL_RING, fill_size, sizeof(fill_size))
,fill_size
=u32
(https://github.com/torvalds/linux/blob/v6.6/net/xdp/xsk.c#L944) -
setsockopt(fs, SOL_XDP, XDP_UMEM_COMPLETION_RING, comp_size, sizeof(comp_size))
,comp_size
=u32
-
setsockopt(fs, SOL_XDP, XDP_RX_RING, rx_size, sizeof(rx_size))
,rx_size
=u32
-
setsockopt(fs, SOL_XDP, XDP_TX_RING, tx_size, sizeof(tx_size))
tx_size
=u32
-
- getsockopt
- bind
-
bind(fd, *sockaddr_xdp, sizeof(sockaddr_xdp))
,sockaddr_xdp
see structs,bind
with various addresses is already supported but not withsockaddr_xdp
-
-
if_indextoname
-
if_nametoindex
(optional)
Constants:
-
AF_XDP
-
PF_XDP
same asAF_XDP
-
SOL_XDP
- XDP socket options
- XDP offsets
- sockaddr_xdp map flags
- xsk_umem_config flags
- XDP_RING flags
- xdp_options flags
- masks for unaligned chunks mode
- xdp_desc options
Structs:
- sockaddr_xdp, used by
bind(fd, *sockaddr_xdp, sizeof(sockaddr_xdp))
- xdp_ring_offset / xdp_ring_offset_v1, used in
xdp_mmap_offsets
- xdp_mmap_offsets / xdp_mmap_offsets_v1, used by
getsockopt(...,XDP_MMAP_OFFSETS,...)
- xdp_umem_reg / umem_reg_v1 used by
setsockopt(...,XDP_UMEM_REG,...)
- xdp_desc, used by
mmap
assizeof(xdp_desc)
forXDP_PGOFF_{RX,TX}_RING
- xdp_statistics / xdp_statistics_v1, used by
getsockopt(...,XDP_STATISTICS,...)
- xdp_options, used by
getsockopt(...,XDP_OPTIONS,...)
If this is something you are interested in adding, I'd be happy to work on PR(s) to implement it but I would require some guidance:
- Some syscall parameters/returns come in two versions, how should this be implemented?
- Should kernel versions required for syscalls be listed?
- I'm unsure how testing can be done for things like
setsockopt
as I don't think there is a syscall to check their result. - For
{get,set}sockopt
andbind
I can orient myself at already existing syscalls inrustix
but forif_indextoname
andif_nametoindex
, I'm unsure how to implement them.
arctic-alpaca commented