github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/socket_xdp.txt (about) 1 # Copyright 2018 syzkaller project authors. All rights reserved. 2 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 # AF_XDP support. 5 6 include <linux/net.h> 7 include <linux/socket.h> 8 include <uapi/linux/if_xdp.h> 9 10 resource sock_xdp[sock] 11 12 socket$xdp(domain const[AF_XDP], type const[SOCK_RAW], proto const[0]) sock_xdp 13 bind$xdp(fd sock_xdp, addr ptr[in, sockaddr_xdp_bind], len bytesize[addr]) 14 sendmsg$xdp(fd sock_xdp, msg ptr[in, msghdr_xdp], f flags[send_flags]) 15 mmap$xdp(addr vma, len len[addr], prot flags[mmap_prot], flags flags[mmap_flags], fd sock_xdp, offset flags[xdp_mmap_offsets]) 16 17 setsockopt$XDP_RX_RING(fd sock_xdp, level const[SOL_XDP], opt const[XDP_RX_RING], val ptr[in, flags[xdp_ring_sizes, int32]], len bytesize[val]) 18 setsockopt$XDP_TX_RING(fd sock_xdp, level const[SOL_XDP], opt const[XDP_TX_RING], val ptr[in, flags[xdp_ring_sizes, int32]], len bytesize[val]) 19 setsockopt$XDP_UMEM_FILL_RING(fd sock_xdp, level const[SOL_XDP], opt const[XDP_UMEM_FILL_RING], val ptr[in, flags[xdp_ring_sizes, int32]], len bytesize[val]) 20 setsockopt$XDP_UMEM_COMPLETION_RING(fd sock_xdp, level const[SOL_XDP], opt const[XDP_UMEM_COMPLETION_RING], val ptr[in, flags[xdp_ring_sizes, int32]], len bytesize[val]) 21 setsockopt$XDP_UMEM_REG(fd sock_xdp, level const[SOL_XDP], opt const[XDP_UMEM_REG], val ptr[in, xdp_umem_reg], len bytesize[val]) 22 23 getsockopt$XDP_MMAP_OFFSETS(fd sock_xdp, level const[SOL_XDP], opt const[XDP_MMAP_OFFSETS], val ptr[out, array[int8, XDP_MMAP_OFFSETS_SIZE]], len ptr[in, bytesize[val, int32]]) 24 getsockopt$XDP_STATISTICS(fd sock_xdp, level const[SOL_XDP], opt const[XDP_STATISTICS], val ptr[out, array[int8, XDP_STATISTICS_SIZE]], len ptr[in, bytesize[val, int32]]) 25 26 xdp_mmap_offsets = XDP_PGOFF_RX_RING, XDP_PGOFF_TX_RING, XDP_UMEM_PGOFF_FILL_RING, XDP_UMEM_PGOFF_COMPLETION_RING 27 xdp_ring_sizes = 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 1048576, 2097152, 16777216 28 29 sockaddr_xdp { 30 sxdp_family const[AF_XDP, int16] 31 sxdp_flags flags[sxdp_flags, int16] 32 sxdp_ifindex ifindex 33 sxdp_queue_id int32[0:64] 34 sxdp_shared_umem_fd const[0, int32] 35 } 36 37 sockaddr_xdp_bind { 38 sxdp_family const[AF_XDP, int16] 39 sxdp_flags flags[sxdp_flags, int16] 40 sxdp_ifindex ifindex 41 sxdp_queue_id int32[0:64] 42 sxdp_shared_umem_fd sock_xdp[opt] 43 } 44 45 sxdp_flags = XDP_SHARED_UMEM, XDP_COPY, XDP_ZEROCOPY, XDP_USE_NEED_WAKEUP 46 47 msghdr_xdp { 48 msg_name ptr[in, sockaddr_xdp, opt] 49 msg_namelen len[msg_name, int32] 50 msg_iov ptr[in, array[iovec_in]] 51 msg_iovlen len[msg_iov, intptr] 52 msg_control const[0, intptr] 53 msg_controllen const[0, intptr] 54 msg_flags flags[send_flags, int32] 55 } 56 57 xdp_umem_reg { 58 addr ptr64[out, array[int8]] 59 len flags[xdp_umem_sizes, int64] 60 chunk_size flags[xdp_umem_chunk_sizes, int32] 61 headroom int32 62 flags flags[xdp_umem_flags, int32] 63 } 64 65 xdp_umem_sizes = 4096, 8192, 16384, 32768, 65536, 131072, 1048576, 2097152, 16777216 66 xdp_umem_chunk_sizes = 2048, 4096 67 xdp_umem_flags = XDP_UMEM_UNALIGNED_CHUNK_FLAG, XDP_UMEM_USES_NEED_WAKEUP 68 69 define XDP_UMEM_USES_NEED_WAKEUP (1 << 1) 70 define XDP_MMAP_OFFSETS_SIZE sizeof(struct xdp_mmap_offsets) 71 define XDP_STATISTICS_SIZE sizeof(struct xdp_statistics) 72 73 _ = __NR_mmap2