github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/socket_packet.txt (about) 1 # Copyright 2017 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 # http://man7.org/linux/man-pages/man7/packet.7.html 5 # https://www.kernel.org/doc/Documentation/networking/packet_mmap.txt 6 7 # AF_PACKET support. 8 9 include <linux/socket.h> 10 include <linux/net.h> 11 include <linux/if_ether.h> 12 include <linux/if_arp.h> 13 14 define ETH_P_ALL_BE htons(ETH_P_ALL) 15 16 resource sock_packet[sock] 17 18 socket$packet(domain const[AF_PACKET], type flags[packet_socket_type], proto const[ETH_P_ALL_BE]) sock_packet 19 bind$packet(fd sock_packet, addr ptr[in, sockaddr_ll], addrlen len[addr]) 20 connect$packet(fd sock_packet, addr ptr[in, sockaddr_ll], addrlen len[addr]) 21 accept$packet(fd sock_packet, peer ptr[out, sockaddr_ll, opt], peerlen ptr[inout, len[peer, int32]]) sock_packet 22 accept4$packet(fd sock_packet, peer ptr[out, sockaddr_ll, opt], peerlen ptr[inout, len[peer, int32]], flags flags[accept_flags]) sock_packet 23 24 sendto$packet(fd sock_packet, buf buffer[in], len len[buf], f flags[send_flags], addr ptr[in, sockaddr_ll, opt], addrlen len[addr]) 25 recvfrom$packet(fd sock_packet, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_ll, opt], addrlen len[addr]) 26 getsockname$packet(fd sock_packet, addr ptr[out, sockaddr_ll], addrlen ptr[inout, len[addr, int32]]) 27 getpeername$packet(fd sock_packet, peer ptr[out, sockaddr_ll], peerlen ptr[inout, len[peer, int32]]) 28 29 packet_socket_type = SOCK_RAW, SOCK_DGRAM 30 packet_protocols = ETH_P_802_3, ETH_P_AX25, ETH_P_ALL, ETH_P_802_2, ETH_P_SNAP, ETH_P_DDCMP, ETH_P_WAN_PPP, ETH_P_PPP_MP, ETH_P_LOCALTALK, ETH_P_CAN, ETH_P_CANFD, ETH_P_PPPTALK, ETH_P_TR_802_2, ETH_P_MOBITEX, ETH_P_CONTROL, ETH_P_IRDA, ETH_P_ECONET, ETH_P_HDLC, ETH_P_ARCNET, ETH_P_DSA, ETH_P_TRAILER, ETH_P_PHONET, ETH_P_IEEE802154, ETH_P_CAIF, ETH_P_XDSA 31 32 sockaddr_ll { 33 sll_family const[AF_PACKET, int16] 34 sll_protocol flags[packet_protocols, int16be] 35 sll_ifindex ifindex 36 sll_hatype const[ARPHRD_ETHER, int16] 37 sll_pkttype int8 38 sll_halen const[6, int8] 39 sll_addr mac_addr 40 pad array[const[0, int8], 2] 41 } 42 43 # Generic options 44 45 packet_option_types_int = PACKET_RECV_OUTPUT, PACKET_COPY_THRESH, PACKET_AUXDATA, PACKET_ORIGDEV, PACKET_VERSION, PACKET_HDRLEN, PACKET_RESERVE, PACKET_LOSS, PACKET_VNET_HDR, PACKET_TX_TIMESTAMP, PACKET_TIMESTAMP, PACKET_FANOUT, PACKET_TX_HAS_OFF, PACKET_QDISC_BYPASS 46 47 packet_option_types_buf = PACKET_ADD_MEMBERSHIP, PACKET_DROP_MEMBERSHIP, PACKET_RX_RING, PACKET_STATISTICS, PACKET_TX_RING, PACKET_FANOUT_DATA 48 49 getsockopt$packet_int(fd sock_packet, level const[SOL_PACKET], optname flags[packet_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]]) 50 setsockopt$packet_int(fd sock_packet, level const[SOL_PACKET], optname flags[packet_option_types_int], optval ptr[in, int32], optlen len[optval]) 51 getsockopt$packet_buf(fd sock_packet, level const[SOL_PACKET], optname flags[packet_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]]) 52 setsockopt$packet_buf(fd sock_packet, level const[SOL_PACKET], optname flags[packet_option_types_buf], optval buffer[in], optlen len[optval]) 53 54 # Specific options 55 56 packet_mreq { 57 mr_ifindex ifindex 58 mr_type const[ARPHRD_ETHER, int16] 59 mr_alen len[mr_address, int16] 60 mr_address mac_addr 61 pad array[const[0, int8], 2] 62 } 63 64 setsockopt$packet_add_memb(fd sock_packet, level const[SOL_PACKET], optname const[PACKET_ADD_MEMBERSHIP], optval ptr[in, packet_mreq], optlen len[optval]) 65 setsockopt$packet_drop_memb(fd sock_packet, level const[SOL_PACKET], optname const[PACKET_DROP_MEMBERSHIP], optval ptr[in, packet_mreq], optlen len[optval]) 66 67 tpacket_req { 68 tp_block_size int32 69 tp_block_nr int32 70 tp_frame_size int32 71 tp_frame_nr int32 72 } 73 74 tpacket_req3 { 75 tp_block_size int32 76 tp_block_nr int32 77 tp_frame_size int32 78 tp_frame_nr int32 79 tp_retire_blk_tov int32 80 tp_sizeof_priv int32 81 tp_feature_req_word int32 82 } 83 84 tpacket_req_u [ 85 req tpacket_req 86 req3 tpacket_req3 87 ] [varlen] 88 89 setsockopt$packet_rx_ring(fd sock_packet, level const[SOL_PACKET], optname const[PACKET_RX_RING], optval ptr[in, tpacket_req_u], optlen len[optval]) 90 setsockopt$packet_tx_ring(fd sock_packet, level const[SOL_PACKET], optname const[PACKET_TX_RING], optval ptr[in, tpacket_req_u], optlen len[optval]) 91 92 packet_fanout_types = PACKET_FANOUT_HASH, PACKET_FANOUT_LB, PACKET_FANOUT_CPU, PACKET_FANOUT_ROLLOVER, PACKET_FANOUT_RND, PACKET_FANOUT_QM, PACKET_FANOUT_CBPF, PACKET_FANOUT_EBPF, PACKET_FANOUT_FLAG_ROLLOVER, PACKET_FANOUT_FLAG_DEFRAG, PACKET_FANOUT_FLAG_UNIQUEID 93 94 # TODO: Add descriptions 95 _ = PACKET_MR_MULTICAST, PACKET_MR_PROMISC, PACKET_MR_ALLMULTI, PACKET_MR_UNICAST 96 97 packet_fanout_val { 98 id int16[0:4] 99 type flags[packet_fanout_types, int16] 100 } 101 102 setsockopt$packet_fanout(fd sock_packet, level const[SOL_PACKET], optname const[PACKET_FANOUT], optval ptr[in, packet_fanout_val], optlen len[optval]) 103 104 setsockopt$packet_fanout_data(fd sock_packet, level const[SOL_PACKET], optname const[PACKET_FANOUT_DATA], optval ptr[in, sock_fprog], optlen len[optval])