aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/strategies
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/strategies')
-rw-r--r--hicn-plugin/src/strategies/dpo_mw.c34
-rw-r--r--hicn-plugin/src/strategies/dpo_mw.h19
-rw-r--r--hicn-plugin/src/strategies/dpo_rr.c36
-rw-r--r--hicn-plugin/src/strategies/dpo_rr.h20
-rw-r--r--hicn-plugin/src/strategies/strategy_mw_cli.c2
5 files changed, 51 insertions, 60 deletions
diff --git a/hicn-plugin/src/strategies/dpo_mw.c b/hicn-plugin/src/strategies/dpo_mw.c
index 12c77bce8..70ef7d7c9 100644
--- a/hicn-plugin/src/strategies/dpo_mw.c
+++ b/hicn-plugin/src/strategies/dpo_mw.c
@@ -34,7 +34,7 @@ static const hicn_dpo_vft_t hicn_dpo_mw_vft = {
};
int
-hicn_dpo_is_type_strategy_mw (const dpo_id_t * dpo)
+hicn_dpo_is_type_strategy_mw (const dpo_id_t *dpo)
{
return dpo->dpoi_type == hicn_dpo_type_mw;
}
@@ -45,10 +45,9 @@ hicn_dpo_strategy_mw_module_init (void)
/*
* Register our type of dpo
*/
- hicn_dpo_type_mw =
- hicn_dpo_register_new_type (hicn_nodes_strategy, &hicn_dpo_mw_vft,
- hicn_mw_strategy_get_vft (),
- &dpo_strategy_mw_ctx_vft);
+ hicn_dpo_type_mw = hicn_dpo_register_new_type (
+ hicn_nodes_strategy, &hicn_dpo_mw_vft, hicn_mw_strategy_get_vft (),
+ &dpo_strategy_mw_ctx_vft);
}
dpo_type_t
@@ -59,9 +58,8 @@ hicn_dpo_strategy_mw_get_type (void)
//////////////////////////////////////////////////////////////////////////////////////////////////
-
u8 *
-hicn_strategy_mw_format_ctx (u8 * s, int n, ...)
+hicn_strategy_mw_format_ctx (u8 *s, int n, ...)
{
va_list args;
va_start (args, n);
@@ -70,13 +68,14 @@ hicn_strategy_mw_format_ctx (u8 * s, int n, ...)
}
u8 *
-format_hicn_strategy_mw_ctx (u8 * s, va_list * ap)
+format_hicn_strategy_mw_ctx (u8 *s, va_list *ap)
{
int i = 0;
index_t index = va_arg (*ap, index_t);
hicn_dpo_ctx_t *dpo_ctx = NULL;
hicn_strategy_mw_ctx_t *mw_dpo_ctx = NULL;
- u32 indent = va_arg (*ap, u32);;
+ u32 indent = va_arg (*ap, u32);
+ ;
dpo_ctx = hicn_strategy_dpo_ctx_get (index);
if (dpo_ctx == NULL)
@@ -90,16 +89,13 @@ format_hicn_strategy_mw_ctx (u8 * s, va_list * ap)
u8 *buf = NULL;
if (i < dpo_ctx->entry_count)
buf = format (NULL, "FIB");
- else if (i >=
- HICN_PARAM_FIB_ENTRY_NHOPS_MAX - dpo_ctx->tfib_entry_count)
+ else if (i >= HICN_PARAM_FIB_ENTRY_NHOPS_MAX - dpo_ctx->tfib_entry_count)
buf = format (NULL, "TFIB");
else
continue;
s = format (s, "\n");
- s =
- format (s, "%U ", format_hicn_face, dpo_ctx->next_hops[i],
- indent);
+ s = format (s, "%U ", format_hicn_face, dpo_ctx->next_hops[i], indent);
s = format (s, "weight %u", mw_dpo_ctx->weight[i]);
s = format (s, " %s", buf);
}
@@ -108,8 +104,9 @@ format_hicn_strategy_mw_ctx (u8 * s, va_list * ap)
}
void
-hicn_strategy_mw_ctx_create (fib_protocol_t proto, const hicn_face_id_t * next_hop,
- int nh_len, index_t * dpo_idx)
+hicn_strategy_mw_ctx_create (fib_protocol_t proto,
+ const hicn_face_id_t *next_hop, int nh_len,
+ index_t *dpo_idx)
{
hicn_strategy_mw_ctx_t *hicn_strategy_mw_ctx;
hicn_dpo_ctx_t *hicn_strategy_ctx;
@@ -138,7 +135,7 @@ hicn_strategy_mw_ctx_add_nh (hicn_face_id_t nh, index_t dpo_idx)
hicn_strategy_dpo_ctx_add_nh (nh, hicn_strategy_dpo_ctx, &pos);
hicn_strategy_mw_ctx_t *hicn_strategy_mw_ctx =
- (hicn_strategy_mw_ctx_t *) & hicn_strategy_dpo_ctx->data;
+ (hicn_strategy_mw_ctx_t *) &hicn_strategy_dpo_ctx->data;
hicn_strategy_mw_ctx->weight[pos] = DEFAULT_WEIGHT;
return HICN_ERROR_NONE;
@@ -148,7 +145,8 @@ int
hicn_strategy_mw_ctx_del_nh (hicn_face_id_t face_id, index_t dpo_idx)
{
hicn_dpo_ctx_t *hicn_strategy_dpo_ctx = hicn_strategy_dpo_ctx_get (dpo_idx);
- //No need to flush the weights, they are initialized when a dpo_ctx is created;
+ // No need to flush the weights, they are initialized when a dpo_ctx is
+ // created;
return hicn_strategy_dpo_ctx_del_nh (face_id, hicn_strategy_dpo_ctx);
}
diff --git a/hicn-plugin/src/strategies/dpo_mw.h b/hicn-plugin/src/strategies/dpo_mw.h
index 433c415fb..1a174631a 100644
--- a/hicn-plugin/src/strategies/dpo_mw.h
+++ b/hicn-plugin/src/strategies/dpo_mw.h
@@ -42,7 +42,7 @@ typedef struct hicn_strategy_mw_ctx_s
*
* @result The string with the formatted dpo ctx
*/
-u8 *format_hicn_strategy_mw_ctx (u8 * s, va_list * ap);
+u8 *format_hicn_strategy_mw_ctx (u8 *s, va_list *ap);
const static dpo_vft_t dpo_strategy_mw_ctx_vft = {
.dv_lock = hicn_strategy_dpo_ctx_lock,
@@ -67,15 +67,15 @@ hicn_dpo_ctx_t *hicn_strategy_mw_ctx_get (index_t index);
* @param dpo_idx index_t that will hold the index of the created dpo ctx
* @return HICN_ERROR_NONE if the creation was fine, otherwise EINVAL
*/
-void
-hicn_strategy_mw_ctx_create (fib_protocol_t proto, const hicn_face_id_t * next_hop,
- int nh_len, index_t * dpo_idx);
+void hicn_strategy_mw_ctx_create (fib_protocol_t proto,
+ const hicn_face_id_t *next_hop, int nh_len,
+ index_t *dpo_idx);
/**
* @brief Add or update a next hop in the dpo ctx.
*
- * This function is meant to be used in the control plane and not in the data plane,
- * as it is not optimized for the latter.
+ * This function is meant to be used in the control plane and not in the data
+ * plane, as it is not optimized for the latter.
*
* @param nh Next hop to insert in the dpo ctx
* @param dpo_idx Index of the dpo ctx to update with the new or updated next
@@ -108,7 +108,7 @@ void hicn_strategy_mw_ctx_prefetch (index_t dpo_idx);
*
* @param dpo Dpo to check the type
*/
-int hicn_dpo_is_type_strategy_mw (const dpo_id_t * dpo);
+int hicn_dpo_is_type_strategy_mw (const dpo_id_t *dpo);
/**
* @brief Initialize the Maximum Weight strategy
@@ -126,7 +126,7 @@ dpo_type_t hicn_dpo_strategy_mw_get_type (void);
* @param s String to append the formatted dpo ctx
* @param ap List of arguments to format
*/
-u8 *format_hicn_dpo_strategy_mw (u8 * s, va_list * ap);
+u8 *format_hicn_dpo_strategy_mw (u8 *s, va_list *ap);
/**
* @brief Format the dpo ctx for the strategy Maximum Weight. To
@@ -135,8 +135,7 @@ u8 *format_hicn_dpo_strategy_mw (u8 * s, va_list * ap);
* @param s String to append the formatted dpo ctx
* @param ... List of arguments to format
*/
-u8 *hicn_strategy_mw_format_ctx (u8 * s, int n, ...);
-
+u8 *hicn_strategy_mw_format_ctx (u8 *s, int n, ...);
#endif // __HICN_DPO_MW_H__
diff --git a/hicn-plugin/src/strategies/dpo_rr.c b/hicn-plugin/src/strategies/dpo_rr.c
index adb7e1025..3fe506bd1 100644
--- a/hicn-plugin/src/strategies/dpo_rr.c
+++ b/hicn-plugin/src/strategies/dpo_rr.c
@@ -34,7 +34,7 @@ static const hicn_dpo_vft_t hicn_dpo_rr_vft = {
};
int
-hicn_dpo_is_type_strategy_rr (const dpo_id_t * dpo)
+hicn_dpo_is_type_strategy_rr (const dpo_id_t *dpo)
{
return dpo->dpoi_type == hicn_dpo_type_rr;
}
@@ -45,10 +45,9 @@ hicn_dpo_strategy_rr_module_init (void)
/*
* Register our type of dpo
*/
- hicn_dpo_type_rr =
- hicn_dpo_register_new_type (hicn_nodes_strategy, &hicn_dpo_rr_vft,
- hicn_rr_strategy_get_vft (),
- &dpo_strategy_rr_ctx_vft);
+ hicn_dpo_type_rr = hicn_dpo_register_new_type (
+ hicn_nodes_strategy, &hicn_dpo_rr_vft, hicn_rr_strategy_get_vft (),
+ &dpo_strategy_rr_ctx_vft);
}
dpo_type_t
@@ -59,9 +58,8 @@ hicn_dpo_strategy_rr_get_type (void)
//////////////////////////////////////////////////////////////////////////////////////////////////
-
u8 *
-hicn_strategy_rr_format_ctx (u8 * s, int n, ...)
+hicn_strategy_rr_format_ctx (u8 *s, int n, ...)
{
va_list args;
va_start (args, n);
@@ -70,7 +68,7 @@ hicn_strategy_rr_format_ctx (u8 * s, int n, ...)
}
u8 *
-format_hicn_strategy_rr_ctx (u8 * s, va_list * ap)
+format_hicn_strategy_rr_ctx (u8 *s, va_list *ap)
{
int i = 0;
index_t index = va_arg (*ap, index_t);
@@ -84,25 +82,21 @@ format_hicn_strategy_rr_ctx (u8 * s, va_list * ap)
rr_dpo_ctx = (hicn_strategy_rr_ctx_t *) dpo_ctx->data;
- s =
- format (s, "hicn-rr, next hop Face %d",
- dpo_ctx->next_hops[rr_dpo_ctx->current_nhop]);
+ s = format (s, "hicn-rr, next hop Face %d",
+ dpo_ctx->next_hops[rr_dpo_ctx->current_nhop]);
for (i = 0; i < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; i++)
{
u8 *buf = NULL;
if (i < dpo_ctx->entry_count)
buf = format (NULL, "FIB");
- else if (i >=
- HICN_PARAM_FIB_ENTRY_NHOPS_MAX - dpo_ctx->tfib_entry_count)
+ else if (i >= HICN_PARAM_FIB_ENTRY_NHOPS_MAX - dpo_ctx->tfib_entry_count)
buf = format (NULL, "TFIB");
else
continue;
s = format (s, "\n");
- s =
- format (s, "%U ", format_hicn_face, dpo_ctx->next_hops[i],
- indent);
+ s = format (s, "%U ", format_hicn_face, dpo_ctx->next_hops[i], indent);
s = format (s, " %s", buf);
}
@@ -110,8 +104,9 @@ format_hicn_strategy_rr_ctx (u8 * s, va_list * ap)
}
void
-hicn_strategy_rr_ctx_create (fib_protocol_t proto, const hicn_face_id_t * next_hop,
- int nh_len, index_t * dpo_idx)
+hicn_strategy_rr_ctx_create (fib_protocol_t proto,
+ const hicn_face_id_t *next_hop, int nh_len,
+ index_t *dpo_idx)
{
hicn_strategy_rr_ctx_t *hicn_strategy_rr_ctx;
hicn_dpo_ctx_t *hicn_strategy_ctx;
@@ -139,7 +134,7 @@ hicn_strategy_rr_ctx_add_nh (hicn_face_id_t nh, index_t dpo_idx)
}
hicn_strategy_dpo_ctx_add_nh (nh, hicn_strategy_dpo_ctx, &pos);
- //nothing else to initialize in this strategy
+ // nothing else to initialize in this strategy
return HICN_ERROR_NONE;
}
@@ -147,7 +142,8 @@ int
hicn_strategy_rr_ctx_del_nh (hicn_face_id_t face_id, index_t dpo_idx)
{
hicn_dpo_ctx_t *hicn_strategy_dpo_ctx = hicn_strategy_dpo_ctx_get (dpo_idx);
- //No need to change the current_nhop. It will be updated at the next selection.
+ // No need to change the current_nhop. It will be updated at the next
+ // selection.
return hicn_strategy_dpo_ctx_del_nh (face_id, hicn_strategy_dpo_ctx);
}
diff --git a/hicn-plugin/src/strategies/dpo_rr.h b/hicn-plugin/src/strategies/dpo_rr.h
index e4e5b5372..e68e2917d 100644
--- a/hicn-plugin/src/strategies/dpo_rr.h
+++ b/hicn-plugin/src/strategies/dpo_rr.h
@@ -27,7 +27,6 @@
* round robin.
*/
-
/**
* Context for the Round Robin strategy
*/
@@ -45,7 +44,7 @@ typedef struct hicn_strategy_rr_ctx_s
*
* @result The string with the formatted dpo ctx
*/
-u8 *format_hicn_strategy_rr_ctx (u8 * s, va_list * ap);
+u8 *format_hicn_strategy_rr_ctx (u8 *s, va_list *ap);
const static dpo_vft_t dpo_strategy_rr_ctx_vft = {
.dv_lock = hicn_strategy_dpo_ctx_lock,
@@ -70,15 +69,15 @@ hicn_dpo_ctx_t *hicn_strategy_rr_ctx_get (index_t index);
* @param dpo_idx index_t that will hold the index of the created dpo ctx
* @return HICN_ERROR_NONE if the creation was fine, otherwise EINVAL
*/
-void
-hicn_strategy_rr_ctx_create (fib_protocol_t proto, const hicn_face_id_t * next_hop,
- int nh_len, index_t * dpo_idx);
+void hicn_strategy_rr_ctx_create (fib_protocol_t proto,
+ const hicn_face_id_t *next_hop, int nh_len,
+ index_t *dpo_idx);
/**
* @brief Add or update a next hop in the dpo ctx.
*
- * This function is meant to be used in the control plane and not in the data plane,
- * as it is not optimized for the latter.
+ * This function is meant to be used in the control plane and not in the data
+ * plane, as it is not optimized for the latter.
*
* @param nh Next hop to insert in the dpo ctx
* @param dpo_idx Index of the dpo ctx to update with the new or updated next
@@ -111,7 +110,7 @@ void hicn_strategy_rr_ctx_prefetch (index_t dpo_idx);
*
* @param dpo Dpo to check the type
*/
-int hicn_dpo_is_type_strategy_rr (const dpo_id_t * dpo);
+int hicn_dpo_is_type_strategy_rr (const dpo_id_t *dpo);
/**
* @brief Initialize the Round Robin strategy
@@ -129,7 +128,7 @@ dpo_type_t hicn_dpo_strategy_rr_get_type (void);
* @param s String to append the formatted dpo ctx
* @param ap List of arguments to format
*/
-u8 *format_hicn_dpo_strategy_rr (u8 * s, va_list * ap);
+u8 *format_hicn_dpo_strategy_rr (u8 *s, va_list *ap);
/**
* @brief Format the dpo ctx for the strategy Round Robin. To
@@ -138,8 +137,7 @@ u8 *format_hicn_dpo_strategy_rr (u8 * s, va_list * ap);
* @param s String to append the formatted dpo ctx
* @param ... List of arguments to format
*/
-u8 *hicn_strategy_rr_format_ctx (u8 * s, int n, ...);
-
+u8 *hicn_strategy_rr_format_ctx (u8 *s, int n, ...);
#endif // __HICN_DPO_RR_H__
diff --git a/hicn-plugin/src/strategies/strategy_mw_cli.c b/hicn-plugin/src/strategies/strategy_mw_cli.c
index 473ff0e19..6b56e9fd5 100644
--- a/hicn-plugin/src/strategies/strategy_mw_cli.c
+++ b/hicn-plugin/src/strategies/strategy_mw_cli.c
@@ -76,7 +76,7 @@ hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t *vm,
}
prefix.fp_proto = ip46_address_is_ip4 (&prefix.fp_addr) ? FIB_PROTOCOL_IP4 :
- FIB_PROTOCOL_IP6;
+ FIB_PROTOCOL_IP6;
ret = hicn_route_get_dpo (&prefix, &hicn_dpo_id, &fib_index);
if (ret == HICN_ERROR_NONE)