LISP: make TTL for map register messages configurable
[vpp.git] / src / vnet / lisp-cp / control.h
index e89c6fd..d030e58 100644 (file)
@@ -19,6 +19,7 @@
 #include <vnet/vnet.h>
 #include <vnet/lisp-cp/gid_dictionary.h>
 #include <vnet/lisp-cp/lisp_types.h>
+#include <vppinfra/timing_wheel.h>
 
 #define NUMBER_OF_RETRIES                   1
 #define PENDING_MREQ_EXPIRATION_TIME        3.0        /* seconds */
@@ -36,8 +37,8 @@
 /* normal map-register period */
 #define MAP_REGISTER_INTERVAL               60.0
 
-/* 15 minutes */
-#define MAP_REGISTER_DEFAULT_TTL            900
+/* 24 hours */
+#define MAP_REGISTER_DEFAULT_TTL            86400
 
 typedef struct
 {
@@ -87,6 +88,12 @@ typedef struct
   miss_packet_type_t type;
 } miss_packet_t;
 
+typedef struct
+{
+  u8 mac[6];
+  u32 ip4;
+} lisp_api_l2_arp_entry_t;
+
 typedef enum
 {
   MR_MODE_DST_ONLY = 0,
@@ -94,8 +101,42 @@ typedef enum
   _MR_MODE_MAX
 } map_request_mode_t;
 
+#define foreach_lisp_flag_bit       \
+  _(USE_PETR, "Use Proxy-ETR")                  \
+  _(STATS_ENABLED, "Statistics enabled")
+
+typedef enum lisp_flag_bits
+{
+#define _(sym, str) LISP_FLAG_BIT_##sym,
+  foreach_lisp_flag_bit
+#undef _
+} lisp_flag_bits_e;
+
+typedef enum lisp_flags
+{
+#define _(sym, str) LISP_FLAG_##sym = 1 << LISP_FLAG_BIT_##sym,
+  foreach_lisp_flag_bit
+#undef _
+} lisp_flags_e;
+
+typedef struct
+{
+  ip_address_t addr;
+  u32 bd;
+} lisp_l2_arp_key_t;
+
+typedef struct
+{
+  u64 nonce;
+  u8 is_rloc_probe;
+  mapping_t *mappings;
+  volatile u8 is_free;
+} map_records_arg_t;
+
 typedef struct
 {
+  u32 flags;
+
   /* LISP feature status */
   u8 is_enabled;
 
@@ -170,12 +211,18 @@ typedef struct
   /* track l2 and l3 interfaces that have been created for vni */
   uword *l2_dp_intf_by_vni;
 
-  /* Proxy ETR map index */
+  /* Proxy ITR map index */
   u32 pitr_map_index;
 
+  /** Proxy ETR map index */
+  u32 petr_map_index;
+
   /* LISP PITR mode */
   u8 lisp_pitr;
 
+  /* mapping index for NSH */
+  u32 nsh_map_index;
+
   /* map request mode */
   u8 map_request_mode;
 
@@ -188,6 +235,12 @@ typedef struct
   /* timing wheel for mappping timeouts */
   timing_wheel_t wheel;
 
+  /** Per thread pool of records shared with thread0 */
+  map_records_arg_t **map_records_args_pool;
+
+  /* TTL used for all mappings when registering */
+  u32 map_register_ttl;
+
   /* commodity */
   ip4_main_t *im4;
   ip6_main_t *im6;
@@ -196,7 +249,7 @@ typedef struct
 } lisp_cp_main_t;
 
 /* lisp-gpe control plane */
-lisp_cp_main_t lisp_control_main;
+extern lisp_cp_main_t lisp_control_main;
 
 extern vlib_node_registration_t lisp_cp_input_node;
 extern vlib_node_registration_t lisp_cp_lookup_ip4_node;
@@ -210,6 +263,11 @@ vnet_lisp_cp_get_main ()
   return &lisp_control_main;
 }
 
+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);
+
 typedef struct
 {
   u8 is_add;
@@ -280,6 +338,7 @@ clib_error_t *vnet_lisp_enable_disable (u8 is_enabled);
 u8 vnet_lisp_enable_disable_status (void);
 
 int vnet_lisp_pitr_set_locator_set (u8 * locator_set_name, u8 is_add);
+int vnet_lisp_use_petr (ip_address_t * ip, u8 is_add);
 
 typedef struct
 {
@@ -302,6 +361,20 @@ int vnet_lisp_rloc_probe_enable_disable (u8 is_enable);
 int vnet_lisp_map_register_enable_disable (u8 is_enable);
 u8 vnet_lisp_map_register_state_get (void);
 u8 vnet_lisp_rloc_probe_state_get (void);
+int vnet_lisp_add_del_l2_arp_entry (gid_address_t * key, u8 * mac, u8 is_add);
+u32 *vnet_lisp_l2_arp_bds_get (void);
+lisp_api_l2_arp_entry_t *vnet_lisp_l2_arp_entries_get_by_bd (u32 bd);
+int vnet_lisp_nsh_set_locator_set (u8 * locator_set_name, u8 is_add);
+int vnet_lisp_map_register_set_ttl (u32 ttl);
+u32 vnet_lisp_map_register_get_ttl (void);
+
+map_records_arg_t *parse_map_reply (vlib_buffer_t * b);
+
+always_inline mapping_t *
+lisp_get_petr_mapping (lisp_cp_main_t * lcm)
+{
+  return pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
+}
 
 #endif /* VNET_CONTROL_H_ */