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/l2/l2_input.h>
28 #include <vnet/l2/l2_output.h>
29 #include <vnet/l2/l2_bd.h>
30 #include <vnet/ethernet/ethernet.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
32 #include <vnet/ip/ip4_packet.h>
33 #include <vnet/ip/ip6_packet.h>
34 #include <vnet/udp/udp.h>
35 #include <vnet/dpo/dpo.h>
36 #include <vnet/adj/adj_types.h>
39 * @brief VXLAN GPE header struct
43 typedef CLIB_PACKED (struct {
49 vxlan_gpe_header_t vxlan;
50 }) ip4_vxlan_gpe_header_t;
54 typedef CLIB_PACKED (struct {
60 vxlan_gpe_header_t vxlan;
61 }) ip6_vxlan_gpe_header_t;
65 * @brief Key struct for IPv4 VXLAN GPE tunnel.
66 * Key fields: local remote, vni
67 * all fields in NET byte order
71 typedef CLIB_PACKED(struct {
82 }) vxlan4_gpe_tunnel_key_t;
86 * @brief Key struct for IPv6 VXLAN GPE tunnel.
87 * Key fields: local remote, vni
88 * all fields in NET byte order
92 typedef CLIB_PACKED(struct {
96 }) vxlan6_gpe_tunnel_key_t;
100 * @brief Struct for VXLAN GPE tunnel
104 /** Rewrite string. $$$$ embed vnet_rewrite header */
107 /** encapsulated protocol */
110 /* FIB DPO for IP forwarding of VXLAN-GPE encap packet */
112 /** tunnel local address */
113 ip46_address_t local;
114 /** tunnel remote address */
115 ip46_address_t remote;
117 /* mcast packet output intfc index (used only if dst is mcast) */
118 u32 mcast_sw_if_index;
120 /** FIB indices - tunnel partner lookup here */
122 /** FIB indices - inner IP packet lookup here */
125 /** VXLAN GPE VNI in HOST byte order, shifted left 8 bits */
128 /** vnet intfc hw_if_index */
130 /** vnet intfc sw_if_index */
136 /** rewrite size for dynamic plugins like iOAM */
139 /** Next node after VxLAN-GPE encap */
140 uword encap_next_node;
143 * Linkage into the FIB object graph
148 * The FIB entry for (depending on VXLAN-GPE tunnel is unicast or mcast)
149 * sending unicast VXLAN-GPE encap packets or receiving mcast VXLAN-GPE packets
151 fib_node_index_t fib_entry_index;
152 adj_index_t mcast_adj_index;
155 * The tunnel is a child of the FIB entry for its desintion. This is
156 * so it receives updates when the forwarding information for that entry
158 * The tunnels sibling index on the FIB entry's dependency list.
162 } vxlan_gpe_tunnel_t;
164 /** Flags for vxlan_gpe_tunnel_t */
165 #define VXLAN_GPE_TUNNEL_IS_IPV4 1
167 /** next nodes for VXLAN GPE input */
168 #define foreach_vxlan_gpe_input_next \
169 _(DROP, "error-drop") \
170 _(IP4_INPUT, "ip4-input") \
171 _(IP6_INPUT, "ip6-input") \
172 _(L2_INPUT, "l2-input")
174 /** struct for next nodes for VXLAN GPE input */
177 #define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
178 foreach_vxlan_gpe_input_next
180 VXLAN_GPE_INPUT_N_NEXT,
181 } vxlan_gpe_input_next_t;
183 /** struct for VXLAN GPE errors */
186 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
187 #include <vnet/vxlan-gpe/vxlan_gpe_error.def>
188 #undef vxlan_gpe_error
190 } vxlan_gpe_input_error_t;
192 /** Struct for VXLAN GPE node state */
195 /** vector of encap tunnel instances */
196 vxlan_gpe_tunnel_t *tunnels;
198 /** lookup IPv4 VXLAN GPE tunnel by key */
199 uword *vxlan4_gpe_tunnel_by_key;
200 /** lookup IPv6 VXLAN GPE tunnel by key */
201 uword *vxlan6_gpe_tunnel_by_key;
203 /* local VTEP IPs ref count used by vxlan-bypass node to check if
204 received VXLAN packet DIP matches any local VTEP address */
205 uword *vtep4; /* local ip4 VTEPs keyed on their ip4 addr */
206 uword *vtep6; /* local ip6 VTEPs keyed on their ip6 addr */
207 /* mcast shared info */
208 uword *mcast_shared; /* keyed on mcast ip46 addr */
209 /** Free vlib hw_if_indices */
210 u32 *free_vxlan_gpe_tunnel_hw_if_indices;
212 /** Mapping from sw_if_index to tunnel index */
213 u32 *tunnel_index_by_sw_if_index;
215 /** State convenience vlib_main_t */
216 vlib_main_t *vlib_main;
217 /** State convenience vnet_main_t */
218 vnet_main_t *vnet_main;
220 /** List of next nodes for the decap indexed on protocol */
221 uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
224 extern vxlan_gpe_main_t vxlan_gpe_main;
226 extern vlib_node_registration_t vxlan_gpe_encap_node;
227 extern vlib_node_registration_t vxlan4_gpe_input_node;
228 extern vlib_node_registration_t vxlan6_gpe_input_node;
230 u8 *format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
232 /** Struct for VXLAN GPE add/del args */
237 ip46_address_t local, remote;
239 u32 mcast_sw_if_index;
243 } vnet_vxlan_gpe_add_del_tunnel_args_t;
246 int vnet_vxlan_gpe_add_del_tunnel
247 (vnet_vxlan_gpe_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
250 int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
251 u8 protocol_override, uword encap_next_node);
252 int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
253 u8 protocol_override, uword encap_next_node);
256 * @brief Struct for defining VXLAN GPE next nodes
260 VXLAN_GPE_ENCAP_NEXT_IP4_LOOKUP,
261 VXLAN_GPE_ENCAP_NEXT_IP6_LOOKUP,
262 VXLAN_GPE_ENCAP_NEXT_DROP,
263 VXLAN_GPE_ENCAP_N_NEXT
264 } vxlan_gpe_encap_next_t;
267 void vxlan_gpe_unregister_decap_protocol (u8 protocol_id,
268 uword next_node_index);
270 void vxlan_gpe_register_decap_protocol (u8 protocol_id,
271 uword next_node_index);
273 void vnet_int_vxlan_gpe_bypass_mode (u32 sw_if_index, u8 is_ip6,
276 #endif /* included_vnet_vxlan_gpe_h */
279 * fd.io coding-style-patch-verification: ON
282 * eval: (c-set-style "gnu")