aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces/app
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2021-02-10 16:34:47 +0100
committerMauro Sardara <msardara@cisco.com>2021-02-10 16:15:16 +0000
commitb3b64c5a0529bbbbdcaf14f72fb47667bb457e9d (patch)
treecf19fa3d491229ddfd34848c3ac1ee8331404b6e /hicn-plugin/src/faces/app
parent71a5c399d8064e2aa97a047e23174bb784eea399 (diff)
[HICN-682] Fix hicn-plugin to be compatible with version 21.01
Signed-off-by: Mauro Sardara <msardara@cisco.com> Change-Id: Ia116ad74ce78e2ca2d7ee624eea75a38936d27f8 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'hicn-plugin/src/faces/app')
-rw-r--r--hicn-plugin/src/faces/app/face_prod.c216
1 files changed, 99 insertions, 117 deletions
diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c
index 645154325..16b6e6158 100644
--- a/hicn-plugin/src/faces/app/face_prod.c
+++ b/hicn-plugin/src/faces/app/face_prod.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -30,28 +30,23 @@ hicn_face_prod_state_t *face_state_vec;
u32 *face_state_pool;
static int
-hicn_app_state_create (u32 swif, fib_prefix_t * prefix)
+hicn_app_state_create (u32 swif, fib_prefix_t *prefix)
{
/* Make sure that the pool is not empty */
pool_validate_index (face_state_pool, 0);
u32 *swif_app;
u8 found = 0;
- /* *INDENT-OFF* */
- pool_foreach (swif_app, face_state_pool,{
- if (*swif_app == swif)
- {
- found = 1;
- }
- }
- );
- /* *INDENT-ON* */
+ pool_foreach (swif_app, face_state_pool)
+ if (*swif_app == swif)
+ {
+ found = 1;
+ }
if (found)
return HICN_ERROR_APPFACE_ALREADY_ENABLED;
-
/* Create the appif and store in the vector */
vec_validate (face_state_vec, swif);
clib_memcpy (&(face_state_vec[swif].prefix), prefix, sizeof (fib_prefix_t));
@@ -63,15 +58,13 @@ hicn_app_state_create (u32 swif, fib_prefix_t * prefix)
int ret = HICN_ERROR_NONE;
if (ip46_address_is_ip4 (&(prefix->fp_addr)))
{
- ret =
- vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
- swif, 1, 0, 0);
+ ret = vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
+ swif, 1, 0, 0);
}
else
{
- ret =
- vnet_feature_enable_disable ("ip6-unicast", "hicn-face-prod-input",
- swif, 1, 0, 0);
+ ret = vnet_feature_enable_disable ("ip6-unicast", "hicn-face-prod-input",
+ swif, 1, 0, 0);
}
return ret == 0 ? HICN_ERROR_NONE : HICN_ERROR_APPFACE_FEATURE;
@@ -87,16 +80,12 @@ hicn_app_state_del (u32 swif)
u32 *swif_app = NULL;
u8 found = 0;
fib_prefix_t *prefix;
- /* *INDENT-OFF* */
- pool_foreach (temp, face_state_pool,{
- if (*temp == swif)
- {
- found = 1;
- swif_app = temp;
- }
- }
- );
- /* *INDENT-ON* */
+ pool_foreach (temp, face_state_pool)
+ if (*temp == swif)
+ {
+ found = 1;
+ swif_app = temp;
+ }
if (!found)
return HICN_ERROR_APPFACE_NOT_FOUND;
@@ -106,15 +95,13 @@ hicn_app_state_del (u32 swif)
int ret = HICN_ERROR_NONE;
if (ip46_address_is_ip4 (&prefix->fp_addr))
{
- ret =
- vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
- swif, 0, 0, 0);
+ ret = vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
+ swif, 0, 0, 0);
}
else
{
- ret =
- vnet_feature_enable_disable ("ip6-unicast", "hicn-face-prod-input",
- swif, 0, 0, 0);
+ ret = vnet_feature_enable_disable ("ip6-unicast", "hicn-face-prod-input",
+ swif, 0, 0, 0);
}
pool_put (face_state_pool, swif_app);
@@ -124,8 +111,8 @@ hicn_app_state_del (u32 swif)
}
int
-hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
- ip46_address_t * prod_addr, hicn_face_id_t * faceid)
+hicn_face_prod_add (fib_prefix_t *prefix, u32 sw_if, u32 *cs_reserved,
+ ip46_address_t *prod_addr, hicn_face_id_t *faceid)
{
vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
@@ -133,7 +120,7 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
hicn_main_t *hm = &hicn_main;
ip46_address_t local_app_ip;
- CLIB_UNUSED(ip46_address_t remote_app_ip);
+ CLIB_UNUSED (ip46_address_t remote_app_ip);
u32 if_flags = 0;
if (!hm->is_enabled)
@@ -162,15 +149,17 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
return HICN_ERROR_APPFACE_PROD_PREFIX_NULL;
}
- u8 isv6 = ip46_address_is_ip4(prod_addr);
- index_t adj_index = adj_nbr_find(isv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4, isv6 ? VNET_LINK_IP6 : VNET_LINK_IP4, prod_addr, sw_if);
+ u8 isv6 = ip46_address_is_ip4 (prod_addr);
+ index_t adj_index =
+ adj_nbr_find (isv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4,
+ isv6 ? VNET_LINK_IP6 : VNET_LINK_IP4, prod_addr, sw_if);
/*
* Check if a producer face is already existing for the same prefix
* and sw_if
*/
- face = hicn_face_get (&(prefix->fp_addr), sw_if,
- &hicn_face_hashtb, adj_index);
+ face =
+ hicn_face_get (&(prefix->fp_addr), sw_if, &hicn_face_hashtb, adj_index);
if (face != NULL)
{
@@ -207,13 +196,13 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
ip4_address_t local_app_ip4;
ip4_address_t remote_app_ip4;
get_two_ip4_addresses (&local_app_ip4, &remote_app_ip4);
- ip4_add_del_interface_address (vm,
- sw_if,
- &local_app_ip4, 31, 0 /* is_del */ );
- local_app_ip = to_ip46 ( /* isv6 */ 0, local_app_ip4.as_u8);
- remote_app_ip = to_ip46 ( /* isv6 */ 0, remote_app_ip4.as_u8);
+ ip4_add_del_interface_address (vm, sw_if, &local_app_ip4, 31,
+ 0 /* is_del */);
+ local_app_ip = to_ip46 (/* isv6 */ 0, local_app_ip4.as_u8);
+ remote_app_ip = to_ip46 (/* isv6 */ 0, remote_app_ip4.as_u8);
- vnet_build_rewrite_for_sw_interface(vnm, sw_if, VNET_LINK_IP4, &remote_app_ip4);
+ vnet_build_rewrite_for_sw_interface (vnm, sw_if, VNET_LINK_IP4,
+ &remote_app_ip4);
}
else
{
@@ -225,74 +214,75 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
vlib_cli_output (vm, "Setting ip address %s\n", s0);
- ip6_add_del_interface_address (vm,
- sw_if,
- &local_app_ip6, 127,
- 0 /* is_del */ );
- local_app_ip = to_ip46 ( /* isv6 */ 1, local_app_ip6.as_u8);
- remote_app_ip = to_ip46 ( /* isv6 */ 1, remote_app_ip6.as_u8);
+ ip6_add_del_interface_address (vm, sw_if, &local_app_ip6, 127,
+ 0 /* is_del */);
+ local_app_ip = to_ip46 (/* isv6 */ 1, local_app_ip6.as_u8);
+ remote_app_ip = to_ip46 (/* isv6 */ 1, remote_app_ip6.as_u8);
}
}
if (ret == HICN_ERROR_NONE)
- // && hicn_face_prod_set_lru_max (*faceid, cs_reserved) == HICN_ERROR_NONE)
+ // && hicn_face_prod_set_lru_max (*faceid, cs_reserved) ==
+ // HICN_ERROR_NONE)
{
- fib_route_path_t rpath = {0};
- fib_route_path_t * rpaths = NULL;
-
- if (ip46_address_is_ip4(&(prefix->fp_addr)))
- {
- ip4_address_t mask;
- ip4_preflen_to_mask (prefix->fp_len, &mask);
- prefix->fp_addr.ip4.as_u32 = prefix->fp_addr.ip4.as_u32 & mask.as_u32;
- prefix->fp_proto = FIB_PROTOCOL_IP4;
-
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_addr.ip4.as_u32 = remote_app_ip.ip4.as_u32;
- rpath.frp_sw_if_index = sw_if;
- rpath.frp_proto = DPO_PROTO_IP4;
-
- vec_add1 (rpaths, rpath);
- }
+ fib_route_path_t rpath = { 0 };
+ fib_route_path_t *rpaths = NULL;
+
+ if (ip46_address_is_ip4 (&(prefix->fp_addr)))
+ {
+ ip4_address_t mask;
+ ip4_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip4.as_u32 =
+ prefix->fp_addr.ip4.as_u32 & mask.as_u32;
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
+
+ rpath.frp_weight = 1;
+ rpath.frp_sw_if_index = ~0;
+ rpath.frp_addr.ip4.as_u32 = remote_app_ip.ip4.as_u32;
+ rpath.frp_sw_if_index = sw_if;
+ rpath.frp_proto = DPO_PROTO_IP4;
+
+ vec_add1 (rpaths, rpath);
+ }
else
- {
- ip6_address_t mask;
- ip6_preflen_to_mask (prefix->fp_len, &mask);
- prefix->fp_addr.ip6.as_u64[0] =
- prefix->fp_addr.ip6.as_u64[0] & mask.as_u64[0];
- prefix->fp_addr.ip6.as_u64[1] =
- prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
- prefix->fp_proto = FIB_PROTOCOL_IP6;
-
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_addr.ip6.as_u64[0] = remote_app_ip.ip6.as_u64[0];
- rpath.frp_addr.ip6.as_u64[1] = remote_app_ip.ip6.as_u64[1];
- rpath.frp_sw_if_index = sw_if;
- rpath.frp_proto = DPO_PROTO_IP6;
-
- vec_add1 (rpaths, rpath);
- }
+ {
+ ip6_address_t mask;
+ ip6_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip6.as_u64[0] =
+ prefix->fp_addr.ip6.as_u64[0] & mask.as_u64[0];
+ prefix->fp_addr.ip6.as_u64[1] =
+ prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
+
+ rpath.frp_weight = 1;
+ rpath.frp_sw_if_index = ~0;
+ rpath.frp_addr.ip6.as_u64[0] = remote_app_ip.ip6.as_u64[0];
+ rpath.frp_addr.ip6.as_u64[1] = remote_app_ip.ip6.as_u64[1];
+ rpath.frp_sw_if_index = sw_if;
+ rpath.frp_proto = DPO_PROTO_IP6;
+
+ vec_add1 (rpaths, rpath);
+ }
u32 fib_index = fib_table_find (prefix->fp_proto, 0);
- fib_table_entry_path_add2 (fib_index,
- prefix,
- FIB_SOURCE_CLI,
- FIB_ENTRY_FLAG_NONE, rpaths);
+ fib_table_entry_path_add2 (fib_index, prefix, FIB_SOURCE_CLI,
+ FIB_ENTRY_FLAG_NONE, rpaths);
- hicn_route_enable(prefix);
+ hicn_route_enable (prefix);
hicn_app_state_create (sw_if, prefix);
}
- adj_index = adj_nbr_find(isv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4, isv6 ? VNET_LINK_IP6 : VNET_LINK_IP4, prod_addr, sw_if);
- face = hicn_face_get(&local_app_ip, sw_if, &hicn_face_hashtb, adj_index);//HICN_FACE_FLAGS_APPFACE_PROD);
+ adj_index =
+ adj_nbr_find (isv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4,
+ isv6 ? VNET_LINK_IP6 : VNET_LINK_IP4, prod_addr, sw_if);
+ face = hicn_face_get (&local_app_ip, sw_if, &hicn_face_hashtb,
+ adj_index); // HICN_FACE_FLAGS_APPFACE_PROD);
*faceid = hicn_dpoi_get_index (face);
face->flags |= HICN_FACE_FLAGS_APPFACE_PROD;
- hicn_face_unlock_with_id(*faceid);
+ hicn_face_unlock_with_id (*faceid);
*prod_addr = local_app_ip;
@@ -315,13 +305,13 @@ hicn_face_prod_del (hicn_face_id_t face_id)
if (face->flags & HICN_FACE_FLAGS_APPFACE_PROD)
{
/* Remove the face from the fib */
- hicn_route_disable(&(face_state_vec[face->sw_if].prefix));
- //hicn_route_del_nhop (&(face_state_vec[face->sw_if].prefix),
- // face_id);
+ hicn_route_disable (&(face_state_vec[face->sw_if].prefix));
+ // hicn_route_del_nhop (&(face_state_vec[face->sw_if].prefix),
+ // face_id);
- //int ret = hicn_face_del (face_id);
+ // int ret = hicn_face_del (face_id);
return hicn_app_state_del (face->sw_if);
- //ret == HICN_ERROR_NONE ? hicn_app_state_del (face->sw_if) : ret;
+ // ret == HICN_ERROR_NONE ? hicn_app_state_del (face->sw_if) : ret;
}
else
{
@@ -332,35 +322,27 @@ hicn_face_prod_del (hicn_face_id_t face_id)
}
u8 *
-format_hicn_face_prod (u8 * s, va_list * args)
+format_hicn_face_prod (u8 *s, va_list *args)
{
CLIB_UNUSED (index_t index) = va_arg (*args, index_t);
CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
- s =
- format (s, " (producer)");
+ s = format (s, " (producer)");
return s;
}
-/* *INDENT-OFF* */
-VNET_FEATURE_INIT(hicn_prod_app_input_ip6, static)=
-{
+VNET_FEATURE_INIT (hicn_prod_app_input_ip6, static) = {
.arc_name = "ip6-unicast",
.node_name = "hicn-face-prod-input",
- .runs_before = VNET_FEATURES("ip6-inacl"),
+ .runs_before = VNET_FEATURES ("ip6-inacl"),
};
-/* *INDENT-ON* */
-/* *INDENT-OFF* */
-VNET_FEATURE_INIT(hicn_prod_app_input_ip4, static)=
-{
+VNET_FEATURE_INIT (hicn_prod_app_input_ip4, static) = {
.arc_name = "ip4-unicast",
.node_name = "hicn-face-prod-input",
- .runs_before = VNET_FEATURES("ip4-inacl"),
+ .runs_before = VNET_FEATURES ("ip4-inacl"),
};
-/* *INDENT-ON* */
-
/*
* fd.io coding-style-patch-verification: ON