summaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-cp
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-08-02 12:45:07 +0200
committerFlorin Coras <florin.coras@gmail.com>2017-08-02 17:10:14 +0000
commit1e553a00389fb0eb2d54b950a3cfd91dd1a72644 (patch)
tree7203f85d0e4ddda6b0f79f9d40b7bbe810a8239d /src/vnet/lisp-cp
parent5780898e5be8e8c279ac469417688d5b884f0217 (diff)
LISP: make TTL for map register messages configurable
Change-Id: I38e1c6a6b033e12ef3f4345a1deff73fa4adbea0 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/vnet/lisp-cp')
-rw-r--r--src/vnet/lisp-cp/control.c16
-rw-r--r--src/vnet/lisp-cp/control.h5
-rw-r--r--src/vnet/lisp-cp/one.api34
-rw-r--r--src/vnet/lisp-cp/one_api.c31
-rw-r--r--src/vnet/lisp-cp/one_cli.c67
5 files changed, 153 insertions, 0 deletions
diff --git a/src/vnet/lisp-cp/control.c b/src/vnet/lisp-cp/control.c
index fc860e14d89..a85656b3fb2 100644
--- a/src/vnet/lisp-cp/control.c
+++ b/src/vnet/lisp-cp/control.c
@@ -2075,6 +2075,21 @@ vnet_lisp_add_del_map_resolver (vnet_lisp_add_del_map_resolver_args_t * a)
}
int
+vnet_lisp_map_register_set_ttl (u32 ttl)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ lcm->map_register_ttl = ttl;
+ return 0;
+}
+
+u32
+vnet_lisp_map_register_get_ttl (void)
+{
+ lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
+ return lcm->map_register_ttl;
+}
+
+int
vnet_lisp_add_del_mreq_itr_rlocs (vnet_lisp_add_del_mreq_itr_rloc_args_t * a)
{
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
@@ -4005,6 +4020,7 @@ lisp_cp_init (vlib_main_t * vm)
u64 now = clib_cpu_time_now ();
timing_wheel_init (&lcm->wheel, now, vm->clib_time.clocks_per_second);
lcm->nsh_map_index = ~0;
+ lcm->map_register_ttl = MAP_REGISTER_DEFAULT_TTL;
return 0;
}
diff --git a/src/vnet/lisp-cp/control.h b/src/vnet/lisp-cp/control.h
index 0e63b3c7454..d030e588821 100644
--- a/src/vnet/lisp-cp/control.h
+++ b/src/vnet/lisp-cp/control.h
@@ -238,6 +238,9 @@ typedef struct
/** 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;
@@ -362,6 +365,8 @@ 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);
diff --git a/src/vnet/lisp-cp/one.api b/src/vnet/lisp-cp/one.api
index 31811a34bf5..5087c63408e 100644
--- a/src/vnet/lisp-cp/one.api
+++ b/src/vnet/lisp-cp/one.api
@@ -102,6 +102,40 @@ autoreply define one_add_del_local_eid
u8 key[64];
};
+/** \brief Set TTL for map register messages
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param ttl - time to live
+*/
+autoreply define one_map_register_set_ttl
+{
+ u32 client_index;
+ u32 context;
+ u32 ttl;
+};
+
+/** \brief Get TTL for map register messages
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+define show_one_map_register_ttl
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief Contains current TTL for map register messages
+ @param client_index - opaque cookie to identify the sender
+ @param retval - return code
+ @param ttl - time to live
+*/
+define show_one_map_register_ttl_reply
+{
+ u32 context;
+ i32 retval;
+ u32 ttl;
+};
+
/** \brief Add/delete map server
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c
index cac3313f7d1..2922993ff30 100644
--- a/src/vnet/lisp-cp/one_api.c
+++ b/src/vnet/lisp-cp/one_api.c
@@ -101,9 +101,11 @@ _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
_(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
_(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
_(ONE_ADJACENCIES_GET, one_adjacencies_get) \
+_(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
_(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
_(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
_(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
+_(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
_(SHOW_ONE_STATUS, show_one_status) \
_(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
one_add_del_map_request_itr_rlocs) \
@@ -144,6 +146,35 @@ unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num)
}
static void
+vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
+ mp)
+{
+ vl_api_one_map_register_set_ttl_reply_t *rmp;
+ int rv = 0;
+
+ vl_api_one_map_register_set_ttl_t_endian (mp);
+ rv = vnet_lisp_map_register_set_ttl (mp->ttl);
+
+ REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
+}
+
+static void
+ vl_api_show_one_map_register_ttl_t_handler
+ (vl_api_show_one_map_register_ttl_t * mp)
+{
+ vl_api_show_one_map_register_ttl_reply_t *rmp;
+ int rv = 0;
+
+ u32 ttl = vnet_lisp_map_register_get_ttl ();
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
+ ({
+ rmp->ttl = clib_host_to_net_u32 (ttl);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
mp)
{
diff --git a/src/vnet/lisp-cp/one_cli.c b/src/vnet/lisp-cp/one_cli.c
index e3fbf5a1f07..3b411899dd8 100644
--- a/src/vnet/lisp-cp/one_cli.c
+++ b/src/vnet/lisp-cp/one_cli.c
@@ -1082,6 +1082,73 @@ VLIB_CLI_COMMAND (one_cp_enable_disable_command) = {
/* *INDENT-ON* */
static clib_error_t *
+lisp_map_register_set_ttl_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ u32 ttl = 0;
+ u8 is_set = 0;
+ clib_error_t *error = NULL;
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "%u", &ttl))
+ is_set = 1;
+ else
+ {
+ vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
+ line_input);
+ goto done;
+ }
+ }
+
+ if (!is_set)
+ {
+ vlib_cli_output (vm, "expected integer value for TTL!");
+ goto done;
+ }
+
+ vnet_lisp_map_register_set_ttl (ttl);
+
+done:
+ unformat_free (line_input);
+ return error;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (one_map_register_set_ttl_command) = {
+ .path = "one map-register ttl",
+ .short_help = "one map-register ttl",
+ .function = lisp_map_register_set_ttl_command_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+lisp_map_register_show_ttl_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ u32 ttl = vnet_lisp_map_register_get_ttl ();
+
+ vlib_cli_output (vm, "map-register TTL: %u", ttl);
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (one_map_register_show_ttl_command) = {
+ .path = "show one map-register ttl",
+ .short_help = "show one map-register ttl",
+ .function = lisp_map_register_show_ttl_command_fn,
+};
+
+/* *INDENT-ON* */
+
+static clib_error_t *
lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)