aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/mpls
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/mpls')
-rw-r--r--src/vnet/mpls/mpls.api129
-rw-r--r--src/vnet/mpls/mpls_api.c352
-rw-r--r--src/vnet/mpls/mpls_tunnel.c14
3 files changed, 220 insertions, 275 deletions
diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api
index ca1aa3a8513..5d85812807a 100644
--- a/src/vnet/mpls/mpls.api
+++ b/src/vnet/mpls/mpls.api
@@ -15,6 +15,7 @@
option version = "1.1.0";
import "vnet/fib/fib_types.api";
+import "vnet/ip/ip_types.api";
/** \brief Bind/Unbind an MPLS local label to an IP prefix. i.e. create
a per-prefix label entry.
@@ -36,28 +37,24 @@ autoreply define mpls_ip_bind_unbind
u32 mb_label;
u32 mb_ip_table_id;
u8 mb_is_bind;
- u8 mb_is_ip4;
- u8 mb_address_length;
- u8 mb_address[16];
+ vl_api_prefix_t mb_prefix;
};
+typeonly define mpls_tunnel
+{
+ u32 mt_sw_if_index;
+ u32 mt_tunnel_index;
+ u8 mt_l2_only;
+ u8 mt_is_multicast;
+ u8 mt_n_paths;
+ vl_api_fib_path_t mt_paths[mt_n_paths];
+};
define mpls_tunnel_add_del
{
u32 client_index;
u32 context;
- u32 mt_sw_if_index;
u8 mt_is_add;
- u8 mt_l2_only;
- u8 mt_is_multicast;
- u8 mt_next_hop_proto_is_ip4;
- u8 mt_next_hop_weight;
- u8 mt_next_hop_preference;
- u8 mt_next_hop[16];
- u8 mt_next_hop_n_out_labels;
- u32 mt_next_hop_via_label;
- u32 mt_next_hop_sw_if_index;
- u32 mt_next_hop_table_id;
- vl_api_fib_mpls_label_t mt_next_hop_out_label_stack[mt_next_hop_n_out_labels];
+ vl_api_mpls_tunnel_t mt_tunnel;
};
/** \brief Reply for MPLS tunnel add / del request
@@ -90,12 +87,7 @@ define mpls_tunnel_dump
manual_endian manual_print define mpls_tunnel_details
{
u32 context;
- u32 mt_sw_if_index;
- u32 mt_tunnel_index;
- u8 mt_l2_only;
- u8 mt_is_multicast;
- u32 mt_count;
- vl_api_fib_path_t mt_paths[mt_count];
+ vl_api_mpls_tunnel_t mt_tunnel;
};
/** \brief MPLS Route Add / del route
@@ -107,68 +99,71 @@ manual_endian manual_print define mpls_tunnel_details
is not set by the client, then VPP will generate
something meaningfull.
*/
+typeonly define mpls_table
+{
+ u32 mt_table_id;
+ u8 mt_name[64];
+};
autoreply define mpls_table_add_del
{
u32 client_index;
u32 context;
- u32 mt_table_id;
u8 mt_is_add;
- u8 mt_name[64];
+ vl_api_mpls_table_t mt_table;
};
-/** \brief MPLS Route Add / del route
+/** \brief Dump MPLS fib table
@param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
+*/
+define mpls_table_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+define mpls_table_details
+{
+ u32 context;
+ vl_api_mpls_table_t mt_table;
+};
+
+/** \brief MPLS Route
@param mr_label - The MPLS label value
@param mr_eos - The End of stack bit
+ @param mr_eos_proto - If EOS then this is the DPO packect's proto post pop
@param mr_table_id - The MPLS table-id the route is added in
- @param mr_classify_table_index - If this is a classify route,
- this is the classify table index
- create them
@param mr_is_add - Is this a route add or delete
- @param mr_is_classify - Is this route result a classify
@param mr_is_multicast - Is this a multicast route
+ @param mr_n_paths - The number of paths
+ @param mr_paths - The paths
+*/
+typeonly define mpls_route
+{
+ u32 mr_table_id;
+ u32 mr_label;
+ u8 mr_eos;
+ u8 mr_eos_proto;
+ u8 mr_is_multicast;
+ u8 mr_n_paths;
+ vl_api_fib_path_t mr_paths[mr_n_paths];
+};
+
+/** \brief MPLS Route Add / del route
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param mr_table_id - The MPLS table-id the route is added in
+ @param mr_is_add - Is this a route add or delete
@param mr_is_multipath - Is this route update a multipath - i.e. is this
a path addition to an existing route
- @param mr_is_resolve_host - Recurse resolution constraint via a host prefix
- @param mr_is_resolve_attached - Recurse resolution constraint via attached prefix
- @param mr_is_interface_rx - Interface Receive path
- @param mr_is_interface_rx - RPF-ID Receive path. The next-hop interface
- is used as the RPF-ID
- @param mr_next_hop_proto - The next-hop protocol, of type dpo_proto_t
- @param mr_next_hop_weight - The weight, for UCMP
- @param mr_next_hop[16] - the nextop address
- @param mr_next_hop_sw_if_index - the next-hop SW interface
- @param mr_next_hop_table_id - the next-hop table-id (if appropriate)
- @param mr_next_hop_n_out_labels - the number of labels in the label stack
- @param mr_next_hop_out_label_stack - the next-hop output label stack, outer most first
- @param next_hop_via_label - The next-hop is a resolved via a local label
+ @param mr_route - The Route
*/
define mpls_route_add_del
{
u32 client_index;
u32 context;
- u32 mr_label;
- u8 mr_eos;
- u32 mr_table_id;
- u32 mr_classify_table_index;
u8 mr_is_add;
- u8 mr_is_classify;
- u8 mr_is_multicast;
u8 mr_is_multipath;
- u8 mr_is_resolve_host;
- u8 mr_is_resolve_attached;
- u8 mr_is_interface_rx;
- u8 mr_is_rpf_id;
- u8 mr_next_hop_proto;
- u8 mr_next_hop_weight;
- u8 mr_next_hop_preference;
- u8 mr_next_hop[16];
- u8 mr_next_hop_n_out_labels;
- u32 mr_next_hop_sw_if_index;
- u32 mr_next_hop_table_id;
- u32 mr_next_hop_via_label;
- vl_api_fib_mpls_label_t mr_next_hop_out_label_stack[mr_next_hop_n_out_labels];
+ vl_api_mpls_route_t mr_route;
};
define mpls_route_add_del_reply
@@ -181,10 +176,11 @@ define mpls_route_add_del_reply
/** \brief Dump MPLS fib table
@param client_index - opaque cookie to identify the sender
*/
-define mpls_fib_dump
+define mpls_route_dump
{
u32 client_index;
u32 context;
+ vl_api_mpls_table_t table;
};
/** \brief mpls FIB table response
@@ -194,15 +190,10 @@ define mpls_fib_dump
@param count - the number of fib_path in path
@param path - array of of fib_path structures
*/
-manual_endian manual_print define mpls_fib_details
+manual_endian manual_print define mpls_route_details
{
u32 context;
- u32 table_id;
- u8 table_name[64];
- u8 eos_bit;
- u32 label;
- u32 count;
- vl_api_fib_path_t path[count];
+ vl_api_mpls_route_t mr_route;
};
/** \brief Enable or Disable MPLS on and interface
diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c
index 52434dae8aa..cb20df5695b 100644
--- a/src/vnet/mpls/mpls_api.c
+++ b/src/vnet/mpls/mpls_api.c
@@ -28,6 +28,7 @@
#include <vnet/fib/fib_api.h>
#include <vnet/fib/mpls_fib.h>
#include <vnet/fib/fib_path_list.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -54,7 +55,8 @@ _(MPLS_TABLE_ADD_DEL, mpls_table_add_del) \
_(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del) \
_(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \
_(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
-_(MPLS_FIB_DUMP, mpls_fib_dump)
+_(MPLS_TABLE_DUMP, mpls_table_dump) \
+_(MPLS_ROUTE_DUMP, mpls_route_dump)
void
mpls_table_delete (u32 table_id, u8 is_api)
@@ -90,9 +92,10 @@ 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, mp->mt_name);
+ mpls_table_create (ntohl (mp->mt_table.mt_table_id),
+ 1, mp->mt_table.mt_name);
else
- mpls_table_delete (ntohl (mp->mt_table_id), 1);
+ mpls_table_delete (ntohl (mp->mt_table.mt_table_id), 1);
// NB: Nothing sets rv; none of the above returns an error
@@ -104,6 +107,7 @@ mpls_ip_bind_unbind_handler (vnet_main_t * vnm,
vl_api_mpls_ip_bind_unbind_t * mp)
{
u32 mpls_fib_index, ip_fib_index;
+ fib_prefix_t pfx;
mpls_fib_index =
fib_table_find (FIB_PROTOCOL_MPLS, ntohl (mp->mb_mpls_table_id));
@@ -113,30 +117,12 @@ mpls_ip_bind_unbind_handler (vnet_main_t * vnm,
return VNET_API_ERROR_NO_SUCH_FIB;
}
- ip_fib_index = fib_table_find ((mp->mb_is_ip4 ?
- FIB_PROTOCOL_IP4 :
- FIB_PROTOCOL_IP6),
- ntohl (mp->mb_ip_table_id));
+ ip_prefix_decode (&mp->mb_prefix, &pfx);
+
+ ip_fib_index = fib_table_find (pfx.fp_proto, ntohl (mp->mb_ip_table_id));
if (~0 == ip_fib_index)
return VNET_API_ERROR_NO_SUCH_FIB;
- fib_prefix_t pfx = {
- .fp_len = mp->mb_address_length,
- };
-
- if (mp->mb_is_ip4)
- {
- pfx.fp_proto = FIB_PROTOCOL_IP4;
- clib_memcpy (&pfx.fp_addr.ip4, mp->mb_address,
- sizeof (pfx.fp_addr.ip4));
- }
- else
- {
- pfx.fp_proto = FIB_PROTOCOL_IP6;
- clib_memcpy (&pfx.fp_addr.ip6, mp->mb_address,
- sizeof (pfx.fp_addr.ip6));
- }
-
if (mp->mb_is_bind)
fib_table_entry_local_label_add (ip_fib_index, &pfx,
ntohl (mp->mb_label));
@@ -168,92 +154,58 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
vl_api_mpls_route_add_del_t * mp,
u32 * stats_index)
{
- fib_mpls_label_t *label_stack = NULL;
- u32 fib_index, next_hop_fib_index;
- int rv, ii, n_labels;;
+ fib_route_path_t *rpaths = NULL, *rpath;
+ vl_api_fib_path_t *apath;
+ u32 fib_index;
+ int rv, ii;
fib_prefix_t pfx = {
.fp_len = 21,
.fp_proto = FIB_PROTOCOL_MPLS,
- .fp_eos = mp->mr_eos,
- .fp_label = ntohl (mp->mr_label),
+ .fp_eos = mp->mr_route.mr_eos,
+ .fp_label = ntohl (mp->mr_route.mr_label),
};
if (pfx.fp_eos)
{
- pfx.fp_payload_proto = mp->mr_next_hop_proto;
+ pfx.fp_payload_proto = mp->mr_route.mr_eos_proto;
}
else
{
pfx.fp_payload_proto = DPO_PROTO_MPLS;
}
- rv = add_del_route_check (FIB_PROTOCOL_MPLS,
- mp->mr_table_id,
- mp->mr_next_hop_sw_if_index,
- pfx.fp_payload_proto,
- mp->mr_next_hop_table_id,
- mp->mr_is_rpf_id,
- &fib_index, &next_hop_fib_index);
-
+ rv = fib_api_table_id_decode (FIB_PROTOCOL_MPLS,
+ ntohl (mp->mr_route.mr_table_id), &fib_index);
if (0 != rv)
- return (rv);
-
- ip46_address_t nh;
- clib_memset (&nh, 0, sizeof (nh));
+ goto out;
- if (DPO_PROTO_IP4 == mp->mr_next_hop_proto)
- memcpy (&nh.ip4, mp->mr_next_hop, sizeof (nh.ip4));
- else if (DPO_PROTO_IP6 == mp->mr_next_hop_proto)
- memcpy (&nh.ip6, mp->mr_next_hop, sizeof (nh.ip6));
+ vec_validate (rpaths, mp->mr_route.mr_n_paths - 1);
- n_labels = mp->mr_next_hop_n_out_labels;
- if (n_labels == 0)
- ;
- else
+ for (ii = 0; ii < mp->mr_route.mr_n_paths; ii++)
{
- vec_validate (label_stack, n_labels - 1);
- for (ii = 0; ii < n_labels; ii++)
- {
- label_stack[ii].fml_value =
- ntohl (mp->mr_next_hop_out_label_stack[ii].label);
- label_stack[ii].fml_ttl = mp->mr_next_hop_out_label_stack[ii].ttl;
- label_stack[ii].fml_exp = mp->mr_next_hop_out_label_stack[ii].exp;
- label_stack[ii].fml_mode =
- (mp->mr_next_hop_out_label_stack[ii].is_uniform ?
- FIB_MPLS_LSP_MODE_UNIFORM : FIB_MPLS_LSP_MODE_PIPE);
- }
+ apath = &mp->mr_route.mr_paths[ii];
+ rpath = &rpaths[ii];
+
+ rv = fib_api_path_decode (apath, rpath);
+
+ if (0 != rv)
+ goto out;
}
- /* *INDENT-OFF* */
- rv = add_del_route_t_handler (mp->mr_is_multipath, mp->mr_is_add,
- 0, // mp->is_drop,
- 0, // mp->is_unreach,
- 0, // mp->is_prohibit,
- 0, // mp->is_local,
- mp->mr_is_multicast,
- mp->mr_is_classify,
- mp->mr_classify_table_index,
- mp->mr_is_resolve_host,
- mp->mr_is_resolve_attached,
- mp->mr_is_interface_rx,
- mp->mr_is_rpf_id,
- 0, // l2_bridged
- 0, // is source_lookup
- 0, // is_udp_encap
- fib_index, &pfx,
- mp->mr_next_hop_proto,
- &nh, ~0, // next_hop_id
- ntohl (mp->mr_next_hop_sw_if_index),
- next_hop_fib_index,
- mp->mr_next_hop_weight,
- mp->mr_next_hop_preference,
- ntohl (mp->mr_next_hop_via_label),
- label_stack);
- /* *INDENT-ON* */
+ fib_api_route_add_del (mp->mr_is_add,
+ mp->mr_is_multipath,
+ fib_index,
+ &pfx,
+ (mp->mr_route.mr_is_multicast ?
+ FIB_ENTRY_FLAG_MULTICAST :
+ FIB_ENTRY_FLAG_NONE), rpaths);
if (mp->mr_is_add && 0 == rv)
*stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
+out:
+ vec_free (rpaths);
+
return (rv);
}
@@ -308,73 +260,30 @@ mpls_table_create (u32 table_id, u8 is_api, const u8 * name)
static void
vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
{
- u32 tunnel_sw_if_index = ~0, tunnel_index = ~0, next_hop_via_label;
+ u32 tunnel_sw_if_index = ~0, tunnel_index = ~0;
vl_api_mpls_tunnel_add_del_reply_t *rmp;
- fib_route_path_t rpath, *rpaths = NULL;
+ fib_route_path_t *rpath, *rpaths = NULL;
int ii, rv = 0;
- clib_memset (&rpath, 0, sizeof (rpath));
+ vec_validate (rpaths, mp->mt_tunnel.mt_n_paths - 1);
- if (mp->mt_next_hop_proto_is_ip4)
+ for (ii = 0; ii < mp->mt_tunnel.mt_n_paths; ii++)
{
- rpath.frp_proto = DPO_PROTO_IP4;
- clib_memcpy (&rpath.frp_addr.ip4,
- mp->mt_next_hop, sizeof (rpath.frp_addr.ip4));
- }
- else
- {
- rpath.frp_proto = DPO_PROTO_IP6;
- clib_memcpy (&rpath.frp_addr.ip6,
- mp->mt_next_hop, sizeof (rpath.frp_addr.ip6));
- }
- rpath.frp_sw_if_index = ntohl (mp->mt_next_hop_sw_if_index);
- rpath.frp_weight = mp->mt_next_hop_weight;
- rpath.frp_preference = mp->mt_next_hop_preference;
+ rpath = &rpaths[ii];
- next_hop_via_label = ntohl (mp->mt_next_hop_via_label);
- if ((MPLS_LABEL_INVALID != next_hop_via_label) && (0 != next_hop_via_label))
- {
- rpath.frp_proto = DPO_PROTO_MPLS;
- rpath.frp_local_label = next_hop_via_label;
- rpath.frp_eos = MPLS_NON_EOS;
- }
+ rv = fib_api_path_decode (&mp->mt_tunnel.mt_paths[ii], rpath);
- if (rpath.frp_sw_if_index == ~0)
- { /* recursive path, set fib index */
- rpath.frp_fib_index =
- fib_table_find (dpo_proto_to_fib (rpath.frp_proto),
- ntohl (mp->mt_next_hop_table_id));
- if (rpath.frp_fib_index == ~0)
- {
- rv = VNET_API_ERROR_NO_SUCH_FIB;
- goto out;
- }
+ if (0 != rv)
+ goto out;
}
-
- if (mp->mt_is_add)
- {
- for (ii = 0; ii < mp->mt_next_hop_n_out_labels; ii++)
- {
- fib_mpls_label_t fml = {
- .fml_value = ntohl (mp->mt_next_hop_out_label_stack[ii].label),
- .fml_ttl = mp->mt_next_hop_out_label_stack[ii].ttl,
- .fml_exp = mp->mt_next_hop_out_label_stack[ii].exp,
- .fml_mode = (mp->mt_next_hop_out_label_stack[ii].is_uniform ?
- FIB_MPLS_LSP_MODE_UNIFORM : FIB_MPLS_LSP_MODE_PIPE),
- };
- vec_add1 (rpath.frp_label_stack, fml);
- }
- }
-
- vec_add1 (rpaths, rpath);
-
- tunnel_sw_if_index = ntohl (mp->mt_sw_if_index);
+ tunnel_sw_if_index = ntohl (mp->mt_tunnel.mt_sw_if_index);
if (mp->mt_is_add)
{
if (~0 == tunnel_sw_if_index)
- tunnel_sw_if_index = vnet_mpls_tunnel_create (mp->mt_l2_only,
- mp->mt_is_multicast);
+ tunnel_sw_if_index =
+ vnet_mpls_tunnel_create (mp->mt_tunnel.mt_l2_only,
+ mp->mt_tunnel.mt_is_multicast);
vnet_mpls_tunnel_path_add (tunnel_sw_if_index, rpaths);
tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
@@ -382,7 +291,7 @@ vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
else
{
tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
- tunnel_sw_if_index = ntohl (mp->mt_sw_if_index);
+ tunnel_sw_if_index = ntohl (mp->mt_tunnel.mt_sw_if_index);
if (!vnet_mpls_tunnel_path_remove (tunnel_sw_if_index, rpaths))
vnet_mpls_tunnel_del (tunnel_sw_if_index);
}
@@ -426,10 +335,13 @@ typedef struct mpls_tunnel_send_walk_ctx_t_
static void
send_mpls_tunnel_entry (u32 mti, void *arg)
{
- fib_route_path_encode_t *api_rpaths = NULL, *api_rpath;
mpls_tunnel_send_walk_ctx_t *ctx;
vl_api_mpls_tunnel_details_t *mp;
+ fib_path_encode_ctx_t path_ctx = {
+ .rpaths = NULL,
+ };
const mpls_tunnel_t *mt;
+ fib_route_path_t *rpath;
vl_api_fib_path_t *fp;
u32 n;
@@ -448,21 +360,25 @@ send_mpls_tunnel_entry (u32 mti, void *arg)
mp->_vl_msg_id = ntohs (VL_API_MPLS_TUNNEL_DETAILS);
mp->context = ctx->context;
- mp->mt_tunnel_index = ntohl (mti);
- mp->mt_sw_if_index = ntohl (mt->mt_sw_if_index);
- mp->mt_count = ntohl (n);
+ mp->mt_tunnel.mt_n_paths = ntohl (n);
+ mp->mt_tunnel.mt_sw_if_index = ntohl (mt->mt_sw_if_index);
+ mp->mt_tunnel.mt_tunnel_index = ntohl (mti);
+ mp->mt_tunnel.mt_l2_only = ! !(MPLS_TUNNEL_FLAG_L2 & mt->mt_flags);
+ mp->mt_tunnel.mt_is_multicast = ! !(MPLS_TUNNEL_FLAG_MCAST & mt->mt_flags);
fib_path_list_walk_w_ext (mt->mt_path_list,
- &mt->mt_path_exts, fib_path_encode, &api_rpaths);
+ &mt->mt_path_exts, fib_path_encode, &path_ctx);
- fp = mp->mt_paths;
- vec_foreach (api_rpath, api_rpaths)
+ fp = mp->mt_tunnel.mt_paths;
+ vec_foreach (rpath, path_ctx.rpaths)
{
- fib_api_path_encode (api_rpath, fp);
+ fib_api_path_encode (rpath, fp);
fp++;
}
vl_api_send_msg (ctx->reg, (u8 *) mp);
+
+ vec_free (path_ctx.rpaths);
}
static void
@@ -483,51 +399,95 @@ 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,
- vl_api_registration_t * reg,
- const fib_table_t * table,
- const fib_prefix_t * pfx,
- fib_route_path_encode_t * api_rpaths, u32 context)
+send_mpls_table_details (vpe_api_main_t * am,
+ vl_api_registration_t * reg,
+ u32 context, const fib_table_t * table)
+{
+ vl_api_mpls_table_details_t *mp;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_MPLS_TABLE_DETAILS);
+ mp->context = context;
+
+ mp->mt_table.mt_table_id = htonl (table->ft_table_id);
+ memcpy (mp->mt_table.mt_name,
+ table->ft_desc,
+ clib_min (vec_len (table->ft_desc), sizeof (mp->mt_table.mt_name)));
+
+ vl_api_send_msg (reg, (u8 *) mp);
+}
+
+static void
+vl_api_mpls_table_dump_t_handler (vl_api_mpls_table_dump_t * mp)
{
- vl_api_mpls_fib_details_t *mp;
- fib_route_path_encode_t *api_rpath;
+ vpe_api_main_t *am = &vpe_api_main;
+ vl_api_registration_t *reg;
+ mpls_main_t *mm = &mpls_main;
+ fib_table_t *fib_table;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ /* *INDENT-OFF* */
+ pool_foreach (fib_table, mm->fibs,
+ ({
+ send_mpls_table_details(am, reg, mp->context, fib_table);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void
+send_mpls_route_details (vpe_api_main_t * am,
+ vl_api_registration_t * reg,
+ u32 context, fib_node_index_t fib_entry_index)
+{
+ fib_route_path_t *rpaths, *rpath;
+ vl_api_mpls_route_details_t *mp;
+ const fib_prefix_t *pfx;
vl_api_fib_path_t *fp;
int path_count;
- path_count = vec_len (api_rpaths);
+ rpaths = fib_entry_encode (fib_entry_index);
+ pfx = fib_entry_get_prefix (fib_entry_index);
+
+ path_count = vec_len (rpaths);
mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
if (!mp)
return;
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_DETAILS);
+ mp->_vl_msg_id = ntohs (VL_API_MPLS_ROUTE_DETAILS);
mp->context = context;
- 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 = pfx->fp_eos;
- mp->label = htonl (pfx->fp_label);
+ mp->mr_route.mr_table_id =
+ htonl (fib_table_get_table_id
+ (fib_entry_get_fib_index (fib_entry_index), pfx->fp_proto));
+ mp->mr_route.mr_eos = pfx->fp_eos;
+ mp->mr_route.mr_eos_proto = pfx->fp_payload_proto;
+ mp->mr_route.mr_label = htonl (pfx->fp_label);
- mp->count = htonl (path_count);
- fp = mp->path;
- vec_foreach (api_rpath, api_rpaths)
+ mp->mr_route.mr_n_paths = path_count;
+ fp = mp->mr_route.mr_paths;
+ vec_foreach (rpath, rpaths)
{
- fib_api_path_encode (api_rpath, fp);
+ fib_api_path_encode (rpath, fp);
fp++;
}
+ vec_free (rpaths);
vl_api_send_msg (reg, (u8 *) mp);
}
-typedef struct vl_api_mpls_fib_dump_table_walk_ctx_t_
+typedef struct vl_api_mpls_route_dump_table_walk_ctx_t_
{
fib_node_index_t *lfeis;
-} vl_api_mpls_fib_dump_table_walk_ctx_t;
+} vl_api_mpls_route_dump_table_walk_ctx_t;
static fib_table_walk_rc_t
-vl_api_mpls_fib_dump_table_walk (fib_node_index_t fei, void *arg)
+vl_api_mpls_route_dump_table_walk (fib_node_index_t fei, void *arg)
{
- vl_api_mpls_fib_dump_table_walk_ctx_t *ctx = arg;
+ vl_api_mpls_route_dump_table_walk_ctx_t *ctx = arg;
vec_add1 (ctx->lfeis, fei);
@@ -535,47 +495,37 @@ vl_api_mpls_fib_dump_table_walk (fib_node_index_t fei, void *arg)
}
static void
-vl_api_mpls_fib_dump_t_handler (vl_api_mpls_fib_dump_t * mp)
+vl_api_mpls_route_dump_t_handler (vl_api_mpls_route_dump_t * mp)
{
vpe_api_main_t *am = &vpe_api_main;
vl_api_registration_t *reg;
- mpls_main_t *mm = &mpls_main;
- fib_table_t *fib_table;
- mpls_fib_t *mpls_fib;
fib_node_index_t *lfeip = NULL;
- const fib_prefix_t *pfx;
- u32 fib_index;
- fib_route_path_encode_t *api_rpaths;
- vl_api_mpls_fib_dump_table_walk_ctx_t ctx = {
+ vl_api_mpls_route_dump_table_walk_ctx_t ctx = {
.lfeis = NULL,
};
+ u32 fib_index;
reg = vl_api_client_index_to_registration (mp->client_index);
if (!reg)
return;
- /* *INDENT-OFF* */
- pool_foreach (mpls_fib, mm->mpls_fibs,
- ({
- mpls_fib_table_walk (mpls_fib,
- vl_api_mpls_fib_dump_table_walk,
- &ctx);
- }));
- /* *INDENT-ON* */
- vec_sort_with_function (ctx.lfeis, fib_entry_cmp_for_sort);
+ fib_index = fib_table_find (FIB_PROTOCOL_MPLS,
+ ntohl (mp->table.mt_table_id));
- vec_foreach (lfeip, ctx.lfeis)
- {
- pfx = fib_entry_get_prefix (*lfeip);
- fib_index = fib_entry_get_fib_index (*lfeip);
- fib_table = fib_table_get (fib_index, pfx->fp_proto);
- api_rpaths = NULL;
- fib_entry_encode (*lfeip, &api_rpaths);
- send_mpls_fib_details (am, reg, fib_table, pfx, api_rpaths, mp->context);
- vec_free (api_rpaths);
- }
+ if (INDEX_INVALID != fib_index)
+ {
+ fib_table_walk (fib_index,
+ FIB_PROTOCOL_MPLS,
+ vl_api_mpls_route_dump_table_walk, &ctx);
+ vec_sort_with_function (ctx.lfeis, fib_entry_cmp_for_sort);
- vec_free (ctx.lfeis);
+ vec_foreach (lfeip, ctx.lfeis)
+ {
+ send_mpls_route_details (am, reg, mp->context, *lfeip);
+ }
+
+ vec_free (ctx.lfeis);
+ }
}
/*
diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c
index 8db08c3a387..b7bcbfd14f7 100644
--- a/src/vnet/mpls/mpls_tunnel.c
+++ b/src/vnet/mpls/mpls_tunnel.c
@@ -242,7 +242,7 @@ mpls_tunnel_stack (adj_index_t ai)
mt = mpls_tunnel_get_from_sw_if_index(sw_if_index);
- if (NULL == mt)
+ if (NULL == mt || FIB_NODE_INDEX_INVALID == mt->mt_path_list)
return;
if (FIB_NODE_INDEX_INVALID == mt->mt_path_list)
@@ -654,6 +654,7 @@ void
vnet_mpls_tunnel_path_add (u32 sw_if_index,
fib_route_path_t *rpaths)
{
+ fib_route_path_t *rpath;
mpls_tunnel_t *mt;
u32 mti;
@@ -695,10 +696,13 @@ vnet_mpls_tunnel_path_add (u32 sw_if_index,
*/
fib_path_ext_list_resolve(&mt->mt_path_exts, mt->mt_path_list);
}
- fib_path_ext_list_insert(&mt->mt_path_exts,
- mt->mt_path_list,
- FIB_PATH_EXT_MPLS,
- rpaths);
+ vec_foreach(rpath, rpaths)
+ {
+ fib_path_ext_list_insert(&mt->mt_path_exts,
+ mt->mt_path_list,
+ FIB_PATH_EXT_MPLS,
+ rpath);
+ }
mpls_tunnel_restack(mt);
}