FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
control.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 VNET_CONTROL_H_
17 #define VNET_CONTROL_H_
18 
19 #include <vnet/vnet.h>
22 #include <vppinfra/timing_wheel.h>
24 
25 #define NUMBER_OF_RETRIES 1
26 #define PENDING_MREQ_EXPIRATION_TIME 3.0 /* seconds */
27 #define PENDING_MREQ_QUEUE_LEN 5
28 
29 #define RLOC_PROBING_INTERVAL 60.0
30 
31 /* when map-registration is enabled "quick registration" takes place first.
32  In this mode ETR sends map-register messages at an increased frequency
33  until specified message count is reached */
34 #define QUICK_MAP_REGISTER_MSG_COUNT 5
35 #define QUICK_MAP_REGISTER_INTERVAL 3.0
36 
37 /* normal map-register period */
38 #define MAP_REGISTER_INTERVAL 60.0
39 
40 /* how many tries until next map-server election */
41 #define MAX_EXPIRED_MAP_REGISTERS_DEFAULT 3
42 
43 #define PENDING_MREG_EXPIRATION_TIME 3.0 /* seconds */
44 
45 /* 24 hours */
46 #define MAP_REGISTER_DEFAULT_TTL 86400
47 
48 typedef struct
49 {
58 
59 typedef struct
60 {
63 
64 typedef struct
65 {
70 } fwd_entry_t;
71 
72 typedef struct
73 {
77 
78 typedef enum
79 {
83 
84 /* map-server/map-resolver structure */
85 typedef struct
86 {
90  char *key;
91 } lisp_msmr_t;
92 
93 typedef struct
94 {
95  /* headers */
96  u8 data[100];
100 
101 typedef struct
102 {
103  u8 mac[6];
106 
107 typedef struct
108 {
109  u8 mac[6];
110  u8 ip6[16];
112 
113 typedef enum
114 {
117  _MR_MODE_MAX
119 
120 #define foreach_lisp_flag_bit \
121  _(USE_PETR, "Use Proxy-ETR") \
122  _(XTR_MODE, "ITR/ETR mode") \
123  _(PETR_MODE, "Proxy-ETR mode") \
124  _(PITR_MODE, "Proxy-ITR mode") \
125  _(STATS_ENABLED, "Statistics enabled")
126 
127 typedef enum lisp_flag_bits
128 {
129 #define _(sym, str) LISP_FLAG_BIT_##sym,
131 #undef _
133 
134 typedef enum lisp_flags
135 {
136 #define _(sym, str) LISP_FLAG_##sym = 1 << LISP_FLAG_BIT_##sym,
138 #undef _
139 } lisp_flags_e;
140 
141 typedef struct
142 {
146 
147 typedef enum
148 {
152 
153 typedef struct
154 {
158  volatile u8 is_free;
160 
161 typedef struct
162 {
164 
165  /* LISP feature status */
167 
168  /* eid table */
170 
171  /* pool of mappings */
173 
174  /* hash map of secret keys by mapping index */
176 
177  /* pool of locators */
179 
180  /* pool of locator-sets */
182 
183  /* vector of locator-set vectors composed of and indexed by locator index */
185 
186  /* hash map of locators by name */
188 
189  /* vector of eid index vectors supported and indexed by locator-set index */
191 
192  /* vectors of indexes for local locator-sets and mappings */
195 
196  /* hash map of forwarding entries by mapping index */
198 
199  /* pool of vectors of rmts per lcl mapping in adjacencies */
201 
202  /* hash of pool positions of vectors of rmts by lcl mapping index */
204 
205  /* forwarding entries pool */
207 
208  /* hash map keyed by nonce of pending map-requests */
210 
211  /* pool of pending map requests */
213 
214  /* pool of pending map registers */
216 
217  /* hash map of sent map register messages */
219 
220  /* vector of map-resolvers */
222 
223  /* vector of map-servers */
225 
226  /* map resolver address currently being used for sending requests.
227  * This has to be an actual address and not an index to map_resolvers vector
228  * since the vector may be modified during request resend/retry procedure
229  * and break things :-) */
232 
235 
236  /* map-request locator set index */
238 
239  /* vni to vrf hash tables */
242 
243  /* vni to bd-index hash tables */
246 
247  /* track l2 and l3 interfaces that have been created for vni */
249 
250  /* Proxy ITR map index */
252 
253  /** Proxy ETR map index used for 'use-petr'.
254  * Not related to PETR tunnel mode */
256 
257  /* mapping index for NSH */
259 
260  /* map request mode */
262 
263  /* enable/disable map registering */
265 
266  /* enable/disable rloc-probing */
268 
269  /* timing wheel for mapping timeouts */
270  TWT (tw_timer_wheel) wheel;
271 
272  /** Per thread pool of records shared with thread0 */
274 
275  /* TTL used for all mappings when registering */
277 
278  /* control variables for map server election */
281 
282  /** either UDP based or binary API. Default is UDP */
284 
285  /** Retry service node index */
287 
288  /* commodity */
294 
295 /* lisp-gpe control plane */
297 
301 
303 
306 {
307  return &lisp_control_main;
308 }
309 
310 void
313  u16 type);
314 
315 typedef struct
316 {
318  union
319  {
322  };
326 
327 int
329  u32 * ls_index);
330 int
332  locator_set_t * ls, u32 * ls_index);
333 
334 typedef struct
335 {
339 
343 
346  u8 *key;
349 
350 int
352  u32 * map_index);
353 int
355  u32 * map_index_result);
356 
357 int
359  locator_t * rlocs, u32 * res_map_index,
360  u8 * is_changed);
361 
362 int vnet_lisp_del_mapping (gid_address_t * eid, u32 * res_map_index);
363 
364 typedef struct
365 {
370 
372 
373 typedef struct
374 {
378 
379 int
382 
386 
387 int vnet_lisp_pitr_set_locator_set (u8 * locator_set_name, u8 is_add);
388 int vnet_lisp_use_petr (ip_address_t * ip, u8 is_add);
389 
390 typedef struct
391 {
395 
396 int
398 
400 
401 int vnet_lisp_eid_table_map (u32 vni, u32 vrf, u8 is_l2, u8 is_add);
403  u8 is_add);
412  u8 is_add);
415 int vnet_lisp_nsh_set_locator_set (u8 * locator_set_name, u8 is_add);
420 u32 *vnet_lisp_ndp_bds_get (void);
424 
425 extern int vnet_lisp_enable_disable_xtr_mode (u8 is_enabled);
426 extern int vnet_lisp_enable_disable_pitr_mode (u8 is_enabled);
427 extern int vnet_lisp_enable_disable_petr_mode (u8 is_enabled);
428 extern u8 vnet_lisp_get_xtr_mode (void);
429 extern u8 vnet_lisp_get_pitr_mode (void);
430 extern u8 vnet_lisp_get_petr_mode (void);
431 
433 
436 {
437  return pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
438 }
439 
440 #endif /* VNET_CONTROL_H_ */
441 
442 /*
443  * fd.io coding-style-patch-verification: ON
444  *
445  * Local Variables:
446  * eval: (c-set-style "gnu")
447  * End:
448  */
u8 vnet_lisp_map_register_state_get(void)
Definition: control.c:376
int vnet_lisp_add_mapping(vnet_lisp_add_del_mapping_args_t *a, locator_t *rlocs, u32 *res_map_index, u8 *is_changed)
Adds/updates mapping.
Definition: control.c:1230
u32 vnet_lisp_map_register_fallback_threshold_get(void)
Definition: control.c:1634
map_records_arg_t ** map_records_args_pool
Per thread pool of records shared with thread0.
Definition: control.h:273
u16 vni
Definition: flow_types.api:160
u8 is_down
Definition: control.h:87
u32 pitr_map_index
Definition: control.h:251
gid_address_t leid
Definition: control.h:74
int vnet_lisp_del_mapping(gid_address_t *eid, u32 *res_map_index)
Removes a mapping.
Definition: control.c:1339
int vnet_lisp_enable_disable_pitr_mode(u8 is_enabled)
Definition: control.c:4945
vl_api_mac_address_t mac
Definition: l2.api:502
u32 * lcl_to_rmt_adjs_by_lcl_idx
Definition: control.h:203
int vnet_lisp_enable_disable_xtr_mode(u8 is_enabled)
Definition: control.c:4908
a
Definition: bitmap.h:538
int vnet_lisp_add_del_map_table_key(gid_address_t *eid, char *key, u8 is_add)
int vnet_lisp_add_del_locator(vnet_lisp_add_del_locator_set_args_t *a, locator_set_t *ls, u32 *ls_index)
Definition: control.c:1892
int vnet_lisp_add_del_map_server(ip_address_t *addr, u8 is_add)
Definition: control.c:633
ip_address_t active_map_resolver
Definition: control.h:230
lisp_msmr_t * map_resolvers
Definition: control.h:221
int vnet_lisp_add_del_l2_arp_ndp_entry(gid_address_t *key, u8 *mac, u8 is_add)
Definition: control.c:997
locator_pair_t * locator_pairs
Definition: control.h:69
uword * table_id_by_vni
Definition: control.h:240
unsigned long u64
Definition: types.h:89
lisp_adjacency_t * vnet_lisp_adjacencies_get_by_vni(u32 vni)
Returns vector of adjacencies.
Definition: control.c:579
u32 retry_service_index
Retry service node index.
Definition: control.h:286
lisp_api_ndp_entry_t * vnet_lisp_ndp_entries_get_by_bd(u32 bd)
Definition: control.c:982
u32 * local_mappings_indexes
Definition: control.h:193
locator_t * locator_pool
Definition: control.h:178
Definition: control.h:64
vl_api_address_t src
Definition: gre.api:54
vlib_node_registration_t lisp_cp_lookup_ip6_node
(constructor) VLIB_REGISTER_NODE (lisp_cp_lookup_ip6_node)
Definition: control.c:3625
clib_error_t * lisp_cp_init()
u32 ip4
Definition: control.h:104
u32 nsh_map_index
Definition: control.h:258
int vnet_lisp_map_register_enable_disable(u8 is_enable)
Definition: control.c:2140
ip_address_t address
Definition: control.h:89
uword * vni_by_table_id
Definition: control.h:241
vhost_vring_addr_t addr
Definition: vhost_user.h:111
unsigned char u8
Definition: types.h:56
u8 data[128]
Definition: ipsec_types.api:89
double f64
Definition: types.h:142
enum lisp_flag_bits lisp_flag_bits_e
lisp_msmr_t * map_servers
Definition: control.h:224
vl_api_ip_proto_t protocol
Definition: lb_types.api:71
u32 ** locator_to_locator_sets
Definition: control.h:184
vlib_main_t * vlib_main
Definition: control.h:291
vlib_node_registration_t lisp_cp_lookup_ip4_node
(constructor) VLIB_REGISTER_NODE (lisp_cp_lookup_ip4_node)
Definition: control.c:3605
void get_src_and_dst_eids_from_buffer(lisp_cp_main_t *lcm, vlib_buffer_t *b, gid_address_t *src, gid_address_t *dst, u16 type)
Definition: control.c:3265
vl_api_ip6_address_t ip6
Definition: one.api:424
u32 * fwd_entry_by_mapping_index
Definition: control.h:197
int vnet_lisp_map_register_set_ttl(u32 ttl)
Definition: control.c:2326
u32 expired_map_registers
Definition: control.h:280
typedef eid
Definition: lisp_types.api:59
#define foreach_lisp_flag_bit
Definition: control.h:120
unsigned int u32
Definition: types.h:88
uword * bd_id_by_vni
Definition: control.h:244
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:305
u8 do_map_server_election
Definition: control.h:234
uword * vni_by_bd_id
Definition: control.h:245
u8 vnet_lisp_get_map_request_mode(void)
Definition: control.c:57
lisp_flags
Definition: control.h:134
gid_address_t src
Definition: control.h:50
u32 petr_map_index
Proxy ETR map index used for &#39;use-petr&#39;.
Definition: control.h:255
ip6_main_t * im6
Definition: control.h:290
enum lisp_flags lisp_flags_e
vl_api_fib_path_type_t type
Definition: fib_types.api:123
u8 is_src_dst
Definition: control.h:68
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:534
u8 vnet_lisp_enable_disable_status(void)
Definition: control.c:2271
u8 do_map_resolver_election
Definition: control.h:233
f64 last_update
Definition: control.h:88
void vnet_lisp_create_retry_process(lisp_cp_main_t *lcm)
Definition: control.c:4876
unsigned short u16
Definition: types.h:57
u8 vnet_lisp_get_pitr_mode(void)
Definition: control.c:5012
map_records_arg_t * parse_map_reply(vlib_buffer_t *b)
Definition: control.c:4309
#define TWT(a)
int vnet_lisp_set_map_request_mode(u8 mode)
Definition: control.c:1510
u8 * key_by_mapping_index
Definition: control.h:175
u32 * local_locator_set_indexes
Definition: control.h:194
gid_address_t reid
Definition: control.h:67
#define always_inline
Definition: ipsec.h:28
lisp_api_l2_arp_entry_t * vnet_lisp_l2_arp_entries_get_by_bd(u32 bd)
Definition: control.c:946
u8 map_request_mode
Definition: control.h:261
volatile u8 is_free
Definition: control.h:158
lisp_transport_protocol_t vnet_lisp_get_transport_protocol(void)
Definition: control.c:4901
int vnet_lisp_rloc_probe_enable_disable(u8 is_enable)
Definition: control.c:2131
lisp_cp_main_t lisp_control_main
Definition: control.c:37
u32 vnet_lisp_set_transport_protocol(u8 protocol)
Definition: control.c:4888
vl_api_address_t dst
Definition: gre.api:55
vl_api_tunnel_mode_t mode
Definition: gre.api:48
u8 map_registering
Definition: control.h:264
int vnet_lisp_use_petr(ip_address_t *ip, u8 is_add)
Configure Proxy-ETR.
Definition: control.c:1649
uword * pending_map_requests_by_nonce
Definition: control.h:209
int vnet_lisp_map_cache_add_del(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index)
Add/remove mapping to/from map-cache.
Definition: control.c:684
int vnet_lisp_eid_table_map(u32 vni, u32 vrf, u8 is_l2, u8 is_add)
Definition: control.c:1036
char * key
Definition: control.h:90
u8 ttl
Definition: fib_types.api:26
u32 * vnet_lisp_l2_arp_bds_get(void)
Definition: control.c:884
int vnet_lisp_nsh_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1531
lisp_transport_protocol_t
Definition: control.h:147
ip_address_t addr
Definition: control.h:143
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1582
u8 vnet_lisp_rloc_probe_state_get(void)
Definition: control.c:383
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
Definition: control.c:2278
Definition: control.h:107
struct _gid_address_t gid_address_t
lisp_flag_bits
Definition: control.h:127
u8 value
Definition: qos.api:54
int vnet_lisp_add_del_local_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
Add/update/delete mapping to/in/from map-cache.
Definition: control.c:837
int vnet_lisp_enable_disable_petr_mode(u8 is_enabled)
Definition: control.c:4974
lisp_transport_protocol_t transport_protocol
either UDP based or binary API.
Definition: control.h:283
gid_dictionary_t mapping_index_by_gid
Definition: control.h:169
IPv4 main type.
Definition: ip4.h:106
uword * l2_dp_intf_by_vni
Definition: control.h:248
u32 vnet_lisp_map_register_get_ttl(void)
Definition: control.c:2334
locator_set_t * locator_set_pool
Definition: control.h:181
u32 ** locator_set_to_eids
Definition: control.h:190
Definition: control.h:101
pending_map_register_t * pending_map_registers_pool
Definition: control.h:215
u32 map_register_ttl
Definition: control.h:276
fwd_entry_t * fwd_entry_pool
Definition: control.h:206
pending_map_request_t * pending_map_requests_pool
Definition: control.h:212
typedef key
Definition: ipsec_types.api:85
struct _vlib_node_registration vlib_node_registration_t
miss_packet_type_t
Definition: control.h:78
int vnet_lisp_add_del_mreq_itr_rlocs(vnet_lisp_add_del_mreq_itr_rloc_args_t *a)
Definition: control.c:2341
vl_api_address_t ip
Definition: l2.api:501
map_request_mode_t
Definition: control.h:113
ip_address_t active_map_server
Definition: control.h:231
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
static mapping_t * lisp_get_petr_mapping(lisp_cp_main_t *lcm)
Definition: control.h:435
mapping_t * mapping_pool
Definition: control.h:172
uword * locator_set_index_by_name
Definition: control.h:187
u8 vnet_lisp_get_petr_mode(void)
Definition: control.c:5019
int vnet_lisp_add_del_adjacency(vnet_lisp_add_del_adjacency_args_t *a)
Adds adjacency or removes forwarding entry associated to remote mapping.
Definition: control.c:1439
gid_address_t reid
Definition: control.h:75
vlib_node_registration_t lisp_cp_input_node
(constructor) VLIB_REGISTER_NODE (lisp_cp_input_node)
Definition: control.c:4454
gid_address_t dst
Definition: control.h:51
u32 ** lcl_to_rmt_adjacencies
Definition: control.h:200
uword * map_register_messages_by_nonce
Definition: control.h:218
clib_error_t * vnet_lisp_enable_disable(u8 is_enabled)
Definition: control.c:2206
u8 vnet_lisp_get_xtr_mode(void)
Definition: control.c:5005
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:1388
mapping_t * mappings
Definition: control.h:157
u32 max_expired_map_registers
Definition: control.h:279
u32 mreq_itr_rlocs
Definition: control.h:237
u32 * vnet_lisp_ndp_bds_get(void)
Definition: control.c:908
vnet_main_t * vnet_main
Definition: control.h:292
u32 length
Definition: control.h:97
ip4_main_t * im4
Definition: control.h:289
gid_address_t leid
Definition: control.h:66
int vnet_lisp_map_register_fallback_threshold_set(u32 value)
Definition: control.c:1621
miss_packet_type_t type
Definition: control.h:98
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_index)
Definition: control.c:1996