• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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$TUNSETIFF(fd fd_tun, cmd const[TUNSETIFF], arg ptr[in, ifreq_t[flags[tun_setiff_flags, int16]]])
15 ioctl$TUNSETIFINDEX(fd fd_tun, cmd const[TUNSETIFINDEX], arg ptr[in, ifindex])
16 ioctl$TUNGETIFF(fd fd_tun, cmd const[TUNGETIFF], arg ptr[out, ifreq_t[void]])
17 ioctl$TUNSETNOCSUM(fd fd_tun, cmd const[TUNSETNOCSUM], arg bool32)
18 ioctl$TUNSETPERSIST(fd fd_tun, cmd const[TUNSETPERSIST], arg bool32)
19 ioctl$TUNSETOWNER(fd fd_tun, cmd const[TUNSETOWNER], arg uid)
20 ioctl$TUNSETGROUP(fd fd_tun, cmd const[TUNSETGROUP], arg gid)
21 ioctl$TUNSETLINK(fd fd_tun, cmd const[TUNSETLINK], arg flags[dev_type_arphdr])
22 ioctl$TUNSETOFFLOAD(fd fd_tun, cmd const[TUNSETOFFLOAD], arg flags[tun_offload_flags])
23 ioctl$TUNSETTXFILTER(fd fd_tun, cmd const[TUNSETTXFILTER], arg ptr[in, tun_filter])
24 ioctl$SIOCGIFHWADDR(fd fd_tun, cmd const[SIOCGIFHWADDR], arg ptr[out, ifreq_t[void]])
25 ioctl$SIOCSIFHWADDR(fd fd_tun, cmd const[SIOCSIFHWADDR], arg ptr[in, ifreq_t[mac_addr]])
26 ioctl$TUNGETSNDBUF(fd fd_tun, cmd const[TUNGETSNDBUF], arg ptr[out, int32])
27 ioctl$TUNSETSNDBUF(fd fd_tun, cmd const[TUNSETSNDBUF], arg ptr[in, int32])
28 ioctl$TUNGETVNETHDRSZ(fd fd_tun, cmd const[TUNGETVNETHDRSZ], arg ptr[out, int32])
29 ioctl$TUNSETVNETHDRSZ(fd fd_tun, cmd const[TUNSETVNETHDRSZ], arg ptr[in, int32])
30 ioctl$TUNATTACHFILTER(fd fd_tun, cmd const[TUNATTACHFILTER], arg ptr[in, sock_fprog])
31 ioctl$TUNDETACHFILTER(fd fd_tun, cmd const[TUNDETACHFILTER], arg const[0])
32 ioctl$TUNGETFILTER(fd fd_tun, cmd const[TUNGETFILTER], arg buffer[out])
33 ioctl$TUNSETSTEERINGEBPF(fd fd_tun, cmd const[TUNSETSTEERINGEBPF], arg ptr[in, fd_bpf_prog])
34 ioctl$TUNSETFILTEREBPF(fd fd_tun, cmd const[TUNSETFILTEREBPF], arg ptr[in, fd_bpf_prog])
35 ioctl$TUNSETVNETLE(fd fd_tun, cmd const[TUNSETVNETLE], arg ptr[in, bool32])
36 ioctl$TUNSETVNETBE(fd fd_tun, cmd const[TUNSETVNETBE], arg ptr[in, bool32])
37 
38 # There are 4 combinations of tun packets:
39 # tun_pi can be present or missing (depending on !IFF_NO_PI),
40 # virtio_net_hdr can be present or missing (depending on IFF_VNET_HDR).
41 # We may want to support optional fields, which will make this simpler.
42 tun_buffer {
43 	pi	optional[tun_pi]
44 	hdr	optional[virtio_net_hdr]
45 	data	tun_payload
46 } [packed]
47 
48 tun_pi {
49 	flags	const[0, int16]
50 	proto	flags[ether_types, int16be]
51 }
52 
53 virtio_net_hdr {
54 	flags	flags[virtio_net_flags, int8]
55 	gsotype	flags[virtio_net_types, int8]
56 	hdrlen	int16
57 	gsosize	int16
58 	start	int16
59 	offset	int16
60 }
61 
62 tun_payload [
63 	eth	eth_packet
64 	ipv4	ipv4_packet
65 	ipv6	ipv6_packet
66 	arp	arp_packet
67 	llc	llc_packet
68 	ipx	ipx_packet
69 	x25	x25_packet
70 	mpls	mpls_packet
71 ] [varlen]
72 
73 tun_filter {
74 	flags	flags[tun_filter_flags, int16]
75 	count	len[addr, int16]
76 	addr	array[mac_addr]
77 }
78 
79 tun_filter_flags = TUN_FLT_ALLMULTI
80 virtio_net_flags = VIRTIO_NET_HDR_F_NEEDS_CSUM, VIRTIO_NET_HDR_F_DATA_VALID
81 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
82 tun_offload_flags = TUN_F_CSUM, TUN_F_TSO4, TUN_F_TSO6, TUN_F_TSO_ECN, TUN_F_UFO
83 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
84 tun_queue_flags = IFF_ATTACH_QUEUE, IFF_DETACH_QUEUE
85 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
86