github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/dev_net_tun.txt (about) 1 # Copyright 2015 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 <linux/if_tun.h> 5 include <linux/virtio_net.h> 6 include <uapi/linux/if_arp.h> 7 8 resource fd_tun[fd] 9 10 openat$tun(fd const[AT_FDCWD], file ptr[in, string["/dev/net/tun"]], flags flags[open_flags], mode const[0]) fd_tun 11 write$tun(fd fd_tun, buf ptr[in, tun_buffer], count len[buf]) 12 ioctl$TUNGETFEATURES(fd fd_tun, cmd const[TUNGETFEATURES], arg ptr[out, int32]) 13 ioctl$TUNSETQUEUE(fd fd_tun, cmd const[TUNSETQUEUE], arg ptr[in, ifreq_t[flags[tun_queue_flags, int16]]]) 14 ioctl$SIOCGSKNS(fd fd_tun, cmd const[SIOCGSKNS], arg ptr[in, ifreq_t[flags[tun_queue_flags, int16]]]) 15 ioctl$TUNSETIFF(fd fd_tun, cmd const[TUNSETIFF], arg ptr[in, ifreq_t[flags[tun_setiff_flags, int16]]]) 16 ioctl$TUNSETIFINDEX(fd fd_tun, cmd const[TUNSETIFINDEX], arg ptr[in, ifindex]) 17 ioctl$TUNGETIFF(fd fd_tun, cmd const[TUNGETIFF], arg ptr[out, ifreq_t[void]]) 18 ioctl$TUNSETNOCSUM(fd fd_tun, cmd const[TUNSETNOCSUM], arg boolptr) 19 ioctl$TUNSETPERSIST(fd fd_tun, cmd const[TUNSETPERSIST], arg boolptr) 20 ioctl$TUNSETOWNER(fd fd_tun, cmd const[TUNSETOWNER], arg uid) 21 ioctl$TUNSETGROUP(fd fd_tun, cmd const[TUNSETGROUP], arg gid) 22 ioctl$TUNSETLINK(fd fd_tun, cmd const[TUNSETLINK], arg flags[dev_type_arphdr]) 23 ioctl$TUNSETDEBUG(fd fd_tun, cmd const[TUNSETDEBUG], arg ptr[in, int32]) 24 ioctl$TUNSETOFFLOAD(fd fd_tun, cmd const[TUNSETOFFLOAD], arg flags[tun_offload_flags]) 25 ioctl$TUNSETTXFILTER(fd fd_tun, cmd const[TUNSETTXFILTER], arg ptr[in, tun_filter]) 26 ioctl$SIOCGIFHWADDR(fd fd_tun, cmd const[SIOCGIFHWADDR], arg ptr[out, ifreq_t[void]]) 27 ioctl$SIOCSIFHWADDR(fd fd_tun, cmd const[SIOCSIFHWADDR], arg ptr[in, ifreq_t[mac_addr]]) 28 ioctl$TUNGETSNDBUF(fd fd_tun, cmd const[TUNGETSNDBUF], arg ptr[out, int32]) 29 ioctl$TUNSETSNDBUF(fd fd_tun, cmd const[TUNSETSNDBUF], arg ptr[in, int32]) 30 ioctl$TUNGETVNETHDRSZ(fd fd_tun, cmd const[TUNGETVNETHDRSZ], arg ptr[out, int32]) 31 ioctl$TUNSETVNETHDRSZ(fd fd_tun, cmd const[TUNSETVNETHDRSZ], arg ptr[in, int32]) 32 ioctl$TUNATTACHFILTER(fd fd_tun, cmd const[TUNATTACHFILTER], arg ptr[in, sock_fprog]) 33 ioctl$TUNDETACHFILTER(fd fd_tun, cmd const[TUNDETACHFILTER], arg const[0]) 34 ioctl$TUNGETFILTER(fd fd_tun, cmd const[TUNGETFILTER], arg buffer[out]) 35 ioctl$TUNSETSTEERINGEBPF(fd fd_tun, cmd const[TUNSETSTEERINGEBPF], arg ptr[in, fd_bpf_prog]) 36 ioctl$TUNSETFILTEREBPF(fd fd_tun, cmd const[TUNSETFILTEREBPF], arg ptr[in, fd_bpf_prog]) 37 ioctl$TUNGETVNETLE(fd fd_tun, cmd const[TUNGETVNETLE], arg ptr[out, int32]) 38 ioctl$TUNSETVNETLE(fd fd_tun, cmd const[TUNSETVNETLE], arg ptr[in, bool32]) 39 ioctl$TUNGETVNETBE(fd fd_tun, cmd const[TUNGETVNETBE], arg ptr[in, bool32]) 40 ioctl$TUNSETVNETBE(fd fd_tun, cmd const[TUNSETVNETBE], arg ptr[in, bool32]) 41 ioctl$TUNSETCARRIER(fd fd_tun, cmd const[TUNSETCARRIER], arg ptr[in, bool32]) 42 ioctl$TUNGETDEVNETNS(fd fd_tun, cmd const[TUNGETDEVNETNS], arg const[0]) fd_namespace 43 44 # There are 4 combinations of tun packets: 45 # tun_pi can be present or missing (depending on !IFF_NO_PI), 46 # virtio_net_hdr can be present or missing (depending on IFF_VNET_HDR). 47 # We may want to support optional fields, which will make this simpler. 48 tun_buffer { 49 pi optional[tun_pi] 50 hdr optional[virtio_net_hdr] 51 data tun_payload 52 } [packed] 53 54 tun_pi { 55 flags const[0, int16] 56 proto flags[ether_types, int16be] 57 } 58 59 virtio_net_hdr { 60 flags flags[virtio_net_flags, int8] 61 gsotype flags[virtio_net_types, int8] 62 hdrlen int16 63 gsosize int16 64 start int16 65 offset int16 66 } 67 68 tun_payload [ 69 eth eth_packet 70 ipv4 ipv4_packet 71 ipv6 ipv6_packet 72 arp arp_packet 73 llc llc_packet 74 x25 x25_packet 75 mpls mpls_packet 76 ] [varlen] 77 78 tun_filter { 79 flags flags[tun_filter_flags, int16] 80 count len[addr, int16] 81 addr array[mac_addr] 82 } 83 84 tun_filter_flags = TUN_FLT_ALLMULTI 85 virtio_net_flags = VIRTIO_NET_HDR_F_NEEDS_CSUM, VIRTIO_NET_HDR_F_DATA_VALID 86 virtio_net_types = VIRTIO_NET_HDR_GSO_NONE, VIRTIO_NET_HDR_GSO_TCPV4, VIRTIO_NET_HDR_GSO_UDP, VIRTIO_NET_HDR_GSO_TCPV6, VIRTIO_NET_HDR_GSO_ECN 87 tun_offload_flags = TUN_F_CSUM, TUN_F_TSO4, TUN_F_TSO6, TUN_F_TSO_ECN, TUN_F_UFO 88 tun_setiff_flags = IFF_TUN, IFF_TAP, IFF_NAPI, IFF_NAPI_FRAGS, 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 89 tun_queue_flags = IFF_ATTACH_QUEUE, IFF_DETACH_QUEUE 90 dev_type_arphdr = ARPHRD_NETROM, ARPHRD_ETHER, ARPHRD_EETHER, ARPHRD_AX25, ARPHRD_PRONET, ARPHRD_CHAOS, ARPHRD_IEEE802, ARPHRD_ARCNET, ARPHRD_APPLETLK, ARPHRD_DLCI, ARPHRD_ATM, ARPHRD_METRICOM, ARPHRD_IEEE1394, ARPHRD_EUI64, ARPHRD_INFINIBAND, ARPHRD_SLIP, ARPHRD_CSLIP, ARPHRD_SLIP6, ARPHRD_CSLIP6, ARPHRD_RSRVD, ARPHRD_ADAPT, ARPHRD_ROSE, ARPHRD_X25, ARPHRD_HWX25, ARPHRD_CAN, ARPHRD_PPP, ARPHRD_CISCO, ARPHRD_HDLC, ARPHRD_LAPB, ARPHRD_DDCMP, ARPHRD_RAWHDLC, ARPHRD_RAWIP, ARPHRD_TUNNEL, ARPHRD_TUNNEL6, ARPHRD_FRAD, ARPHRD_SKIP, ARPHRD_LOOPBACK, ARPHRD_LOCALTLK, ARPHRD_FDDI, ARPHRD_BIF, ARPHRD_SIT, ARPHRD_IPDDP, ARPHRD_IPGRE, ARPHRD_PIMREG, ARPHRD_HIPPI, ARPHRD_ASH, ARPHRD_ECONET, ARPHRD_IRDA, ARPHRD_FCPP, ARPHRD_FCAL, ARPHRD_FCPL, ARPHRD_FCFABRIC, ARPHRD_IEEE802_TR, ARPHRD_IEEE80211, ARPHRD_IEEE80211_PRISM, ARPHRD_IEEE80211_RADIOTAP, ARPHRD_IEEE802154, ARPHRD_IEEE802154_MONITOR, ARPHRD_PHONET, ARPHRD_PHONET_PIPE, ARPHRD_CAIF, ARPHRD_IP6GRE, ARPHRD_NETLINK, ARPHRD_6LOWPAN, ARPHRD_VSOCKMON, ARPHRD_VOID, ARPHRD_NONE