FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
vxlan_gpe.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * @file
17  * @brief VXLAN GPE definitions
18  *
19 */
20 #ifndef included_vnet_vxlan_gpe_h
21 #define included_vnet_vxlan_gpe_h
22 
23 #include <vppinfra/error.h>
24 #include <vppinfra/hash.h>
25 #include <vnet/vnet.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip/vtep.h>
28 #include <vnet/l2/l2_input.h>
29 #include <vnet/l2/l2_output.h>
30 #include <vnet/l2/l2_bd.h>
31 #include <vnet/ethernet/ethernet.h>
33 #include <vnet/ip/ip4_packet.h>
34 #include <vnet/ip/ip6_packet.h>
35 #include <vnet/udp/udp_packet.h>
36 #include <vnet/dpo/dpo.h>
37 #include <vnet/adj/adj_types.h>
38 
39 /**
40  * @brief VXLAN GPE header struct
41  *
42  */
43 /* *INDENT-OFF* */
44 typedef CLIB_PACKED (struct {
45  /** 20 bytes */
47  /** 8 bytes */
48  udp_header_t udp;
49  /** 8 bytes */
50  vxlan_gpe_header_t vxlan;
51 }) ip4_vxlan_gpe_header_t;
52 /* *INDENT-ON* */
53 
54 /* *INDENT-OFF* */
55 typedef CLIB_PACKED (struct {
56  /** 40 bytes */
58  /** 8 bytes */
59  udp_header_t udp;
60  /** 8 bytes */
61  vxlan_gpe_header_t vxlan;
62 }) ip6_vxlan_gpe_header_t;
63 /* *INDENT-ON* */
64 
65 /**
66  * @brief Key struct for IPv4 VXLAN GPE tunnel.
67  * Key fields: local remote, vni
68  * all fields in NET byte order
69  * VNI shifted 8 bits
70  */
71 /* *INDENT-OFF* */
72 typedef CLIB_PACKED(struct {
73  union {
74  struct {
75  u32 local;
76  u32 remote;
77 
78  u32 vni;
79  u32 pad;
80  };
81  u64 as_u64[2];
82  };
83 }) vxlan4_gpe_tunnel_key_t;
84 /* *INDENT-ON* */
85 
86 /**
87  * @brief Key struct for IPv6 VXLAN GPE tunnel.
88  * Key fields: local remote, vni
89  * all fields in NET byte order
90  * VNI shifted 8 bits
91  */
92 /* *INDENT-OFF* */
93 typedef CLIB_PACKED(struct {
94  ip6_address_t local;
95  ip6_address_t remote;
96  u32 vni;
97 }) vxlan6_gpe_tunnel_key_t;
98 /* *INDENT-ON* */
99 
100 /**
101  * @brief Struct for VXLAN GPE tunnel
102  */
103 typedef struct
104 {
105  /* Required for pool_get_aligned */
106  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
107 
108  /** Rewrite string. $$$$ embed vnet_rewrite header */
110 
111  /** encapsulated protocol */
113 
114  /* FIB DPO for IP forwarding of VXLAN-GPE encap packet */
116  /** tunnel local address */
117  ip46_address_t local;
118  /** tunnel remote address */
119  ip46_address_t remote;
120 
121  /* mcast packet output intfc index (used only if dst is mcast) */
123 
124  /** FIB indices - tunnel partner lookup here */
126  /** FIB indices - inner IP packet lookup here */
128 
129  /** VXLAN GPE VNI in HOST byte order, shifted left 8 bits */
131 
132  /** vnet intfc hw_if_index */
134  /** vnet intfc sw_if_index */
136 
137  /** flags */
139 
140  /** rewrite size for dynamic plugins like iOAM */
142 
143  /** Next node after VxLAN-GPE encap */
145 
146  /**
147  * Linkage into the FIB object graph
148  */
150 
151  /*
152  * The FIB entry for (depending on VXLAN-GPE tunnel is unicast or mcast)
153  * sending unicast VXLAN-GPE encap packets or receiving mcast VXLAN-GPE packets
154  */
157 
158  /**
159  * The tunnel is a child of the FIB entry for its destination. This is
160  * so it receives updates when the forwarding information for that entry
161  * changes.
162  * The tunnels sibling index on the FIB entry's dependency list.
163  */
165 
167 
168 /** Flags for vxlan_gpe_tunnel_t */
169 #define VXLAN_GPE_TUNNEL_IS_IPV4 1
170 
171 /** next nodes for VXLAN GPE input */
172 #define foreach_vxlan_gpe_input_next \
173 _(DROP, "error-drop") \
174 _(IP4_INPUT, "ip4-input") \
175 _(IP6_INPUT, "ip6-input") \
176 _(L2_INPUT, "l2-input")
177 
178 /** struct for next nodes for VXLAN GPE input */
179 typedef enum
180 {
181 #define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
183 #undef _
186 
187 /** struct for VXLAN GPE errors */
188 typedef enum
189 {
190 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
192 #undef vxlan_gpe_error
195 
196 /** Struct for VXLAN GPE node state */
197 typedef struct
198 {
199  /** vector of encap tunnel instances */
201 
202  /** lookup IPv4 VXLAN GPE tunnel by key */
204  /** lookup IPv6 VXLAN GPE tunnel by key */
206 
207  /* local VTEP IPs ref count used by vxlan-bypass node to check if
208  received VXLAN packet DIP matches any local VTEP address */
210  /* mcast shared info */
211  uword *mcast_shared; /* keyed on mcast ip46 addr */
212  /** Free vlib hw_if_indices */
214 
215  /** Mapping from sw_if_index to tunnel index */
217 
218  /** State convenience vlib_main_t */
220  /** State convenience vnet_main_t */
222 
223  /* cache for last 8 vxlan_gpe tunnel */
224 #ifdef CLIB_HAVE_VEC512
225  vtep4_cache_t vtep4_u512;
226 #endif
227 
228  /** List of next nodes for the decap indexed on protocol */
229  uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
231 
233 
237 
238 u8 *format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
239 
240 /** Struct for VXLAN GPE add/del args */
241 typedef struct
242 {
245  ip46_address_t local, remote;
252 
253 
255  (vnet_vxlan_gpe_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
256 
257 
258 int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
259  u8 protocol_override, uword encap_next_node);
260 int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
261  u8 protocol_override, uword encap_next_node);
262 
263 /**
264  * @brief Struct for defining VXLAN GPE next nodes
265  */
266 typedef enum
267 {
273 
274 
276  uword next_node_index);
277 
279  uword next_node_index);
280 
282  u8 is_enable);
283 
284 #endif /* included_vnet_vxlan_gpe_h */
285 
286 /*
287  * fd.io coding-style-patch-verification: ON
288  *
289  * Local Variables:
290  * eval: (c-set-style "gnu")
291  * End:
292  */
vnet_vxlan_gpe_add_del_tunnel_args_t::encap_fib_index
u32 encap_fib_index
Definition: vxlan_gpe.h:248
adj_types.h
vxlan_gpe_tunnel_t::decap_fib_index
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
Definition: vxlan_gpe.h:127
vnet_vxlan_gpe_add_del_tunnel_args_t::decap_fib_index
u32 decap_fib_index
Definition: vxlan_gpe.h:249
vxlan_gpe_tunnel_t::mcast_sw_if_index
u32 mcast_sw_if_index
Definition: vxlan_gpe.h:122
vxlan_gpe_tunnel_t::sibling_index
u32 sibling_index
The tunnel is a child of the FIB entry for its destination.
Definition: vxlan_gpe.h:164
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
vxlan_gpe_error.def
CLIB_CACHE_LINE_ALIGN_MARK
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
VXLAN_GPE_N_ERROR
@ VXLAN_GPE_N_ERROR
Definition: vxlan_gpe.h:193
vxlan_gpe_main_t::free_vxlan_gpe_tunnel_hw_if_indices
u32 * free_vxlan_gpe_tunnel_hw_if_indices
Free vlib hw_if_indices.
Definition: vxlan_gpe.h:213
vnet_vxlan_gpe_add_del_tunnel
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Add or Del a VXLAN GPE tunnel.
Definition: vxlan_gpe.c:442
vxlan_gpe_main
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.c:47
vni
u32 vni
Definition: flow_types.api:160
vxlan_gpe_input_error_t
vxlan_gpe_input_error_t
struct for VXLAN GPE errors
Definition: vxlan_gpe.h:188
vxlan_gpe_tunnel_t::rewrite_size
u8 rewrite_size
rewrite size for dynamic plugins like iOAM
Definition: vxlan_gpe.h:141
vxlan_gpe_main_t
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:197
vxlan_gpe_tunnel_t::mcast_adj_index
adj_index_t mcast_adj_index
Definition: vxlan_gpe.h:156
vxlan_gpe_main_t::vnet_main
vnet_main_t * vnet_main
State convenience vnet_main_t.
Definition: vxlan_gpe.h:221
vxlan_gpe_main_t::vxlan6_gpe_tunnel_by_key
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:205
vxlan_gpe_input_next_t
vxlan_gpe_input_next_t
struct for next nodes for VXLAN GPE input
Definition: vxlan_gpe.h:179
vxlan_gpe_tunnel_t::protocol
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:112
vxlan_gpe_tunnel_t::encap_fib_index
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
Definition: vxlan_gpe.h:125
VXLAN_GPE_PROTOCOL_MAX
@ VXLAN_GPE_PROTOCOL_MAX
Definition: vxlan_gpe_packet.h:88
vxlan_gpe_register_decap_protocol
void vxlan_gpe_register_decap_protocol(u8 protocol_id, uword next_node_index)
Definition: decap.c:687
vxlan6_gpe_input_node
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
Definition: decap.c:754
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
ethernet.h
vxlan_gpe_tunnel_t::node
fib_node_t node
Linkage into the FIB object graph.
Definition: vxlan_gpe.h:149
ip6_packet.h
vxlan_gpe_tunnel_t::vni
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
Definition: vxlan_gpe.h:130
vxlan_gpe_encap_node
vlib_node_registration_t vxlan_gpe_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_encap_node)
Definition: encap.c:403
error.h
dpo.h
l2_output.h
vxlan_gpe_tunnel_t::rewrite
u8 * rewrite
Rewrite string.
Definition: vxlan_gpe.h:109
vnet_vxlan_gpe_add_del_tunnel_args_t::is_ip6
u8 is_ip6
Definition: vxlan_gpe.h:244
vxlan_gpe_tunnel_t::local
ip46_address_t local
tunnel local address
Definition: vxlan_gpe.h:117
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
VXLAN_GPE_INPUT_N_NEXT
@ VXLAN_GPE_INPUT_N_NEXT
Definition: vxlan_gpe.h:184
udp_packet.h
uword
u64 uword
Definition: types.h:112
vxlan_gpe_encap_next_t
vxlan_gpe_encap_next_t
Struct for defining VXLAN GPE next nodes.
Definition: vxlan_gpe.h:266
vxlan_gpe_tunnel_t::fib_entry_index
fib_node_index_t fib_entry_index
Definition: vxlan_gpe.h:155
vxlan_gpe_tunnel_t
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:103
VXLAN_GPE_ENCAP_NEXT_IP6_LOOKUP
@ VXLAN_GPE_ENCAP_NEXT_IP6_LOOKUP
Definition: vxlan_gpe.h:269
vnet_vxlan_gpe_add_del_tunnel_args_t
Struct for VXLAN GPE add/del args.
Definition: vxlan_gpe.h:241
vxlan_gpe_main_t::tunnels
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:200
vxlan6_gpe_rewrite
int vxlan6_gpe_rewrite(vxlan_gpe_tunnel_t *t, u32 extension_size, u8 protocol_override, uword encap_next_node)
Calculate IPv6 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:338
VXLAN_GPE_ENCAP_NEXT_IP4_LOOKUP
@ VXLAN_GPE_ENCAP_NEXT_IP4_LOOKUP
Definition: vxlan_gpe.h:268
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vxlan_gpe_main_t::vxlan4_gpe_tunnel_by_key
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:203
vxlan4_gpe_rewrite
int vxlan4_gpe_rewrite(vxlan_gpe_tunnel_t *t, u32 extension_size, u8 protocol_override, uword encap_next_node)
Calculate IPv4 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:280
vxlan_gpe_tunnel_t::encap_next_node
uword encap_next_node
Next node after VxLAN-GPE encap.
Definition: vxlan_gpe.h:144
l2_input.h
vxlan_gpe_main_t::vtep_table
vtep_table_t vtep_table
Definition: vxlan_gpe.h:209
ip4_packet.h
VXLAN_GPE_ENCAP_N_NEXT
@ VXLAN_GPE_ENCAP_N_NEXT
Definition: vxlan_gpe.h:271
is_ip6
bool is_ip6
Definition: ip.api:43
vnet_main_t
Definition: vnet.h:76
vxlan_gpe_packet.h
VXLAN GPE packet header structure.
u64
unsigned long u64
Definition: types.h:89
vxlan_gpe_tunnel_t::sw_if_index
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:135
ip.h
u32
unsigned int u32
Definition: types.h:88
vxlan_gpe_tunnel_t::remote
ip46_address_t remote
tunnel remote address
Definition: vxlan_gpe.h:119
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
protocol_id
u8 protocol_id
Definition: ikev2_types.api:34
vnet_int_vxlan_gpe_bypass_mode
void vnet_int_vxlan_gpe_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
Definition: vxlan_gpe.c:1027
as_u64
u64 as_u64
Definition: bihash_doc.h:63
CLIB_PACKED
typedef CLIB_PACKED(struct { ip4_header_t ip4;udp_header_t udp;vxlan_gpe_header_t vxlan;}) ip4_vxlan_gpe_header_t
VXLAN GPE header struct.
vxlan_gpe_tunnel_t::hw_if_index
u32 hw_if_index
vnet intfc hw_if_index
Definition: vxlan_gpe.h:133
ip6_header_t
Definition: ip6_packet.h:294
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
vnet_vxlan_gpe_add_del_tunnel_args_t::protocol
u8 protocol
Definition: vxlan_gpe.h:246
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
vxlan_gpe_main_t::vlib_main
vlib_main_t * vlib_main
State convenience vlib_main_t.
Definition: vxlan_gpe.h:219
vlib_main_t
Definition: main.h:102
vxlan_gpe_tunnel_t::next_dpo
dpo_id_t next_dpo
Definition: vxlan_gpe.h:115
hash.h
u8
unsigned char u8
Definition: types.h:56
a
a
Definition: bitmap.h:544
vtep_table_t
Definition: vtep.h:62
vxlan_gpe_main_t::tunnel_index_by_sw_if_index
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
Definition: vxlan_gpe.h:216
VXLAN_GPE_ENCAP_NEXT_DROP
@ VXLAN_GPE_ENCAP_NEXT_DROP
Definition: vxlan_gpe.h:270
vnet_vxlan_gpe_add_del_tunnel_args_t::vni
u32 vni
Definition: vxlan_gpe.h:250
vnet_vxlan_gpe_add_del_tunnel_args_t::is_add
u8 is_add
Definition: vxlan_gpe.h:243
vnet_vxlan_gpe_add_del_tunnel_args_t::mcast_sw_if_index
u32 mcast_sw_if_index
Definition: vxlan_gpe.h:247
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
vnet_vxlan_gpe_add_del_tunnel_args_t::remote
ip46_address_t remote
Definition: vxlan_gpe.h:245
pad
u8 pad[3]
log2 (size of the packing page block)
Definition: bihash_doc.h:61
vtep.h
vxlan_gpe_tunnel_t::flags
u32 flags
flags
Definition: vxlan_gpe.h:138
vnet.h
vxlan_gpe_header_t
VXLAN GPE Header definition.
Definition: vxlan_gpe_packet.h:94
format_vxlan_gpe_encap_trace
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
Trace of packets encapsulated in VXLAN GPE.
Definition: encap.c:70
vxlan4_gpe_input_node
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
Definition: decap.c:732
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vxlan_gpe_unregister_decap_protocol
void vxlan_gpe_unregister_decap_protocol(u8 protocol_id, uword next_node_index)
Definition: decap.c:695
l2_bd.h
foreach_vxlan_gpe_input_next
#define foreach_vxlan_gpe_input_next
next nodes for VXLAN GPE input
Definition: vxlan_gpe.h:172
vxlan_gpe_main_t::mcast_shared
uword * mcast_shared
Definition: vxlan_gpe.h:211