blob: bb0f788b1977a408a78a7c746281fa38b9a07d86 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
Florin Corase127a7e2016-02-18 22:20:01 +01002 * Copyright (c) 2016 Cisco and/or its affiliates.
Ed Warnickecb9cada2015-12-08 15:45:58 -07003 * 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 */
Florin Corasff0bf132016-09-05 19:30:35 +020015/**
16 * @file
17 * @brief LISP-GPE definitions.
18 */
Florin Corase127a7e2016-02-18 22:20:01 +010019
Ed Warnickecb9cada2015-12-08 15:45:58 -070020#ifndef included_vnet_lisp_gpe_h
21#define included_vnet_lisp_gpe_h
22
23#include <vppinfra/error.h>
Florin Corase127a7e2016-02-18 22:20:01 +010024#include <vppinfra/mhash.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070025#include <vnet/vnet.h>
26#include <vnet/ip/ip.h>
27#include <vnet/l2/l2_input.h>
28#include <vnet/ethernet/ethernet.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070029#include <vnet/ip/ip4_packet.h>
30#include <vnet/ip/udp.h>
Florin Corase127a7e2016-02-18 22:20:01 +010031#include <vnet/lisp-cp/lisp_types.h>
32#include <vnet/lisp-gpe/lisp_gpe_packet.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010033#include <vnet/adj/adj_types.h>
Florin Corase127a7e2016-02-18 22:20:01 +010034
Florin Corasff0bf132016-09-05 19:30:35 +020035/** IP4-UDP-LISP encap header */
Florin Coras220beac2016-08-16 23:04:00 +020036/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -070037typedef CLIB_PACKED (struct {
38 ip4_header_t ip4; /* 20 bytes */
39 udp_header_t udp; /* 8 bytes */
40 lisp_gpe_header_t lisp; /* 8 bytes */
41}) ip4_udp_lisp_gpe_header_t;
Florin Coras220beac2016-08-16 23:04:00 +020042/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -070043
Florin Corasff0bf132016-09-05 19:30:35 +020044/** IP6-UDP-LISP encap header */
Florin Coras220beac2016-08-16 23:04:00 +020045/* *INDENT-OFF* */
Florin Coras02655bd2016-04-26 00:17:24 +020046typedef CLIB_PACKED (struct {
47 ip6_header_t ip6; /* 40 bytes */
48 udp_header_t udp; /* 8 bytes */
49 lisp_gpe_header_t lisp; /* 8 bytes */
50}) ip6_udp_lisp_gpe_header_t;
Florin Coras220beac2016-08-16 23:04:00 +020051/* *INDENT-ON* */
Florin Coras02655bd2016-04-26 00:17:24 +020052
Florin Coras02655bd2016-04-26 00:17:24 +020053#define foreach_lisp_gpe_ip_input_next \
Ed Warnickecb9cada2015-12-08 15:45:58 -070054_(DROP, "error-drop") \
55_(IP4_INPUT, "ip4-input") \
56_(IP6_INPUT, "ip6-input") \
Florin Coras1a1adc72016-07-22 01:45:30 +020057_(L2_INPUT, "l2-input")
Ed Warnickecb9cada2015-12-08 15:45:58 -070058
Florin Corasff0bf132016-09-05 19:30:35 +020059/** Enum of possible next nodes post LISP-GPE decap */
Florin Coras220beac2016-08-16 23:04:00 +020060typedef enum
61{
Ed Warnickecb9cada2015-12-08 15:45:58 -070062#define _(s,n) LISP_GPE_INPUT_NEXT_##s,
Florin Coras02655bd2016-04-26 00:17:24 +020063 foreach_lisp_gpe_ip_input_next
Ed Warnickecb9cada2015-12-08 15:45:58 -070064#undef _
Florin Coras220beac2016-08-16 23:04:00 +020065 LISP_GPE_INPUT_N_NEXT,
Ed Warnickecb9cada2015-12-08 15:45:58 -070066} lisp_gpe_input_next_t;
67
Florin Coras220beac2016-08-16 23:04:00 +020068typedef enum
69{
Ed Warnickecb9cada2015-12-08 15:45:58 -070070#define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
71#include <vnet/lisp-gpe/lisp_gpe_error.def>
72#undef lisp_gpe_error
73 LISP_GPE_N_ERROR,
Florin Coras577c3552016-04-21 00:45:40 +020074} lisp_gpe_error_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070075
Florin Coras1a1adc72016-07-22 01:45:30 +020076typedef struct tunnel_lookup
77{
Florin Corasff0bf132016-09-05 19:30:35 +020078 /** Lookup lisp-gpe interfaces by dp table (eg. vrf/bridge index) */
Florin Coras220beac2016-08-16 23:04:00 +020079 uword *hw_if_index_by_dp_table;
Florin Coras1a1adc72016-07-22 01:45:30 +020080
Florin Corasff0bf132016-09-05 19:30:35 +020081 /** lookup decap tunnel termination sw_if_index by vni and vice versa */
Florin Coras220beac2016-08-16 23:04:00 +020082 uword *sw_if_index_by_vni;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010083
84 // FIXME - Need this?
Florin Coras220beac2016-08-16 23:04:00 +020085 uword *vni_by_sw_if_index;
Florin Coras1a1adc72016-07-22 01:45:30 +020086} tunnel_lookup_t;
87
Florin Corasff0bf132016-09-05 19:30:35 +020088/** LISP-GPE global state*/
Florin Corase127a7e2016-02-18 22:20:01 +010089typedef struct lisp_gpe_main
90{
Neale Ranns5e575b12016-10-03 09:40:25 +010091 /**
92 * @brief DB of all forwarding entries. The Key is:{l-EID,r-EID,vni}
93 * where the EID encodes L2 or L3
94 */
95 uword *lisp_gpe_fwd_entries;
96
97 /**
98 * @brief A Pool of all LISP forwarding entries
99 */
100 struct lisp_gpe_fwd_entry_t_ *lisp_fwd_entry_pool;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700101
Florin Corasff0bf132016-09-05 19:30:35 +0200102 /** Free vlib hw_if_indices */
Florin Coras220beac2016-08-16 23:04:00 +0200103 u32 *free_tunnel_hw_if_indices;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700104
Florin Coras1a1adc72016-07-22 01:45:30 +0200105 u8 is_en;
106
107 /* L3 data structures
108 * ================== */
Florin Coras1a1adc72016-07-22 01:45:30 +0200109 tunnel_lookup_t l3_ifaces;
Florin Coras577c3552016-04-21 00:45:40 +0200110
Florin Coras1a1adc72016-07-22 01:45:30 +0200111 /* L2 data structures
112 * ================== */
113
Florin Corasff0bf132016-09-05 19:30:35 +0200114 /** L2 LISP FIB */
Florin Coras220beac2016-08-16 23:04:00 +0200115 BVT (clib_bihash) l2_fib;
Florin Coras1a1adc72016-07-22 01:45:30 +0200116
117 tunnel_lookup_t l2_ifaces;
118
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100119 /** Load-balance for a miss in the table */
Neale Ranns5e575b12016-10-03 09:40:25 +0100120 dpo_id_t l2_lb_cp_lkup;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100121
Florin Corasff0bf132016-09-05 19:30:35 +0200122 /** convenience */
Florin Coras220beac2016-08-16 23:04:00 +0200123 vlib_main_t *vlib_main;
124 vnet_main_t *vnet_main;
125 ip4_main_t *im4;
126 ip6_main_t *im6;
127 ip_lookup_main_t *lm4;
128 ip_lookup_main_t *lm6;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700129} lisp_gpe_main_t;
130
Florin Corasff0bf132016-09-05 19:30:35 +0200131/** LISP-GPE global state*/
Ed Warnickecb9cada2015-12-08 15:45:58 -0700132lisp_gpe_main_t lisp_gpe_main;
133
Florin Coras1a1adc72016-07-22 01:45:30 +0200134always_inline lisp_gpe_main_t *
Florin Coras220beac2016-08-16 23:04:00 +0200135vnet_lisp_gpe_get_main ()
136{
Florin Coras1a1adc72016-07-22 01:45:30 +0200137 return &lisp_gpe_main;
138}
139
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100140
Florin Coras02655bd2016-04-26 00:17:24 +0200141extern vlib_node_registration_t lisp_gpe_ip4_input_node;
142extern vlib_node_registration_t lisp_gpe_ip6_input_node;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100143extern vnet_hw_interface_class_t lisp_gpe_hw_class;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700144
Florin Coras220beac2016-08-16 23:04:00 +0200145u8 *format_lisp_gpe_header_with_length (u8 * s, va_list * args);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700146
Florin Corasff0bf132016-09-05 19:30:35 +0200147/** Read LISP-GPE status */
Florin Coras220beac2016-08-16 23:04:00 +0200148u8 vnet_lisp_gpe_enable_disable_status (void);
Florin Corasff0bf132016-09-05 19:30:35 +0200149
Neale Ranns5e575b12016-10-03 09:40:25 +0100150u32
151lisp_gpe_l3_iface_find_or_create (lisp_gpe_main_t * lgm,
152 u32 overlay_table_id, u32 vni);
153
Florin Corasff0bf132016-09-05 19:30:35 +0200154/** Add/del LISP-GPE interface. */
Neale Ranns5e575b12016-10-03 09:40:25 +0100155extern void lisp_gpe_del_l2_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
156extern u32 lisp_gpe_add_l2_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
157extern void lisp_gpe_del_l3_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
158extern u32 lisp_gpe_add_l3_iface (lisp_gpe_main_t * lgm, u32 vni, u32 bd_id);
159
Florin Corase127a7e2016-02-18 22:20:01 +0100160
Florin Coras577c3552016-04-21 00:45:40 +0200161typedef struct
162{
163 u8 is_en;
164} vnet_lisp_gpe_enable_disable_args_t;
165
Florin Coras220beac2016-08-16 23:04:00 +0200166clib_error_t
167 * vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t * a);
Florin Coras577c3552016-04-21 00:45:40 +0200168
Neale Ranns5e575b12016-10-03 09:40:25 +0100169typedef enum
170{
171 NO_ACTION,
172 FORWARD_NATIVE,
173 SEND_MAP_REQUEST,
174 DROP
175} negative_fwd_actions_e;
176
Florin Corasff0bf132016-09-05 19:30:35 +0200177/** */
Florin Corase127a7e2016-02-18 22:20:01 +0100178typedef struct
179{
180 u8 is_add;
Florin Corased09a052016-05-06 14:22:40 +0200181
Florin Corasff0bf132016-09-05 19:30:35 +0200182 /** type of mapping */
Florin Corase127a7e2016-02-18 22:20:01 +0100183 u8 is_negative;
Florin Corasff0bf132016-09-05 19:30:35 +0200184
185 /** action for negative mappings */
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100186 negative_fwd_actions_e action;
Florin Corased09a052016-05-06 14:22:40 +0200187
Florin Corasff0bf132016-09-05 19:30:35 +0200188 /** local eid */
Florin Coras1a1adc72016-07-22 01:45:30 +0200189 gid_address_t lcl_eid;
Florin Corasff0bf132016-09-05 19:30:35 +0200190
191 /** remote eid */
Florin Coras1a1adc72016-07-22 01:45:30 +0200192 gid_address_t rmt_eid;
Florin Corased09a052016-05-06 14:22:40 +0200193
Florin Corasff0bf132016-09-05 19:30:35 +0200194 /** vector of locator pairs */
Florin Coras220beac2016-08-16 23:04:00 +0200195 locator_pair_t *locator_pairs;
Florin Corased09a052016-05-06 14:22:40 +0200196
Florin Corasff0bf132016-09-05 19:30:35 +0200197 /** FIB index to lookup remote locator at encap */
Florin Corase127a7e2016-02-18 22:20:01 +0100198 u32 encap_fib_index;
Florin Corasff0bf132016-09-05 19:30:35 +0200199
200 /** FIB index to lookup inner IP at decap */
Florin Corase127a7e2016-02-18 22:20:01 +0100201 u32 decap_fib_index;
Florin Corased09a052016-05-06 14:22:40 +0200202
Florin Corasff0bf132016-09-05 19:30:35 +0200203 /* TODO remove */
204 u32 decap_next_index;
Florin Corased09a052016-05-06 14:22:40 +0200205
Florin Corasff0bf132016-09-05 19:30:35 +0200206 /** VNI/tenant id in HOST byte order */
Florin Corased09a052016-05-06 14:22:40 +0200207 u32 vni;
208
Florin Corasff0bf132016-09-05 19:30:35 +0200209 /** vrf or bd where fwd entry should be inserted */
Florin Coras1a1adc72016-07-22 01:45:30 +0200210 union
211 {
Florin Corasff0bf132016-09-05 19:30:35 +0200212 /** table (vrf) id */
Florin Coras1a1adc72016-07-22 01:45:30 +0200213 u32 table_id;
Florin Corasff0bf132016-09-05 19:30:35 +0200214
215 /** bridge domain id */
Florin Coras1a1adc72016-07-22 01:45:30 +0200216 u16 bd_id;
Florin Coras429e7952016-08-02 02:31:03 +0200217
Florin Corasff0bf132016-09-05 19:30:35 +0200218 /** generic access */
Florin Coras429e7952016-08-02 02:31:03 +0200219 u32 dp_table;
Florin Coras1a1adc72016-07-22 01:45:30 +0200220 };
Florin Corase127a7e2016-02-18 22:20:01 +0100221} vnet_lisp_gpe_add_del_fwd_entry_args_t;
222
Florin Coras02655bd2016-04-26 00:17:24 +0200223#define foreach_lgpe_ip4_lookup_next \
224 _(DROP, "error-drop") \
225 _(LISP_CP_LOOKUP, "lisp-cp-lookup")
226
227typedef enum lgpe_ip4_lookup_next
228{
229#define _(sym,str) LGPE_IP4_LOOKUP_NEXT_##sym,
230 foreach_lgpe_ip4_lookup_next
231#undef _
Florin Coras220beac2016-08-16 23:04:00 +0200232 LGPE_IP4_LOOKUP_N_NEXT,
Florin Coras02655bd2016-04-26 00:17:24 +0200233} lgpe_ip4_lookup_next_t;
234
Florin Corasff0bf132016-09-05 19:30:35 +0200235#define foreach_lgpe_ip6_lookup_next \
Florin Coras02655bd2016-04-26 00:17:24 +0200236 _(DROP, "error-drop") \
237 _(LISP_CP_LOOKUP, "lisp-cp-lookup")
238
239typedef enum lgpe_ip6_lookup_next
240{
241#define _(sym,str) LGPE_IP6_LOOKUP_NEXT_##sym,
242 foreach_lgpe_ip6_lookup_next
243#undef _
Florin Coras220beac2016-08-16 23:04:00 +0200244 LGPE_IP6_LOOKUP_N_NEXT,
Florin Coras02655bd2016-04-26 00:17:24 +0200245} lgpe_ip6_lookup_next_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700246
Florin Coras220beac2016-08-16 23:04:00 +0200247u8 *format_vnet_lisp_gpe_status (u8 * s, va_list * args);
Filip Tehlar46d4e362016-05-09 09:39:26 +0200248
Ed Warnickecb9cada2015-12-08 15:45:58 -0700249#endif /* included_vnet_lisp_gpe_h */
Florin Coras220beac2016-08-16 23:04:00 +0200250
251/*
252 * fd.io coding-style-patch-verification: ON
253 *
254 * Local Variables:
255 * eval: (c-set-style "gnu")
256 * End:
257 */