FD.io VPP  v16.09
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 #ifndef included_vnet_lisp_gpe_h
17 #define included_vnet_lisp_gpe_h
18 
19 #include <vppinfra/error.h>
20 #include <vppinfra/mhash.h>
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/l2/l2_input.h>
24 #include <vnet/ethernet/ethernet.h>
25 #include <vnet/ip/ip4_packet.h>
26 #include <vnet/ip/udp.h>
29 
30 /* encap headers */
31 /* *INDENT-OFF* */
32 typedef CLIB_PACKED (struct {
33  ip4_header_t ip4; /* 20 bytes */
34  udp_header_t udp; /* 8 bytes */
35  lisp_gpe_header_t lisp; /* 8 bytes */
36 }) ip4_udp_lisp_gpe_header_t;
37 /* *INDENT-ON* */
38 
39 /* *INDENT-OFF* */
40 typedef CLIB_PACKED (struct {
41  ip6_header_t ip6; /* 40 bytes */
42  udp_header_t udp; /* 8 bytes */
43  lisp_gpe_header_t lisp; /* 8 bytes */
44 }) ip6_udp_lisp_gpe_header_t;
45 /* *INDENT-ON* */
46 
47 typedef struct
48 {
49  union
50  {
51  struct
52  {
56  };
57  u8 as_u8[40];
58  };
60 
61 typedef struct lisp_gpe_sub_tunnel
62 {
63  /* Rewrite string. $$$$ embed vnet_rewrite header */
70 
71 typedef struct nomalized_sub_tunnel
72 {
76 
77 typedef struct
78 {
79  /* tunnel src and dst addresses */
81 
82  /* locator-pairs with best priority become sub-tunnels */
84 
85  /* sub-tunnels load balancing vector: contains list of sub-tunnel
86  * indexes replicated according to weight */
88 
89  /* number of entries in load balancing vector */
91 
92  /* normalized sub tunnel weights */
94 
95  /* decap next index */
97 
98  /* TODO remove */
99  ip_address_t src, dst;
100 
101  /* FIB indices */
102  u32 encap_fib_index; /* tunnel partner lookup here */
103  u32 decap_fib_index; /* inner IP lookup here */
104 
105  /* vnet intfc hw/sw_if_index */
108 
109  /* action for 'negative' tunnels */
111 
112  /* LISP header fields in HOST byte order */
119 
120 #define foreach_lisp_gpe_ip_input_next \
121 _(DROP, "error-drop") \
122 _(IP4_INPUT, "ip4-input") \
123 _(IP6_INPUT, "ip6-input") \
124 _(L2_INPUT, "l2-input")
125 
126 typedef enum
127 {
128 #define _(s,n) LISP_GPE_INPUT_NEXT_##s,
130 #undef _
133 
134 typedef enum
135 {
136 #define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
138 #undef lisp_gpe_error
139  LISP_GPE_N_ERROR,
141 
142 /* As a first step, reuse v4 fib. The goal of the typedef is to shield
143  * consumers from future updates that may result in the lisp ip4 fib diverging
144  * from ip4 fib */
146 
147 typedef struct ip6_src_fib
148 {
149  BVT (clib_bihash) ip6_lookup_table;
150 
151  /* bitmap/vector of mask widths to search */
153  u8 *prefix_lengths_in_search_order;
154  ip6_address_t fib_masks[129];
155  i32 dst_address_length_refcounts[129];
156 
157  /* ip6 lookup table config parameters */
160 } ip6_src_fib_t;
161 
162 typedef struct tunnel_lookup
163 {
164  /* Lookup lisp-gpe interfaces by dp table (eg. vrf/bridge index) */
166 
167  /* lookup decap tunnel termination sw_if_index by vni and vice versa */
171 
172 typedef struct lisp_gpe_main
173 {
174  /* pool of encap tunnel instances */
176 
177  /* lookup tunnel by key */
179 
180  /* Free vlib hw_if_indices */
182 
184 
185  /* L3 data structures
186  * ================== */
187 
188  /* Pool of src fibs that are paired with dst fibs */
189  ip4_src_fib_t *ip4_src_fibs;
191 
193 
194  /* Lookup lgpe_ipX_lookup_next by vrf */
197 
198  /* next node indexes that point ip4/6 lookup to lisp gpe ip lookup */
201 
202  /* L2 data structures
203  * ================== */
204 
205  /* l2 lisp fib */
206  BVT (clib_bihash) l2_fib;
207 
208  tunnel_lookup_t l2_ifaces;
209 
210  /* convenience */
218 
220 
223 {
224  return &lisp_gpe_main;
225 }
226 
231 
232 u8 *format_lisp_gpe_header_with_length (u8 * s, va_list * args);
233 
234 typedef struct
235 {
237  union
238  {
239  /* vrf */
241 
242  /* bridge domain */
244 
245  /* generic access */
247  };
249  u32 vni; /* host byte order */
251 
253 int
255  u32 * hw_if_indexp);
256 
257 typedef struct
258 {
261 
264 
265 typedef struct
266 {
268 
269  /* type of mapping */
272 
273  /* local and remote eids */
276 
277  /* vector of locator pairs */
279 
280  /* FIB indices to lookup remote locator at encap and inner IP at decap */
283 
284  u32 decap_next_index; /* TODO is this really needed? */
285 
286  /* VNI/tenant id in HOST byte order */
288 
289  /* vrf or bd where fwd entry should be inserted */
290  union
291  {
294 
295  /* generic access */
297  };
299 
300 int
302  u32 * hw_if_indexp);
303 
304 int
305 ip_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
306  ip_prefix_t * src_prefix, u32 table_id,
307  ip_adjacency_t * add_adj, u8 is_add);
308 u32
309 ip_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
310  ip_prefix_t * src_prefix, u32 table_id);
311 
312 #define foreach_lgpe_ip4_lookup_next \
313  _(DROP, "error-drop") \
314  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
315 
317 {
318 #define _(sym,str) LGPE_IP4_LOOKUP_NEXT_##sym,
320 #undef _
323 
324 #define foreach_lgpe_ip6_lookup_next \
325  _(DROP, "error-drop") \
326  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
327 
329 {
330 #define _(sym,str) LGPE_IP6_LOOKUP_NEXT_##sym,
332 #undef _
335 
336 u8 *format_vnet_lisp_gpe_status (u8 * s, va_list * args);
337 
338 #define L2_FIB_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
339 #define L2_FIB_DEFAULT_HASH_MEMORY_SIZE (32<<20)
340 
341 u32
342 lisp_l2_fib_lookup (lisp_gpe_main_t * lgm, u16 bd_index, u8 src_mac[8],
343  u8 dst_mac[8]);
344 
345 #endif /* included_vnet_lisp_gpe_h */
346 
347 /*
348  * fd.io coding-style-patch-verification: ON
349  *
350  * Local Variables:
351  * eval: (c-set-style "gnu")
352  * End:
353  */
#define foreach_lisp_gpe_ip_input_next
Definition: lisp_gpe.h:120
u32 * free_tunnel_hw_if_indices
Definition: lisp_gpe.h:181
Definition: mhash.h:46
lisp_gpe_main_t lisp_gpe_main
Definition: lisp_gpe.h:219
u32 decap_next_index
Definition: lisp_gpe.h:96
u32 ip4_lookup_next_lgpe_ip4_lookup
Definition: lisp_gpe.h:199
a
Definition: bitmap.h:516
IP unicast adjacency.
Definition: lookup.h:164
lisp_gpe_tunnel_t * tunnels
Definition: lisp_gpe.h:175
u32 encap_fib_index
Definition: lisp_gpe.h:281
struct lisp_gpe_sub_tunnel lisp_gpe_sub_tunnel_t
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Definition: lisp_gpe.c:797
struct _vlib_node_registration vlib_node_registration_t
uword * lgpe_ip6_lookup_next_index_by_table_id
Definition: lisp_gpe.h:196
dp_address_t lcl
Definition: lisp_gpe.h:54
uword * vni_by_sw_if_index
Definition: lisp_gpe.h:169
vlib_node_registration_t lisp_gpe_ip4_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node)
Definition: decap.c:432
static lisp_gpe_main_t * vnet_lisp_gpe_get_main()
Definition: lisp_gpe.h:222
lgpe_ip6_lookup_next
Definition: lisp_gpe.h:328
#define always_inline
Definition: clib.h:84
int ip_sd_fib_add_del_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id, ip_adjacency_t *add_adj, u8 is_add)
Definition: ip_forward.c:719
u16 bd_id
Definition: lisp_gpe.h:293
u32 ip_sd_fib_get_route(lisp_gpe_main_t *lgm, ip_prefix_t *dst_prefix, ip_prefix_t *src_prefix, u32 table_id)
Definition: ip_forward.c:733
u8 is_add
Definition: lisp_gpe.h:267
typedef CLIB_PACKED(struct{ip4_header_t ip4;udp_header_t udp;lisp_gpe_header_t lisp;}) ip4_udp_lisp_gpe_header_t
int i32
Definition: types.h:81
int vlib_main(vlib_main_t *vm, unformat_input_t *input)
Definition: main.c:1572
struct tunnel_lookup tunnel_lookup_t
Definition: lisp_gpe.h:265
ip6_src_fib_t * ip6_src_fibs
Definition: lisp_gpe.h:190
ip4_src_fib_t * ip4_src_fibs
Definition: lisp_gpe.h:189
int vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
Definition: interface.c:1060
mhash_t lisp_gpe_tunnel_by_key
Definition: lisp_gpe.h:178
u32 * sub_tunnels_lbv
Definition: lisp_gpe.h:87
u32 table_id
Definition: lisp_gpe.h:292
vlib_node_registration_t lisp_gpe_ip6_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node)
Definition: decap.c:454
vlib_node_registration_t lgpe_ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip4_lookup_node)
Definition: ip_forward.c:1029
u32 ip6_lookup_next_lgpe_ip6_lookup
Definition: lisp_gpe.h:200
vnet_main_t vnet_main
Definition: misc.c:42
struct nomalized_sub_tunnel normalized_sub_tunnel_weights_t
u32 decap_next_index
Definition: lisp_gpe.h:284
u8 * format_lisp_gpe_header_with_length(u8 *s, va_list *args)
Definition: interface.c:346
u8 is_negative
Definition: lisp_gpe.h:270
uword * sw_if_index_by_vni
Definition: lisp_gpe.h:168
BVT(clib_bihash)
Definition: l2_fib.c:577
struct ip6_src_fib ip6_src_fib_t
u32 sub_tunnels_lbv_count
Definition: lisp_gpe.h:90
u32 vni
Definition: lisp_gpe.h:287
lisp_gpe_input_next_t
Definition: lisp_gpe.h:126
u32 decap_fib_index
Definition: lisp_gpe.h:282
Definition: ip4.h:48
enum lgpe_ip6_lookup_next lgpe_ip6_lookup_next_t
#define foreach_lgpe_ip4_lookup_next
Definition: lisp_gpe.h:312
struct _gid_address_t gid_address_t
uword * non_empty_dst_address_length_bitmap
Definition: lisp_gpe.h:152
enum lgpe_ip4_lookup_next lgpe_ip4_lookup_next_t
unsigned int u32
Definition: types.h:88
locator_pair_t * locator_pairs
Definition: lisp_gpe.h:80
IPv4 main type.
Definition: ip4.h:114
uword * hw_if_index_by_dp_table
Definition: lisp_gpe.h:165
u32 lisp_l2_fib_lookup(lisp_gpe_main_t *lgm, u16 bd_index, u8 src_mac[8], u8 dst_mac[8])
lisp_gpe_error_t
Definition: lisp_gpe.h:134
#define foreach_lgpe_ip6_lookup_next
Definition: lisp_gpe.h:324
gid_address_t rmt_eid
Definition: lisp_gpe.h:275
u64 uword
Definition: types.h:112
uword lookup_table_size
Definition: lisp_gpe.h:159
normalized_sub_tunnel_weights_t * norm_sub_tunnel_weights
Definition: lisp_gpe.h:93
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
tunnel_lookup_t l3_ifaces
Definition: lisp_gpe.h:192
int vnet_lisp_gpe_add_del_fwd_entry(vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u32 *hw_if_indexp)
Definition: lisp_gpe.c:539
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
Definition: lisp_gpe.c:979
u32 dp_table
Definition: lisp_gpe.h:296
locator_pair_t * locator_pairs
Definition: lisp_gpe.h:278
u8 vnet_lisp_gpe_enable_disable_status(void)
Definition: lisp_gpe.c:789
vlib_node_registration_t lgpe_ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip6_lookup_node)
Definition: ip_forward.c:1323
u8 action
Definition: lisp_gpe.h:271
ip4_fib_t ip4_src_fib_t
Definition: lisp_gpe.h:145
u32 lookup_table_nbuckets
Definition: lisp_gpe.h:158
lgpe_ip4_lookup_next
Definition: lisp_gpe.h:316
dp_address_t rmt
Definition: lisp_gpe.h:53
gid_address_t lcl_eid
Definition: lisp_gpe.h:274
uword * lgpe_ip4_lookup_next_index_by_table_id
Definition: lisp_gpe.h:195
ip_address_t src
Definition: lisp_gpe.h:99
lisp_gpe_sub_tunnel_t * sub_tunnels
Definition: lisp_gpe.h:83