FD.io VPP  v16.06
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 typedef CLIB_PACKED (struct {
31  ip4_header_t ip4; /* 20 bytes */
32  udp_header_t udp; /* 8 bytes */
33  lisp_gpe_header_t lisp; /* 8 bytes */
34 }) ip4_udp_lisp_gpe_header_t;
35 
36 typedef CLIB_PACKED (struct {
37  ip6_header_t ip6; /* 40 bytes */
38  udp_header_t udp; /* 8 bytes */
39  lisp_gpe_header_t lisp; /* 8 bytes */
40 }) ip6_udp_lisp_gpe_header_t;
41 
42 typedef struct
43 {
44  union
45  {
46  struct
47  {
48  ip_prefix_t eid; /* within the dp only ip and mac can be eids */
49  ip_address_t dst_loc;
51  };
52  u8 as_u8[40];
53  };
55 
56 typedef struct
57 {
58  /* Rewrite string. $$$$ embed vnet_rewrite header */
60 
61  /* decap next index */
63 
64  /* tunnel src and dst addresses */
65  ip_address_t src;
66  ip_address_t dst;
67 
68  /* FIB indices */
69  u32 encap_fib_index; /* tunnel partner lookup here */
70  u32 decap_fib_index; /* inner IP lookup here */
71 
72  /* vnet intfc hw/sw_if_index */
75 
76  /* LISP header fields in HOST byte order */
83 
84 #define foreach_lisp_gpe_ip_input_next \
85 _(DROP, "error-drop") \
86 _(IP4_INPUT, "ip4-input") \
87 _(IP6_INPUT, "ip6-input") \
88 _(ETHERNET_INPUT, "ethernet-input")
89 
90 typedef enum {
91 #define _(s,n) LISP_GPE_INPUT_NEXT_##s,
93 #undef _
96 
97 typedef enum {
98 #define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
100 #undef lisp_gpe_error
103 
104 /* As a first step, reuse v4 fib. The goal of the typedef is to shield
105  * consumers from future updates that may result in the lisp ip4 fib diverging
106  * from ip4 fib */
108 
109 typedef struct ip6_src_fib
110 {
111  BVT(clib_bihash) ip6_lookup_table;
112 
113  /* bitmap/vector of mask widths to search */
118 
119  /* ip6 lookup table config parameters */
122 } ip6_src_fib_t;
123 
124 typedef struct lisp_gpe_main
125 {
126  /* Pool of src fibs that are paired with dst fibs */
127  ip4_src_fib_t * ip4_src_fibs;
129 
130  /* vector of encap tunnel instances */
132 
133  /* lookup tunnel by key */
135 
136  /* lookup decap tunnel termination sw_if_index by vni and vice versa */
139 
140  /* Free vlib hw_if_indices */
142 
143  /* Lookup lisp-gpe interfaces by vrf */
145 
146  /* Lookup lgpe_ipX_lookup_next by vrf */
149 
150  /* next node indexes that point ip4/6 lookup to lisp gpe ip lookup */
153 
154  /* convenience */
163 
165 
170 
171 u8 *
172 format_lisp_gpe_header_with_length (u8 * s, va_list * args);
173 
174 typedef struct
175 {
177  u32 table_id; /* vrf */
178  u32 vni; /* host byte order */
180 
181 u8
183 void
185  u32 * hw_if_indexp);
186 
187 typedef struct
188 {
191 
192 clib_error_t *
194 
195 typedef enum
196 {
202 
203 typedef struct
204 {
206 
207  /* type of mapping */
209  negative_fwd_actions_e action;
210 
211  /* local and remote eids */
212  gid_address_t seid; /* TODO convert to ip4, ip6, mac ? */
214 
215  /* local and remote locators (underlay attachment points) */
216  ip_address_t slocator;
217  ip_address_t dlocator;
218 
219  /* FIB indices to lookup remote locator at encap and inner IP at decap */
222 
223  u32 decap_next_index; /* TODO is this really needed? */
224 
225  /* VNI/tenant id in HOST byte order */
227 
228  /* vrf where fwd entry should be inserted */
231 
232 int
234  u32 * hw_if_indexp);
235 
236 int
237 ip_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
238  ip_prefix_t * src_prefix, u32 table_id,
239  ip_adjacency_t * add_adj, u8 is_add);
240 u32
241 ip_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
242  ip_prefix_t * src_prefix, u32 table_id);
243 
244 #define foreach_lgpe_ip4_lookup_next \
245  _(DROP, "error-drop") \
246  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
247 
249 {
250 #define _(sym,str) LGPE_IP4_LOOKUP_NEXT_##sym,
252 #undef _
255 
256 #define foreach_lgpe_ip6_lookup_next \
257  _(DROP, "error-drop") \
258  _(LISP_CP_LOOKUP, "lisp-cp-lookup")
259 
261 {
262 #define _(sym,str) LGPE_IP6_LOOKUP_NEXT_##sym,
264 #undef _
267 
268 u8 * format_vnet_lisp_gpe_status (u8 * s, va_list * args);
269 
270 #endif /* included_vnet_lisp_gpe_h */
#define foreach_lisp_gpe_ip_input_next
Definition: lisp_gpe.h:84
Definition: mhash.h:46
lisp_gpe_main_t lisp_gpe_main
Definition: lisp_gpe.h:164
u32 decap_next_index
Definition: lisp_gpe.h:62
u32 ip4_lookup_next_lgpe_ip4_lookup
Definition: lisp_gpe.h:151
void vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
Definition: interface.c:484
a
Definition: bitmap.h:393
uword * tunnel_term_sw_if_index_by_vni
Definition: lisp_gpe.h:137
lisp_gpe_tunnel_t * tunnels
Definition: lisp_gpe.h:131
i32 dst_address_length_refcounts[129]
Definition: lisp_gpe.h:117
u32 encap_fib_index
Definition: lisp_gpe.h:220
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Definition: lisp_gpe.c:444
struct _vlib_node_registration vlib_node_registration_t
gid_address_t deid
Definition: lisp_gpe.h:213
ip6_address_t fib_masks[129]
Definition: lisp_gpe.h:116
uword * lgpe_ip6_lookup_next_index_by_table_id
Definition: lisp_gpe.h:148
ip_address_t dlocator
Definition: lisp_gpe.h:217
vlib_main_t * vlib_main
Definition: lisp_gpe.h:155
vlib_node_registration_t lisp_gpe_ip4_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node)
Definition: decap.c:359
lgpe_ip6_lookup_next
Definition: lisp_gpe.h:260
ip6_main_t * im6
Definition: lisp_gpe.h:158
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:666
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:679
u8 is_add
Definition: lisp_gpe.h:205
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
Definition: lisp_gpe.h:203
ip_prefix_t eid
Definition: lisp_gpe.h:48
ip6_src_fib_t * ip6_src_fibs
Definition: lisp_gpe.h:128
u32 * free_lisp_gpe_tunnel_hw_if_indices
Definition: lisp_gpe.h:141
ip4_src_fib_t * ip4_src_fibs
Definition: lisp_gpe.h:127
mhash_t lisp_gpe_tunnel_by_key
Definition: lisp_gpe.h:134
u32 table_id
Definition: lisp_gpe.h:229
vlib_node_registration_t lisp_gpe_ip6_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node)
Definition: decap.c:380
uword * lisp_gpe_hw_if_index_by_table_id
Definition: lisp_gpe.h:144
u8 * prefix_lengths_in_search_order
Definition: lisp_gpe.h:115
vlib_node_registration_t lgpe_ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip4_lookup_node)
Definition: ip_forward.c:912
u32 ip6_lookup_next_lgpe_ip6_lookup
Definition: lisp_gpe.h:152
BVT(clib_bihash) ip6_lookup_table
u32 decap_next_index
Definition: lisp_gpe.h:223
u8 * format_lisp_gpe_header_with_length(u8 *s, va_list *args)
Definition: interface.c:326
uword * vni_by_tunnel_term_sw_if_index
Definition: lisp_gpe.h:138
u8 is_negative
Definition: lisp_gpe.h:208
struct ip6_src_fib ip6_src_fib_t
u32 vni
Definition: lisp_gpe.h:226
lisp_gpe_input_next_t
Definition: lisp_gpe.h:90
u32 decap_fib_index
Definition: lisp_gpe.h:221
vnet_main_t * vnet_main
Definition: lisp_gpe.h:156
Definition: ip4.h:47
enum lgpe_ip6_lookup_next lgpe_ip6_lookup_next_t
#define foreach_lgpe_ip4_lookup_next
Definition: lisp_gpe.h:244
struct _gid_address_t gid_address_t
uword * non_empty_dst_address_length_bitmap
Definition: lisp_gpe.h:114
enum lgpe_ip4_lookup_next lgpe_ip4_lookup_next_t
unsigned int u32
Definition: types.h:88
struct lisp_gpe_main lisp_gpe_main_t
ip_address_t slocator
Definition: lisp_gpe.h:216
lisp_gpe_error_t
Definition: lisp_gpe.h:97
#define foreach_lgpe_ip6_lookup_next
Definition: lisp_gpe.h:256
u64 uword
Definition: types.h:112
uword lookup_table_size
Definition: lisp_gpe.h:121
negative_fwd_actions_e action
Definition: lisp_gpe.h:209
Definition: lisp_gpe.h:200
ip_lookup_main_t * lm4
Definition: lisp_gpe.h:159
unsigned char u8
Definition: types.h:56
ip4_main_t * im4
Definition: lisp_gpe.h:157
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:214
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
Definition: lisp_gpe.c:581
gid_address_t seid
Definition: lisp_gpe.h:212
negative_fwd_actions_e
Definition: lisp_gpe.h:195
u8 vnet_lisp_gpe_enable_disable_status(void)
Definition: lisp_gpe.c:436
vlib_node_registration_t lgpe_ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (lgpe_ip6_lookup_node)
Definition: ip_forward.c:1129
ip4_fib_t ip4_src_fib_t
Definition: lisp_gpe.h:107
u32 lookup_table_nbuckets
Definition: lisp_gpe.h:120
lgpe_ip4_lookup_next
Definition: lisp_gpe.h:248
ip_lookup_main_t * lm6
Definition: lisp_gpe.h:160
ip_address_t dst_loc
Definition: lisp_gpe.h:49
uword * lgpe_ip4_lookup_next_index_by_table_id
Definition: lisp_gpe.h:147
ip_address_t src
Definition: lisp_gpe.h:65
ip_address_t dst
Definition: lisp_gpe.h:66