FD.io VPP  v21.01.1
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_packet.h>
31 #include <vnet/udp/udp_local.h>
34 #include <vnet/adj/adj_types.h>
35 #include <vppinfra/bihash_24_8.h>
37 
38 /** IP4-UDP-LISP encap header */
39 /* *INDENT-OFF* */
40 typedef CLIB_PACKED (struct {
41  ip4_header_t ip4; /* 20 bytes */
42  udp_header_t udp; /* 8 bytes */
43  lisp_gpe_header_t lisp; /* 8 bytes */
44 }) ip4_udp_lisp_gpe_header_t;
45 /* *INDENT-ON* */
46 
47 /** IP6-UDP-LISP encap header */
48 /* *INDENT-OFF* */
49 typedef CLIB_PACKED (struct {
50  ip6_header_t ip6; /* 40 bytes */
51  udp_header_t udp; /* 8 bytes */
52  lisp_gpe_header_t lisp; /* 8 bytes */
53 }) ip6_udp_lisp_gpe_header_t;
54 /* *INDENT-ON* */
55 
56 #define foreach_lisp_gpe_ip_input_next \
57 _(DROP, "error-drop") \
58 _(IP4_INPUT, "ip4-input") \
59 _(IP6_INPUT, "ip6-input") \
60 _(L2_INPUT, "l2-input")
61 
62 /** Enum of possible next nodes post LISP-GPE decap */
63 typedef enum
64 {
65 #define _(s,n) LISP_GPE_INPUT_NEXT_##s,
67 #undef _
70 
71 /* Arc to nsh-input added only if nsh-input exists */
72 #define LISP_GPE_INPUT_NEXT_NSH_INPUT 4
73 
74 typedef enum
75 {
76 #define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
78 #undef lisp_gpe_error
81 
82 typedef struct tunnel_lookup
83 {
84  /** Lookup lisp-gpe interfaces by dp table (eg. vrf/bridge index) */
86 
87  /** lookup decap tunnel termination sw_if_index by vni and vice versa */
89 
90  // FIXME - Need this?
93 
94 typedef struct
95 {
99 
100 typedef struct
101 {
107 
110 
111 typedef enum gpe_encap_mode_e
112 {
117 
118 /** LISP-GPE global state*/
119 typedef struct lisp_gpe_main
120 {
121  /**
122  * @brief DB of all forwarding entries. The Key is:{l-EID,r-EID,vni}
123  * where the EID encodes L2 or L3
124  */
126 
127  /**
128  * @brief A Pool of all LISP forwarding entries
129  */
131 
132  /** Free vlib hw_if_indices */
134 
136 
137  /* L3 data structures
138  * ================== */
140 
141  /* L2 data structures
142  * ================== */
143 
144  /** L2 LISP FIB */
145  BVT (clib_bihash) l2_fib;
146 
148 
149  /** Load-balance for a miss in the table */
151 
152  /* NSH data structures
153  * ================== */
154 
155  BVT (clib_bihash) nsh_fib;
156 
158 
160 
161  gpe_encap_mode_t encap_mode;
162 
166 
167  /** Native fwd data structures */
168  fib_route_path_t *native_fwd_rpath[2];
169  u32 *native_fwd_lfes[2];
170 
171  /** convenience */
179 
180 /** LISP-GPE global state*/
182 
185 {
186  return &lisp_gpe_main;
187 }
188 
189 
193 
194 u8 *format_lisp_gpe_header_with_length (u8 * s, va_list * args);
195 
196 /** Read LISP-GPE status */
198 
199 u32
201  u32 overlay_table_id, u32 vni);
202 
203 /** Add/del LISP-GPE interface. */
204 extern void lisp_gpe_del_l2_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
205 extern u32 lisp_gpe_add_l2_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
206 extern void lisp_gpe_del_l3_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
207 extern u32 lisp_gpe_add_l3_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id,
208  u8 with_default_route);
209 
210 
211 typedef struct
212 {
215 
218 
219 typedef enum
220 {
226 
227 /** */
228 typedef struct
229 {
230  /** forwarding entry index of */
232 
234 
236 
237  /** type of mapping */
239 
240  /** action for negative mappings */
241  negative_fwd_actions_e action;
242 
243  /** local eid */
245 
246  /** remote eid */
248 
249  /** vector of locator pairs */
251 
252  /** FIB index to lookup remote locator at encap */
254 
255  /** FIB index to lookup inner IP at decap */
257 
258  /* TODO remove */
260 
261  /** VNI/tenant id in HOST byte order */
263 
264  /** vrf or bd where fwd entry should be inserted */
265  union
266  {
267  /** table (vrf) id */
269 
270  /** bridge domain id */
272 
273  /** generic access */
275  };
277 
278 typedef struct
279 {
283 
284 typedef struct
285 {
293 
294 #define foreach_lgpe_ip4_lookup_next \
295  _(DROP, "error-drop") \
296  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
297 
299 {
300 #define _(sym,str) LGPE_IP4_LOOKUP_NEXT_##sym,
302 #undef _
305 
306 #define foreach_lgpe_ip6_lookup_next \
307  _(DROP, "error-drop") \
308  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
309 
311 {
312 #define _(sym,str) LGPE_IP6_LOOKUP_NEXT_##sym,
314 #undef _
317 
318 u8 *format_vnet_lisp_gpe_status (u8 * s, va_list * args);
319 
321 gpe_encap_mode_t vnet_gpe_get_encap_mode (void);
322 int vnet_gpe_set_encap_mode (gpe_encap_mode_t mode);
323 
327 int vnet_lisp_flush_stats (void);
331 
332 #endif /* included_vnet_lisp_gpe_h */
333 
334 /*
335  * fd.io coding-style-patch-verification: ON
336  *
337  * Local Variables:
338  * eval: (c-set-style "gnu")
339  * End:
340  */
u32 fwd_entry_index
Definition: lisp_gpe.h:286
#define foreach_lisp_gpe_ip_input_next
Definition: lisp_gpe.h:56
u32 * free_tunnel_hw_if_indices
Free vlib hw_if_indices.
Definition: lisp_gpe.h:133
lisp_gpe_main_t lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.c:30
vnet_api_error_t
Definition: api_errno.h:162
int vnet_gpe_set_encap_mode(gpe_encap_mode_t mode)
Set GPE encapsulation mode.
Definition: lisp_gpe.c:224
a
Definition: bitmap.h:544
gpe_encap_mode_t vnet_gpe_get_encap_mode(void)
Definition: lisp_gpe.c:631
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.
A representation of a path as described by a route producer.
Definition: fib_types.h:500
u32 bd_id
bridge domain id
Definition: lisp_gpe.h:271
u8 vnet_lisp_stats_enable_disable_state(void)
Definition: control.c:4863
u8 action
Definition: lisp_gpe.h:289
vnet_api_error_t vnet_lisp_stats_enable_disable(u8 enable)
Definition: control.c:4847
dp_address_t seid
Definition: lisp_gpe.h:104
LISP-GPE global state.
Definition: lisp_gpe.h:119
u32 encap_fib_index
FIB index to lookup remote locator at encap.
Definition: lisp_gpe.h:253
ip_address_t loc_rloc
Definition: lisp_gpe.h:105
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_types.h:26
void vnet_lisp_gpe_del_nsh_iface(lisp_gpe_main_t *lgm)
Del LISP-GPE NSH interface.
Definition: interface.c:794
vnet_hw_interface_class_t lisp_gpe_hw_class
uword * vni_by_sw_if_index
Definition: lisp_gpe.h:91
unsigned char u8
Definition: types.h:56
void lisp_gpe_del_l2_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id)
Add/del LISP-GPE interface.
Definition: interface.c:720
vlib_main_t * vlib_main
convenience
Definition: lisp_gpe.h:172
vlib_node_registration_t lisp_gpe_ip4_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node)
Definition: decap.c:460
static lisp_gpe_main_t * vnet_lisp_gpe_get_main()
Definition: lisp_gpe.h:184
const dpo_id_t * nsh_cp_lkup
Definition: lisp_gpe.h:159
lgpe_ip6_lookup_next
Definition: lisp_gpe.h:310
lisp_api_stats_t * vnet_lisp_get_stats(void)
Definition: control.c:4548
ip6_main_t * im6
Definition: lisp_gpe.h:175
u32 fwd_entry_index
Definition: lisp_gpe.h:96
vl_api_ip6_address_t ip6
Definition: one.api:424
ip_address_t rmt_rloc
Definition: lisp_gpe.h:106
vlib_combined_counter_main_t counters
Definition: lisp_gpe.h:165
u8 is_add
Definition: lisp_gpe.h:235
int vnet_lisp_flush_stats(void)
gpe_encap_mode_e
Definition: lisp_gpe.h:111
uword * lisp_gpe_fwd_entries
DB of all forwarding entries.
Definition: lisp_gpe.h:125
unsigned int u32
Definition: types.h:88
enum gpe_encap_mode_e gpe_encap_mode_t
struct tunnel_lookup tunnel_lookup_t
Definition: lisp_gpe.h:228
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:170
u32 table_id
table (vrf) id
Definition: lisp_gpe.h:268
vlib_node_registration_t lisp_gpe_ip6_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node)
Definition: decap.c:482
lisp_api_gpe_fwd_entry_t * vnet_lisp_gpe_fwd_entries_get_by_vni(u32 vni)
#define always_inline
Definition: ipsec.h:28
vl_api_ip4_address_t ip4
Definition: one.api:376
u32 vni
Definition: lisp_gpe.h:288
vl_api_tunnel_mode_t mode
Definition: gre.api:48
u32 decap_next_index
Definition: lisp_gpe.h:259
LISP-GPE packet header structure.
Definition: lisp_gpe.h:284
u8 * format_lisp_gpe_header_with_length(u8 *s, va_list *args)
Definition: interface.c:171
dp_address_t deid
Definition: lisp_gpe.h:103
u8 is_negative
type of mapping
Definition: lisp_gpe.h:238
uword * sw_if_index_by_vni
lookup decap tunnel termination sw_if_index by vni and vice versa
Definition: lisp_gpe.h:88
BVT(clib_bihash)
Definition: l2_fib.c:1019
u32 vni
VNI/tenant id in HOST byte order.
Definition: lisp_gpe.h:262
u32 fwd_entry_index
forwarding entry index of
Definition: lisp_gpe.h:231
vlib_counter_t counters
Definition: lisp_gpe.h:108
void lisp_gpe_del_l3_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id)
Definition: interface.c:620
lisp_gpe_input_next_t
Enum of possible next nodes post LISP-GPE decap.
Definition: lisp_gpe.h:63
u32 decap_fib_index
FIB index to lookup inner IP at decap.
Definition: lisp_gpe.h:256
dp_address_t reid
Definition: lisp_gpe.h:291
tunnel_lookup_t l2_ifaces
Definition: lisp_gpe.h:147
vnet_main_t * vnet_main
Definition: lisp_gpe.h:173
enum lgpe_ip6_lookup_next lgpe_ip6_lookup_next_t
LISP-GPE header.
#define foreach_lgpe_ip4_lookup_next
Definition: lisp_gpe.h:294
struct _gid_address_t gid_address_t
u8 * placeholder_stats_pool
Definition: lisp_gpe.h:163
enum lgpe_ip4_lookup_next lgpe_ip4_lookup_next_t
struct lisp_gpe_main lisp_gpe_main_t
LISP-GPE global state.
gpe_encap_mode_t encap_mode
Definition: lisp_gpe.h:161
IPv4 main type.
Definition: ip4.h:107
uword * hw_if_index_by_dp_table
Lookup lisp-gpe interfaces by dp table (eg.
Definition: lisp_gpe.h:85
u8 is_src_dst
Definition: lisp_gpe.h:233
lisp_gpe_error_t
Definition: lisp_gpe.h:74
#define foreach_lgpe_ip6_lookup_next
Definition: lisp_gpe.h:306
gid_address_t rmt_eid
remote eid
Definition: lisp_gpe.h:247
u32 lisp_gpe_l3_iface_find_or_create(lisp_gpe_main_t *lgm, u32 overlay_table_id, u32 vni)
struct _vlib_node_registration vlib_node_registration_t
negative_fwd_actions_e action
action for negative mappings
Definition: lisp_gpe.h:241
Definition: lisp_gpe.h:224
struct lisp_gpe_fwd_entry_t_ * lisp_fwd_entry_pool
A Pool of all LISP forwarding entries.
Definition: lisp_gpe.h:130
u32 vnet_lisp_gpe_add_nsh_iface(lisp_gpe_main_t *lgm)
Add LISP-GPE NSH interface.
Definition: interface.c:754
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:657
ip_lookup_main_t * lm4
Definition: lisp_gpe.h:176
struct _vnet_hw_interface_class vnet_hw_interface_class_t
tunnel_lookup_t l3_ifaces
Definition: lisp_gpe.h:139
ip4_main_t * im4
Definition: lisp_gpe.h:174
dpo_id_t l2_lb_cp_lkup
Load-balance for a miss in the table.
Definition: lisp_gpe.h:150
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
Format LISP-GPE status.
Definition: lisp_gpe.c:592
u32 dp_table
generic access
Definition: lisp_gpe.h:274
negative_fwd_actions_e
Definition: lisp_gpe.h:219
u64 uword
Definition: types.h:112
locator_pair_t * locator_pairs
vector of locator pairs
Definition: lisp_gpe.h:250
int vnet_gpe_add_del_native_fwd_rpath(vnet_gpe_native_fwd_rpath_args_t *a)
Definition: lisp_gpe.c:458
A collection of combined counters.
Definition: counter.h:207
u32 lisp_gpe_add_l3_iface(lisp_gpe_main_t *lgm, u32 vni, u32 bd_id, u8 with_default_route)
Add/del LISP-GPE L3 interface.
Definition: interface.c:578
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:290
lgpe_ip4_lookup_next
Definition: lisp_gpe.h:298
uword * lisp_stats_index_by_key
Definition: lisp_gpe.h:164
ip_lookup_main_t * lm6
Definition: lisp_gpe.h:177
gid_address_t lcl_eid
local eid
Definition: lisp_gpe.h:244
tunnel_lookup_t nsh_ifaces
Definition: lisp_gpe.h:157
A LISP Forwarding Entry.
u32 dp_table
Definition: lisp_gpe.h:287