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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @brief VXLAN GPE definitions
20 #ifndef included_vnet_vxlan_gpe_h
21 #define included_vnet_vxlan_gpe_h
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>
32 #include <vnet/vxlan-gpe/vxlan_gpe_packet.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>
40 * @brief VXLAN GPE header struct
44 typedef CLIB_PACKED (struct {
50 vxlan_gpe_header_t vxlan;
51 }) ip4_vxlan_gpe_header_t;
55 typedef CLIB_PACKED (struct {
61 vxlan_gpe_header_t vxlan;
62 }) ip6_vxlan_gpe_header_t;
66 * @brief Key struct for IPv4 VXLAN GPE tunnel.
67 * Key fields: local remote, vni, udp-port
68 * all fields in NET byte order
72 typedef CLIB_PACKED(struct {
83 }) vxlan4_gpe_tunnel_key_t;
87 * @brief Key struct for IPv6 VXLAN GPE tunnel.
88 * Key fields: local remote, vni, udp-port
89 * all fields in NET byte order
93 typedef CLIB_PACKED(struct {
98 }) vxlan6_gpe_tunnel_key_t;
110 } vxlan_gpe_decap_info_t;
113 * @brief Struct for VXLAN GPE tunnel
117 /* Required for pool_get_aligned */
118 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
120 /** Rewrite string. $$$$ embed vnet_rewrite header */
123 /** encapsulated protocol */
126 /* FIB DPO for IP forwarding of VXLAN-GPE encap packet */
128 /** tunnel local address */
129 ip46_address_t local;
130 /** tunnel remote address */
131 ip46_address_t remote;
132 /** local udp-port **/
134 /** remote udp-port **/
137 /* mcast packet output intfc index (used only if dst is mcast) */
138 u32 mcast_sw_if_index;
140 /** FIB indices - tunnel partner lookup here */
142 /** FIB indices - inner IP packet lookup here */
145 /** VXLAN GPE VNI in HOST byte order, shifted left 8 bits */
148 /** vnet intfc hw_if_index */
150 /** vnet intfc sw_if_index */
156 /** rewrite size for dynamic plugins like iOAM */
159 /** Next node after VxLAN-GPE encap */
160 uword encap_next_node;
163 * Linkage into the FIB object graph
168 * The FIB entry for (depending on VXLAN-GPE tunnel is unicast or mcast)
169 * sending unicast VXLAN-GPE encap packets or receiving mcast VXLAN-GPE packets
171 fib_node_index_t fib_entry_index;
172 adj_index_t mcast_adj_index;
175 * The tunnel is a child of the FIB entry for its destination. This is
176 * so it receives updates when the forwarding information for that entry
178 * The tunnels sibling index on the FIB entry's dependency list.
182 } vxlan_gpe_tunnel_t;
184 /** Flags for vxlan_gpe_tunnel_t */
185 #define VXLAN_GPE_TUNNEL_IS_IPV4 1
187 /** next nodes for VXLAN GPE input */
188 #define foreach_vxlan_gpe_input_next \
189 _(DROP, "error-drop") \
190 _(IP4_INPUT, "ip4-input") \
191 _(IP6_INPUT, "ip6-input") \
192 _(L2_INPUT, "l2-input")
194 /** struct for next nodes for VXLAN GPE input */
197 #define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
198 foreach_vxlan_gpe_input_next
200 VXLAN_GPE_INPUT_N_NEXT,
201 } vxlan_gpe_input_next_t;
203 /** struct for VXLAN GPE errors */
206 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
207 #include <vnet/vxlan-gpe/vxlan_gpe_error.def>
208 #undef vxlan_gpe_error
210 } vxlan_gpe_input_error_t;
212 /** Struct for VXLAN GPE node state */
215 /** vector of encap tunnel instances */
216 vxlan_gpe_tunnel_t *tunnels;
218 /** lookup IPv4 VXLAN GPE tunnel by key */
219 uword *vxlan4_gpe_tunnel_by_key;
220 /** lookup IPv6 VXLAN GPE tunnel by key */
221 uword *vxlan6_gpe_tunnel_by_key;
223 /* local VTEP IPs ref count used by vxlan-bypass node to check if
224 received VXLAN packet DIP matches any local VTEP address */
225 vtep_table_t vtep_table;
226 /* mcast shared info */
227 uword *mcast_shared; /* keyed on mcast ip46 addr */
228 /** Free vlib hw_if_indices */
229 u32 *free_vxlan_gpe_tunnel_hw_if_indices;
231 /** Mapping from sw_if_index to tunnel index */
232 u32 *tunnel_index_by_sw_if_index;
234 /** State convenience vlib_main_t */
235 vlib_main_t *vlib_main;
236 /** State convenience vnet_main_t */
237 vnet_main_t *vnet_main;
239 /* cache for last 8 vxlan_gpe tunnel */
240 #ifdef CLIB_HAVE_VEC512
241 vtep4_cache_t vtep4_u512;
244 /** List of next nodes for the decap indexed on protocol */
245 uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
248 extern vxlan_gpe_main_t vxlan_gpe_main;
250 extern vlib_node_registration_t vxlan_gpe_encap_node;
251 extern vlib_node_registration_t vxlan4_gpe_input_node;
252 extern vlib_node_registration_t vxlan6_gpe_input_node;
254 u8 *format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
256 /** Struct for VXLAN GPE add/del args */
261 ip46_address_t local, remote;
263 u32 mcast_sw_if_index;
269 } vnet_vxlan_gpe_add_del_tunnel_args_t;
272 int vnet_vxlan_gpe_add_del_tunnel
273 (vnet_vxlan_gpe_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
276 int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
277 u8 protocol_override, uword encap_next_node);
278 int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
279 u8 protocol_override, uword encap_next_node);
282 * @brief Struct for defining VXLAN GPE next nodes
286 VXLAN_GPE_ENCAP_NEXT_IP4_LOOKUP,
287 VXLAN_GPE_ENCAP_NEXT_IP6_LOOKUP,
288 VXLAN_GPE_ENCAP_NEXT_DROP,
289 VXLAN_GPE_ENCAP_N_NEXT
290 } vxlan_gpe_encap_next_t;
293 void vxlan_gpe_unregister_decap_protocol (u8 protocol_id,
294 uword next_node_index);
296 void vxlan_gpe_register_decap_protocol (u8 protocol_id,
297 uword next_node_index);
299 void vnet_int_vxlan_gpe_bypass_mode (u32 sw_if_index, u8 is_ip6,
302 #endif /* included_vnet_vxlan_gpe_h */
305 * fd.io coding-style-patch-verification: ON
308 * eval: (c-set-style "gnu")