diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2017-08-02 12:45:07 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2017-08-02 17:10:14 +0000 |
commit | 1e553a00389fb0eb2d54b950a3cfd91dd1a72644 (patch) | |
tree | 7203f85d0e4ddda6b0f79f9d40b7bbe810a8239d /src | |
parent | 5780898e5be8e8c279ac469417688d5b884f0217 (diff) |
LISP: make TTL for map register messages configurable
Change-Id: I38e1c6a6b033e12ef3f4345a1deff73fa4adbea0
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vat/api_format.c | 95 | ||||
-rw-r--r-- | src/vnet/lisp-cp/control.c | 16 | ||||
-rw-r--r-- | src/vnet/lisp-cp/control.h | 5 | ||||
-rw-r--r-- | src/vnet/lisp-cp/one.api | 34 | ||||
-rw-r--r-- | src/vnet/lisp-cp/one_api.c | 31 | ||||
-rw-r--r-- | src/vnet/lisp-cp/one_cli.c | 67 |
6 files changed, 248 insertions, 0 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 6a2d36de163..bbd97ba115f 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -3851,6 +3851,42 @@ static void } static void + vl_api_show_one_map_register_ttl_reply_t_handler + (vl_api_show_one_map_register_ttl_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vl_api_show_one_map_register_ttl_reply_t_endian (mp); + + if (0 <= retval) + { + print (vam->ofp, "ttl: %u", mp->ttl); + } + + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_show_one_map_register_ttl_reply_t_handler_json + (vl_api_show_one_map_register_ttl_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vl_api_show_one_map_register_ttl_reply_t_endian (mp); + vat_json_init_object (&node); + vat_json_object_add_uint (&node, "ttl", mp->ttl); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp) { vat_main_t *vam = &vat_main; @@ -4601,6 +4637,7 @@ _(one_add_del_map_server_reply) \ _(one_enable_disable_reply) \ _(one_rloc_probe_enable_disable_reply) \ _(one_map_register_enable_disable_reply) \ +_(one_map_register_set_ttl_reply) \ _(one_pitr_set_locator_set_reply) \ _(one_map_request_mode_reply) \ _(one_add_del_map_request_itr_rlocs_reply) \ @@ -4825,6 +4862,7 @@ _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \ _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \ _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \ one_map_register_enable_disable_reply) \ +_(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \ _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \ one_rloc_probe_enable_disable_reply) \ _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \ @@ -4871,6 +4909,7 @@ _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \ _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \ _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \ show_one_map_register_state_reply) \ +_(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \ _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \ _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \ _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \ @@ -16051,6 +16090,60 @@ api_lisp_gpe_add_del_iface (vat_main_t * vam) return ret; } +static int +api_one_map_register_set_ttl (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_one_map_register_set_ttl_t *mp; + u32 ttl = 0; + u8 is_set = 0; + int ret; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "%u", &ttl)) + is_set = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (!is_set) + { + errmsg ("TTL value missing!"); + return -99; + } + + M (ONE_MAP_REGISTER_SET_TTL, mp); + mp->ttl = clib_host_to_net_u32 (ttl); + + /* send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + +static int +api_show_one_map_register_ttl (vat_main_t * vam) +{ + vl_api_show_one_map_register_ttl_t *mp; + int ret; + + M (SHOW_ONE_MAP_REGISTER_TTL, mp); + + /* send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + /** * Add/del map request itr rlocs from ONE control plane and updates * @@ -19984,10 +20077,12 @@ _(show_one_status, "") \ _(one_stats_dump, "") \ _(one_stats_flush, "") \ _(one_get_map_request_itr_rlocs, "") \ +_(one_map_register_set_ttl, "<ttl>") \ _(show_one_nsh_mapping, "") \ _(show_one_pitr, "") \ _(show_one_use_petr, "") \ _(show_one_map_request_mode, "") \ +_(show_one_map_register_ttl, "") \ _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\ " sw_if_index <sw_if_index> p <priority> " \ "w <weight>] [del]") \ 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) |