FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
lisp_gpe.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 LISP-GPE definitions.
18  */
19 
20 #ifndef included_vnet_lisp_gpe_h
21 #define included_vnet_lisp_gpe_h
22 
23 #include <vppinfra/error.h>
24 #include <vppinfra/mhash.h>
25 #include <vnet/vnet.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/ethernet/ethernet.h>
29 #include <vnet/ip/ip4_packet.h>
30 #include <vnet/udp/udp.h>
33 #include <vnet/adj/adj_types.h>
34 #include <vppinfra/bihash_24_8.h>
36 
37 /** IP4-UDP-LISP encap header */
38 /* *INDENT-OFF* */
39 typedef CLIB_PACKED (struct {
40  ip4_header_t ip4; /* 20 bytes */
41  udp_header_t udp; /* 8 bytes */
42  lisp_gpe_header_t lisp; /* 8 bytes */
43 }) ip4_udp_lisp_gpe_header_t;
44 /* *INDENT-ON* */
45 
46 /** IP6-UDP-LISP encap header */
47 /* *INDENT-OFF* */
48 typedef CLIB_PACKED (struct {
49  ip6_header_t ip6; /* 40 bytes */
50  udp_header_t udp; /* 8 bytes */
51  lisp_gpe_header_t lisp; /* 8 bytes */
52 }) ip6_udp_lisp_gpe_header_t;
53 /* *INDENT-ON* */
54 
55 #define foreach_lisp_gpe_ip_input_next \
56 _(DROP, "error-drop") \
57 _(IP4_INPUT, "ip4-input") \
58 _(IP6_INPUT, "ip6-input") \
59 _(L2_INPUT, "l2-input")
60 
61 /** Enum of possible next nodes post LISP-GPE decap */
62 typedef enum
63 {
64 #define _(s,n) LISP_GPE_INPUT_NEXT_##s,
66 #undef _
69 
70 /* Arc to nsh-input added only if nsh-input exists */
71 #define LISP_GPE_INPUT_NEXT_NSH_INPUT 4
72 
73 typedef enum
74 {
75 #define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
77 #undef lisp_gpe_error
80 
81 typedef struct tunnel_lookup
82 {
83  /** Lookup lisp-gpe interfaces by dp table (eg. vrf/bridge index) */
85 
86  /** lookup decap tunnel termination sw_if_index by vni and vice versa */
88 
89  // FIXME - Need this?
92 
93 typedef struct
94 {
98 
99 typedef struct
100 {
104  ip_address_t loc_rloc;
105  ip_address_t rmt_rloc;
106 
109 
110 typedef enum gpe_encap_mode_e
111 {
116 
117 /** LISP-GPE global state*/
118 typedef struct lisp_gpe_main
119 {
120  /**
121  * @brief DB of all forwarding entries. The Key is:{l-EID,r-EID,vni}
122  * where the EID encodes L2 or L3
123  */
125 
126  /**
127  * @brief A Pool of all LISP forwarding entries
128  */
130 
131  /** Free vlib hw_if_indices */
133 
135 
136  /* L3 data structures
137  * ================== */
139 
140  /* L2 data structures
141  * ================== */
142 
143  /** L2 LISP FIB */
144  BVT (clib_bihash) l2_fib;
145 
146  tunnel_lookup_t l2_ifaces;
147 
148  /** Load-balance for a miss in the table */
149  dpo_id_t l2_lb_cp_lkup;
150 
151  /* NSH data structures
152  * ================== */
153 
154  BVT (clib_bihash) nsh_fib;
155 
156  tunnel_lookup_t nsh_ifaces;
157 
158  const dpo_id_t *nsh_cp_lkup;
159 
160  gpe_encap_mode_t encap_mode;
161 
162  u8 *dummy_stats_pool;
163  uword *lisp_stats_index_by_key;
165 
166  /** Native fwd data structures */
167  fib_route_path_t *native_fwd_rpath[2];
168  u32 *native_fwd_lfes[2];
169 
170  /** convenience */
178 
179 /** LISP-GPE global state*/
181 
184 {
185  return &lisp_gpe_main;
186 }
187 
188 
192 
193 u8 *format_lisp_gpe_header_with_length (u8 * s, va_list * args);
194 
195 /** Read LISP-GPE status */
197 
198 u32
200  u32 overlay_table_id, u32 vni);
201 
202 /** Add/del LISP-GPE interface. */
203 extern void lisp_gpe_del_l2_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
204 extern u32 lisp_gpe_add_l2_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
205 extern void lisp_gpe_del_l3_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
206 extern u32 lisp_gpe_add_l3_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
207 
208 
209 typedef struct
210 {
213 
216 
217 typedef enum
218 {
224 
225 /** */
226 typedef struct
227 {
228  /** forwarding entry index of */
230 
232 
234 
235  /** type of mapping */
237 
238  /** action for negative mappings */
239  negative_fwd_actions_e action;
240 
241  /** local eid */
243 
244  /** remote eid */
246 
247  /** vector of locator pairs */
249 
250  /** FIB index to lookup remote locator at encap */
252 
253  /** FIB index to lookup inner IP at decap */
255 
256  /* TODO remove */
258 
259  /** VNI/tenant id in HOST byte order */
261 
262  /** vrf or bd where fwd entry should be inserted */
263  union
264  {
265  /** table (vrf) id */
267 
268  /** bridge domain id */
270 
271  /** generic access */
273  };
275 
276 typedef struct
277 {
281 
282 typedef struct
283 {
291 
292 #define foreach_lgpe_ip4_lookup_next \
293  _(DROP, "error-drop") \
294  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
295 
297 {
298 #define _(sym,str) LGPE_IP4_LOOKUP_NEXT_##sym,
300 #undef _
303 
304 #define foreach_lgpe_ip6_lookup_next \
305  _(DROP, "error-drop") \
306  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
307 
309 {
310 #define _(sym,str) LGPE_IP6_LOOKUP_NEXT_##sym,
312 #undef _
315 
316 u8 *format_vnet_lisp_gpe_status (u8 * s, va_list * args);
317 
319 gpe_encap_mode_t vnet_gpe_get_encap_mode (void);
320 int vnet_gpe_set_encap_mode (gpe_encap_mode_t mode);
321 
325 int vnet_lisp_flush_stats (void);
329 
330 #endif /* included_vnet_lisp_gpe_h */
331 
332 /*
333  * fd.io coding-style-patch-verification: ON
334  *
335  * Local Variables:
336  * eval: (c-set-style "gnu")
337  * End:
338  */
u32 fwd_entry_index
Definition: lisp_gpe.h:284
#define foreach_lisp_gpe_ip_input_next
Definition: lisp_gpe.h:55
u32 * free_tunnel_hw_if_indices
Free vlib hw_if_indices.
Definition: lisp_gpe.h:132
lisp_gpe_main_t lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.h:180
vnet_api_error_t
Definition: api_errno.h:117
int vnet_gpe_set_encap_mode(gpe_encap_mode_t mode)
Set GPE encapsulation mode.
Definition: lisp_gpe.c:217
a
Definition: bitmap.h:516
gpe_encap_mode_t vnet_gpe_get_encap_mode(void)
Definition: lisp_gpe.c:628
A representation of a path as described by a route producer.
Definition: fib_types.h:336
u32 bd_id
bridge domain id
Definition: lisp_gpe.h:269
u8 vnet_lisp_stats_enable_disable_state(void)
Definition: control.c:4276
u8 action
Definition: lisp_gpe.h:287
vnet_api_error_t vnet_lisp_stats_enable_disable(u8 enable)
Definition: control.c:4260
dp_address_t seid
Definition: lisp_gpe.h:103
LISP-GPE global state.
Definition: lisp_gpe.h:118
u32 encap_fib_index
FIB index to lookup remote locator at encap.
Definition: lisp_gpe.h:251
ip_address_t loc_rloc
Definition: lisp_gpe.h:104
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Enable/disable LISP-GPE.
Definition: lisp_gpe.c:193
Combined counter to hold both packets and byte differences.
Definition: counter.h:139
void vnet_lisp_gpe_del_nsh_iface(lisp_gpe_main_t *lgm)
Del LISP-GPE NSH interface.
Definition: interface.c:785
struct _vlib_node_registration vlib_node_registration_t
vnet_hw_interface_class_t lisp_gpe_hw_class
uword * vni_by_sw_if_index
Definition: lisp_gpe.h:90
void lisp_gpe_del_l2_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id)
Add/del LISP-GPE interface.
Definition: interface.c:711
vlib_node_registration_t lisp_gpe_ip4_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node)
Definition: decap.c:461
static lisp_gpe_main_t * vnet_lisp_gpe_get_main()
Definition: lisp_gpe.h:183
lgpe_ip6_lookup_next
Definition: lisp_gpe.h:308
lisp_api_stats_t * vnet_lisp_get_stats(void)
Definition: control.c:4043
u32 fwd_entry_index
Definition: lisp_gpe.h:95
#define always_inline
Definition: clib.h:84
ip_address_t rmt_rloc
Definition: lisp_gpe.h:105
static BVT(clib_bihash)
Definition: adj_nbr.c:26
u8 is_add
Definition: lisp_gpe.h:233
typedef CLIB_PACKED(struct{ip4_header_t ip4;udp_header_t udp;lisp_gpe_header_t lisp;}) ip4_udp_lisp_gpe_header_t
IP4-UDP-LISP encap header.
int vnet_lisp_flush_stats(void)
gpe_encap_mode_e
Definition: lisp_gpe.h:110
uword * lisp_gpe_fwd_entries
DB of all forwarding entries.
Definition: lisp_gpe.h:124
enum gpe_encap_mode_e gpe_encap_mode_t
struct tunnel_lookup tunnel_lookup_t
Definition: lisp_gpe.h:226
u32 lisp_gpe_add_l3_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id)
Add/del LISP-GPE L3 interface.
Definition: interface.c:571
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:152
u32 table_id
table (vrf) id
Definition: lisp_gpe.h:266
vlib_node_registration_t lisp_gpe_ip6_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node)
Definition: decap.c:483
lisp_api_gpe_fwd_entry_t * vnet_lisp_gpe_fwd_entries_get_by_vni(u32 vni)
vnet_main_t vnet_main
Definition: misc.c:43
u32 vni
Definition: lisp_gpe.h:286
u32 decap_next_index
Definition: lisp_gpe.h:257
LISP-GPE packet header structure.
Definition: lisp_gpe.h:282
u8 * format_lisp_gpe_header_with_length(u8 *s, va_list *args)
Definition: interface.c:171
dp_address_t deid
Definition: lisp_gpe.h:102
u8 is_negative
type of mapping
Definition: lisp_gpe.h:236
uword * sw_if_index_by_vni
lookup decap tunnel termination sw_if_index by vni and vice versa
Definition: lisp_gpe.h:87
u32 vni
VNI/tenant id in HOST byte order.
Definition: lisp_gpe.h:260
u32 fwd_entry_index
forwarding entry index of
Definition: lisp_gpe.h:229
vlib_counter_t counters
Definition: lisp_gpe.h:107
void lisp_gpe_del_l3_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id)
Definition: interface.c:611
lisp_gpe_input_next_t
Enum of possible next nodes post LISP-GPE decap.
Definition: lisp_gpe.h:62
u32 decap_fib_index
FIB index to lookup inner IP at decap.
Definition: lisp_gpe.h:254
dp_address_t reid
Definition: lisp_gpe.h:289
enum lgpe_ip6_lookup_next lgpe_ip6_lookup_next_t
LISP-GPE header.
#define foreach_lgpe_ip4_lookup_next
Definition: lisp_gpe.h:292
struct _gid_address_t gid_address_t
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
Definition: main.c:1692
enum lgpe_ip4_lookup_next lgpe_ip4_lookup_next_t
unsigned int u32
Definition: types.h:88
IPv4 main type.
Definition: ip4.h:83
uword * hw_if_index_by_dp_table
Lookup lisp-gpe interfaces by dp table (eg.
Definition: lisp_gpe.h:84
u8 is_src_dst
Definition: lisp_gpe.h:231
lisp_gpe_error_t
Definition: lisp_gpe.h:73
#define foreach_lgpe_ip6_lookup_next
Definition: lisp_gpe.h:304
gid_address_t rmt_eid
remote eid
Definition: lisp_gpe.h:245
u64 uword
Definition: types.h:112
u32 lisp_gpe_l3_iface_find_or_create(lisp_gpe_main_t *lgm, u32 overlay_table_id, u32 vni)
negative_fwd_actions_e action
action for negative mappings
Definition: lisp_gpe.h:239
Definition: lisp_gpe.h:222
struct lisp_gpe_fwd_entry_t_ * lisp_fwd_entry_pool
A Pool of all LISP forwarding entries.
Definition: lisp_gpe.h:129
u32 vnet_lisp_gpe_add_nsh_iface(lisp_gpe_main_t *lgm)
Add LISP-GPE NSH interface.
Definition: interface.c:745
u32 lisp_gpe_add_l2_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id)
Add/del LISP-GPE L2 interface.
Definition: interface.c:648
struct _vnet_hw_interface_class vnet_hw_interface_class_t
unsigned char u8
Definition: types.h:56
tunnel_lookup_t l3_ifaces
Definition: lisp_gpe.h:138
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
Format LISP-GPE status.
Definition: lisp_gpe.c:584
u32 dp_table
generic access
Definition: lisp_gpe.h:272
negative_fwd_actions_e
Definition: lisp_gpe.h:217
locator_pair_t * locator_pairs
vector of locator pairs
Definition: lisp_gpe.h:248
int vnet_gpe_add_del_native_fwd_rpath(vnet_gpe_native_fwd_rpath_args_t *a)
Definition: lisp_gpe.c:451
A collection of combined counters.
Definition: counter.h:180
u8 vnet_lisp_gpe_enable_disable_status(void)
Read LISP-GPE status.
Definition: lisp_gpe.c:184
dp_address_t leid
Definition: lisp_gpe.h:288
lgpe_ip4_lookup_next
Definition: lisp_gpe.h:296
gid_address_t lcl_eid
local eid
Definition: lisp_gpe.h:242
A LISP Forwarding Entry.
u32 dp_table
Definition: lisp_gpe.h:285