github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/socket.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  include <asm/ioctls.h>
     5  include <linux/if_tun.h>
     6  include <linux/if_bridge.h>
     7  include <linux/net.h>
     8  include <linux/net_tstamp.h>
     9  include <linux/route.h>
    10  include <linux/socket.h>
    11  include <uapi/linux/in.h>
    12  include <uapi/linux/ethtool.h>
    13  include <uapi/linux/if_ether.h>
    14  include <uapi/linux/if_vlan.h>
    15  include <uapi/asm-generic/socket.h>
    16  
    17  resource sock[fd]
    18  type sock_port int16be[20000:20004]
    19  
    20  # TODO: describe socketcall syscall
    21  
    22  socket(domain flags[socket_domain], type flags[socket_type], proto int32) sock
    23  socketpair(domain flags[socket_domain], type flags[socket_type], proto int32, fds ptr[out, sock_pair])
    24  bind(fd sock, addr ptr[in, sockaddr_storage], addrlen len[addr])
    25  connect(fd sock, addr ptr[in, sockaddr_storage], addrlen len[addr])
    26  accept(fd sock, peer ptr[out, sockaddr_storage, opt], peerlen ptr[inout, len[peer, int32]]) sock
    27  accept4(fd sock, peer ptr[out, sockaddr_storage, opt], peerlen ptr[inout, len[peer, int32]], flags flags[accept_flags]) sock
    28  sendto(fd sock, buf buffer[in], len len[buf], f flags[send_flags], addr ptr[in, sockaddr_storage, opt], addrlen len[addr])
    29  recvfrom(fd sock, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_storage, opt], addrlen len[addr])
    30  getsockname(fd sock, addr ptr[out, sockaddr_storage], addrlen ptr[inout, len[addr, int32]])
    31  getpeername(fd sock, peer ptr[out, sockaddr_storage], peerlen ptr[inout, len[peer, int32]])
    32  
    33  sendmsg(fd sock, msg ptr[in, send_msghdr], f flags[send_flags])
    34  sendmmsg(fd sock, mmsg ptr[in, array[send_mmsghdr]], vlen len[mmsg], f flags[send_flags])
    35  recvmsg(fd sock, msg ptr[inout, recv_msghdr], f flags[recv_flags])
    36  recvmmsg(fd sock, mmsg ptr[in, array[recv_mmsghdr]], vlen len[mmsg], f flags[recv_flags], timeout ptr[in, timespec, opt])
    37  
    38  listen(fd sock, backlog int32)
    39  shutdown(fd sock, how flags[shutdown_flags])
    40  
    41  getsockopt(fd sock, level int32, optname int32, optval buffer[out], optlen ptr[inout, len[optval, int32]])
    42  setsockopt(fd sock, level int32, optname int32, optval buffer[in], optlen len[optval])
    43  
    44  socket_domain = AF_UNIX, AF_INET, AF_INET6, AF_NETLINK, AF_X25, AF_AX25, AF_ATMPVC, AF_APPLETALK, AF_PACKET, AF_VSOCK, AF_XDP, AF_TIPC, AF_RXRPC, AF_PPPOX, AF_RDS, AF_ROSE, AF_PHONET, AF_NFC, AF_NETROM, AF_KEY, AF_KCM, AF_ISDN, AF_SMC, AF_CAN, AF_CAIF, AF_BLUETOOTH, AF_LLC, AF_ALG, AF_QIPCRTR
    45  socket_type = SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET, SOCK_DCCP, SOCK_PACKET, SOCK_NONBLOCK, SOCK_CLOEXEC
    46  accept_flags = SOCK_NONBLOCK, SOCK_CLOEXEC
    47  shutdown_flags = SHUT_RD, SHUT_WR
    48  send_flags = MSG_CONFIRM, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_MORE, MSG_NOSIGNAL, MSG_OOB, MSG_PROBE, MSG_BATCH, MSG_FASTOPEN, MSG_ZEROCOPY
    49  recv_flags = MSG_CMSG_CLOEXEC, MSG_DONTWAIT, MSG_ERRQUEUE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, MSG_WAITFORONE
    50  cmsg_levels = SOL_SOCKET, IPPROTO_ICMP, SOL_IP, SOL_TCP, SOL_UDP, SOL_IPV6, SOL_ICMPV6, SOL_SCTP, SOL_UDPLITE, SOL_RAW, SOL_AX25, SOL_ATALK, SOL_NETROM, SOL_ROSE, SOL_PACKET, SOL_ATM, SOL_AAL, SOL_IRDA, SOL_NETBEUI, SOL_LLC, SOL_DCCP, SOL_NETLINK, SOL_TIPC, SOL_RXRPC, SOL_PPPOL2TP, SOL_BLUETOOTH, SOL_PNPIPE, SOL_RDS, SOL_IUCV, SOL_CAIF, SOL_ALG, SOL_NFC, SOL_KCM
    51  
    52  sock_pair {
    53  	fd0	sock
    54  	fd1	sock
    55  }
    56  
    57  # This sockaddr type corresponds to the struct sockaddr and is 16 bytes or less.
    58  # TODO: add AF_APPLETALK, AF_ATMPVC, AF_ROSE, AF_ATMSVC, AF_IRDA, AF_IB, AF_IUCV
    59  # Note: AF_UNIX, AF_INET6, AF_PACKET, AF_ALG, AF_PPPOX sockaddr is bigger than 16 bytes
    60  # Note: AF_NETROM sockaddr is the same as AF_AX25
    61  sockaddr [
    62  	in		sockaddr_in
    63  	ax25		sockaddr_ax25
    64  	nl		sockaddr_nl
    65  	llc		sockaddr_llc
    66  	can		sockaddr_can
    67  	sco		sockaddr_sco
    68  	l2		sockaddr_l2
    69  	hci		sockaddr_hci
    70  	rc		sockaddr_rc
    71  	nfc		sockaddr_nfc
    72  	vsock		sockaddr_vm
    73  	xdp		sockaddr_xdp
    74  	tipc		sockaddr_tipc
    75  	isdn		sockaddr_mISDN
    76  	l2tp		sockaddr_l2tpip
    77  	phonet		sockaddr_pn
    78  	ethernet	sockaddr_ethernet
    79  	qipcrtr		sockaddr_qrtr
    80  	generic		sockaddr_generic
    81  ] [size[SOCKADDR_SIZE]]
    82  
    83  # This sockaddr type corresponds to the sockaddr_storage type and is 128 bytes size.
    84  sockaddr_storage [
    85  	un		sockaddr_un
    86  	in		sockaddr_in
    87  	x25		sockaddr_x25
    88  	ax25		full_sockaddr_ax25
    89  	in6		sockaddr_in6
    90  	nl		sockaddr_nl
    91  	ll		sockaddr_ll
    92  	pppoe		sockaddr_pppoe
    93  	pppol2tp	sockaddr_pppol2tp
    94  	pppol2tpin6	sockaddr_pppol2tpin6
    95  	pppol2tpv3	sockaddr_pppol2tpv3
    96  	pppol2tpv3in6	sockaddr_pppol2tpv3in6
    97  	pptp		sockaddr_pptp
    98  	l2tp		sockaddr_l2tpip
    99  	l2tp6		sockaddr_l2tpip6
   100  	llc		sockaddr_llc
   101  	can		sockaddr_can
   102  	sco		sockaddr_sco
   103  	l2		sockaddr_l2
   104  	hci		sockaddr_hci
   105  	rc		sockaddr_rc
   106  	alg		sockaddr_alg
   107  	nfc		sockaddr_nfc
   108  	nfc_llcp	sockaddr_nfc_llcp
   109  	vsock		sockaddr_vm
   110  	xdp		sockaddr_xdp
   111  	tipc		sockaddr_tipc
   112  	caif		sockaddr_caif
   113  	isdn		sockaddr_mISDN
   114  	rxrpc		sockaddr_rxrpc
   115  	phonet		sockaddr_pn
   116  	ethernet	sockaddr_ethernet
   117  	qipcrtr		sockaddr_qrtr
   118  	ieee802154	sockaddr_ieee802154
   119  	generic		sockaddr_storage_generic
   120  ] [size[SOCKADDR_STORAGE_SIZE]]
   121  
   122  define SOCKADDR_SIZE	sizeof(struct sockaddr)
   123  define SOCKADDR_STORAGE_SIZE	sizeof(struct sockaddr_storage)
   124  
   125  sockaddr_generic {
   126  	sa_family	flags[socket_domain, int16]
   127  	sa_data		array[int8, 14]
   128  }
   129  
   130  sockaddr_storage_generic {
   131  	sa_family	flags[socket_domain, int16]
   132  	sa_data		array[int8, 126]
   133  }
   134  
   135  send_msghdr {
   136  	msg_name	ptr[in, sockaddr_storage, opt]
   137  	msg_namelen	len[msg_name, int32]
   138  	msg_iov		ptr[in, array[iovec_in]]
   139  	msg_iovlen	len[msg_iov, intptr]
   140  	msg_control	ptr[in, array[cmsghdr], opt]
   141  	msg_controllen	bytesize[msg_control, intptr]
   142  	msg_flags	const[0, int32]
   143  }
   144  
   145  msghdr_sock {
   146  	msg_name	ptr[in, sockaddr_storage, opt]
   147  	msg_namelen	len[msg_name, int32]
   148  	msg_iov		ptr[in, array[iovec_in]]
   149  	msg_iovlen	len[msg_iov, intptr]
   150  	msg_control	ptr[in, array[cmsghdr_sock], opt]
   151  	msg_controllen	bytesize[msg_control, intptr]
   152  	msg_flags	const[0, int32]
   153  }
   154  
   155  send_mmsghdr {
   156  	msg_hdr	send_msghdr
   157  	msg_len	const[0, int32]
   158  }
   159  
   160  mmsghdr_sock {
   161  	msg_hdr	msghdr_sock
   162  	msg_len	const[0, int32]
   163  }
   164  
   165  recv_msghdr {
   166  	msg_name	ptr[out, sockaddr_storage, opt]
   167  	msg_namelen	len[msg_name, int32]
   168  	msg_iov		ptr[in, array[iovec_out]]
   169  	msg_iovlen	len[msg_iov, intptr]
   170  	msg_control	ptr[out, array[int8], opt]
   171  	msg_controllen	bytesize[msg_control, intptr]
   172  	msg_flags	const[0, int32]
   173  }
   174  
   175  recv_mmsghdr {
   176  	msg_hdr	recv_msghdr
   177  	msg_len	int32
   178  }
   179  
   180  cmsghdr {
   181  	cmsg_len	len[parent, intptr]
   182  	cmsg_level	flags[cmsg_levels, int32]
   183  	cmsg_type	int32
   184  	data		array[int8]
   185  } [align[PTR_SIZE]]
   186  
   187  type cmsghdr_t[SOL, TYP, DATA] {
   188  	unaligned	cmsghdr_unaligned[SOL, TYP, DATA]
   189  } [align[PTR_SIZE]]
   190  
   191  type cmsghdr_unaligned[SOL, TYP, DATA] {
   192  	cmsg_len	len[parent, intptr]
   193  	cmsg_level	const[SOL, int32]
   194  	cmsg_type	const[TYP, int32]
   195  	data		DATA
   196  } [packed]
   197  
   198  # For __sock_cmsg_send
   199  cmsghdr_sock [
   200  	mark		cmsghdr_t[SOL_SOCKET, SO_MARK, int32]
   201  	timestamping	cmsghdr_t[SOL_SOCKET, SO_TIMESTAMPING_OLD, int32]
   202  	txtime		cmsghdr_t[SOL_SOCKET, SCM_TXTIME, int64]
   203  ] [varlen]
   204  
   205  # Socket options
   206  
   207  # http://lxr.free-electrons.com/source/include/uapi/asm-generic/socket.h
   208  
   209  setsockopt$sock_void(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_void], optval const[0], optlen const[0])
   210  getsockopt$sock_int(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
   211  setsockopt$sock_int(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_int], optval ptr[in, int32], optlen len[optval])
   212  getsockopt$sock_linger(fd sock, level const[SOL_SOCKET], optname const[SO_LINGER], optval ptr[out, linger], optlen ptr[inout, len[optval, int32]])
   213  setsockopt$sock_linger(fd sock, level const[SOL_SOCKET], optname const[SO_LINGER], optval ptr[in, linger], optlen len[optval])
   214  getsockopt$sock_cred(fd sock, level const[SOL_SOCKET], optname const[SO_PEERCRED], optval ptr[out, ucred], optlen ptr[inout, len[optval, int32]])
   215  setsockopt$sock_cred(fd sock, level const[SOL_SOCKET], optname const[SO_PEERCRED], optval ptr[in, ucred], optlen len[optval])
   216  getsockopt$sock_timeval(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_timeval], optval ptr[out, timeval], optlen ptr[inout, len[optval, int32]])
   217  setsockopt$sock_timeval(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_timeval], optval ptr[in, timeval], optlen len[optval])
   218  setsockopt$sock_attach_bpf(fd sock, level const[SOL_SOCKET], optname const[SO_ATTACH_BPF], optval ptr[in, fd_bpf_prog], optlen len[optval])
   219  setsockopt$SO_TIMESTAMP(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_timestamp], optval ptr[in, int32], optlen len[optval])
   220  getsockopt$SO_TIMESTAMP(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_timestamp], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
   221  setsockopt$SO_TIMESTAMPING(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_timestamping], optval ptr[in, flags[sockopt_so_timestamping, int32]], optlen len[optval])
   222  getsockopt$SO_TIMESTAMPING(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_timestamping], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
   223  setsockopt$SO_ATTACH_FILTER(fd sock, level const[SOL_SOCKET], optname const[SO_ATTACH_FILTER], optval ptr[in, sock_fprog], optlen len[optval])
   224  setsockopt$SO_BINDTODEVICE(fd sock, level const[SOL_SOCKET], optname const[SO_BINDTODEVICE], optval ptr[in, devname], optlen len[optval])
   225  getsockopt$SO_BINDTODEVICE(fd sock, level const[SOL_SOCKET], optname const[SO_BINDTODEVICE], optval ptr[out, devname], optlen len[optval])
   226  getsockopt$sock_buf(fd sock, level const[SOL_SOCKET], optname flags[sockopt_opt_sock_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
   227  getsockopt$SO_COOKIE(fd sock, level const[SOL_SOCKET], optname const[SO_COOKIE], optval ptr[out, int64], optlen ptr[inout, len[optval, int32]])
   228  
   229  linger {
   230  	onoff	bool32
   231  	linger	int32
   232  }
   233  
   234  sockopt_opt_sock_void = SO_DETACH_FILTER, SO_MARK
   235  sockopt_opt_sock_int = SO_ACCEPTCONN, SO_BROADCAST, SO_DEBUG, SO_DOMAIN, SO_ERROR, SO_DONTROUTE, SO_KEEPALIVE, SO_PEEK_OFF, SO_PRIORITY, SO_PROTOCOL, SO_RCVBUF, SO_RCVBUFFORCE, SO_RCVLOWAT, SO_SNDLOWAT, SO_REUSEADDR, SO_SNDBUF, SO_SNDBUFFORCE, SO_TIMESTAMP_OLD, SO_TYPE, SO_REUSEPORT, SO_OOBINLINE, SO_NO_CHECK, SO_PASSCRED, SO_TIMESTAMPNS_OLD, SO_LOCK_FILTER, SO_PASSSEC, SO_RXQ_OVFL, SO_WIFI_STATUS, SO_NOFCS, SO_SELECT_ERR_QUEUE, SO_BUSY_POLL, SO_MAX_PACING_RATE, SO_ZEROCOPY
   236  sockopt_opt_sock_timeval = SO_RCVTIMEO_OLD, SO_RCVTIMEO_NEW, SO_SNDTIMEO_OLD, SO_SNDTIMEO_NEW
   237  sockopt_opt_sock_timestamp = SO_TIMESTAMP_OLD, SO_TIMESTAMP_NEW, SO_TIMESTAMPNS_OLD, SO_TIMESTAMPNS_NEW
   238  sockopt_opt_sock_timestamping = SO_TIMESTAMPING_OLD, SO_TIMESTAMPING_NEW
   239  sockopt_opt_sock_buf = SO_PEERNAME, SO_PEERSEC, SO_GET_FILTER, SO_MEMINFO, SO_PEERGROUPS, SO_TXTIME
   240  sockopt_so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE, SOF_TIMESTAMPING_TX_SOFTWARE, SOF_TIMESTAMPING_RX_HARDWARE, SOF_TIMESTAMPING_RX_SOFTWARE, SOF_TIMESTAMPING_SOFTWARE, SOF_TIMESTAMPING_SYS_HARDWARE, SOF_TIMESTAMPING_RAW_HARDWARE, SOF_TIMESTAMPING_OPT_ID, SOF_TIMESTAMPING_TX_SCHED, SOF_TIMESTAMPING_TX_ACK, SOF_TIMESTAMPING_OPT_CMSG, SOF_TIMESTAMPING_OPT_TSONLY, SOF_TIMESTAMPING_OPT_STATS, SOF_TIMESTAMPING_OPT_PKTINFO, SOF_TIMESTAMPING_OPT_TX_SWHW
   241  
   242  # Socket ioctls
   243  
   244  # Since some socket ioctls are forwarded to the network device, adding device ioctls here as well.
   245  
   246  # http://lxr.free-electrons.com/linux/latest/source/include/uapi/linux/sockios.h
   247  
   248  # http://lxr.free-electrons.com/linux/latest/source/include/uapi/asm-generic/sockios.h
   249  
   250  ioctl$sock_SIOCADDRT(fd sock, cmd const[SIOCADDRT], arg ptr[inout, rtentry])
   251  ioctl$sock_SIOCDELRT(fd sock, cmd const[SIOCDELRT], arg ptr[inout, rtentry])
   252  
   253  ioctl$sock_SIOCGIFVLAN_SET_VLAN_INGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[in, vlan_args[SET_VLAN_INGRESS_PRIORITY_CMD, int32]])
   254  ioctl$sock_SIOCGIFVLAN_SET_VLAN_EGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[in, vlan_args[SET_VLAN_EGRESS_PRIORITY_CMD, int32]])
   255  ioctl$sock_SIOCGIFVLAN_SET_VLAN_FLAG_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[in, vlan_args[SET_VLAN_FLAG_CMD, int32]])
   256  ioctl$sock_SIOCGIFVLAN_SET_VLAN_NAME_TYPE_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[in, vlan_args[SET_VLAN_NAME_TYPE_CMD, int32]])
   257  ioctl$sock_SIOCGIFVLAN_ADD_VLAN_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[in, vlan_args[ADD_VLAN_CMD, int32[0:4]]])
   258  ioctl$sock_SIOCGIFVLAN_DEL_VLAN_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[in, vlan_args[DEL_VLAN_CMD, const[0, int32]]])
   259  ioctl$sock_SIOCGIFVLAN_GET_VLAN_REALDEV_NAME_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[inout, vlan_args[GET_VLAN_REALDEV_NAME_CMD, string[devnames, 24]]])
   260  ioctl$sock_SIOCGIFVLAN_GET_VLAN_VID_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[out, vlan_args[GET_VLAN_VID_CMD, int32]])
   261  ioctl$sock_SIOCGIFVLAN_GET_VLAN_INGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[out, vlan_args[GET_VLAN_INGRESS_PRIORITY_CMD, const[0, int32]]])
   262  ioctl$sock_SIOCGIFVLAN_GET_VLAN_EGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCGIFVLAN], arg ptr[out, vlan_args[GET_VLAN_EGRESS_PRIORITY_CMD, const[0, int32]]])
   263  
   264  ioctl$sock_SIOCSIFVLAN_SET_VLAN_INGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[in, vlan_args[SET_VLAN_INGRESS_PRIORITY_CMD, int32]])
   265  ioctl$sock_SIOCSIFVLAN_SET_VLAN_EGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[in, vlan_args[SET_VLAN_EGRESS_PRIORITY_CMD, int32]])
   266  ioctl$sock_SIOCSIFVLAN_SET_VLAN_FLAG_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[in, vlan_args[SET_VLAN_FLAG_CMD, int32]])
   267  ioctl$sock_SIOCSIFVLAN_SET_VLAN_NAME_TYPE_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[in, vlan_args[SET_VLAN_NAME_TYPE_CMD, int32]])
   268  ioctl$sock_SIOCSIFVLAN_ADD_VLAN_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[in, vlan_args[ADD_VLAN_CMD, int32[0:4]]])
   269  ioctl$sock_SIOCSIFVLAN_DEL_VLAN_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[in, vlan_args[DEL_VLAN_CMD, const[0, int32]]])
   270  ioctl$sock_SIOCSIFVLAN_GET_VLAN_REALDEV_NAME_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[inout, vlan_args[GET_VLAN_REALDEV_NAME_CMD, string[devnames, 24]]])
   271  ioctl$sock_SIOCSIFVLAN_GET_VLAN_VID_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[out, vlan_args[GET_VLAN_VID_CMD, int32]])
   272  ioctl$sock_SIOCSIFVLAN_GET_VLAN_INGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[out, vlan_args[GET_VLAN_INGRESS_PRIORITY_CMD, const[0, int32]]])
   273  ioctl$sock_SIOCSIFVLAN_GET_VLAN_EGRESS_PRIORITY_CMD(fd sock, cmd const[SIOCSIFVLAN], arg ptr[out, vlan_args[GET_VLAN_EGRESS_PRIORITY_CMD, const[0, int32]]])
   274  
   275  ioctl$sock_SIOCETHTOOL(fd sock, cmd const[SIOCETHTOOL], arg ptr[inout, ifreq_t[ptr[inout, ethtool_cmd_u]]])
   276  
   277  ioctl$sock_SIOCOUTQ(fd sock, cmd const[SIOCOUTQ], arg ptr[out, int32])
   278  ioctl$sock_SIOCINQ(fd sock, cmd const[SIOCINQ], arg ptr[out, int32])
   279  
   280  ioctl$sock_SIOCGIFCONF(fd sock, cmd const[SIOCGIFCONF], arg ptr[inout, ifconf])
   281  
   282  ifreq_ioctls = SIOCGIFNAME, SIOCSIFLINK, SIOCGIFFLAGS, SIOCSIFFLAGS, SIOCGIFADDR, SIOCSIFADDR, SIOCGIFDSTADDR, SIOCSIFDSTADDR, SIOCGIFBRDADDR, SIOCSIFBRDADDR, SIOCGIFNETMASK, SIOCSIFNETMASK, SIOCGIFMETRIC, SIOCSIFMETRIC, SIOCGIFMEM, SIOCSIFMEM, SIOCGIFMTU, SIOCSIFMTU, SIOCSIFNAME, SIOCSIFHWADDR, SIOCGIFENCAP, SIOCSIFENCAP, SIOCGIFHWADDR, SIOCGIFSLAVE, SIOCSIFSLAVE, SIOCADDMULTI, SIOCDELMULTI, SIOCGIFINDEX, SIOCSIFPFLAGS, SIOCGIFPFLAGS, SIOCDIFADDR, SIOCSIFHWBROADCAST, SIOCGIFCOUNT, SIOCGIFTXQLEN, SIOCSIFTXQLEN, SIOCETHTOOL, SIOCGMIIPHY, SIOCGMIIREG, SIOCSMIIREG, SIOCWANDEV, SIOCGIFMAP, SIOCSIFMAP, SIOCBONDENSLAVE, SIOCBONDRELEASE, SIOCBONDSETHWADDR, SIOCBONDSLAVEINFOQUERY, SIOCBONDINFOQUERY, SIOCBONDCHANGEACTIVE, SIOCBRADDIF, SIOCBRDELIF, SIOCSHWTSTAMP, SIOCGHWTSTAMP
   283  
   284  ioctl$sock_ifreq(fd sock, cmd flags[ifreq_ioctls], arg ptr[inout, ifreq])
   285  
   286  ioctl$sock_SIOCGIFINDEX(fd sock, cmd const[SIOCGIFINDEX], arg ptr[out, ifreq_t[ifindex]])
   287  
   288  ioctl$sock_SIOCGIFBR(fd sock, cmd const[SIOCGIFBR], arg ptr[inout, brctl_arg])
   289  ioctl$sock_SIOCSIFBR(fd sock, cmd const[SIOCSIFBR], arg ptr[inout, brctl_arg])
   290  
   291  ioctl$sock_SIOCOUTQNSD(fd sock, cmd const[SIOCOUTQNSD], arg ptr[out, int32])
   292  
   293  ioctl$sock_SIOCGSKNS(fd sock, cmd const[SIOCGSKNS], arg ptr[inout, int32])
   294  
   295  ioctl$sock_SIOCADDDLCI(fd sock, cmd const[SIOCADDDLCI], arg ptr[inout, dlci_add])
   296  ioctl$sock_SIOCDELDLCI(fd sock, cmd const[SIOCDELDLCI], arg ptr[in, dlci_add])
   297  
   298  ioctl$sock_SIOCBRADDBR(fd sock, cmd const[SIOCBRADDBR], arg ptr[in, devname])
   299  ioctl$sock_SIOCBRDELBR(fd sock, cmd const[SIOCBRDELBR], arg ptr[in, devname])
   300  
   301  define SIOCDEVPRIVATE_BEG	(SIOCDEVPRIVATE)
   302  define SIOCDEVPRIVATE_END	(SIOCDEVPRIVATE + 15)
   303  
   304  define SIOCPROTOPRIVATE_BEG	(SIOCPROTOPRIVATE)
   305  define SIOCPROTOPRIVATE_END	(SIOCPROTOPRIVATE + 15)
   306  
   307  ioctl$sock_netdev_private(fd sock, cmd int32[SIOCDEVPRIVATE_BEG:SIOCDEVPRIVATE_END], arg ptr[in, array[int8]])
   308  ioctl$sock_proto_private(fd sock, cmd int32[SIOCPROTOPRIVATE_BEG:SIOCPROTOPRIVATE_END], arg ptr[in, array[int8]])
   309  
   310  ioctl$sock_FIOSETOWN(fd sock, cmd const[FIOSETOWN], arg ptr[in, pid])
   311  ioctl$sock_SIOCSPGRP(fd sock, cmd const[SIOCSPGRP], arg ptr[in, pid])
   312  
   313  ioctl$sock_FIOGETOWN(fd sock, cmd const[FIOGETOWN], arg ptr[out, pid])
   314  ioctl$sock_SIOCGPGRP(fd sock, cmd const[SIOCGPGRP], arg ptr[out, pid])
   315  
   316  ioctl$sock_TIOCOUTQ(fd sock, cmd const[TIOCOUTQ], arg ptr[out, int32])
   317  ioctl$sock_TIOCINQ(fd sock, cmd const[TIOCINQ], arg ptr[out, int32])
   318  ioctl$SIOCGSTAMP(fd sock, cmd const[SIOCGSTAMP], arg ptr[out, timeval])
   319  ioctl$SIOCGSTAMPNS(fd sock, cmd const[SIOCGSTAMPNS], arg ptr[out, timespec])
   320  
   321  # Socket sendmsg
   322  sendmsg$sock(fd sock, msg ptr[in, msghdr_sock], f flags[send_flags])
   323  sendmmsg$sock(fd sock, mmsg ptr[in, array[mmsghdr_sock]], vlen len[mmsg], f flags[send_flags])
   324  
   325  resource ifindex[int32]
   326  
   327  type ifreq_dev_t[DEVNAME, ELEM] {
   328  	ifr_ifrn	string[DEVNAME, IFNAMSIZ]	(in)
   329  	elem		ELEM
   330  } [size[IFREQ_SIZE]]
   331  
   332  type ifreq_t[ELEM] ifreq_dev_t[devnames, ELEM]
   333  
   334  type ifreq ifreq_t[ifr_ifru]
   335  
   336  ifr_ifru [
   337  	ifru_addrs	sockaddr
   338  	ifru_hwaddr	mac_addr
   339  	ifru_flags	flags[ifru_flags, int16]
   340  	ifru_ivalue	int32
   341  	ifru_mtu	int32
   342  	ifru_map	ifmap
   343  	ifru_names	devname
   344  	ifru_data	ptr[in, array[int8, 32]]
   345  	ifru_settings	if_settings
   346  ]
   347  
   348  define IFREQ_SIZE	sizeof(struct ifreq)
   349  
   350  # https://elixir.bootlin.com/linux/v5.3.11/source/include/uapi/linux/if_vlan.h
   351  type vlan_args[CMD, DATA] {
   352  	cmd		const[CMD, int32]
   353  	device1		string[devnames, 24]
   354  	u		vlan_args_u[DATA]
   355  	vlan_qos	int16
   356  }
   357  
   358  type vlan_args_u[DATA] {
   359  	datadata	DATA
   360  } [size[24]]
   361  
   362  # https://elixir.bootlin.com/linux/v5.3.12/source/include/uapi/linux/route.h#L31
   363  rtentry {
   364  	rt_pad1		const[0, intptr]
   365  	rt_dst		sockaddr
   366  	rt_gateway	sockaddr
   367  	rt_genmask	sockaddr
   368  	rt_flags	int16
   369  	rt_pad2		const[0, int16]
   370  	rt_pad3		const[0, intptr]
   371  	rt_pad4		const[0, intptr]
   372  	rt_metric	int16
   373  	rt_dev		ptr[in, devname, opt]
   374  	rt_mtu		intptr
   375  	rt_window	intptr
   376  	rt_irtt		int16
   377  }
   378  
   379  # We could add "eth0" to this list as well, but this will affect the connection
   380  # between fuzzer and manager and produce lots of "no output" crashes
   381  # (actually, this is not true now since all testing is done in a separate
   382  # network namespace, but we still don't mess with eth0).
   383  # Note: lapb0, bpq0 and hwsim0 are only present in init namespace.
   384  # Note: for roseN and nrN we should use proc type, but for simplicity we currently use N=0.
   385  # Note: netdevsim0 and netpci0 are renamed in initialize_devlink_ports()
   386  devnames = "", "lo", "tunl0", "gre0", "gretap0", "ip_vti0", "ip6_vti0", "sit0", "ip6tnl0", "ip6gre0", "ip6gretap0", "bond0", "dummy0", "nr0", "rose0", "erspan0", "vlan0", "bridge0", "vcan0", "team0", "syz_tun", "veth0", "veth1", "veth0_to_bridge", "veth1_to_bridge", "veth0_to_bond", "veth1_to_bond", "veth0_to_team", "veth1_to_team", "bridge_slave_0", "bridge_slave_1", "bond_slave_0", "bond_slave_1", "team_slave_0", "team_slave_1", "syzkaller0", "syzkaller1", "veth0_to_hsr", "veth1_to_hsr", "hsr0", "ip6erspan0", "vxcan1", "caif0", "batadv0", "veth0_to_batadv", "veth1_to_batadv", "batadv_slave_0", "batadv_slave_1", "netdevsim0", "netpci0", "nicvf0", "xfrm0", "veth0_virt_wifi", "veth1_virt_wifi", "virt_wifi0", "veth0_vlan", "veth1_vlan", "vlan0", "vlan1", "macvlan0", "macvlan1", "ipvlan0", "ipvlan1", "veth0_macvtap", "veth1_macvtap", "macvtap0", "macsec0", "geneve0", "geneve1", "wg0", "wg1", "wg2", "wlan0", "wlan1", "dvmrp0", "dvmrp1", "pimreg", "pimreg0", "pimreg1", "pim6reg", "pim6reg0", "pim6reg1"
   387  
   388  type devname string[devnames, IFNAMSIZ]
   389  
   390  devname_mask {
   391  	lo	flags[devname_mask_values, int8]
   392  } [size[IFNAMSIZ]]
   393  
   394  devname_mask_values = 0, 0xff
   395  
   396  ifru_flags = IFF_TUN, IFF_TAP, IFF_NO_PI, IFF_ONE_QUEUE, IFF_VNET_HDR, IFF_TUN_EXCL, IFF_MULTI_QUEUE, IFF_ATTACH_QUEUE, IFF_DETACH_QUEUE, IFF_PERSIST, IFF_NOFILTER
   397  
   398  ifmap {
   399  	mem_start	intptr
   400  	mem_end		intptr
   401  	base_addr	int16
   402  	irq		int8
   403  	dma		int8
   404  	port		int8
   405  }
   406  
   407  if_settings {
   408  	type		int32
   409  	size		int32
   410  	ifs_ifsu	ifs_ifsu
   411  }
   412  
   413  ifs_ifsu [
   414  	raw_hdlc	ptr[in, raw_hdlc_proto]
   415  	cisco		ptr[in, cisco_proto]
   416  	fr		ptr[in, fr_proto]
   417  	fr_pvc		ptr[in, fr_proto_pvc]
   418  	fr_pvc_info	ptr[in, fr_proto_pvc_info]
   419  	sync		ptr[in, sync_serial_settings]
   420  	te1		ptr[in, te1_settings]
   421  ]
   422  
   423  raw_hdlc_proto {
   424  	encode	int16
   425  	parity	int16
   426  }
   427  
   428  cisco_proto {
   429  	val	int32
   430  	timeout	int32
   431  }
   432  
   433  fr_proto {
   434  	t391	int32
   435  	t392	int32
   436  	n391	int32
   437  	n392	int32
   438  	n393	int32
   439  	lmi	int16
   440  	dce	int16
   441  }
   442  
   443  fr_proto_pvc {
   444  	dlcl	int32
   445  }
   446  
   447  fr_proto_pvc_info {
   448  	dlci	int32
   449  	master	devname
   450  }
   451  
   452  sync_serial_settings {
   453  	rate	int32
   454  	type	int32
   455  	loop	int16
   456  }
   457  
   458  te1_settings {
   459  	rate	int32
   460  	type	int32
   461  	loop	int16
   462  	slot	int32
   463  }
   464  
   465  ifconf [
   466  	req	ifconf_req
   467  	buf	ifconf_buf
   468  ]
   469  
   470  ifconf_buf {
   471  	ifc_len		len[ifcu_buf, int32]
   472  	ifcu_buf	ptr[inout, array[int8], opt]
   473  }
   474  
   475  ifconf_req {
   476  	ifc_len		len[ifcu_req, int32]
   477  	ifcu_req	ptr[inout, ifreq, opt]
   478  }
   479  
   480  brctl_cmds = BRCTL_GET_VERSION, BRCTL_GET_BRIDGES, BRCTL_ADD_BRIDGE, BRCTL_DEL_BRIDGE
   481  
   482  brctl_arg [
   483  	get	brctl_arg_get
   484  	add_del	brctl_arg_add_del
   485  	generic	brctl_arg_generic
   486  ]
   487  
   488  brctl_arg_get {
   489  	cmd	const[BRCTL_GET_BRIDGES, int64]
   490  	buf	ptr[out, array[int8]]
   491  	indices	int64
   492  }
   493  
   494  brctl_arg_add_del {
   495  	cmd	const[BRCTL_ADD_BRIDGE, int64]
   496  	devname	ptr[in, devname]
   497  	pad	const[0, int64]
   498  }
   499  
   500  brctl_arg_generic {
   501  	a0	flags[brctl_cmds, int64]
   502  	a1	int64
   503  	a2	int64
   504  }
   505  
   506  dlci_add {
   507  	devname	devname
   508  	dlci	int16
   509  }
   510  
   511  # ETHTOOL declaration part
   512  # http://elixir.free-electrons.com/linux/latest/source/include/uapi/linux/ethtool.h
   513  
   514  ethtool_cmd_u [
   515  	ethtool_cmd		ethtool_cmd
   516  	ethtool_drvinfo		ethtool_drvinfo
   517  	ethtool_wolinfo		ethtool_wolinfo
   518  	ethtool_regs		ethtool_regs
   519  	ethtool_eeprom		ethtool_eeprom
   520  	ethtool_eee		ethtool_eee
   521  	ethtool_modinfo		ethtool_modinfo
   522  	ethtool_coalesce	ethtool_coalesce
   523  	ethtool_ringparam	ethtool_ringparam
   524  	ethtool_channels	ethtool_channels
   525  	ethtool_pauseparam	ethtool_pauseparam
   526  	ethtool_gstrings	ethtool_gstrings
   527  	ethtool_sset_info	ethtool_sset_info
   528  	ethtool_test		ethtool_test
   529  	ethtool_stats		ethtool_stats
   530  	ethtool_perm_addr	ethtool_perm_addr
   531  	ethtool_rxnfc		ethtool_rxnfc
   532  	ethtool_rxfh_indir	ethtool_rxfh_indir
   533  	ethtool_rxfh		ethtool_rxfh
   534  	ethtool_rx_ntuple	ethtool_rx_ntuple
   535  	ethtool_flash		ethtool_flash
   536  	ethtool_dump		ethtool_dump
   537  	ethtool_gfeatures	ethtool_gfeatures
   538  	ethtool_sfeatures	ethtool_sfeatures
   539  	ethtool_ts_info		ethtool_ts_info
   540  	ethtool_per_queue_op	ethtool_per_queue_op
   541  	ethtool_link_settings	ethtool_link_settings
   542  ] [varlen]
   543  
   544  ethtool_cmd {
   545  	cmd			flags[ethtool_cmd_flags, int32]
   546  	supported		int32
   547  	advertising		int32
   548  	speed			int16
   549  	duplex			int8
   550  	port			int8
   551  	phy_address		int8
   552  	transceiver		int8
   553  	autoneg			int8
   554  	mdio_support		int8
   555  	maxtxpkt		int32
   556  	maxrxpkt		int32
   557  	speed_hi		int16
   558  	eth_tp_mdix		int8
   559  	eth_tp_mdix_ctrl	int8
   560  	lp_advertising		int32
   561  	reserved		array[int32, 2]
   562  }
   563  
   564  ethtool_cmd_flags = ETHTOOL_GSET, ETHTOOL_SSET, ETHTOOL_GDRVINFO, ETHTOOL_GREGS, ETHTOOL_GWOL, ETHTOOL_SWOL, ETHTOOL_GMSGLVL, ETHTOOL_SMSGLVL, ETHTOOL_NWAY_RST, ETHTOOL_GLINK, ETHTOOL_GCOALESCE, ETHTOOL_SCOALESCE, ETHTOOL_GRINGPARAM, ETHTOOL_SRINGPARAM, ETHTOOL_GPAUSEPARAM, ETHTOOL_SPAUSEPARAM, ETHTOOL_GRXCSUM, ETHTOOL_SRXCSUM, ETHTOOL_GTXCSUM, ETHTOOL_STXCSUM, ETHTOOL_GSG, ETHTOOL_SSG, ETHTOOL_TEST, ETHTOOL_PHYS_ID, ETHTOOL_GSTATS, ETHTOOL_GTSO, ETHTOOL_STSO, ETHTOOL_GPERMADDR, ETHTOOL_GUFO, ETHTOOL_SUFO, ETHTOOL_GGSO, ETHTOOL_SGSO, ETHTOOL_GFLAGS, ETHTOOL_SFLAGS, ETHTOOL_GPFLAGS, ETHTOOL_SPFLAGS, ETHTOOL_GGRO, ETHTOOL_SGRO, ETHTOOL_RESET, ETHTOOL_SRXNTUPLE, ETHTOOL_GRXNTUPLE, ETHTOOL_GSSET_INFO, ETHTOOL_GRXFHINDIR, ETHTOOL_SRXFHINDIR, ETHTOOL_GFEATURES, ETHTOOL_SFEATURES, ETHTOOL_GCHANNELS, ETHTOOL_SCHANNELS, ETHTOOL_GET_TS_INFO, ETHTOOL_GEEE, ETHTOOL_SEEE, ETHTOOL_GRSSH, ETHTOOL_SRSSH, ETHTOOL_GTUNABLE, ETHTOOL_STUNABLE, ETHTOOL_GPHYSTATS, ETHTOOL_PERQUEUE, ETHTOOL_GLINKSETTINGS, ETHTOOL_SLINKSETTINGS, ETHTOOL_PHY_GTUNABLE, ETHTOOL_PHY_STUNABLE, ethtool_eeprom_cmd_flags, ethtool_rxnfc_cmd_flags, ethtool_dump_cmd_flags
   565  
   566  ethtool_drvinfo {
   567  	cmd		const[ETHTOOL_GDRVINFO, int32]
   568  	driver		array[int8, 32]
   569  	version		array[int8, 32]
   570  	fw_version	array[int8, ETHTOOL_FWVERS_LEN]
   571  	bus_info	array[int8, ETHTOOL_BUSINFO_LEN]
   572  	erom_version	array[int8, ETHTOOL_EROMVERS_LEN]
   573  	reserved2	array[int8, 12]
   574  	n_priv_flags	int32
   575  	n_stats		int32
   576  	testinfo_len	int32
   577  	eedump_len	int32
   578  	regdump_len	int32
   579  }
   580  
   581  ethtool_wolinfo_cmd_flags = ETHTOOL_GWOL, ETHTOOL_SWOL
   582  
   583  ethtool_wolinfo {
   584  	cmd		flags[ethtool_wolinfo_cmd_flags, int32]
   585  	supported	int32
   586  	wolopts		int32
   587  	sopass		array[int8, SOPASS_MAX]
   588  }
   589  
   590  ethtool_regs {
   591  	cmd	const[ETHTOOL_GREGS, int32]
   592  	version	int32
   593  	len	len[data, int32]
   594  	data	array[int8]
   595  }
   596  
   597  ethtool_eeprom_cmd_flags = ETHTOOL_GEEPROM, ETHTOOL_GMODULEEEPROM, ETHTOOL_SEEPROM
   598  
   599  ethtool_eeprom {
   600  	cmd	flags[ethtool_eeprom_cmd_flags, int32]
   601  	magic	int32
   602  	offset	int32
   603  	len	len[data, int32]
   604  	data	array[int8]
   605  }
   606  
   607  ethtool_eee_cmd_flags = ETHTOOL_GEEE, ETHTOOL_SEEE
   608  
   609  ethtool_eee {
   610  	cmd		flags[ethtool_eee_cmd_flags, int32]
   611  	supported	int32
   612  	advertised	int32
   613  	lp_advertised	int32
   614  	eee_active	int32
   615  	eee_enabled	int32
   616  	tx_lpi_enabled	int32
   617  	tx_lpi_timer	int32
   618  	reserved	array[int32, 2]
   619  }
   620  
   621  ethtool_modinfo {
   622  	cmd		const[ETHTOOL_GMODULEINFO, int32]
   623  	type		int32
   624  	eeprom_len	int32
   625  	reserved	array[const[0, int32], 8]
   626  }
   627  
   628  ethtool_coalesce_cmd_flags = ETHTOOL_GCOALESCE, ETHTOOL_SCOALESCE
   629  
   630  ethtool_coalesce {
   631  	cmd				flags[ethtool_coalesce_cmd_flags, int32]
   632  	rx_coalesce_usecs		int32
   633  	rx_max_coalesced_frames		int32
   634  	rx_coalesce_usecs_irq		int32
   635  	rx_max_coalesced_frames_irq	int32
   636  	tx_coalesce_usecs		int32
   637  	tx_max_coalesced_frames		int32
   638  	tx_coalesce_usecs_irq		int32
   639  	tx_max_coalesced_frames_irq	int32
   640  	stats_block_coalesce_usecs	int32
   641  	use_adaptive_rx_coalesce	int32
   642  	use_adaptive_tx_coalesce	int32
   643  	pkt_rate_low			int32
   644  	rx_coalesce_usecs_low		int32
   645  	rx_max_coalesced_frames_low	int32
   646  	tx_coalesce_usecs_low		int32
   647  	tx_max_coalesced_frames_low	int32
   648  	pkt_rate_high			int32
   649  	rx_coalesce_usecs_high		int32
   650  	rx_max_coalesced_frames_high	int32
   651  	tx_coalesce_usecs_high		int32
   652  	tx_max_coalesced_frames_high	int32
   653  	rate_sample_interval		int32
   654  }
   655  
   656  ethtool_ringparam_cmd_flags = ETHTOOL_GRINGPARAM, ETHTOOL_SRINGPARAM
   657  
   658  ethtool_ringparam {
   659  	cmd			flags[ethtool_ringparam_cmd_flags, int32]
   660  	rx_max_pending		int32
   661  	rx_mini_max_pending	int32
   662  	rx_jumbo_max_pending	int32
   663  	tx_max_pending		int32
   664  	rx_pending		int32
   665  	rx_mini_pending		int32
   666  	rx_jumbo_pending	int32
   667  	tx_pending		int32
   668  }
   669  
   670  ethtool_channels_cmd_flags = ETHTOOL_GCHANNELS, ETHTOOL_SCHANNELS
   671  
   672  ethtool_channels {
   673  	cmd		flags[ethtool_channels_cmd_flags, int32]
   674  	max_rx		int32
   675  	max_tx		int32
   676  	max_other	int32
   677  	max_combined	int32
   678  	rx_count	int32
   679  	tx_count	int32
   680  	other_count	int32
   681  	combined_count	int32
   682  }
   683  
   684  ethtool_pauseparam_cmd_flags = ETHTOOL_GPAUSEPARAM, ETHTOOL_SPAUSEPARAM
   685  
   686  ethtool_pauseparam {
   687  	cmd		flags[ethtool_pauseparam_cmd_flags, int32]
   688  	autoneg		int32
   689  	rx_pause	int32
   690  	tx_pause	int32
   691  }
   692  
   693  ethtool_gstrings {
   694  	cmd		const[ETHTOOL_GSTRINGS, int32]
   695  	string_set	flags[ethtool_stringset, int32]
   696  	len		len[data, int32]
   697  	data		array[int8]
   698  }
   699  
   700  ethtool_stringset = ETH_SS_TEST, ETH_SS_STATS, ETH_SS_PRIV_FLAGS, ETH_SS_NTUPLE_FILTERS, ETH_SS_FEATURES, ETH_SS_RSS_HASH_FUNCS, ETH_SS_TUNABLES, ETH_SS_PHY_STATS, ETH_SS_PHY_TUNABLES
   701  
   702  ethtool_sset_info {
   703  	cmd		const[ETHTOOL_GSSET_INFO, int32]
   704  	reserved	int32
   705  	sset_mask	int64
   706  	data		array[int32]
   707  }
   708  
   709  ethtool_test {
   710  	cmd		const[ETHTOOL_TEST, int32]
   711  	flags		int32
   712  	reserved	int32
   713  	len		len[data, int32]
   714  	data		array[int64]
   715  }
   716  
   717  ethtool_stats {
   718  	cmd	const[ETHTOOL_GSTATS, int32]
   719  	n_stats	len[data, int32]
   720  	data	array[int64]
   721  }
   722  
   723  ethtool_perm_addr {
   724  	cmd	const[ETHTOOL_GPERMADDR, int32]
   725  	size	len[data, int32]
   726  	data	array[int8]
   727  }
   728  
   729  # http://elixir.free-electrons.com/linux/latest/source/include/uapi/linux/ethtool.h#L1565
   730  traffic_flow_types = TCP_V4_FLOW, UDP_V4_FLOW, SCTP_V4_FLOW, AH_ESP_V4_FLOW, TCP_V6_FLOW, UDP_V6_FLOW, SCTP_V6_FLOW, AH_ESP_V6_FLOW, AH_V4_FLOW, ESP_V4_FLOW, AH_V6_FLOW, ESP_V6_FLOW, IPV4_USER_FLOW, IP_USER_FLOW, IPV6_USER_FLOW, IPV4_FLOW, IPV6_FLOW, ETHER_FLOW
   731  
   732  ethtool_rxnfc_cmd_flags = ETHTOOL_GRXFH, ETHTOOL_SRXFH, ETHTOOL_GRXRINGS, ETHTOOL_GRXCLSRLCNT, ETHTOOL_GRXCLSRULE, ETHTOOL_GRXCLSRLALL, ETHTOOL_SRXCLSRLDEL, ETHTOOL_SRXCLSRLINS
   733  
   734  ethtool_rxnfc {
   735  	cmd		flags[ethtool_rxnfc_cmd_flags, int32]
   736  	flow_type	flags[traffic_flow_types, int32]
   737  	data		int64
   738  	fs		ethtool_rx_flow_spec
   739  	rule_cnt	len[rule_locs, int32]
   740  	rule_locs	array[int32]
   741  }
   742  
   743  ethtool_rx_flow_spec {
   744  	flow_type	flags[traffic_flow_types, int32]
   745  	h_u		ethtool_flow_union
   746  	h_ext		ethtool_flow_ext
   747  	m_u		ethtool_flow_union
   748  	m_ext		ethtool_flow_ext
   749  	ring_cookie	int64
   750  	location	int32
   751  }
   752  
   753  ethtool_flow_union [
   754  	tcp_ip4_spec	ethtool_tcpip4_spec
   755  	udp_ip4_spec	ethtool_tcpip4_spec
   756  	sctp_ip4_spec	ethtool_tcpip4_spec
   757  	ah_ip4_spec	ethtool_ah_espip4_spec
   758  	esp_ip4_spec	ethtool_ah_espip4_spec
   759  	usr_ip4_spec	ethtool_usrip4_spec
   760  	tcp_ip6_spec	ethtool_tcpip6_spec
   761  	udp_ip6_spec	ethtool_tcpip6_spec
   762  	sctp_ip6_spec	ethtool_tcpip6_spec
   763  	ah_ip6_spec	ethtool_ah_espip6_spec
   764  	esp_ip6_spec	ethtool_ah_espip6_spec
   765  	usr_ip6_spec	ethtool_usrip6_spec
   766  	ether_spec	ethhdr
   767  	hdata		array[int8, 52]
   768  ]
   769  
   770  ethtool_flow_ext {
   771  	padding		const[0, int16]
   772  	h_dest		mac_addr
   773  	vlan_etype	int16be
   774  	vlan_tci	int16be
   775  	data		array[int32be, 2]
   776  }
   777  
   778  ethtool_tcpip4_spec {
   779  	ip4src	ipv4_addr
   780  	ip4dst	ipv4_addr
   781  	psrc	sock_port
   782  	pdst	sock_port
   783  	tos	int8
   784  }
   785  
   786  ethtool_ah_espip4_spec {
   787  	ip4src	ipv4_addr
   788  	ip4dst	ipv4_addr
   789  	spi	int32be
   790  	tos	int8
   791  }
   792  
   793  ethtool_usrip4_spec {
   794  	ip4src		ipv4_addr
   795  	ip4dst		ipv4_addr
   796  	l4_4_bytes	int32be
   797  	tos		int8
   798  	ip_ver		const[ETH_RX_NFC_IP4, int8]
   799  	proto		int8
   800  }
   801  
   802  ethtool_tcpip6_spec {
   803  	ip6src	ipv6_addr
   804  	ip6dst	ipv6_addr
   805  	psrc	sock_port
   806  	pdst	sock_port
   807  	tclass	int8
   808  }
   809  
   810  ethtool_ah_espip6_spec {
   811  	ip6src	ipv6_addr
   812  	ip6dst	ipv6_addr
   813  	spi	int32be
   814  	tclass	int8
   815  }
   816  
   817  ethtool_usrip6_spec {
   818  	ip6src		ipv6_addr
   819  	ip6dst		ipv6_addr
   820  	l4_4_bytes	int32be
   821  	tclass		int8
   822  	l4_proto	int8
   823  }
   824  
   825  ethhdr {
   826  	h_dest		mac_addr
   827  	h_source	mac_addr
   828  	h_proto		int16be
   829  } [packed]
   830  
   831  ethtool_rxfh_indir_flags = ETHTOOL_GRXFHINDIR, ETHTOOL_SRXFHINDIR
   832  
   833  ethtool_rxfh_indir {
   834  	cmd		flags[ethtool_rxfh_indir_flags, int32]
   835  	size		len[ring_index, int32]
   836  	ring_index	array[int32]
   837  }
   838  
   839  ethtool_rxfh_cmd_flags = ETHTOOL_GRSSH, ETHTOOL_SRSSH
   840  
   841  ethtool_rxfh {
   842  	cmd		flags[ethtool_rxfh_cmd_flags, int32]
   843  	rss_context	int32
   844  	indir_size	int32
   845  	key_size	int32
   846  	hfunc		int8
   847  	rsvd8		array[int8, 3]
   848  	rsvd32		int32
   849  	rss_config	array[int32]
   850  }
   851  
   852  ethtool_rx_ntuple {
   853  	cmd	const[ETHTOOL_SRXNTUPLE, int32]
   854  	fs	ethtool_rx_ntuple_flow_spec
   855  }
   856  
   857  ethtool_rx_ntuple_flow_spec_action_flags = ETHTOOL_RXNTUPLE_ACTION_DROP, ETHTOOL_RXNTUPLE_ACTION_CLEAR
   858  
   859  ethtool_rx_ntuple_flow_spec {
   860  	flow_type	flags[traffic_flow_types, int32]
   861  	h_u		ethtool_rx_ntuple_flow_spec_union
   862  	m_u		ethtool_rx_ntuple_flow_spec_union
   863  	vlan_tag	int16
   864  	vlan_tag_mask	int16
   865  	data		int64
   866  	data_mask	int64
   867  	action		flags[ethtool_rx_ntuple_flow_spec_action_flags, int32]
   868  }
   869  
   870  ethtool_rx_ntuple_flow_spec_union [
   871  	tcp_ip4_spec	ethtool_tcpip4_spec
   872  	udp_ip4_spec	ethtool_tcpip4_spec
   873  	sctp_ip4_spec	ethtool_tcpip4_spec
   874  	ah_ip4_spec	ethtool_ah_espip4_spec
   875  	esp_ip4_spec	ethtool_ah_espip4_spec
   876  	usr_ip4_spec	ethtool_usrip4_spec
   877  	ether_spec	ethhdr
   878  	hdata		array[int8, 72]
   879  ]
   880  
   881  ethtool_flash {
   882  	cmd	const[ETHTOOL_FLASHDEV, int32]
   883  	region	int32
   884  	data	string[filename, ETHTOOL_FLASH_MAX_FILENAME]
   885  }
   886  
   887  ethtool_dump_cmd_flags = ETHTOOL_GET_DUMP_FLAG, ETHTOOL_GET_DUMP_DATA, ETHTOOL_SET_DUMP
   888  
   889  ethtool_dump {
   890  	cmd	flags[ethtool_dump_cmd_flags, int32]
   891  	version	int32
   892  	flag	int32
   893  	len	len[data, int32]
   894  	data	array[int8]
   895  }
   896  
   897  ethtool_gfeatures {
   898  	cmd		const[ETHTOOL_GFEATURES, int32]
   899  	size		len[features, int32]
   900  	features	array[ethtool_get_features_block]
   901  }
   902  
   903  ethtool_get_features_block {
   904  	available	const[0, int32]
   905  	requested	const[0, int32]
   906  	active		const[0, int32]
   907  	never_changed	const[0, int32]
   908  }
   909  
   910  ethtool_sfeatures {
   911  	cmd		const[ETHTOOL_SFEATURES, int32]
   912  	size		len[features, int32]
   913  	features	array[ethtool_set_features_block]
   914  }
   915  
   916  ethtool_set_features_block {
   917  	valid		int32
   918  	requested	int32
   919  }
   920  
   921  ethtool_ts_info {
   922  	cmd		const[ETHTOOL_GET_TS_INFO, int32]
   923  	so_timestamping	const[0, int32]
   924  	phc_index	const[0, int32]
   925  	tx_types	const[0, int32]
   926  	tx_reserved	array[const[0, int32], 3]
   927  	rx_filters	const[0, int32]
   928  	rx_reserved	array[const[0, int32], 3]
   929  }
   930  
   931  ethtool_per_queue_op {
   932  	cmd		const[ETHTOOL_PERQUEUE, int32]
   933  	sub_command	flags[ethtool_per_queue_sub_cmd, int32]
   934  	queue_mask	array[int32, ethtool_per_queue_op_size]
   935  	data		array[int8]
   936  }
   937  
   938  ethtool_per_queue_sub_cmd = ETHTOOL_GCOALESCE, ETHTOOL_SCOALESCE
   939  
   940  define ethtool_per_queue_op_size	__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)
   941  
   942  ethtool_link_settings_cmd_flags = ETHTOOL_GLINKSETTINGS, ETHTOOL_SLINKSETTINGS
   943  
   944  ethtool_link_settings {
   945  	cmd			flags[ethtool_link_settings_cmd_flags, int32]
   946  	speed			int32
   947  	duplex			int8
   948  	port			int8
   949  	phy_address		int8
   950  	autoneg			int8
   951  	mdio_support		int8
   952  	eth_tp_mdix		int8
   953  	eth_tp_mdix_ctrl	int8
   954  	link_mode_masks_nwords	int8
   955  	reserved		array[int32, 8]
   956  	link_mode_masks		array[int32]
   957  }