1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_IF_TUNNEL_H_
3 #define _UAPI_IF_TUNNEL_H_
5 #include <linux/types.h>
9 #include <asm/byteorder.h>
12 #define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0)
13 #define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1)
14 #define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2)
15 #define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3)
16 #define SIOCGETPRL (SIOCDEVPRIVATE + 4)
17 #define SIOCADDPRL (SIOCDEVPRIVATE + 5)
18 #define SIOCDELPRL (SIOCDEVPRIVATE + 6)
19 #define SIOCCHGPRL (SIOCDEVPRIVATE + 7)
20 #define SIOCGET6RD (SIOCDEVPRIVATE + 8)
21 #define SIOCADD6RD (SIOCDEVPRIVATE + 9)
22 #define SIOCDEL6RD (SIOCDEVPRIVATE + 10)
23 #define SIOCCHG6RD (SIOCDEVPRIVATE + 11)
25 #define GRE_CSUM __cpu_to_be16(0x8000)
26 #define GRE_ROUTING __cpu_to_be16(0x4000)
27 #define GRE_KEY __cpu_to_be16(0x2000)
28 #define GRE_SEQ __cpu_to_be16(0x1000)
29 #define GRE_STRICT __cpu_to_be16(0x0800)
30 #define GRE_REC __cpu_to_be16(0x0700)
31 #define GRE_ACK __cpu_to_be16(0x0080)
32 #define GRE_FLAGS __cpu_to_be16(0x0078)
33 #define GRE_VERSION __cpu_to_be16(0x0007)
35 #define GRE_IS_CSUM(f) ((f) & GRE_CSUM)
36 #define GRE_IS_ROUTING(f) ((f) & GRE_ROUTING)
37 #define GRE_IS_KEY(f) ((f) & GRE_KEY)
38 #define GRE_IS_SEQ(f) ((f) & GRE_SEQ)
39 #define GRE_IS_STRICT(f) ((f) & GRE_STRICT)
40 #define GRE_IS_REC(f) ((f) & GRE_REC)
41 #define GRE_IS_ACK(f) ((f) & GRE_ACK)
43 #define GRE_VERSION_0 __cpu_to_be16(0x0000)
44 #define GRE_VERSION_1 __cpu_to_be16(0x0001)
45 #define GRE_PROTO_PPP __cpu_to_be16(0x880b)
46 #define GRE_PPTP_KEY_MASK __cpu_to_be32(0xffff)
48 struct ip_tunnel_parm
{
65 IFLA_IPTUN_ENCAP_LIMIT
,
70 IFLA_IPTUN_6RD_PREFIX
,
71 IFLA_IPTUN_6RD_RELAY_PREFIX
,
72 IFLA_IPTUN_6RD_PREFIXLEN
,
73 IFLA_IPTUN_6RD_RELAY_PREFIXLEN
,
74 IFLA_IPTUN_ENCAP_TYPE
,
75 IFLA_IPTUN_ENCAP_FLAGS
,
76 IFLA_IPTUN_ENCAP_SPORT
,
77 IFLA_IPTUN_ENCAP_DPORT
,
78 IFLA_IPTUN_COLLECT_METADATA
,
82 #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
84 enum tunnel_encap_types
{
91 #define TUNNEL_ENCAP_FLAG_CSUM (1<<0)
92 #define TUNNEL_ENCAP_FLAG_CSUM6 (1<<1)
93 #define TUNNEL_ENCAP_FLAG_REMCSUM (1<<2)
95 /* SIT-mode i_flags */
96 #define SIT_ISATAP 0x0001
98 struct ip_tunnel_prl
{
108 #define PRL_DEFAULT 0x0001
110 struct ip_tunnel_6rd
{
111 struct in6_addr prefix
;
114 __u16 relay_prefixlen
;
129 IFLA_GRE_ENCAP_LIMIT
,
133 IFLA_GRE_ENCAP_FLAGS
,
134 IFLA_GRE_ENCAP_SPORT
,
135 IFLA_GRE_ENCAP_DPORT
,
136 IFLA_GRE_COLLECT_METADATA
,
139 IFLA_GRE_ERSPAN_INDEX
,
142 IFLA_GRE_ERSPAN_HWID
,
146 #define IFLA_GRE_MAX (__IFLA_GRE_MAX - 1)
148 /* VTI-mode i_flags */
149 #define VTI_ISVTI ((__force __be16)0x0001)
162 #define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1)
165 /* Historically, tunnel flags have been defined as __be16 and now there are
166 * no free bits left. It is strongly advised to switch the already existing
167 * userspace code to the new *_BIT definitions from down below, as __be16
168 * can't be simply cast to a wider type on LE systems. All new flags and
169 * code must use *_BIT only.
172 #define TUNNEL_CSUM __cpu_to_be16(0x01)
173 #define TUNNEL_ROUTING __cpu_to_be16(0x02)
174 #define TUNNEL_KEY __cpu_to_be16(0x04)
175 #define TUNNEL_SEQ __cpu_to_be16(0x08)
176 #define TUNNEL_STRICT __cpu_to_be16(0x10)
177 #define TUNNEL_REC __cpu_to_be16(0x20)
178 #define TUNNEL_VERSION __cpu_to_be16(0x40)
179 #define TUNNEL_NO_KEY __cpu_to_be16(0x80)
180 #define TUNNEL_DONT_FRAGMENT __cpu_to_be16(0x0100)
181 #define TUNNEL_OAM __cpu_to_be16(0x0200)
182 #define TUNNEL_CRIT_OPT __cpu_to_be16(0x0400)
183 #define TUNNEL_GENEVE_OPT __cpu_to_be16(0x0800)
184 #define TUNNEL_VXLAN_OPT __cpu_to_be16(0x1000)
185 #define TUNNEL_NOCACHE __cpu_to_be16(0x2000)
186 #define TUNNEL_ERSPAN_OPT __cpu_to_be16(0x4000)
187 #define TUNNEL_GTP_OPT __cpu_to_be16(0x8000)
189 #define TUNNEL_OPTIONS_PRESENT \
190 (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT | \
195 IP_TUNNEL_CSUM_BIT
= 0U,
196 IP_TUNNEL_ROUTING_BIT
,
199 IP_TUNNEL_STRICT_BIT
,
201 IP_TUNNEL_VERSION_BIT
,
202 IP_TUNNEL_NO_KEY_BIT
,
203 IP_TUNNEL_DONT_FRAGMENT_BIT
,
205 IP_TUNNEL_CRIT_OPT_BIT
,
206 IP_TUNNEL_GENEVE_OPT_BIT
, /* OPTIONS_PRESENT */
207 IP_TUNNEL_VXLAN_OPT_BIT
, /* OPTIONS_PRESENT */
208 IP_TUNNEL_NOCACHE_BIT
,
209 IP_TUNNEL_ERSPAN_OPT_BIT
, /* OPTIONS_PRESENT */
210 IP_TUNNEL_GTP_OPT_BIT
, /* OPTIONS_PRESENT */
213 IP_TUNNEL_SIT_ISATAP_BIT
= IP_TUNNEL_VTI_BIT
,
215 /* Flags starting from here are not available via the old UAPI */
216 IP_TUNNEL_PFCP_OPT_BIT
, /* OPTIONS_PRESENT */
218 __IP_TUNNEL_FLAG_NUM
,
221 #endif /* _UAPI_IF_TUNNEL_H_ */