summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/hicn_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/hicn_api.c')
-rw-r--r--hicn-plugin/src/hicn_api.c118
1 files changed, 53 insertions, 65 deletions
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index 7db6cca79..9bca748e6 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -112,20 +112,10 @@ vl_api_hicn_api_node_params_set_t_handler (vl_api_hicn_api_node_params_set_t *
pit_max_size =
pit_max_size == -1 ? HICN_PARAM_PIT_ENTRIES_DFLT : pit_max_size;
- f64 pit_dflt_lifetime_sec = mp->pit_dflt_lifetime_sec;
- pit_dflt_lifetime_sec =
- pit_dflt_lifetime_sec ==
- -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_DFLT_MS : pit_dflt_lifetime_sec;
-
- f64 pit_min_lifetime_sec = mp->pit_min_lifetime_sec;
- pit_min_lifetime_sec =
- pit_min_lifetime_sec ==
- -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_MIN_MS : pit_min_lifetime_sec;
-
f64 pit_max_lifetime_sec = mp->pit_max_lifetime_sec;
pit_max_lifetime_sec =
pit_max_lifetime_sec ==
- -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_MAX_MS : pit_max_lifetime_sec;
+ -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_MAX_MS / SEC_MS : pit_max_lifetime_sec;
int cs_max_size = clib_net_to_host_i32 (mp->cs_max_size);
cs_max_size = cs_max_size == -1 ? HICN_PARAM_CS_ENTRIES_DFLT : cs_max_size;
@@ -136,8 +126,6 @@ vl_api_hicn_api_node_params_set_t_handler (vl_api_hicn_api_node_params_set_t *
rv = hicn_infra_plugin_enable_disable ((int) (mp->enable_disable),
pit_max_size,
- pit_dflt_lifetime_sec,
- pit_min_lifetime_sec,
pit_max_lifetime_sec,
cs_max_size, cs_reserved_app);
@@ -159,8 +147,6 @@ vl_api_hicn_api_node_params_get_t_handler (vl_api_hicn_api_node_params_get_t *
rmp->is_enabled = sm->is_enabled;
rmp->feature_cs = HICN_FEATURE_CS;
rmp->pit_max_size = clib_host_to_net_u32 (hicn_infra_pit_size);
- rmp->pit_dflt_lifetime_sec = ((f64) sm->pit_lifetime_dflt_ms) / SEC_MS;
- rmp->pit_min_lifetime_sec = ((f64) sm->pit_lifetime_min_ms) / SEC_MS;
rmp->pit_max_lifetime_sec = ((f64) sm->pit_lifetime_max_ms) / SEC_MS;
rmp->cs_max_size = clib_host_to_net_u32 (hicn_infra_cs_size);
rmp->retval = clib_host_to_net_i32 (rv);
@@ -491,18 +477,17 @@ static void vl_api_hicn_api_route_get_t_handler
static void
send_route_details (vl_api_registration_t * reg,
- const fib_prefix_t *pfx, u32 context)
+ const fib_prefix_t * pfx, u32 context)
{
vl_api_hicn_api_routes_details_t *mp;
hicn_main_t *hm = &hicn_main;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id =
- htons (VL_API_HICN_API_ROUTES_DETAILS + hm->msg_id_base);
+ mp->_vl_msg_id = htons (VL_API_HICN_API_ROUTES_DETAILS + hm->msg_id_base);
mp->context = context;
- clib_memcpy(&mp->prefix, &pfx->fp_addr, sizeof(ip46_address_t));
+ clib_memcpy (&mp->prefix, &pfx->fp_addr, sizeof (ip46_address_t));
mp->len = pfx->fp_len;
mp->nfaces = 0;
@@ -511,21 +496,25 @@ send_route_details (vl_api_registration_t * reg,
hicn_dpo_ctx_t *hicn_dpo_ctx;
u32 fib_index;
- int rv = hicn_route_get_dpo (&pfx->fp_addr, pfx->fp_len, &hicn_dpo_id, &fib_index);
+ int rv =
+ hicn_route_get_dpo (&pfx->fp_addr, pfx->fp_len, &hicn_dpo_id, &fib_index);
if (rv == HICN_ERROR_NONE)
{
- hicn_dpo_vft = hicn_dpo_get_vft(hicn_dpo_id->dpoi_type);
- hicn_dpo_ctx = hicn_dpo_vft->hicn_dpo_get_ctx(hicn_dpo_id->dpoi_index);
+ hicn_dpo_vft = hicn_dpo_get_vft (hicn_dpo_id->dpoi_type);
+ hicn_dpo_ctx = hicn_dpo_vft->hicn_dpo_get_ctx (hicn_dpo_id->dpoi_index);
for (int i = 0; i < hicn_dpo_ctx->entry_count; i++)
- {
- if (dpo_id_is_valid(&hicn_dpo_ctx->next_hops[i]))
- {
- mp->faceids[i] = clib_host_to_net_u32(((dpo_id_t *) &hicn_dpo_ctx->next_hops[i])->dpoi_index);
- mp->nfaces++;
- }
- }
- mp->strategy_id = clib_host_to_net_u32(hicn_dpo_get_vft_id(hicn_dpo_id));
+ {
+ if (dpo_id_is_valid (&hicn_dpo_ctx->next_hops[i]))
+ {
+ mp->faceids[i] =
+ clib_host_to_net_u32 (((dpo_id_t *) & hicn_dpo_ctx->
+ next_hops[i])->dpoi_index);
+ mp->nfaces++;
+ }
+ }
+ mp->strategy_id =
+ clib_host_to_net_u32 (hicn_dpo_get_vft_id (hicn_dpo_id));
}
vl_api_send_msg (reg, (u8 *) mp);
@@ -537,41 +526,40 @@ typedef struct vl_api_hicn_api_route_dump_walk_ctx_t_
} vl_api_hicn_api_route_dump_walk_ctx_t;
static fib_table_walk_rc_t
-vl_api_hicn_api_route_dump_walk(fib_node_index_t fei, void *arg)
+vl_api_hicn_api_route_dump_walk (fib_node_index_t fei, void *arg)
{
vl_api_hicn_api_route_dump_walk_ctx_t *ctx = arg;
int found = 0;
const dpo_id_t *former_dpo_id;
/* Route already existing. We need to update the dpo. */
- const dpo_id_t * load_balance_dpo_id =
+ const dpo_id_t *load_balance_dpo_id =
fib_entry_contribute_ip_forwarding (fei);
/* The dpo is not a load balance dpo as expected */
if (load_balance_dpo_id->dpoi_type == DPO_LOAD_BALANCE)
{
/* former_dpo_id is a load_balance dpo */
- load_balance_t *lb =
- load_balance_get (load_balance_dpo_id->dpoi_index);
+ load_balance_t *lb = load_balance_get (load_balance_dpo_id->dpoi_index);
/* FIB entry exists but there is no hicn dpo. */
for (int i = 0; i < lb->lb_n_buckets && !found; i++)
- {
- former_dpo_id = load_balance_get_bucket_i (lb, i);
-
- if (dpo_is_hicn (former_dpo_id))
- {
- vec_add1 (ctx->feis, fei);
- }
- }
+ {
+ former_dpo_id = load_balance_get_bucket_i (lb, i);
+
+ if (dpo_is_hicn (former_dpo_id))
+ {
+ vec_add1 (ctx->feis, fei);
+ }
+ }
}
return (FIB_TABLE_WALK_CONTINUE);
}
static void
-vl_api_hicn_api_routes_dump_t_handler
-(vl_api_hicn_api_face_stats_dump_t * mp)
+ vl_api_hicn_api_routes_dump_t_handler
+ (vl_api_hicn_api_face_stats_dump_t * mp)
{
vl_api_registration_t *reg;
fib_table_t *fib_table;
@@ -580,34 +568,34 @@ vl_api_hicn_api_routes_dump_t_handler
fib_node_index_t *lfeip;
const fib_prefix_t *pfx;
vl_api_hicn_api_route_dump_walk_ctx_t ctx = {
- .feis = NULL,
+ .feis = NULL,
};
reg = vl_api_client_index_to_registration (mp->client_index);
if (!reg)
return;
- pool_foreach (fib_table, im->fibs,
- ({
- fib_table_walk(fib_table->ft_index,
- FIB_PROTOCOL_IP4,
- vl_api_hicn_api_route_dump_walk,
- &ctx);
- }));
-
- pool_foreach (fib_table, im6->fibs,
- ({
- fib_table_walk(fib_table->ft_index,
- FIB_PROTOCOL_IP6,
- vl_api_hicn_api_route_dump_walk,
- &ctx);
- }));
+ pool_foreach (fib_table, im->fibs, (
+ {
+ fib_table_walk (fib_table->ft_index,
+ FIB_PROTOCOL_IP4,
+ vl_api_hicn_api_route_dump_walk,
+ &ctx);}
+ ));
+
+ pool_foreach (fib_table, im6->fibs, (
+ {
+ fib_table_walk (fib_table->ft_index,
+ FIB_PROTOCOL_IP6,
+ vl_api_hicn_api_route_dump_walk,
+ &ctx);}
+ ));
vec_foreach (lfeip, ctx.feis)
- {
- pfx = fib_entry_get_prefix (*lfeip);
- send_route_details (reg, pfx, mp->context);
- }
+ {
+ pfx = fib_entry_get_prefix (*lfeip);
+ send_route_details (reg, pfx, mp->context);
+ }
vec_free (ctx.feis);
@@ -842,7 +830,7 @@ hicn_face_api_entry_params_serialize (hicn_face_id_t faceid,
clib_host_to_net_u64 (face_ip->remote_addr.as_u64[1]);
reply->swif = clib_host_to_net_u32 (face->shared.sw_if);
reply->flags = clib_host_to_net_u32 (face->shared.flags);
- reply->faceid = clib_host_to_net_u32(faceid);
+ reply->faceid = clib_host_to_net_u32 (faceid);
}
else
rv = HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;