Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for syscalls required for AF_XDP #941

Closed
14 of 32 tasks
arctic-alpaca opened this issue Nov 23, 2023 · 1 comment
Closed
14 of 32 tasks

Support for syscalls required for AF_XDP #941

arctic-alpaca opened this issue Nov 23, 2023 · 1 comment

Comments

@arctic-alpaca
Copy link
Contributor

arctic-alpaca commented Nov 23, 2023

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
    • getsockopt(fd, SOL_XDP, XDP_MMAP_OFFSETS, *xdp_mmap_offsets, &optlen), xdp_mmap_offsets see structs
    • getsockopt(fd, SOL_XDP, XDP_STATISTICS, *xdp_statistics, &optlen), xdp_statistics see structs
    • getsockopt(fd, SOL_XDP, XDP_OPTIONS, *xdp_options, &optlen), xdp_options see structs
  • bind
    • bind(fd, *sockaddr_xdp, sizeof(sockaddr_xdp)), sockaddr_xdp see structs, bind with various addresses is already supported but not with sockaddr_xdp
  • if_indextoname
  • if_nametoindex (optional)

Constants:

Structs:

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 and bind I can orient myself at already existing syscalls in rustix but for if_indextoname and if_nametoindex, I'm unsure how to implement them.
@arctic-alpaca
Copy link
Contributor Author

With #946 and #972 merged, this is completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant