2 * Copyright (c) 2017 SUSE LLC.
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.
15 #ifndef included_vnet_geneve_h
16 #define included_vnet_geneve_h
18 #include <vppinfra/error.h>
19 #include <vppinfra/hash.h>
20 #include <vnet/vnet.h>
22 #include <geneve/geneve_packet.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/vtep.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2/l2_output.h>
28 #include <vnet/l2/l2_bd.h>
29 #include <vnet/ethernet/ethernet.h>
30 #include <vnet/ip/ip4_packet.h>
31 #include <vnet/ip/ip6_packet.h>
32 #include <vnet/udp/udp_packet.h>
33 #include <vnet/udp/udp_local.h>
34 #include <vnet/dpo/dpo.h>
35 #include <vnet/adj/adj_types.h>
37 #define SUPPORT_OPTIONS_HEADER 0
39 typedef CLIB_PACKED (struct
41 ip4_header_t ip4; /* 20 bytes */
42 udp_header_t udp; /* 8 bytes */
43 geneve_header_t geneve; /* Min 8 bytes, Max 260 bytes */
44 }) ip4_geneve_header_t;
46 typedef CLIB_PACKED (struct
48 ip6_header_t ip6; /* 40 bytes */
49 udp_header_t udp; /* 8 bytes */
50 geneve_header_t geneve; /* Min 8 bytes, Max 260 bytes */
51 }) ip6_geneve_header_t;
53 typedef CLIB_PACKED (struct
56 * Key fields: ip source and geneve vni on incoming GENEVE packet
57 * all fields in NET byte order
64 u32 vni; /* shifted left 8 bits */
68 }) geneve4_tunnel_key_t;
70 typedef CLIB_PACKED (struct
73 * Key fields: ip source and geneve vni on incoming GENEVE packet
74 * all fields in NET byte order
77 u32 vni; /* shifted left 8 bits */
78 }) geneve6_tunnel_key_t;
84 } geneve_encap_trace_t;
88 /* Required for pool_get_aligned */
89 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
91 /* Rewrite string. $$$$ embed vnet_rewrite header */
94 /* FIB DPO for IP forwarding of GENEVE encap packet */
97 /* geneve VNI in HOST byte order */
100 /* geneve OPTIONS LEN in HOST byte order */
101 #if SUPPORT_OPTIONS_HEADER==1
105 /* tunnel local and remote addresses */
106 ip46_address_t local;
107 ip46_address_t remote;
109 /* mcast packet output intfc index (used only if remote is mcast) */
110 u32 mcast_sw_if_index;
112 /* decap next index */
113 u32 decap_next_index;
115 /* The FIB index for local/remote addresses */
118 /* vnet intfc index */
123 * Linkage into the FIB object graph
128 * The FIB entry for (depending on GENEVE tunnel is unicast or mcast)
129 * sending unicast GENEVE encap packets or receiving mcast GENEVE packets
131 fib_node_index_t fib_entry_index;
132 adj_index_t mcast_adj_index;
135 * The tunnel is a child of the FIB entry for its desintion. This is
136 * so it receives updates when the forwarding information for that entry
138 * The tunnels sibling index on the FIB entry's dependency list.
145 #define foreach_geneve_input_next \
146 _(DROP, "error-drop") \
147 _(L2_INPUT, "l2-input")
151 #define _(s,n) GENEVE_INPUT_NEXT_##s,
152 foreach_geneve_input_next
155 } geneve_input_next_t;
159 #define geneve_error(n,s) GENEVE_ERROR_##n,
160 #include <geneve/geneve_error.def>
163 } geneve_input_error_t;
167 /* vector of encap tunnel instances */
168 geneve_tunnel_t *tunnels;
170 /* lookup tunnel by key */
171 uword *geneve4_tunnel_by_key; /* keyed on ipv4.remote + vni */
172 uword *geneve6_tunnel_by_key; /* keyed on ipv6.remote + vni */
174 /* local VTEP IPs ref count used by geneve-bypass node to check if
175 received GENEVE packet DIP matches any local VTEP address */
176 vtep_table_t vtep_table;
178 /* mcast shared info */
179 uword *mcast_shared; /* keyed on mcast ip46 addr */
181 /* Mapping from sw_if_index to tunnel index */
182 u32 *tunnel_index_by_sw_if_index;
185 vlib_main_t *vlib_main;
186 vnet_main_t *vnet_main;
191 extern geneve_main_t geneve_main;
193 extern vlib_node_registration_t geneve4_input_node;
194 extern vlib_node_registration_t geneve6_input_node;
195 extern vlib_node_registration_t geneve4_encap_node;
196 extern vlib_node_registration_t geneve6_encap_node;
198 u8 *format_geneve_encap_trace (u8 * s, va_list * args);
204 /* we normally use is_ip4, but since this adds to the
205 * structure, this seems less of abreaking change */
207 ip46_address_t local, remote;
208 u32 mcast_sw_if_index;
210 u32 decap_next_index;
213 } vnet_geneve_add_del_tunnel_args_t;
215 int vnet_geneve_add_del_tunnel
216 (vnet_geneve_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
218 void vnet_int_geneve_bypass_mode (u32 sw_if_index, u8 is_ip6, u8 is_enable);
219 #endif /* included_vnet_geneve_h */
222 * fd.io coding-style-patch-verification: ON
225 * eval: (c-set-style "gnu")