{
fib_source_t source = va_arg (*args, int);
- s = format (s, "\n src:%s ",
- fib_source_names[source]);
+ s = format (s, "src:%s", fib_source_names[source]);
return (s);
}
FOR_EACH_SRC_ADDED(fib_entry, src, source,
({
- s = format (s, "\n src:%U ",
- format_fib_source, source);
+ s = format (s, "\n %U", format_fib_source, source);
s = fib_entry_src_format(fib_entry, source, s);
s = format (s, " refs:%d ", src->fes_ref_count);
if (FIB_ENTRY_FLAG_NONE != src->fes_entry_flags) {
return (~0);
}
-u32
-fib_table_find_or_create_and_lock (fib_protocol_t proto,
- u32 table_id,
- fib_source_t src)
+static u32
+fib_table_find_or_create_and_lock_i (fib_protocol_t proto,
+ u32 table_id,
+ fib_source_t src,
+ const u8 *name)
{
fib_table_t *fib_table;
fib_node_index_t fi;
fib_table = fib_table_get(fi, proto);
- fib_table->ft_desc = format(NULL, "%U-VRF:%d",
- format_fib_protocol, proto,
- table_id);
+ if (NULL == fib_table->ft_desc)
+ {
+ if (name && name[0])
+ {
+ fib_table->ft_desc = format(NULL, "%s", name);
+ }
+ else
+ {
+ fib_table->ft_desc = format(NULL, "%U-VRF:%d",
+ format_fib_protocol, proto,
+ table_id);
+ }
+ }
return (fi);
}
+u32
+fib_table_find_or_create_and_lock (fib_protocol_t proto,
+ u32 table_id,
+ fib_source_t src)
+{
+ return (fib_table_find_or_create_and_lock_i(proto, table_id,
+ src, NULL));
+}
+
+u32
+fib_table_find_or_create_and_lock_w_name (fib_protocol_t proto,
+ u32 table_id,
+ fib_source_t src,
+ const u8 *name)
+{
+ return (fib_table_find_or_create_and_lock_i(proto, table_id,
+ src, name));
+}
+
u32
fib_table_create_and_lock (fib_protocol_t proto,
fib_source_t src,
u32 table_id,
fib_source_t source);
+/**
+ * @brief
+ * Get the index of the FIB for a Table-ID. This DOES create the
+ * FIB if it does not exist.
+ *
+ * @paran proto
+ * The protocol of the FIB (and thus the entries therein)
+ *
+ * @param table-id
+ * The Table-ID
+ *
+ * @return fib_index
+ * The index of the FIB
+ *
+ * @param source
+ * The ID of the client/source.
+ *
+ * @param name
+ * The client is choosing the name they want the table to have
+ */
+extern u32 fib_table_find_or_create_and_lock_w_name(fib_protocol_t proto,
+ u32 table_id,
+ fib_source_t source,
+ const u8 *name);
+
/**
* @brief
* Create a new table with no table ID. This means it does not get
/*
* MPLS enable an interface so we get the MPLS table created
*/
- mpls_table_create(MPLS_FIB_DEFAULT_TABLE_ID, FIB_SOURCE_API);
+ mpls_table_create(MPLS_FIB_DEFAULT_TABLE_ID, FIB_SOURCE_API, NULL);
mpls_sw_interface_enable_disable(&mpls_main,
tm->hw[0]->sw_if_index,
1, 1);
}
}
s = format (s, "]");
- vlib_cli_output (vm, "%V", s);
+ vlib_cli_output (vm, "%v", s);
vec_free(s);
/* Show summary? */
}
}
s = format (s, "]");
- vlib_cli_output (vm, "%V", s);
+ vlib_cli_output (vm, "%v", s);
vec_free(s);
/* Show summary? */
@param table_id - table ID associated with the route
This table ID will apply to both the unicats
and mlticast FIBs
+ @param 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 ip_table_add_del
{
u32 table_id;
u8 is_ipv6;
u8 is_add;
+ u8 name[64];
};
/** \brief Dump IP fib table
{
u32 context;
u32 table_id;
+ u8 table_name[64];
u8 address_length;
u8 address[4];
u32 count;
u32 context;
};
-/** \brief IP6 FIB table response
+/** \brief IP6 FIB table entry response
@param table_id - IP6 fib table id
- @address_length - mask length
- @address - ip6 prefix
+ @param address_length - mask length
+ @param address - ip6 prefix
@param count - the number of fib_path in path
@param path - array of of fib_path structures
*/
{
u32 context;
u32 table_id;
+ u8 table_name[64];
u8 address_length;
u8 address[16];
u32 count;
extern vlib_node_registration_t ip4_inacl_node;
extern vlib_node_registration_t ip6_inacl_node;
-void ip_table_create (fib_protocol_t fproto, u32 table_id, u8 is_api);
+void ip_table_create (fib_protocol_t fproto, u32 table_id, u8 is_api,
+ const u8 * name);
void ip_table_delete (fib_protocol_t fproto, u32 table_id, u8 is_api);
static void
send_ip_fib_details (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
- u32 table_id, fib_prefix_t * pfx,
+ const fib_table_t * table,
+ const fib_prefix_t * pfx,
fib_route_path_encode_t * api_rpaths, u32 context)
{
vl_api_ip_fib_details_t *mp;
mp->_vl_msg_id = ntohs (VL_API_IP_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->address_length = pfx->fp_len;
memcpy (mp->address, &pfx->fp_addr.ip4, sizeof (pfx->fp_addr.ip4));
fib_table = fib_table_get (fib_index, pfx.fp_proto);
api_rpaths = NULL;
fib_entry_encode (*lfeip, &api_rpaths);
- send_ip_fib_details (am, q,
- fib_table->ft_table_id, &pfx, api_rpaths,
- mp->context);
+ send_ip_fib_details (am, q, fib_table, &pfx, api_rpaths, mp->context);
vec_free (api_rpaths);
}
if (mp->is_add)
{
- ip_table_create (fproto, table_id, 1);
+ ip_table_create (fproto, table_id, 1, mp->name);
}
else
{
}
void
-ip_table_create (fib_protocol_t fproto, u32 table_id, u8 is_api)
+ip_table_create (fib_protocol_t fproto,
+ u32 table_id, u8 is_api, const u8 * name)
{
u32 fib_index, mfib_index;
if (~0 == fib_index)
{
- fib_table_find_or_create_and_lock (fproto, table_id,
- (is_api ?
- FIB_SOURCE_API :
- FIB_SOURCE_CLI));
+ fib_table_find_or_create_and_lock_w_name (fproto, table_id,
+ (is_api ?
+ FIB_SOURCE_API :
+ FIB_SOURCE_CLI), name);
}
if (~0 == mfib_index)
{
- mfib_table_find_or_create_and_lock (fproto, table_id,
- (is_api ?
- MFIB_SOURCE_API :
- MFIB_SOURCE_CLI));
+ mfib_table_find_or_create_and_lock_w_name (fproto, table_id,
+ (is_api ?
+ MFIB_SOURCE_API :
+ MFIB_SOURCE_CLI), name);
}
}
}
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;
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);
{
if (is_add)
{
- ip_table_create (fproto, table_id, 0);
+ ip_table_create (fproto, table_id, 0, name);
}
else
{
return (~0);
}
-u32
-mfib_table_find_or_create_and_lock (fib_protocol_t proto,
- u32 table_id,
- mfib_source_t src)
+static u32
+mfib_table_find_or_create_and_lock_i (fib_protocol_t proto,
+ u32 table_id,
+ mfib_source_t src,
+ const u8 *name)
{
mfib_table_t *mfib_table;
fib_node_index_t fi;
mfib_table = mfib_table_get(fi, proto);
- mfib_table->mft_desc = format(NULL, "%U-VRF:%d",
- format_fib_protocol, proto,
- table_id);
+ if (NULL == mfib_table->mft_desc)
+ {
+ if (name && name[0])
+ {
+ mfib_table->mft_desc = format(NULL, "%s", name);
+ }
+ else
+ {
+ mfib_table->mft_desc = format(NULL, "%U-VRF:%d",
+ format_fib_protocol, proto,
+ table_id);
+ }
+ }
return (fi);
}
+u32
+mfib_table_find_or_create_and_lock (fib_protocol_t proto,
+ u32 table_id,
+ mfib_source_t src)
+{
+ return (mfib_table_find_or_create_and_lock_i(proto, table_id,
+ src, NULL));
+}
+
+u32
+mfib_table_find_or_create_and_lock_w_name (fib_protocol_t proto,
+ u32 table_id,
+ mfib_source_t src,
+ const u8 *name)
+{
+ return (mfib_table_find_or_create_and_lock_i(proto, table_id,
+ src, name));
+}
+
/**
* @brief Table flush context. Store the indicies of matching FIB entries
* that need to be removed.
u32 table_id,
mfib_source_t source);
+/**
+ * @brief
+ * Get the index of the FIB for a Table-ID. This DOES create the
+ * FIB if it does not exist.
+ *
+ * @paran proto
+ * The protocol of the FIB (and thus the entries therein)
+ *
+ * @param table-id
+ * The Table-ID
+ *
+ * @return fib_index
+ * The index of the FIB
+ *
+ * @param source
+ * The ID of the client/source.
+ *
+ * @param name
+ * The client is choosing the name they want the table to have
+ */
+extern u32 mfib_table_find_or_create_and_lock_w_name(fib_protocol_t proto,
+ u32 table_id,
+ mfib_source_t source,
+ const u8 *name);
+
/**
* @brief
/*
* MPLS enable an interface so we get the MPLS table created
*/
- mpls_table_create(MPLS_FIB_DEFAULT_TABLE_ID, FIB_SOURCE_API);
+ mpls_table_create(MPLS_FIB_DEFAULT_TABLE_ID, FIB_SOURCE_API, NULL);
mpls_sw_interface_enable_disable(&mpls_main,
tm->hw[0]->sw_if_index,
1, 0);
@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
{
u32 context;
u32 mt_table_id;
u8 mt_is_add;
+ u8 mt_name[64];
};
/** \brief MPLS Route Add / del route
{
u32 context;
u32 table_id;
+ u8 table_name[64];
u8 eos_bit;
u32 label;
u32 count;
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;
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);
{
if (is_add)
{
- mpls_table_create (table_id, 0);
+ mpls_table_create (table_id, 0, name);
}
else
{
#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
* @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;
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;
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:
+ */
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);
}
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;
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);
}
}
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;
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);
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);
}
vrf_exist = False
vrf_count = 0
for ip6_fib_details in ip6_fib_dump:
- if ip6_fib_details[2] == vrf_id:
+ if ip6_fib_details.table_id == vrf_id:
if not vrf_exist:
vrf_exist = True
- addr = inet_ntop(socket.AF_INET6, ip6_fib_details[4])
+ addr = inet_ntop(socket.AF_INET6, ip6_fib_details.address)
addrtype = in6_getAddrType(addr)
vrf_count += 1 if addrtype == IPV6_ADDR_UNICAST else 0
if not vrf_exist and vrf_count == 0: