summaryrefslogtreecommitdiffstats
path: root/src/vnet/bier
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/bier')
-rw-r--r--src/vnet/bier/bier.api21
-rw-r--r--src/vnet/bier/bier_api.c64
-rw-r--r--src/vnet/bier/bier_entry.c2
-rw-r--r--src/vnet/bier/bier_fmask.c12
-rw-r--r--src/vnet/bier/bier_fmask.h2
-rw-r--r--src/vnet/bier/bier_table.c9
6 files changed, 63 insertions, 47 deletions
diff --git a/src/vnet/bier/bier.api b/src/vnet/bier/bier.api
index b5ac8cabd39..0cc56cab50a 100644
--- a/src/vnet/bier/bier.api
+++ b/src/vnet/bier/bier.api
@@ -1,3 +1,4 @@
+/* Hey Emacs use -*- mode: C -*- */
/*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +19,7 @@
This file defines vpp BIER control-plane API messages which are generally
called through a shared memory interface.
*/
-option version = "1.1.0";
+option version = "1.2.0";
import "vnet/fib/fib_types.api";
/** \brief BIER Table Identifier
@@ -77,16 +78,21 @@ define bier_table_details
@param br_n_paths - The number of paths
@param br_paths - The array of paths
*/
+typedef bier_route
+{
+ u32 br_bp;
+ vl_api_bier_table_id_t br_tbl_id;
+ u8 br_n_paths;
+ vl_api_fib_path_t br_paths[br_n_paths];
+};
+
autoreply define bier_route_add_del
{
u32 client_index;
u32 context;
- u32 br_bp;
u8 br_is_add;
u8 br_is_replace;
- vl_api_bier_table_id_t br_tbl_id;
- u8 br_n_paths;
- vl_api_fib_path_t br_paths[br_n_paths];
+ vl_api_bier_route_t br_route;
};
define bier_route_dump
@@ -99,10 +105,7 @@ define bier_route_dump
define bier_route_details
{
u32 context;
- u16 br_bp;
- vl_api_bier_table_id_t br_tbl_id;
- u32 br_n_paths;
- vl_api_fib_path_t br_paths[br_n_paths];
+ vl_api_bier_route_t br_route;
};
/** \brief BIER Imposition Add
diff --git a/src/vnet/bier/bier_api.c b/src/vnet/bier/bier_api.c
index d8248b1b2bd..66f6b422810 100644
--- a/src/vnet/bier/bier_api.c
+++ b/src/vnet/bier/bier_api.c
@@ -169,10 +169,10 @@ vl_api_bier_route_add_del_t_handler (vl_api_bier_route_add_del_t * mp)
vnm = vnet_get_main ();
vnm->api_errno = 0;
- bp = ntohl(mp->br_bp);
+ bp = ntohl(mp->br_route.br_bp);
brpaths = NULL;
- if (mp->br_tbl_id.bt_hdr_len_id >= BIER_HDR_LEN_2048)
+ if (mp->br_route.br_tbl_id.bt_hdr_len_id >= BIER_HDR_LEN_2048)
{
rv = VNET_API_ERROR_BIER_BSL_UNSUP;
goto done;
@@ -184,19 +184,19 @@ vl_api_bier_route_add_del_t_handler (vl_api_bier_route_add_del_t * mp)
}
bier_table_id_t bti = {
- .bti_set = mp->br_tbl_id.bt_set,
- .bti_sub_domain = mp->br_tbl_id.bt_sub_domain,
- .bti_hdr_len = mp->br_tbl_id.bt_hdr_len_id,
+ .bti_set = mp->br_route.br_tbl_id.bt_set,
+ .bti_sub_domain = mp->br_route.br_tbl_id.bt_sub_domain,
+ .bti_hdr_len = mp->br_route.br_tbl_id.bt_hdr_len_id,
.bti_type = BIER_TABLE_MPLS_SPF,
.bti_ecmp = BIER_ECMP_TABLE_ID_MAIN,
};
- vec_validate(brpaths, mp->br_n_paths - 1);
+ vec_validate(brpaths, mp->br_route.br_n_paths - 1);
vec_foreach_index(ii, brpaths)
{
brpath = &brpaths[ii];
- rv = fib_path_api_parse(&mp->br_paths[ii], brpath);
+ rv = fib_api_path_decode(&mp->br_route.br_paths[ii], brpath);
if (0 != rv)
{
@@ -242,9 +242,12 @@ send_bier_route_details (const bier_table_t *bt,
const bier_entry_t *be,
void *args)
{
- fib_route_path_encode_t *api_rpaths = NULL, *api_rpath;
bier_route_details_walk_t *ctx = args;
vl_api_bier_route_details_t *mp;
+ fib_path_encode_ctx_t path_ctx = {
+ .rpaths = NULL,
+ };
+ fib_route_path_t *rpath;
vl_api_fib_path_t *fp;
u32 n_paths, m_size;
@@ -258,24 +261,25 @@ send_bier_route_details (const bier_table_t *bt,
mp->_vl_msg_id = ntohs(VL_API_BIER_ROUTE_DETAILS);
mp->context = ctx->context;
- mp->br_tbl_id.bt_set = bt->bt_id.bti_set;
- mp->br_tbl_id.bt_sub_domain = bt->bt_id.bti_sub_domain;
- mp->br_tbl_id.bt_hdr_len_id = bt->bt_id.bti_hdr_len;
- mp->br_bp = htons(be->be_bp);
- mp->br_n_paths = htonl(n_paths);
+ mp->br_route.br_tbl_id.bt_set = bt->bt_id.bti_set;
+ mp->br_route.br_tbl_id.bt_sub_domain = bt->bt_id.bti_sub_domain;
+ mp->br_route.br_tbl_id.bt_hdr_len_id = bt->bt_id.bti_hdr_len;
+ mp->br_route.br_bp = htonl(be->be_bp);
+ mp->br_route.br_n_paths = htonl(n_paths);
fib_path_list_walk_w_ext(be->be_path_list,
NULL,
fib_path_encode,
- &api_rpaths);
+ &path_ctx);
- fp = mp->br_paths;
- vec_foreach (api_rpath, api_rpaths)
+ fp = mp->br_route.br_paths;
+ vec_foreach (rpath, path_ctx.rpaths)
{
- fib_api_path_encode(api_rpath, fp);
+ fib_api_path_encode(rpath, fp);
fp++;
}
+ vec_free(path_ctx.rpaths);
vl_api_send_msg (ctx->reg, (u8 *) mp);
}
@@ -506,16 +510,16 @@ vl_api_bier_disp_entry_add_del_t_handler (vl_api_bier_disp_entry_add_del_t * mp)
brp->frp_rpf_id = ntohl(mp->bde_paths[ii].rpf_id);
}
- if (0 == mp->bde_paths[ii].afi)
+ if (FIB_API_PATH_NH_PROTO_IP4 == mp->bde_paths[ii].proto)
{
- clib_memcpy_fast (&brp->frp_addr.ip4,
- mp->bde_paths[ii].next_hop,
+ clib_memcpy (&brp->frp_addr.ip4,
+ &mp->bde_paths[ii].nh.address.ip4,
sizeof (brp->frp_addr.ip4));
}
- else
+ else if (FIB_API_PATH_NH_PROTO_IP6 == mp->bde_paths[ii].proto)
{
- clib_memcpy_fast (&brp->frp_addr.ip6,
- mp->bde_paths[ii].next_hop,
+ clib_memcpy (&brp->frp_addr.ip6,
+ &mp->bde_paths[ii].nh.address.ip6,
sizeof (brp->frp_addr.ip6));
}
if (ip46_address_is_zero(&brp->frp_addr))
@@ -601,7 +605,6 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt,
u16 bp,
void *args)
{
- fib_route_path_encode_t *api_rpaths = NULL, *api_rpath;
bier_disp_entry_details_walk_t *ctx = args;
vl_api_bier_disp_entry_details_t *mp;
bier_hdr_proto_id_t pproto;
@@ -611,8 +614,14 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt,
FOR_EACH_BIER_HDR_PROTO(pproto)
{
fib_node_index_t pl = bde->bde_pl[pproto];
+
if (INDEX_INVALID != pl)
{
+ fib_path_encode_ctx_t path_ctx = {
+ .rpaths = NULL,
+ };
+ fib_route_path_t *rpath;
+
n_paths = fib_path_list_get_n_paths(pl);
m_size = sizeof(*mp) + (n_paths * sizeof(vl_api_fib_path_t));
mp = vl_msg_api_alloc(m_size);
@@ -631,16 +640,17 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt,
fib_path_list_walk_w_ext(pl,
NULL,
fib_path_encode,
- &api_rpaths);
+ &path_ctx);
fp = mp->bde_paths;
- vec_foreach (api_rpath, api_rpaths)
+ 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);
}
}
}
diff --git a/src/vnet/bier/bier_entry.c b/src/vnet/bier/bier_entry.c
index 77d96b80782..e8bf722d88f 100644
--- a/src/vnet/bier/bier_entry.c
+++ b/src/vnet/bier/bier_entry.c
@@ -147,7 +147,7 @@ bier_entry_delete (index_t bei)
be = bier_entry_get(bei);
/*
- * if we still ahve a path-list, unlink from it
+ * if we still have a path-list, unlink from it
*/
if (FIB_NODE_INDEX_INVALID != be->be_path_list)
{
diff --git a/src/vnet/bier/bier_fmask.c b/src/vnet/bier/bier_fmask.c
index b6169d3c4bb..a58a77ff281 100644
--- a/src/vnet/bier/bier_fmask.c
+++ b/src/vnet/bier/bier_fmask.c
@@ -404,7 +404,7 @@ bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes)
void
bier_fmask_encode (index_t bfmi,
bier_table_id_t *btid,
- fib_route_path_encode_t *rpath)
+ fib_route_path_t *rpath)
{
bier_fmask_t *bfm;
@@ -413,17 +413,17 @@ bier_fmask_encode (index_t bfmi,
clib_memset(rpath, 0, sizeof(*rpath));
- rpath->rpath.frp_sw_if_index = ~0;
+ rpath->frp_sw_if_index = ~0;
switch (bfm->bfm_id->bfmi_nh_type)
{
case BIER_NH_UDP:
- rpath->rpath.frp_flags = FIB_ROUTE_PATH_UDP_ENCAP;
- rpath->rpath.frp_udp_encap_id = bfm->bfm_id->bfmi_id;
+ rpath->frp_flags = FIB_ROUTE_PATH_UDP_ENCAP;
+ rpath->frp_udp_encap_id = bfm->bfm_id->bfmi_id;
break;
case BIER_NH_IP:
- memcpy(&rpath->rpath.frp_addr, &bfm->bfm_id->bfmi_nh,
- sizeof(rpath->rpath.frp_addr));
+ memcpy(&rpath->frp_addr, &bfm->bfm_id->bfmi_nh,
+ sizeof(rpath->frp_addr));
break;
}
}
diff --git a/src/vnet/bier/bier_fmask.h b/src/vnet/bier/bier_fmask.h
index e522b0350e7..87845bb031b 100644
--- a/src/vnet/bier/bier_fmask.h
+++ b/src/vnet/bier/bier_fmask.h
@@ -166,7 +166,7 @@ extern void bier_fmask_child_remove (fib_node_index_t fib_entry_index,
extern void bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes);
extern void bier_fmask_encode (index_t bfmi,
bier_table_id_t *btid,
- fib_route_path_encode_t *rpath);
+ fib_route_path_t *rpath);
/*
* provided for fast data-path access
diff --git a/src/vnet/bier/bier_table.c b/src/vnet/bier/bier_table.c
index a9f8a6d338f..0e8cc1e88b4 100644
--- a/src/vnet/bier/bier_table.c
+++ b/src/vnet/bier/bier_table.c
@@ -779,9 +779,12 @@ bier_table_ecmp_walk (index_t bti,
bt = bier_table_get(bti);
- fib_path_list_walk(bt->bt_pl,
- bier_table_ecmp_walk_path_list,
- &ewc);
+ if (FIB_NODE_INDEX_INVALID != bt->bt_pl)
+ {
+ fib_path_list_walk(bt->bt_pl,
+ bier_table_ecmp_walk_path_list,
+ &ewc);
+ }
}
void