From b3b64c5a0529bbbbdcaf14f72fb47667bb457e9d Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Wed, 10 Feb 2021 16:34:47 +0100 Subject: [HICN-682] Fix hicn-plugin to be compatible with version 21.01 Signed-off-by: Mauro Sardara Change-Id: Ia116ad74ce78e2ca2d7ee624eea75a38936d27f8 Signed-off-by: Mauro Sardara --- hicn-plugin/src/faces/app/face_prod.c | 216 ++++++++++++++++------------------ hicn-plugin/src/faces/face.c | 133 ++++++++++----------- hicn-plugin/src/faces/face_cli.c | 180 ++++++++++++++-------------- 3 files changed, 248 insertions(+), 281 deletions(-) (limited to 'hicn-plugin/src/faces') 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 diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c index b495d18b0..7ddf38910 100644 --- a/hicn-plugin/src/faces/face.c +++ b/hicn-plugin/src/faces/face.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: @@ -36,26 +36,24 @@ dpo_type_t hicn_face_type; fib_node_type_t hicn_face_fib_node_type; const char *HICN_FACE_CTRX_STRING[] = { -#define _(a,b,c) c, +#define _(a, b, c) c, foreach_hicn_face_counter #undef _ }; u8 * -face_show (u8 * s, int face_id, u32 indent) +face_show (u8 *s, int face_id, u32 indent) { s = format (s, "%U Faces:\n", format_white_space, indent); indent += 4; int i; vec_foreach_index (i, face_dpo_vec) - { - s = - format (s, "%U", face_vft_vec[i].format_face, - face_dpo_vec[face_id].dpoi_index, indent); - } + { + s = format (s, "%U", face_vft_vec[i].format_face, + face_dpo_vec[face_id].dpoi_index, indent); + } return (s); - } mhash_t hicn_face_vec_hashtb; @@ -64,21 +62,23 @@ mhash_t hicn_face_hashtb; hicn_face_vec_t *hicn_vec_pool; const static char *const hicn_face6_nodes[] = { - "hicn6-face-output", // this is the name you give your node in VLIB_REGISTER_NODE - "hicn6-iface-output", // this is the name you give your node in VLIB_REGISTER_NODE + "hicn6-face-output", // this is the name you give your node in + // VLIB_REGISTER_NODE + "hicn6-iface-output", // this is the name you give your node in + // VLIB_REGISTER_NODE NULL, }; const static char *const hicn_face4_nodes[] = { - "hicn4-face-output", // this is the name you give your node in VLIB_REGISTER_NODE - "hicn4-iface-output", // this is the name you give your node in VLIB_REGISTER_NODE + "hicn4-face-output", // this is the name you give your node in + // VLIB_REGISTER_NODE + "hicn4-iface-output", // this is the name you give your node in + // VLIB_REGISTER_NODE NULL, }; - const static char *const *const hicn_face_nodes[DPO_PROTO_NUM] = { - [DPO_PROTO_IP4] = hicn_face4_nodes, - [DPO_PROTO_IP6] = hicn_face6_nodes + [DPO_PROTO_IP4] = hicn_face4_nodes, [DPO_PROTO_IP6] = hicn_face6_nodes }; const static dpo_vft_t hicn_face_dpo_vft = { @@ -98,19 +98,19 @@ hicn_face_node_get (fib_node_index_t index) } static void -hicn_face_last_lock_gone (fib_node_t * node) +hicn_face_last_lock_gone (fib_node_t *node) { } static hicn_face_t * -hicn_face_from_fib_node (fib_node_t * node) +hicn_face_from_fib_node (fib_node_t *node) { return ((hicn_face_t *) (((char *) node) - STRUCT_OFFSET_OF (hicn_face_t, fib_node))); } static fib_node_back_walk_rc_t -hicn_face_back_walk_notify (fib_node_t * node, fib_node_back_walk_ctx_t * ctx) +hicn_face_back_walk_notify (fib_node_t *node, fib_node_back_walk_ctx_t *ctx) { hicn_face_t *face = hicn_face_from_fib_node (node); @@ -133,7 +133,8 @@ hicn_face_back_walk_notify (fib_node_t * node, fib_node_back_walk_ctx_t * ctx) /* } */ /* else */ /* { */ - /* dpo_stack(hicn_face_type, face->dpo.dpoi_proto, &face->dpo, dpo); */ + /* dpo_stack(hicn_face_type, face->dpo.dpoi_proto, &face->dpo, dpo); + */ /* } */ /* } */ @@ -145,7 +146,6 @@ hicn_face_show_memory (void) { } - static const fib_node_vft_t hicn_face_fib_node_vft = { .fnv_get = hicn_face_node_get, .fnv_last_lock = hicn_face_last_lock_gone, @@ -155,19 +155,18 @@ static const fib_node_vft_t hicn_face_fib_node_vft = { // Make this more flexible for future types face void -hicn_face_module_init (vlib_main_t * vm) +hicn_face_module_init (vlib_main_t *vm) { pool_validate (hicn_dpoi_face_pool); pool_alloc (hicn_dpoi_face_pool, 1024); - counters = - vec_new (vlib_combined_counter_main_t, - HICN_PARAM_FACES_MAX * HICN_N_COUNTER); + counters = vec_new (vlib_combined_counter_main_t, + HICN_PARAM_FACES_MAX * HICN_N_COUNTER); mhash_init (&hicn_face_vec_hashtb, - sizeof (hicn_face_input_faces_t) /* value */ , - sizeof (hicn_face_key_t) /* key */ ); - mhash_init (&hicn_face_hashtb, sizeof (hicn_face_id_t) /* value */ , - sizeof (hicn_face_key_t) /* key */ ); + sizeof (hicn_face_input_faces_t) /* value */, + sizeof (hicn_face_key_t) /* key */); + mhash_init (&hicn_face_hashtb, sizeof (hicn_face_id_t) /* value */, + sizeof (hicn_face_key_t) /* key */); pool_alloc (hicn_vec_pool, 100); @@ -175,19 +174,18 @@ hicn_face_module_init (vlib_main_t * vm) * How much useful is the following registration? * So far it seems that we need it only for setting the dpo_type. */ - hicn_face_type = - dpo_register_new_type (&hicn_face_dpo_vft, hicn_face_nodes); + hicn_face_type = dpo_register_new_type (&hicn_face_dpo_vft, hicn_face_nodes); /* - * We register a new node type to get informed when the adjacency corresponding - * to a face is updated + * We register a new node type to get informed when the adjacency + * corresponding to a face is updated */ hicn_face_fib_node_type = fib_node_register_new_type (&hicn_face_fib_node_vft); } u8 * -format_hicn_face (u8 * s, va_list * args) +format_hicn_face (u8 *s, va_list *args) { index_t index = va_arg (*args, index_t); u32 indent = va_arg (*args, u32); @@ -211,9 +209,8 @@ format_hicn_face (u8 * s, va_list * args) if ((face->flags & HICN_FACE_FLAGS_DELETED)) s = format (s, " (deleted)"); - s = format (s, "\n%U%U", - format_white_space, indent + 2, - format_dpo_id, &face->dpo, indent + 3); + s = format (s, "\n%U%U", format_white_space, indent + 2, format_dpo_id, + &face->dpo, indent + 3); } else { @@ -235,9 +232,8 @@ format_hicn_face (u8 * s, va_list * args) return s; } - u8 * -format_hicn_face_all (u8 * s, int n, ...) +format_hicn_face_all (u8 *s, int n, ...) { va_list ap; va_start (ap, n); @@ -247,12 +243,11 @@ format_hicn_face_all (u8 * s, int n, ...) hicn_face_t *face; - /* *INDENT-OFF* */ - pool_foreach ( face, hicn_dpoi_face_pool, - { - s = format(s, "%U\n", format_hicn_face, hicn_dpoi_get_index(face), indent); - }); - /* *INDENT-ON* */ + pool_foreach (face, hicn_dpoi_face_pool) + { + s = format (s, "%U\n", format_hicn_face, hicn_dpoi_get_index (face), + indent); + } return s; } @@ -267,8 +262,7 @@ hicn_face_del (hicn_face_id_t face_id) hicn_face_get_key (&(face->nat_addr), face->sw_if, &(face->dpo), &key); hicn_face_input_faces_t *in_faces_vec = - hicn_face_get_vec (&(face->nat_addr), - &hicn_face_vec_hashtb); + hicn_face_get_vec (&(face->nat_addr), &hicn_face_vec_hashtb); if (in_faces_vec != NULL) { hicn_face_vec_t *vec = @@ -279,7 +273,7 @@ hicn_face_del (hicn_face_id_t face_id) if (vec_len (*vec) == 0) { pool_put_index (hicn_vec_pool, in_faces_vec->vec_id); - mhash_unset (&hicn_face_vec_hashtb, &key, (uword *) & old_key); + mhash_unset (&hicn_face_vec_hashtb, &key, (uword *) &old_key); vec_free (*vec); } else @@ -292,7 +286,7 @@ hicn_face_del (hicn_face_id_t face_id) } } - mhash_unset (&hicn_face_hashtb, &key, (uword *) & old_key2); + mhash_unset (&hicn_face_hashtb, &key, (uword *) &old_key2); } int ret = HICN_ERROR_NONE; @@ -309,12 +303,11 @@ hicn_face_del (hicn_face_id_t face_id) else ret = HICN_ERROR_FACE_NOT_FOUND; - return ret; } static void -hicn_iface_to_face (hicn_face_t * face, const dpo_id_t * dpo) +hicn_iface_to_face (hicn_face_t *face, const dpo_id_t *dpo) { dpo_stack (hicn_face_type, dpo->dpoi_proto, &face->dpo, dpo); @@ -337,15 +330,11 @@ hicn_iface_to_face (hicn_face_t * face, const dpo_id_t * dpo) { fib_prefix_from_ip46_addr (nh, &prefix); - u32 fib_index = - fib_table_find (prefix.fp_proto, HICN_FIB_TABLE); + u32 fib_index = fib_table_find (prefix.fp_proto, HICN_FIB_TABLE); - face->fib_entry_index = fib_entry_track (fib_index, - &prefix, - hicn_face_fib_node_type, - hicn_dpoi_get_index - (face), - &face->fib_sibling); + face->fib_entry_index = fib_entry_track ( + fib_index, &prefix, hicn_face_fib_node_type, + hicn_dpoi_get_index (face), &face->fib_sibling); } } } @@ -356,8 +345,8 @@ hicn_iface_to_face (hicn_face_t * face, const dpo_id_t * dpo) * the ip_adjacency has already been set up. */ int -hicn_face_add (const dpo_id_t * dpo_nh, ip46_address_t * nat_address, - int sw_if, hicn_face_id_t * pfaceid, u8 is_app_prod) +hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, + hicn_face_id_t *pfaceid, u8 is_app_prod) { hicn_face_flags_t flags = (hicn_face_flags_t) 0; @@ -422,8 +411,7 @@ hicn_face_add (const dpo_id_t * dpo_nh, ip46_address_t * nat_address, hicn_face_get_key (nat_address, 0, &temp_dpo, &key); - mhash_set_mem (&hicn_face_vec_hashtb, &key, - (uword *) & in_faces_temp, 0); + mhash_set_mem (&hicn_face_vec_hashtb, &key, (uword *) &in_faces_temp, 0); } else { @@ -442,30 +430,27 @@ hicn_face_add (const dpo_id_t * dpo_nh, ip46_address_t * nat_address, mhash_set_mem (&hicn_face_vec_hashtb, &key, (uword *) in_faces, 0); - /* If the face is an application producer face, we set it as the preferred incoming face. */ - /* This is required to handle the CS separation, and the push api in a lightway */ + /* If the face is an application producer face, we set it as the + * preferred incoming face. */ + /* This is required to handle the CS separation, and the push api in a + * lightway */ if (is_app_prod) { in_faces->face_id = *pfaceid; } } - retx_t *retx = vlib_process_signal_event_data (vlib_get_main (), - hicn_mapme_eventmgr_process_node. - index, - HICN_MAPME_EVENT_FACE_ADD, 1, - sizeof (retx_t)); + retx_t *retx = vlib_process_signal_event_data ( + vlib_get_main (), hicn_mapme_eventmgr_process_node.index, + HICN_MAPME_EVENT_FACE_ADD, 1, sizeof (retx_t)); - /* *INDENT-OFF* */ - *retx = (retx_t) { + *retx = (retx_t){ .face_id = *pfaceid, }; - /* *INDENT-ON* */ return HICN_ERROR_NONE; } - /* * fd.io coding-style-patch-verification: ON * diff --git a/hicn-plugin/src/faces/face_cli.c b/hicn-plugin/src/faces/face_cli.c index e9e516cc6..a4092e6f4 100644 --- a/hicn-plugin/src/faces/face_cli.c +++ b/hicn-plugin/src/faces/face_cli.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: @@ -19,9 +19,8 @@ #include "../error.h" static clib_error_t * -hicn_face_cli_show_command_fn (vlib_main_t * vm, - unformat_input_t * main_input, - vlib_cli_command_t * cmd) +hicn_face_cli_show_command_fn (vlib_main_t *vm, unformat_input_t *main_input, + vlib_cli_command_t *cmd) { hicn_face_id_t face_id = HICN_FACE_NULL; @@ -46,9 +45,8 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, deleted = 1; else { - return clib_error_return (0, "%s", - get_error_string - (HICN_ERROR_CLI_INVAL)); + return clib_error_return ( + 0, "%s", get_error_string (HICN_ERROR_CLI_INVAL)); } } @@ -56,48 +54,43 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, { int idx = 0; vec_foreach_index (idx, face_type_names_vec) - { - if (!strcmp (face_type_names_vec[idx], face_type_name)) - found = idx; - } + { + if (!strcmp (face_type_names_vec[idx], face_type_name)) + found = idx; + } if (found == ~0) return (clib_error_return (0, "Face type unknown")); } - } if (face_id != HICN_FACE_NULL) { if (!hicn_dpoi_idx_is_valid (face_id)) - return clib_error_return (0, "%s", - get_error_string - (HICN_ERROR_FACE_NOT_FOUND)); + return clib_error_return ( + 0, "%s", get_error_string (HICN_ERROR_FACE_NOT_FOUND)); hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); - vlib_cli_output (vm, "%U\n", format_hicn_face, face_id, 0 /*indent */ ); + vlib_cli_output (vm, "%U\n", format_hicn_face, face_id, 0 /*indent */); u32 indent = 3; for (int i = 0; i < HICN_N_COUNTER; i++) { - vlib_get_combined_counter (&counters - [hicn_dpoi_get_index (face) * - HICN_N_COUNTER], i, &v); - s = - format (s, "%U%s", format_white_space, indent, - HICN_FACE_CTRX_STRING[i]); + vlib_get_combined_counter ( + &counters[hicn_dpoi_get_index (face) * HICN_N_COUNTER], i, &v); + s = format (s, "%U%s", format_white_space, indent, + HICN_FACE_CTRX_STRING[i]); if (n) _vec_len (n) = 0; n = format (n, "packets"); - s = - format (s, "%U%-16v%16Ld", format_white_space, - 30 - strlen (HICN_FACE_CTRX_STRING[i]), n, v.packets); + s = format (s, "%U%-16v%16Ld", format_white_space, + 30 - strlen (HICN_FACE_CTRX_STRING[i]), n, v.packets); _vec_len (n) = 0; n = format (n, "bytes"); - s = format (s, "\n%U%-16v%16Ld\n", - format_white_space, indent + 30, n, v.bytes); + s = format (s, "\n%U%-16v%16Ld\n", format_white_space, indent + 30, + n, v.bytes); } vlib_cli_output (vm, "%s\n", s); } @@ -106,69 +99,79 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, if (found != ~0) { hicn_face_t *face; - /* *INDENT-OFF* */ - pool_foreach(face, hicn_dpoi_face_pool, - { - if (!((face->flags & HICN_FACE_FLAGS_DELETED) && !deleted)) - { - if (face->flags) - { - vlib_cli_output(vm, "%U\n", format_hicn_face, hicn_dpoi_get_index(face), 0); - u8 * s = 0; - u32 indent = 3; - - for (int i = 0; i < HICN_N_COUNTER; i++) - { - vlib_get_combined_counter (&counters[hicn_dpoi_get_index(face) * HICN_N_COUNTER], i, &v); - s = format (s, "%U%s",format_white_space, indent, HICN_FACE_CTRX_STRING[i]); - - if (n) - _vec_len (n) = 0; - n = format (n, "packets"); - s = format (s, "%U%-16v%16Ld", format_white_space, 30-strlen(HICN_FACE_CTRX_STRING[i]), n, v.packets); - - _vec_len (n) = 0; - n = format (n, "bytes"); - s = format (s, "\n%U%-16v%16Ld\n", - format_white_space, indent+30, n, v.bytes); - } - vlib_cli_output (vm, "%s\n", s); - } - } - }); - /* *INDENT-ON* */ + pool_foreach (face, hicn_dpoi_face_pool) + { + if (!((face->flags & HICN_FACE_FLAGS_DELETED) && !deleted)) + { + if (face->flags) + { + vlib_cli_output (vm, "%U\n", format_hicn_face, + hicn_dpoi_get_index (face), 0); + u8 *s = 0; + u32 indent = 3; + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_get_combined_counter ( + &counters[hicn_dpoi_get_index (face) * + HICN_N_COUNTER], + i, &v); + s = format (s, "%U%s", format_white_space, indent, + HICN_FACE_CTRX_STRING[i]); + + if (n) + _vec_len (n) = 0; + n = format (n, "packets"); + s = format (s, "%U%-16v%16Ld", format_white_space, + 30 - strlen (HICN_FACE_CTRX_STRING[i]), + n, v.packets); + + _vec_len (n) = 0; + n = format (n, "bytes"); + s = + format (s, "\n%U%-16v%16Ld\n", format_white_space, + indent + 30, n, v.bytes); + } + vlib_cli_output (vm, "%s\n", s); + } + } + } } else { hicn_face_t *face; - /* *INDENT-OFF* */ - pool_foreach(face, hicn_dpoi_face_pool, - { - if (!((face->flags & HICN_FACE_FLAGS_DELETED) && !deleted)) - { - vlib_cli_output(vm, "%U\n", format_hicn_face, hicn_dpoi_get_index(face), 0); - u32 indent = 3; - u8 * s = 0; - - for (int i = 0; i < HICN_N_COUNTER; i++) - { - vlib_get_combined_counter (&counters[hicn_dpoi_get_index(face) * HICN_N_COUNTER], i, &v); - s = format (s, "%U%s",format_white_space, indent, HICN_FACE_CTRX_STRING[i]); - - if (n) - _vec_len (n) = 0; - n = format (n, "packets"); - s = format (s, "%U%-16v%16Ld", format_white_space, 30-strlen(HICN_FACE_CTRX_STRING[i]), n, v.packets); - - _vec_len (n) = 0; - n = format (n, "bytes"); - s = format (s, "\n%U%-16v%16Ld\n", - format_white_space, indent+30, n, v.bytes); - } - vlib_cli_output (vm, "%s\n", s); - } - }); - /* *INDENT-ON* */ + pool_foreach (face, hicn_dpoi_face_pool) + { + if (!((face->flags & HICN_FACE_FLAGS_DELETED) && !deleted)) + { + vlib_cli_output (vm, "%U\n", format_hicn_face, + hicn_dpoi_get_index (face), 0); + u32 indent = 3; + u8 *s = 0; + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_get_combined_counter ( + &counters[hicn_dpoi_get_index (face) * HICN_N_COUNTER], + i, &v); + s = format (s, "%U%s", format_white_space, indent, + HICN_FACE_CTRX_STRING[i]); + + if (n) + _vec_len (n) = 0; + n = format (n, "packets"); + s = format (s, "%U%-16v%16Ld", format_white_space, + 30 - strlen (HICN_FACE_CTRX_STRING[i]), n, + v.packets); + + _vec_len (n) = 0; + n = format (n, "bytes"); + s = format (s, "\n%U%-16v%16Ld\n", format_white_space, + indent + 30, n, v.bytes); + } + vlib_cli_output (vm, "%s\n", s); + } + } } } @@ -176,14 +179,11 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, } /* cli declaration for 'show faces' */ -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (hicn_face_cli_show_command, static) = -{ +VLIB_CLI_COMMAND (hicn_face_cli_show_command, static) = { .path = "hicn face show", .short_help = "hicn face show []", .function = hicn_face_cli_show_command_fn, }; -/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON -- cgit 1.2.3-korg