diff options
author | Neale Ranns <nranns@cisco.com> | 2017-09-12 09:45:04 -0700 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2017-09-13 17:31:13 +0000 |
commit | 2297af016d4c1ecdd0c695dc736e8f5a988e89bd (patch) | |
tree | f887e39e50144e5052d0058605ed63cfa40c01f9 /src/vnet/mpls | |
parent | 49fe046e431c4d76b0c45c609e05e1b0a3063360 (diff) |
Add a name to the creation of an IP and MPLS table
Change-Id: I4b4648831551519b2ffb6f93255d28a4b8726c22
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/mpls')
-rw-r--r-- | src/vnet/mpls/mpls.api | 5 | ||||
-rw-r--r-- | src/vnet/mpls/mpls.c | 5 | ||||
-rw-r--r-- | src/vnet/mpls/mpls.h | 40 | ||||
-rw-r--r-- | src/vnet/mpls/mpls_api.c | 24 |
4 files changed, 46 insertions, 28 deletions
diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api index bb849998..36488d0c 100644 --- a/src/vnet/mpls/mpls.api +++ b/src/vnet/mpls/mpls.api @@ -141,6 +141,9 @@ manual_endian manual_print define mpls_tunnel_details @param context - sender context, to match reply w/ request @param mt_table_id - The MPLS table-id the route is added in @param mt_is_add - Is this a route add or delete + @param mt_name - A client provided name/tag for the table. If this + is not set by the client, then VPP will generate + something meaningfull. */ autoreply define mpls_table_add_del { @@ -148,6 +151,7 @@ autoreply define mpls_table_add_del u32 context; u32 mt_table_id; u8 mt_is_add; + u8 mt_name[64]; }; /** \brief MPLS Route Add / del route @@ -227,6 +231,7 @@ manual_endian manual_print define mpls_fib_details { u32 context; u32 table_id; + u8 table_name[64]; u8 eos_bit; u32 label; u32 count; diff --git a/src/vnet/mpls/mpls.c b/src/vnet/mpls/mpls.c index 7bdfd8c7..f8bbb8a9 100644 --- a/src/vnet/mpls/mpls.c +++ b/src/vnet/mpls/mpls.c @@ -544,6 +544,7 @@ vnet_mpls_table_cmd (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; clib_error_t *error = NULL; u32 table_id, is_add; + u8 *name = NULL; is_add = 1; table_id = ~0; @@ -560,6 +561,8 @@ vnet_mpls_table_cmd (vlib_main_t * vm, is_add = 0; else if (unformat (line_input, "add")) is_add = 1; + else if (unformat (line_input, "name %s", &name)) + ; else { error = unformat_parse_error (line_input); @@ -581,7 +584,7 @@ vnet_mpls_table_cmd (vlib_main_t * vm, { if (is_add) { - mpls_table_create (table_id, 0); + mpls_table_create (table_id, 0, name); } else { diff --git a/src/vnet/mpls/mpls.h b/src/vnet/mpls/mpls.h index 8dd92887..cc3eeed0 100644 --- a/src/vnet/mpls/mpls.h +++ b/src/vnet/mpls/mpls.h @@ -23,7 +23,8 @@ #include <vnet/fib/fib_node.h> #include <vnet/adj/adj.h> -typedef enum { +typedef enum +{ #define mpls_error(n,s) MPLS_ERROR_##n, #include <vnet/mpls/error.def> #undef mpls_error @@ -34,10 +35,11 @@ typedef enum { * @brief Definition of a callback for receiving MPLS interface state change * notifications */ -typedef void (*mpls_interface_state_change_callback_t)(u32 sw_if_index, - u32 is_enable); +typedef void (*mpls_interface_state_change_callback_t) (u32 sw_if_index, + u32 is_enable); -typedef struct { +typedef struct +{ /* MPLS FIB index for each software interface */ u32 *fib_index_by_sw_if_index; @@ -55,12 +57,12 @@ typedef struct { u8 output_feature_arc_index; /* IP4 enabled count by software interface */ - u8 * mpls_enabled_by_sw_if_index; + u8 *mpls_enabled_by_sw_if_index; } mpls_main_t; extern mpls_main_t mpls_main; -extern clib_error_t * mpls_feature_init(vlib_main_t * vm); +extern clib_error_t *mpls_feature_init (vlib_main_t * vm); format_function_t format_mpls_eos_bit; format_function_t format_mpls_unicast_header_net_byte_order; @@ -81,24 +83,28 @@ unformat_function_t unformat_mpls_header; unformat_function_t unformat_pg_mpls_header; int mpls_sw_interface_enable_disable (mpls_main_t * mm, - u32 sw_if_index, - u8 is_enable, - u8 is_api); + u32 sw_if_index, + u8 is_enable, u8 is_api); u8 mpls_sw_interface_is_enabled (u32 sw_if_index); int mpls_fib_reset_labels (u32 fib_id); -int -mpls_dest_cmp(void * a1, void * a2); +int mpls_dest_cmp (void *a1, void *a2); -int -mpls_fib_index_cmp(void * a1, void * a2); +int mpls_fib_index_cmp (void *a1, void *a2); -int -mpls_label_cmp(void * a1, void * a2); +int mpls_label_cmp (void *a1, void *a2); -void mpls_table_create(u32 table_id, u8 is_api); -void mpls_table_delete(u32 table_id, u8 is_api); +void mpls_table_create (u32 table_id, u8 is_api, const u8 * name); +void mpls_table_delete (u32 table_id, u8 is_api); #endif /* included_vnet_mpls_h */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c index 38f5b014..988c2c98 100644 --- a/src/vnet/mpls/mpls_api.c +++ b/src/vnet/mpls/mpls_api.c @@ -92,7 +92,7 @@ vl_api_mpls_table_add_del_t_handler (vl_api_mpls_table_add_del_t * mp) vnm->api_errno = 0; if (mp->mt_is_add) - mpls_table_create (ntohl (mp->mt_table_id), 1); + mpls_table_create (ntohl (mp->mt_table_id), 1, mp->mt_name); else mpls_table_delete (ntohl (mp->mt_table_id), 1); @@ -258,7 +258,7 @@ vl_api_mpls_route_add_del_t_handler (vl_api_mpls_route_add_del_t * mp) } void -mpls_table_create (u32 table_id, u8 is_api) +mpls_table_create (u32 table_id, u8 is_api, const u8 * name) { u32 fib_index; @@ -276,10 +276,11 @@ mpls_table_create (u32 table_id, u8 is_api) if (~0 == fib_index) { - fib_table_find_or_create_and_lock (FIB_PROTOCOL_MPLS, - table_id, - (is_api ? - FIB_SOURCE_API : FIB_SOURCE_CLI)); + fib_table_find_or_create_and_lock_w_name (FIB_PROTOCOL_MPLS, + table_id, + (is_api ? + FIB_SOURCE_API : + FIB_SOURCE_CLI), name); } } @@ -424,7 +425,8 @@ vl_api_mpls_tunnel_dump_t_handler (vl_api_mpls_tunnel_dump_t * mp) static void send_mpls_fib_details (vpe_api_main_t * am, unix_shared_memory_queue_t * q, - u32 table_id, u32 label, u32 eos, + const fib_table_t * table, + u32 label, u32 eos, fib_route_path_encode_t * api_rpaths, u32 context) { vl_api_mpls_fib_details_t *mp; @@ -440,7 +442,9 @@ send_mpls_fib_details (vpe_api_main_t * am, mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_DETAILS); mp->context = context; - mp->table_id = htonl (table_id); + mp->table_id = htonl (table->ft_table_id); + memcpy (mp->table_name, table->ft_desc, + clib_min (vec_len (table->ft_desc), sizeof (mp->table_name))); mp->eos_bit = eos; mp->label = htonl (label); @@ -512,8 +516,8 @@ vl_api_mpls_fib_dump_t_handler (vl_api_mpls_fib_dump_t * mp) api_rpaths = NULL; fib_entry_encode (*lfeip, &api_rpaths); send_mpls_fib_details (am, q, - fib_table->ft_table_id, - pfx.fp_label, pfx.fp_eos, api_rpaths, mp->context); + fib_table, pfx.fp_label, + pfx.fp_eos, api_rpaths, mp->context); vec_free (api_rpaths); } |