From b4353c871463c06ed47db1ed9c3106f9dd201838 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Tue, 20 Jul 2021 13:20:35 +0200 Subject: HICN-716 Upgrade to VPP 21.06 Also: - Format hicn-plugin code Signed-off-by: Mauro Sardara Change-Id: I0f4626fdeaf0fc5ae1f43904ca006b092e3e9d5f --- hicn-plugin/src/CMakeLists.txt | 18 +- hicn-plugin/src/cache_policies/cs_lru.c | 55 ++- hicn-plugin/src/cache_policies/cs_lru.h | 33 +- hicn-plugin/src/cache_policies/cs_policy.h | 55 ++- hicn-plugin/src/data_fwd.h | 54 ++- hicn-plugin/src/data_fwd_node.c | 6 +- hicn-plugin/src/data_pcslookup.h | 11 +- hicn-plugin/src/error.c | 2 +- hicn-plugin/src/error.h | 125 +++--- hicn-plugin/src/face_db.h | 41 +- hicn-plugin/src/faces/app/address_mgr.c | 62 ++- hicn-plugin/src/faces/app/address_mgr.h | 8 +- hicn-plugin/src/faces/app/face_app_cli.c | 8 +- hicn-plugin/src/faces/app/face_cons.c | 32 +- hicn-plugin/src/faces/app/face_cons.h | 25 +- hicn-plugin/src/faces/app/face_prod.h | 30 +- hicn-plugin/src/faces/app/face_prod_node.c | 4 +- hicn-plugin/src/faces/face.h | 366 +++++++++-------- hicn-plugin/src/faces/face_node.h | 6 +- hicn-plugin/src/faces/iface_node.c | 8 +- hicn-plugin/src/faces/iface_node.h | 13 +- hicn-plugin/src/faces/inlines.h | 16 +- hicn-plugin/src/hashtb.c | 127 +++--- hicn-plugin/src/hashtb.h | 150 ++++--- hicn-plugin/src/hicn.c | 4 +- hicn-plugin/src/hicn.h | 41 +- hicn-plugin/src/hicn_api.c | 4 +- hicn-plugin/src/hicn_api.h | 3 +- hicn-plugin/src/hicn_api_test.c | 424 +++++++++---------- hicn-plugin/src/infra.h | 18 +- hicn-plugin/src/interest_hitcs.h | 11 +- hicn-plugin/src/interest_hitcs_node.c | 2 +- hicn-plugin/src/interest_hitpit.h | 12 +- hicn-plugin/src/interest_hitpit_node.c | 2 +- hicn-plugin/src/interest_pcslookup.h | 12 +- hicn-plugin/src/mapme.h | 130 +++--- hicn-plugin/src/mapme_ctrl.h | 2 +- hicn-plugin/src/mapme_eventmgr.c | 4 +- hicn-plugin/src/mapme_eventmgr.h | 6 +- hicn-plugin/src/mgmt.c | 67 ++- hicn-plugin/src/mgmt.h | 43 +- hicn-plugin/src/params.h | 78 ++-- hicn-plugin/src/parser.h | 30 +- hicn-plugin/src/pcs.c | 3 +- hicn-plugin/src/pg.c | 30 +- hicn-plugin/src/pg.h | 52 +-- hicn-plugin/src/route.c | 587 +++++++++++++-------------- hicn-plugin/src/route.h | 73 ++-- hicn-plugin/src/state.h | 41 +- hicn-plugin/src/strategies/dpo_mw.c | 34 +- hicn-plugin/src/strategies/dpo_mw.h | 19 +- hicn-plugin/src/strategies/dpo_rr.c | 36 +- hicn-plugin/src/strategies/dpo_rr.h | 20 +- hicn-plugin/src/strategies/strategy_mw_cli.c | 2 +- hicn-plugin/src/strategy.h | 56 ++- hicn-plugin/src/strategy_dpo_ctx.c | 23 +- hicn-plugin/src/strategy_dpo_ctx.h | 44 +- hicn-plugin/src/strategy_dpo_manager.c | 25 +- hicn-plugin/src/strategy_dpo_manager.h | 65 +-- hicn-plugin/src/strategy_node.c | 4 +- hicn-plugin/src/udp_tunnels/udp_decap_node.c | 40 +- hicn-plugin/src/udp_tunnels/udp_tunnel.c | 7 +- hicn-plugin/src/udp_tunnels/udp_tunnel.h | 34 +- hicn-plugin/src/utils.h | 17 +- 64 files changed, 1637 insertions(+), 1723 deletions(-) (limited to 'hicn-plugin') diff --git a/hicn-plugin/src/CMakeLists.txt b/hicn-plugin/src/CMakeLists.txt index c90ae80a2..124d9b5cb 100644 --- a/hicn-plugin/src/CMakeLists.txt +++ b/hicn-plugin/src/CMakeLists.txt @@ -182,30 +182,30 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vnet/udp) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/hicn) +include(Packager) +extract_version() + # These files are missing from vpp binary distribution execute_process( COMMAND bash -c "if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vapi_json_parser.py ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vpp-api/vapi/vapi_json_parser.py -o ${CMAKE_CURRENT_BINARY_DIR}/vapi_json_parser.py; + curl https://raw.githubusercontent.com/FDio/vpp/stable/2106/src/vpp-api/vapi/vapi_json_parser.py -o ${CMAKE_CURRENT_BINARY_DIR}/vapi_json_parser.py; fi; if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vapi_c_gen.py ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vpp-api/vapi/vapi_c_gen.py -o ${CMAKE_CURRENT_BINARY_DIR}/vapi_c_gen.py; + curl https://raw.githubusercontent.com/FDio/vpp/stable/2106/src/vpp-api/vapi/vapi_c_gen.py -o ${CMAKE_CURRENT_BINARY_DIR}/vapi_c_gen.py; fi; if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vapi_cpp_gen.py ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vpp-api/vapi/vapi_cpp_gen.py -o ${CMAKE_CURRENT_BINARY_DIR}/vapi_cpp_gen.py; + curl https://raw.githubusercontent.com/FDio/vpp/stable/2106/src/vpp-api/vapi/vapi_cpp_gen.py -o ${CMAKE_CURRENT_BINARY_DIR}/vapi_cpp_gen.py; fi; if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vnet/ip/ip_types.api ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vnet/ip/ip_types.api -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/ip/ip_types.api; - fi; - if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vnet/ip/ip_format_fns.h ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vnet/ip/ip_format_fns.h -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/ip/ip_format_fns.h; + curl https://raw.githubusercontent.com/FDio/vpp/stable/2106/src/vnet/ip/ip_types.api -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/ip/ip_types.api; fi; if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vnet/fib/fib_entry_track.h ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vnet/fib/fib_entry_track.h -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/fib/fib_entry_track.h; + curl https://raw.githubusercontent.com/FDio/vpp/stable/2106/src/vnet/fib/fib_entry_track.h -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/fib/fib_entry_track.h; fi; if [ ! -e ${CMAKE_CURRENT_BINARY_DIR}/vnet/udp/udp_encap.h ]; then - curl https://raw.githubusercontent.com/FDio/vpp/stable/2005/src/vnet/udp/udp_encap.h -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/udp/udp_encap.h; + curl https://raw.githubusercontent.com/FDio/vpp/stable/2106/src/vnet/udp/udp_encap.h -o ${CMAKE_CURRENT_BINARY_DIR}/vnet/udp/udp_encap.h; fi; chmod +x ${CMAKE_CURRENT_BINARY_DIR}/vapi_json_parser.py ${CMAKE_CURRENT_BINARY_DIR}/vapi_c_gen.py ${CMAKE_CURRENT_BINARY_DIR}/vapi_cpp_gen.py" diff --git a/hicn-plugin/src/cache_policies/cs_lru.c b/hicn-plugin/src/cache_policies/cs_lru.c index 079af58ab..408a6cb49 100644 --- a/hicn-plugin/src/cache_policies/cs_lru.c +++ b/hicn-plugin/src/cache_policies/cs_lru.c @@ -32,8 +32,8 @@ hicn_cs_policy_vft_t hicn_cs_lru = { * Insert a new CS element at the head of the CS LRU */ void -hicn_cs_lru_insert (hicn_pit_cs_t * p, hicn_hash_node_t * node, - hicn_pcs_entry_t * pcs, hicn_cs_policy_t * policy_state) +hicn_cs_lru_insert (hicn_pit_cs_t *p, hicn_hash_node_t *node, + hicn_pcs_entry_t *pcs, hicn_cs_policy_t *policy_state) { hicn_hash_node_t *lrunode; hicn_pcs_entry_t *lrupcs; @@ -56,7 +56,7 @@ hicn_cs_lru_insert (hicn_pit_cs_t * p, hicn_hash_node_t * node, } else { - ASSERT (policy_state->tail == 0); /* We think the list is + ASSERT (policy_state->tail == 0); /* We think the list is * empty */ policy_state->head = policy_state->tail = idx; @@ -68,26 +68,24 @@ hicn_cs_lru_insert (hicn_pit_cs_t * p, hicn_hash_node_t * node, } void -hicn_cs_lru_delete_get (hicn_pit_cs_t * p, hicn_cs_policy_t * policy_state, - hicn_hash_node_t ** nodep, - hicn_pcs_entry_t ** pcs_entry, - hicn_hash_entry_t ** hash_entry) +hicn_cs_lru_delete_get (hicn_pit_cs_t *p, hicn_cs_policy_t *policy_state, + hicn_hash_node_t **nodep, hicn_pcs_entry_t **pcs_entry, + hicn_hash_entry_t **hash_entry) { *nodep = hicn_hashtb_node_from_idx (p->pcs_table, policy_state->tail); *pcs_entry = hicn_pit_get_data (*nodep); - *hash_entry = hicn_hashtb_get_entry (p->pcs_table, (*nodep)->entry_idx, - (*nodep)->bucket_id, - (*nodep)->hn_flags & - HICN_HASH_NODE_OVERFLOW_BUCKET); + *hash_entry = hicn_hashtb_get_entry ( + p->pcs_table, (*nodep)->entry_idx, (*nodep)->bucket_id, + (*nodep)->hn_flags & HICN_HASH_NODE_OVERFLOW_BUCKET); } /* * Dequeue an LRU element, for example when it has expired. */ void -hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, - hicn_pcs_entry_t * pcs, hicn_cs_policy_t * lru) +hicn_cs_lru_dequeue (hicn_pit_cs_t *pit, hicn_hash_node_t *pnode, + hicn_pcs_entry_t *pcs, hicn_cs_policy_t *lru) { hicn_hash_node_t *lrunode; hicn_pcs_entry_t *lrupcs; @@ -95,8 +93,8 @@ hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, if (pcs->u.cs.cs_lru_prev != 0) { /* Not already on the head of the LRU */ - lrunode = hicn_hashtb_node_from_idx (pit->pcs_table, - pcs->u.cs.cs_lru_prev); + lrunode = + hicn_hashtb_node_from_idx (pit->pcs_table, pcs->u.cs.cs_lru_prev); lrupcs = hicn_pit_get_data (lrunode); lrupcs->u.cs.cs_lru_next = pcs->u.cs.cs_lru_next; @@ -111,8 +109,8 @@ hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, if (pcs->u.cs.cs_lru_next != 0) { /* Not already the end of the LRU */ - lrunode = hicn_hashtb_node_from_idx (pit->pcs_table, - pcs->u.cs.cs_lru_next); + lrunode = + hicn_hashtb_node_from_idx (pit->pcs_table, pcs->u.cs.cs_lru_next); lrupcs = hicn_pit_get_data (lrunode); lrupcs->u.cs.cs_lru_prev = pcs->u.cs.cs_lru_prev; @@ -133,8 +131,8 @@ hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, * Move a CS LRU element to the head, probably after it's been used. */ void -hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, - hicn_pcs_entry_t * pcs, hicn_cs_policy_t * lru) +hicn_cs_lru_update_head (hicn_pit_cs_t *pit, hicn_hash_node_t *pnode, + hicn_pcs_entry_t *pcs, hicn_cs_policy_t *lru) { if (pcs->u.cs.cs_lru_prev != 0) { @@ -146,7 +144,6 @@ hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, /* Now detached from the list; attach at head */ hicn_cs_lru_insert (pit, pnode, pcs, lru); - } else { @@ -167,8 +164,8 @@ hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, * CS's limit. Return the number of removed nodes. */ int -hicn_cs_lru_trim (hicn_pit_cs_t * pit, u32 * node_list, int sz, - hicn_cs_policy_t * lru) +hicn_cs_lru_trim (hicn_pit_cs_t *pit, u32 *node_list, int sz, + hicn_cs_policy_t *lru) { hicn_hash_node_t *lrunode; hicn_pcs_entry_t *lrupcs; @@ -214,8 +211,8 @@ hicn_cs_lru_trim (hicn_pit_cs_t * pit, u32 * node_list, int sz, } int -hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs, - hicn_cs_policy_t * state) +hicn_cs_lru_flush (vlib_main_t *vm, struct hicn_pit_cs_s *pitcs, + hicn_cs_policy_t *state) { if (state->head == 0 && state->tail == 0) return 0; @@ -233,20 +230,19 @@ hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs, lrupcs = hicn_pit_get_data (lrunode); u64 hashval = 0; - hicn_hashtb_fullhash ((u8 *) & (lrunode->hn_key.ks.key), + hicn_hashtb_fullhash ((u8 *) &(lrunode->hn_key.ks.key), lrunode->hn_keysize, &hashval); hicn_hash_bucket_t *bucket = NULL; if ((hashval & (pitcs->pcs_table->ht_bucket_count - 1)) == lrunode->bucket_id) { - //The bucket is in the non overflown + // The bucket is in the non overflown bucket = pitcs->pcs_table->ht_buckets + lrunode->bucket_id; } else { - bucket = - pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets, - lrunode->bucket_id); + bucket = pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets, + lrunode->bucket_id); } hicn_hash_entry_t *hash_entry = &(bucket->hb_entries[lrunode->entry_idx]); @@ -258,7 +254,6 @@ hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs, } return (i); - } /* diff --git a/hicn-plugin/src/cache_policies/cs_lru.h b/hicn-plugin/src/cache_policies/cs_lru.h index 3bd18060d..c939b45df 100644 --- a/hicn-plugin/src/cache_policies/cs_lru.h +++ b/hicn-plugin/src/cache_policies/cs_lru.h @@ -26,47 +26,40 @@ * This file implements the LRU policy for the CS */ - extern hicn_cs_policy_vft_t hicn_cs_lru; /* * Insert a new CS element at the head of the CS LRU */ -void -hicn_cs_lru_insert (hicn_pit_cs_t * pcs, hicn_hash_node_t * pnode, - hicn_pcs_entry_t * entry, hicn_cs_policy_t * lru); - +void hicn_cs_lru_insert (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode, + hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru); /* * Dequeue an LRU element, for example when it has expired. */ -void -hicn_cs_lru_dequeue (hicn_pit_cs_t * pcs, hicn_hash_node_t * pnode, - hicn_pcs_entry_t * entry, hicn_cs_policy_t * lru); +void hicn_cs_lru_dequeue (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode, + hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru); /* * Move a CS LRU element to the head, probably after it's been used. */ -void -hicn_cs_lru_update_head (hicn_pit_cs_t * pcs, hicn_hash_node_t * pnode, - hicn_pcs_entry_t * entry, hicn_cs_policy_t * lru); +void hicn_cs_lru_update_head (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode, + hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru); -void -hicn_cs_lru_delete_get (hicn_pit_cs_t * p, hicn_cs_policy_t * policy, - hicn_hash_node_t ** node, hicn_pcs_entry_t ** pcs, - hicn_hash_entry_t ** hash_entry); +void hicn_cs_lru_delete_get (hicn_pit_cs_t *p, hicn_cs_policy_t *policy, + hicn_hash_node_t **node, hicn_pcs_entry_t **pcs, + hicn_hash_entry_t **hash_entry); /* * Remove a batch of nodes from the CS LRU, copying their node indexes into * the caller's array. We expect this is done when the LRU size exceeds the * CS's limit. Return the number of removed nodes. */ -int hicn_cs_lru_trim (hicn_pit_cs_t * pcs, u32 * node_list, int sz, - hicn_cs_policy_t * lru); - +int hicn_cs_lru_trim (hicn_pit_cs_t *pcs, u32 *node_list, int sz, + hicn_cs_policy_t *lru); -int hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs, - hicn_cs_policy_t * state); +int hicn_cs_lru_flush (vlib_main_t *vm, struct hicn_pit_cs_s *pitcs, + hicn_cs_policy_t *state); #endif /* // __LRU_H__ */ /* diff --git a/hicn-plugin/src/cache_policies/cs_policy.h b/hicn-plugin/src/cache_policies/cs_policy.h index 0bf745915..505138943 100644 --- a/hicn-plugin/src/cache_policies/cs_policy.h +++ b/hicn-plugin/src/cache_policies/cs_policy.h @@ -24,7 +24,6 @@ * This file provides the needed structures to implement a CS policy */ - /* * Structure */ @@ -57,36 +56,34 @@ struct hicn_cs_policy_s; */ typedef struct hicn_cs_policy_vft_s { - void (*hicn_cs_insert) (struct hicn_pit_cs_s * p, - struct hicn_hash_node_s * node, - struct hicn_pcs_entry_s * pcs, - hicn_cs_policy_t * policy); - - void (*hicn_cs_update) (struct hicn_pit_cs_s * p, - struct hicn_hash_node_s * node, - struct hicn_pcs_entry_s * pcs, - hicn_cs_policy_t * policy); - - void (*hicn_cs_dequeue) (struct hicn_pit_cs_s * p, - struct hicn_hash_node_s * node, - struct hicn_pcs_entry_s * pcs, - hicn_cs_policy_t * policy); - - void (*hicn_cs_delete_get) (struct hicn_pit_cs_s * p, - hicn_cs_policy_t * policy, - struct hicn_hash_node_s ** node, - struct hicn_pcs_entry_s ** pcs, - struct hicn_hash_entry_s ** hash_entry); - - int (*hicn_cs_trim) (struct hicn_pit_cs_s * p, u32 * node_list, int sz, - hicn_cs_policy_t * policy); - - int (*hicn_cs_flush) (vlib_main_t * vm, struct hicn_pit_cs_s * p, - hicn_cs_policy_t * policy_state); + void (*hicn_cs_insert) (struct hicn_pit_cs_s *p, + struct hicn_hash_node_s *node, + struct hicn_pcs_entry_s *pcs, + hicn_cs_policy_t *policy); + + void (*hicn_cs_update) (struct hicn_pit_cs_s *p, + struct hicn_hash_node_s *node, + struct hicn_pcs_entry_s *pcs, + hicn_cs_policy_t *policy); + + void (*hicn_cs_dequeue) (struct hicn_pit_cs_s *p, + struct hicn_hash_node_s *node, + struct hicn_pcs_entry_s *pcs, + hicn_cs_policy_t *policy); + + void (*hicn_cs_delete_get) (struct hicn_pit_cs_s *p, + hicn_cs_policy_t *policy, + struct hicn_hash_node_s **node, + struct hicn_pcs_entry_s **pcs, + struct hicn_hash_entry_s **hash_entry); + + int (*hicn_cs_trim) (struct hicn_pit_cs_s *p, u32 *node_list, int sz, + hicn_cs_policy_t *policy); + + int (*hicn_cs_flush) (vlib_main_t *vm, struct hicn_pit_cs_s *p, + hicn_cs_policy_t *policy_state); } hicn_cs_policy_vft_t; - - #endif /* // __HICN_POLICY_H__ */ /* diff --git a/hicn-plugin/src/data_fwd.h b/hicn-plugin/src/data_fwd.h index d95f564c3..96d8399e4 100644 --- a/hicn-plugin/src/data_fwd.h +++ b/hicn-plugin/src/data_fwd.h @@ -24,23 +24,25 @@ * @file data_fwd.h * * This is the node encoutered by data packets after the hicn-data-pcslookup. - * This node has two goals: 1) clone/copy the vlib buffer as many time as the number - * of faces stored in the pit entry, 2) store a clone/copy of the vlib buffer in the CS. - * Unless there are memory issue (no more vlib buffer available to perform cloning/copy), - * a single vlib buffer received might results in several vlib buffer sent to the next - * vlib node (hicn4-iface-output or hicn6-iface-output). + * This node has two goals: 1) clone/copy the vlib buffer as many time as the + * number of faces stored in the pit entry, 2) store a clone/copy of the vlib + * buffer in the CS. Unless there are memory issue (no more vlib buffer + * available to perform cloning/copy), a single vlib buffer received might + * results in several vlib buffer sent to the next vlib node + * (hicn4-iface-output or hicn6-iface-output). * - * It must be noted that cloning is possible only if the lentgh of the data pointed by - * the vlib buffer is at least 256 bytes. This is due to an imposition in the vpp source - * code. In all the other cases the vlib buffer is copied. Cloning is performed by advancing - * the vlib buffer of 256 bytes and a new vlib buffer is created and chained in from of the received - * buffer. Additionally, the 256 bytes removed (advanced) from the received vlib buffer are - * copied in the head vlib buffer. In case of multiple cloning for the same vlib buffer, this - * mechanism allows us to have a different hICN header for each clone (+ the same additional bytes - * due to the vpp restriction on cloning). + * It must be noted that cloning is possible only if the lentgh of the data + * pointed by the vlib buffer is at least 256 bytes. This is due to an + * imposition in the vpp source code. In all the other cases the vlib buffer is + * copied. Cloning is performed by advancing the vlib buffer of 256 bytes and a + * new vlib buffer is created and chained in from of the received buffer. + * Additionally, the 256 bytes removed (advanced) from the received vlib buffer + * are copied in the head vlib buffer. In case of multiple cloning for the same + * vlib buffer, this mechanism allows us to have a different hICN header for + * each clone (+ the same additional bytes due to the vpp restriction on + * cloning). */ - /* Trace context struct */ typedef struct { @@ -76,7 +78,7 @@ typedef enum * less than the number requested or zero */ always_inline u16 -vlib_buffer_clone_256_2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, +vlib_buffer_clone_256_2 (vlib_main_t *vm, u32 src_buffer, u32 *buffers, u16 n_buffers, u16 head_end_offset) { u16 i; @@ -97,8 +99,8 @@ vlib_buffer_clone_256_2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, } return n_buffers; } - n_buffers = vlib_buffer_alloc_from_pool (vm, buffers, n_buffers, - s->buffer_pool_index); + n_buffers = + vlib_buffer_alloc_from_pool (vm, buffers, n_buffers, s->buffer_pool_index); for (i = 0; i < n_buffers; i++) { @@ -107,8 +109,8 @@ vlib_buffer_clone_256_2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, d->current_length = head_end_offset; d->trace_handle = s->trace_handle; - d->total_length_not_including_first_buffer = s->current_length - - head_end_offset; + d->total_length_not_including_first_buffer = + s->current_length - head_end_offset; if (PREDICT_FALSE (s->flags & VLIB_BUFFER_NEXT_PRESENT)) { d->total_length_not_including_first_buffer += @@ -149,7 +151,7 @@ vlib_buffer_clone_256_2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, * less than the number requested or zero */ always_inline u16 -vlib_buffer_clone2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, +vlib_buffer_clone2 (vlib_main_t *vm, u32 src_buffer, u32 *buffers, u16 n_buffers, u16 head_end_offset) { vlib_buffer_t *s = vlib_get_buffer (vm, src_buffer); @@ -174,11 +176,9 @@ vlib_buffer_clone2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, vlib_buffer_t *copy; /* Ok to call the original vlib_buffer_copy. */ copy = vlib_buffer_copy (vm, s); - n_cloned += vlib_buffer_clone (vm, - vlib_get_buffer_index (vm, copy), - buffers, - n_buffers - n_clone_src, - head_end_offset); + n_cloned += + vlib_buffer_clone (vm, vlib_get_buffer_index (vm, copy), buffers, + n_buffers - n_clone_src, head_end_offset); n_buffers -= n_cloned; } /* @@ -195,9 +195,7 @@ vlib_buffer_clone2 (vlib_main_t * vm, u32 src_buffer, u32 * buffers, * complexity to the code, especially because we need to add 1 to * ref_count when the packet is cloned. */ - n_cloned += vlib_buffer_clone_256_2 (vm, - src_buffer, - (buffers + n_cloned), + n_cloned += vlib_buffer_clone_256_2 (vm, src_buffer, (buffers + n_cloned), n_buffers, head_end_offset); s->ref_count += (tmp_ref_count - 1); diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c index a91439662..fe79b33fa 100644 --- a/hicn-plugin/src/data_fwd_node.c +++ b/hicn-plugin/src/data_fwd_node.c @@ -428,9 +428,9 @@ hicn_satisfy_faces (vlib_main_t *vm, u32 bi0, hicn_pcs_entry_t *pitp, clones += 2; next0 = isv6 ? HICN_DATA_FWD_NEXT_IFACE6_OUT : - HICN_DATA_FWD_NEXT_IFACE4_OUT; + HICN_DATA_FWD_NEXT_IFACE4_OUT; next1 = isv6 ? HICN_DATA_FWD_NEXT_IFACE6_OUT : - HICN_DATA_FWD_NEXT_IFACE4_OUT; + HICN_DATA_FWD_NEXT_IFACE4_OUT; vnet_buffer (h0)->ip.adj_index[VLIB_TX] = face0; vnet_buffer (h1)->ip.adj_index[VLIB_TX] = face1; @@ -481,7 +481,7 @@ hicn_satisfy_faces (vlib_main_t *vm, u32 bi0, hicn_pcs_entry_t *pitp, clones += 1; next0 = isv6 ? HICN_DATA_FWD_NEXT_IFACE6_OUT : - HICN_DATA_FWD_NEXT_IFACE4_OUT; + HICN_DATA_FWD_NEXT_IFACE4_OUT; vnet_buffer (h0)->ip.adj_index[VLIB_TX] = face0; stats->pkts_data_count++; diff --git a/hicn-plugin/src/data_pcslookup.h b/hicn-plugin/src/data_pcslookup.h index e3050c31c..b548497b6 100644 --- a/hicn-plugin/src/data_pcslookup.h +++ b/hicn-plugin/src/data_pcslookup.h @@ -22,9 +22,10 @@ * @file data_pcslookup.h * * This is the node encoutered by data packets after the hicn6-face-input or - * hicn4-face-input. This node performs a lookup in the pit and content store and - * if there is a hit in the PIT, the vlib buffer is passed to the hicn-data-fwd - * while if there is a hit in the CS or there isn't any hit, the packet is dropped. + * hicn4-face-input. This node performs a lookup in the pit and content store + * and if there is a hit in the PIT, the vlib buffer is passed to the + * hicn-data-fwd while if there is a hit in the CS or there isn't any hit, the + * packet is dropped. */ /* @@ -46,8 +47,8 @@ typedef struct typedef enum { - HICN_DATA_PCSLOOKUP_NEXT_DATA_FWD, /* This must be one position - * before the error drop!! */ + HICN_DATA_PCSLOOKUP_NEXT_DATA_FWD, /* This must be one position + * before the error drop!! */ HICN_DATA_PCSLOOKUP_NEXT_ERROR_DROP, HICN_DATA_PCSLOOKUP_N_NEXT, } hicn_data_pcslookup_next_t; diff --git a/hicn-plugin/src/error.c b/hicn-plugin/src/error.c index 588ae2398..4c6986999 100644 --- a/hicn-plugin/src/error.c +++ b/hicn-plugin/src/error.c @@ -16,7 +16,7 @@ #include "error.h" const char *HICN_ERROR_STRING[] = { -#define _(a,b,c) c, +#define _(a, b, c) c, foreach_hicn_error #undef _ }; diff --git a/hicn-plugin/src/error.h b/hicn-plugin/src/error.h index 59ebce61c..b33a1b50d 100644 --- a/hicn-plugin/src/error.h +++ b/hicn-plugin/src/error.h @@ -22,67 +22,72 @@ * Error codes for the hICN plugin. */ - -#define foreach_hicn_error \ - _(NONE, 0, "Ok") \ - _(UNSPECIFIED, -128, "Unspecified Error") \ - _(FACE_NOT_FOUND, -129, "Face not found in Face table") \ - _(FACE_NULL, -130, "Face null") \ - _(FACE_IP_ADJ_NOT_FOUND, -131, "Ip adjacecny for face not found") \ - _(FACE_HW_INT_NOT_FOUND, -132, "Hardware interface not found") \ - _(FACE_NOMEM, -133, "Face table is full") \ - _(FACE_NO_GLOBAL_IP, -134, "No global ip address for face") \ - _(FACE_NOT_FOUND_IN_ENTRY, -135, "Face not found in entry") \ - _(FACE_ALREADY_DELETED, -136, "Face alredy deleted") \ - _(FACE_ALREADY_CREATED, -137, "Face alredy created") \ - _(FWD_NOT_ENABLED, -138, "hICN forwarder not enabled") \ - _(FWD_ALREADY_ENABLED, -139, "hICN forwarder alredy enabled") \ - _(PARSER_UNSUPPORTED_PROTO, -140, "Unsupported protocol") \ - _(PARSER_PKT_INVAL, -141, "Packet null") \ - _(PIT_CONFIG_MINLT_OOB, -142, "Min lifetime ouf of bounds") \ - _(PIT_CONFIG_MAXLT_OOB, -143, "Max lifetime ouf of bounds") \ - _(PIT_CONFIG_MINMAXLT, -144, "Min lifetime grater than max lifetime") \ - _(PIT_CONFIG_DFTLT_OOB, -145, "Default lifetime ouf of bounds") \ - _(PIT_CONFIG_SIZE_OOB, -146, "Pit size ouf of bounds") \ - _(CS_CONFIG_SIZE_OOB, -147, "CS size ouf of bounds") \ - _(CS_CONFIG_RESERVED_OOB, -148, "Reseved CS must be between 0 and 100 (excluded)") \ - _(DPO_CTX_NHOPS_NS, -149, "No space for additional next hop") \ - _(DPO_CTX_NHOPS_EXISTS, -150, "Next hop already in the route") \ - _(DPO_CTX_NOT_FOUND, -151, "Dpo context not found") \ - _(DPO_MGR_ID_NOT_VALID, -152, "Dpo id for strategy and context not valid") \ - _(HASHTB_HASH_NOT_FOUND, -153, "Hash not found in hash table") \ - _(HASHTB_HASH_INVAL, -154, "Error while calculating the hash") \ - _(HASHTB_NOMEM, -155, "Unable to allocate new buckets or nodes") \ - _(HASHTB_INVAL, -156, "Invalid argument") \ - _(HASHTB_KEY_INVAL, -157, "Invalid hashtb key") \ - _(HASHTB_EXIST, -158, "Hash already in hashtable") \ - _(ROUTE_INVAL, -159, "Invalid face id and weight") \ - _(ROUTE_NO_LD, -160, "Expected load balance dpo") \ - _(ROUTE_MLT_LD, -161, "Unexpected mulitple buckets in load balance dpo") \ - _(ROUTE_NO_INSERT, -162, "Unable to insert a new FIB entry") \ - _(ROUTE_DPO_NO_HICN, -163, "Dpo is not of type hICN") \ - _(ROUTE_NOT_FOUND, -164, "Route not found in FIB") \ - _(ROUTE_NOT_UPDATED, -165, "Unable to update route") \ - _(ROUTE_ALREADY_EXISTS, -166, "Route already in FIB") \ - _(CLI_INVAL, -167, "Invalid input") \ - _(IPS_ADDR_TYPE_NONUNIFORM, -168, "Src and dst addr have different ip types") \ - _(FACE_TYPE_EXISTS, -169, "Face type already registered") \ - _(NO_BUFFERS, -170, "No vlib_buffer available for packet cloning.") \ - _(NOT_IMPLEMENTED, -171, "Function not yet implemented") \ - _(IFACE_IP_ADJ_NOT_FOUND, -172, "IP adjacency on incomplete face not available") \ - _(APPFACE_ALREADY_ENABLED, -173, "Application face already enabled on interface") \ - _(APPFACE_FEATURE, -174, "Error while enabling app face feature") \ - _(APPFACE_NOT_FOUND, -175, "Application face not found") \ - _(APPFACE_PROD_PREFIX_NULL, -176, "Prefix must not be null for producer face") \ - _(STRATEGY_NH_NOT_FOUND, -177, "Next hop not found") \ - _(MW_STRATEGY_SET, -178, "Error while setting weight for next hop") \ - _(STRATEGY_NOT_FOUND, -179, "Strategy not found") \ - _(UDP_TUNNEL_NOT_FOUND, -180, "Udp tunnel not found") \ - _(UDP_TUNNEL_SRC_DST_TYPE, -181, "Src and dst addresses have different type (ipv4 and ipv6)") +#define foreach_hicn_error \ + _ (NONE, 0, "Ok") \ + _ (UNSPECIFIED, -128, "Unspecified Error") \ + _ (FACE_NOT_FOUND, -129, "Face not found in Face table") \ + _ (FACE_NULL, -130, "Face null") \ + _ (FACE_IP_ADJ_NOT_FOUND, -131, "Ip adjacecny for face not found") \ + _ (FACE_HW_INT_NOT_FOUND, -132, "Hardware interface not found") \ + _ (FACE_NOMEM, -133, "Face table is full") \ + _ (FACE_NO_GLOBAL_IP, -134, "No global ip address for face") \ + _ (FACE_NOT_FOUND_IN_ENTRY, -135, "Face not found in entry") \ + _ (FACE_ALREADY_DELETED, -136, "Face alredy deleted") \ + _ (FACE_ALREADY_CREATED, -137, "Face alredy created") \ + _ (FWD_NOT_ENABLED, -138, "hICN forwarder not enabled") \ + _ (FWD_ALREADY_ENABLED, -139, "hICN forwarder alredy enabled") \ + _ (PARSER_UNSUPPORTED_PROTO, -140, "Unsupported protocol") \ + _ (PARSER_PKT_INVAL, -141, "Packet null") \ + _ (PIT_CONFIG_MINLT_OOB, -142, "Min lifetime ouf of bounds") \ + _ (PIT_CONFIG_MAXLT_OOB, -143, "Max lifetime ouf of bounds") \ + _ (PIT_CONFIG_MINMAXLT, -144, "Min lifetime grater than max lifetime") \ + _ (PIT_CONFIG_DFTLT_OOB, -145, "Default lifetime ouf of bounds") \ + _ (PIT_CONFIG_SIZE_OOB, -146, "Pit size ouf of bounds") \ + _ (CS_CONFIG_SIZE_OOB, -147, "CS size ouf of bounds") \ + _ (CS_CONFIG_RESERVED_OOB, -148, \ + "Reseved CS must be between 0 and 100 (excluded)") \ + _ (DPO_CTX_NHOPS_NS, -149, "No space for additional next hop") \ + _ (DPO_CTX_NHOPS_EXISTS, -150, "Next hop already in the route") \ + _ (DPO_CTX_NOT_FOUND, -151, "Dpo context not found") \ + _ (DPO_MGR_ID_NOT_VALID, -152, "Dpo id for strategy and context not valid") \ + _ (HASHTB_HASH_NOT_FOUND, -153, "Hash not found in hash table") \ + _ (HASHTB_HASH_INVAL, -154, "Error while calculating the hash") \ + _ (HASHTB_NOMEM, -155, "Unable to allocate new buckets or nodes") \ + _ (HASHTB_INVAL, -156, "Invalid argument") \ + _ (HASHTB_KEY_INVAL, -157, "Invalid hashtb key") \ + _ (HASHTB_EXIST, -158, "Hash already in hashtable") \ + _ (ROUTE_INVAL, -159, "Invalid face id and weight") \ + _ (ROUTE_NO_LD, -160, "Expected load balance dpo") \ + _ (ROUTE_MLT_LD, -161, "Unexpected mulitple buckets in load balance dpo") \ + _ (ROUTE_NO_INSERT, -162, "Unable to insert a new FIB entry") \ + _ (ROUTE_DPO_NO_HICN, -163, "Dpo is not of type hICN") \ + _ (ROUTE_NOT_FOUND, -164, "Route not found in FIB") \ + _ (ROUTE_NOT_UPDATED, -165, "Unable to update route") \ + _ (ROUTE_ALREADY_EXISTS, -166, "Route already in FIB") \ + _ (CLI_INVAL, -167, "Invalid input") \ + _ (IPS_ADDR_TYPE_NONUNIFORM, -168, \ + "Src and dst addr have different ip types") \ + _ (FACE_TYPE_EXISTS, -169, "Face type already registered") \ + _ (NO_BUFFERS, -170, "No vlib_buffer available for packet cloning.") \ + _ (NOT_IMPLEMENTED, -171, "Function not yet implemented") \ + _ (IFACE_IP_ADJ_NOT_FOUND, -172, \ + "IP adjacency on incomplete face not available") \ + _ (APPFACE_ALREADY_ENABLED, -173, \ + "Application face already enabled on interface") \ + _ (APPFACE_FEATURE, -174, "Error while enabling app face feature") \ + _ (APPFACE_NOT_FOUND, -175, "Application face not found") \ + _ (APPFACE_PROD_PREFIX_NULL, -176, \ + "Prefix must not be null for producer face") \ + _ (STRATEGY_NH_NOT_FOUND, -177, "Next hop not found") \ + _ (MW_STRATEGY_SET, -178, "Error while setting weight for next hop") \ + _ (STRATEGY_NOT_FOUND, -179, "Strategy not found") \ + _ (UDP_TUNNEL_NOT_FOUND, -180, "Udp tunnel not found") \ + _ (UDP_TUNNEL_SRC_DST_TYPE, -181, \ + "Src and dst addresses have different type (ipv4 and ipv6)") typedef enum { -#define _(a,b,c) HICN_ERROR_##a = (b), +#define _(a, b, c) HICN_ERROR_##a = (b), foreach_hicn_error #undef _ HICN_N_ERROR, @@ -90,7 +95,9 @@ typedef enum extern const char *HICN_ERROR_STRING[]; -#define get_error_string(errno) (char *)(errno ? HICN_ERROR_STRING[(-errno) - 127] : HICN_ERROR_STRING[errno]) +#define get_error_string(errno) \ + (char *) (errno ? HICN_ERROR_STRING[(-errno) - 127] : \ + HICN_ERROR_STRING[errno]) #endif /* //__HICN_ERROR_H__ */ diff --git a/hicn-plugin/src/face_db.h b/hicn-plugin/src/face_db.h index 4dd8b2f32..1bc061721 100644 --- a/hicn-plugin/src/face_db.h +++ b/hicn-plugin/src/face_db.h @@ -22,18 +22,19 @@ /** * @file face_db.h * - * Define a face db that is store in every pit entry. A face db containes a list - * of incoming faces for interest packets that are used to forward data packets - * on the interests' reverse path + * Define a face db that is store in every pit entry. A face db containes a + * list of incoming faces for interest packets that are used to forward data + * packets on the interests' reverse path */ /* Must be power of two */ #define HICN_FACE_DB_INLINE_FACES 8 -#define HICN_PIT_BITMAP_SIZE_BYTE HICN_PARAM_FACES_MAX/8 +#define HICN_PIT_BITMAP_SIZE_BYTE HICN_PARAM_FACES_MAX / 8 #define HICN_PIT_N_HOP_BITMAP_SIZE HICN_PARAM_FACES_MAX -#define HICN_PIT_N_HOP_BUCKET (HICN_PARAM_PIT_ENTRY_PHOPS_MAX - HICN_FACE_DB_INLINE_FACES) +#define HICN_PIT_N_HOP_BUCKET \ + (HICN_PARAM_PIT_ENTRY_PHOPS_MAX - HICN_FACE_DB_INLINE_FACES) typedef struct hicn_face_bucket_s { @@ -67,18 +68,20 @@ typedef struct __attribute__ ((packed)) hicn_face_db_s /* 60B + 4B = 64B */ u32 align; - //align back to 64 + // align back to 64 } hicn_face_db_t; always_inline hicn_face_id_t -hicn_face_db_get_dpo_face (u32 index, hicn_face_db_t * face_db) +hicn_face_db_get_dpo_face (u32 index, hicn_face_db_t *face_db) { ASSERT (index < face_db->n_faces); - return index < HICN_FACE_DB_INLINE_FACES ? (face_db->inline_faces[index]) : - (pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket)->faces - [(index - HICN_FACE_DB_INLINE_FACES) & (HICN_PIT_N_HOP_BUCKET - 1)]); + return index < HICN_FACE_DB_INLINE_FACES ? + (face_db->inline_faces[index]) : + (pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket) + ->faces[(index - HICN_FACE_DB_INLINE_FACES) & + (HICN_PIT_N_HOP_BUCKET - 1)]); } always_inline void @@ -94,19 +97,18 @@ hicn_face_db_get_bucket (u32 bucket_index) } always_inline void -hicn_face_db_add_face (hicn_face_id_t face_id, hicn_face_db_t * face_db) +hicn_face_db_add_face (hicn_face_id_t face_id, hicn_face_db_t *face_db) { - //ASSERT (dpo->dpoi_index != ~0); + // ASSERT (dpo->dpoi_index != ~0); hicn_face_bucket_t *faces_bkt = pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket); hicn_face_id_t *element = - face_db->n_faces < - HICN_FACE_DB_INLINE_FACES ? &(face_db->inline_faces[face_db->n_faces]) : - &(faces_bkt->faces - [(face_db->n_faces - - HICN_FACE_DB_INLINE_FACES) & (HICN_PIT_N_HOP_BUCKET - 1)]); + face_db->n_faces < HICN_FACE_DB_INLINE_FACES ? + &(face_db->inline_faces[face_db->n_faces]) : + &(faces_bkt->faces[(face_db->n_faces - HICN_FACE_DB_INLINE_FACES) & + (HICN_PIT_N_HOP_BUCKET - 1)]); *element = face_id; @@ -119,7 +121,7 @@ hicn_face_db_add_face (hicn_face_id_t face_id, hicn_face_db_t * face_db) } always_inline u8 -hicn_face_search (hicn_face_id_t index, hicn_face_db_t * face_db) +hicn_face_search (hicn_face_id_t index, hicn_face_db_t *face_db) { hicn_face_bucket_t *faces_bkt = pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket); @@ -132,7 +134,7 @@ hicn_face_search (hicn_face_id_t index, hicn_face_db_t * face_db) } always_inline void -hicn_faces_flush (hicn_face_db_t * face_db) +hicn_faces_flush (hicn_face_db_t *face_db) { hicn_face_bucket_t *faces_bkt = pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket); @@ -141,7 +143,6 @@ hicn_faces_flush (hicn_face_db_t * face_db) pool_put_index (hicn_face_bucket_pool, face_db->next_bucket); } - #endif /* // __HICN_FACE_DB_H__ */ /* diff --git a/hicn-plugin/src/faces/app/address_mgr.c b/hicn-plugin/src/faces/app/address_mgr.c index 2d5894ab8..b5d8ce7cb 100644 --- a/hicn-plugin/src/faces/app/address_mgr.c +++ b/hicn-plugin/src/faces/app/address_mgr.c @@ -24,12 +24,12 @@ #include #include //ip4_add_del_ip_address #include //ip6_add_del_ip_address -#include //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID -#include //FIB_SOURCE_PRIORITY_HI +#include //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID +#include //FIB_SOURCE_PRIORITY_HI #include #include -#include //appif_flags -#include //vnet_sw_interface_set_flags +#include //appif_flags +#include //vnet_sw_interface_set_flags #include "address_mgr.h" #include "../../hicn.h" @@ -48,7 +48,7 @@ typedef struct address_mgr_main_s address_mgr_main_t address_mgr_main; static void -increment_v4_address (ip4_address_t * a, u32 val) +increment_v4_address (ip4_address_t *a, u32 val) { u32 v; @@ -57,7 +57,7 @@ increment_v4_address (ip4_address_t * a, u32 val) } static void -increment_v6_address (ip6_address_t * a, u64 val) +increment_v6_address (ip6_address_t *a, u64 val) { u64 v; @@ -66,7 +66,7 @@ increment_v6_address (ip6_address_t * a, u64 val) } void -get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr) +get_two_ip4_addresses (ip4_address_t *appif_addr, ip4_address_t *nh_addr) { /* We want two consecutives address that fall into a /31 mask */ if (address_mgr_main.next_ip4_local_addr.as_u8[3] & 0x01) @@ -85,20 +85,17 @@ get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr) do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, appif_addr->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, appif_addr->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); if (fib_entry_index != FIB_NODE_INDEX_INVALID) { - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); - fib_entry_index = - fib_table_lookup_exact_match (fib_index, &fib_pfx); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, nh_addr->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); + fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); } @@ -115,7 +112,7 @@ get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr) } void -get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr) +get_two_ip6_addresses (ip6_address_t *appif_addr, ip6_address_t *nh_addr) { /* We want two consecutives address that fall into a /127 mask */ @@ -126,7 +123,6 @@ get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr) increment_v6_address (&(address_mgr_main.next_ip6_local_addr), 1); *nh_addr = address_mgr_main.next_ip6_local_addr; - fib_prefix_t fib_pfx; fib_node_index_t fib_entry_index = FIB_NODE_INDEX_INVALID; u32 fib_index; @@ -140,18 +136,18 @@ get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr) do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, appif_addr->as_u8); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 1, appif_addr->as_u8); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); - //fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); + // fib_table_unlock (fib_index, fib_pfx.fp_proto, + // FIB_SOURCE_PRIORITY_HI); if (fib_entry_index != FIB_NODE_INDEX_INVALID) { - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, nh_addr->as_u8); - fib_entry_index = - fib_table_lookup_exact_match (fib_index, &fib_pfx); - // fib_table_unlock (fib_index, fib_pfx.fp_proto, - // FIB_SOURCE_PRIORITY_HI); + fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); + // fib_table_unlock (fib_index, fib_pfx.fp_proto, + // FIB_SOURCE_PRIORITY_HI); } if (fib_entry_index != FIB_NODE_INDEX_INVALID) { @@ -179,10 +175,9 @@ get_ip4_address () do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, prefix->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, prefix->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); increment_v4_address (prefix, 1); @@ -206,10 +201,9 @@ get_ip6_address () do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, prefix->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 1, prefix->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); increment_v6_address (prefix, 1); diff --git a/hicn-plugin/src/faces/app/address_mgr.h b/hicn-plugin/src/faces/app/address_mgr.h index 99450dcdd..bd834f063 100644 --- a/hicn-plugin/src/faces/app/address_mgr.h +++ b/hicn-plugin/src/faces/app/address_mgr.h @@ -25,9 +25,9 @@ * an interface. */ -#define ADDR_MGR_IP4_LEN 32 +#define ADDR_MGR_IP4_LEN 32 #define ADDR_MGR_IP4_CONS_LEN 31 -#define ADDR_MGR_IP6_LEN 128 +#define ADDR_MGR_IP6_LEN 128 #define ADDR_MGR_IP6_CONS_LEN 127 /** @@ -36,7 +36,7 @@ * @param addr1 first ip address with the least significant bit set to 0 * @param addr2 second ip address with the least significant bit set to 1 */ -void get_two_ip4_addresses (ip4_address_t * addr1, ip4_address_t * addr2); +void get_two_ip4_addresses (ip4_address_t *addr1, ip4_address_t *addr2); /** * @brief Get two consecutive IP v6 addresses from the same /126 subnet @@ -44,7 +44,7 @@ void get_two_ip4_addresses (ip4_address_t * addr1, ip4_address_t * addr2); * @param addr1 first ip address with the least significant bit set to 0 * @param addr2 second ip address with the least significant bit set to 1 */ -void get_two_ip6_addresses (ip6_address_t * addr1, ip6_address_t * addr2); +void get_two_ip6_addresses (ip6_address_t *addr1, ip6_address_t *addr2); /** * @brief Get one IP v4 address diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c index 36f8bf3f7..ccdee4450 100644 --- a/hicn-plugin/src/faces/app/face_app_cli.c +++ b/hicn-plugin/src/faces/app/face_app_cli.c @@ -114,8 +114,8 @@ hicn_face_app_cli_set_command_fn (vlib_main_t *vm, if (prod) { prefix.fp_proto = ip46_address_is_ip4 (&prefix.fp_addr) ? - FIB_PROTOCOL_IP4 : - FIB_PROTOCOL_IP6; + FIB_PROTOCOL_IP4 : + FIB_PROTOCOL_IP6; rv = hicn_face_prod_add (&prefix, sw_if, &cs_reserved, &prod_addr, &face_id1); if (rv == HICN_ERROR_NONE) @@ -175,8 +175,8 @@ hicn_face_app_cli_set_command_fn (vlib_main_t *vm, break; } return (rv == HICN_ERROR_NONE) ? - 0 : - clib_error_return (0, "%s\n", get_error_string (rv)); + 0 : + clib_error_return (0, "%s\n", get_error_string (rv)); } /* cli declaration for 'cfg face' */ diff --git a/hicn-plugin/src/faces/app/face_cons.c b/hicn-plugin/src/faces/app/face_cons.c index d44ba1a2b..53b955775 100644 --- a/hicn-plugin/src/faces/app/face_cons.c +++ b/hicn-plugin/src/faces/app/face_cons.c @@ -22,9 +22,8 @@ #include "../../infra.h" int -hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6, - u32 swif, hicn_face_id_t * faceid1, - hicn_face_id_t * faceid2) +hicn_face_cons_add (ip4_address_t *nh_addr4, ip6_address_t *nh_addr6, u32 swif, + hicn_face_id_t *faceid1, hicn_face_id_t *faceid2) { /* Create the corresponding appif if */ /* Retrieve a valid local ip address to assign to the appif */ @@ -49,32 +48,33 @@ hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6, if_flags |= VNET_SW_INTERFACE_FLAG_ADMIN_UP; vnet_sw_interface_set_flags (vnm, swif, if_flags); +#if 0 get_two_ip4_addresses (&(if_ip.ip4), nh_addr4); - ip4_add_del_interface_address (vm, - swif, - &(if_ip.ip4), - ADDR_MGR_IP4_CONS_LEN, 0 /* is_del */ ); + ip4_add_del_interface_address (vm, swif, &(if_ip.ip4), ADDR_MGR_IP4_CONS_LEN, + 0 /* is_del */); ip46_address_t nh_addr = to_ip46 (0, (u8 *) nh_addr4); - index_t adj_index = adj_nbr_find(FIB_PROTOCOL_IP4, VNET_LINK_IP4, &nh_addr, swif); + index_t adj_index = + adj_nbr_find (FIB_PROTOCOL_IP4, VNET_LINK_IP4, &nh_addr, swif); hicn_iface_add (&nh_addr, swif, faceid1, DPO_PROTO_IP4, adj_index); hicn_face_t *face = hicn_dpoi_get_from_idx (*faceid1); face->flags |= HICN_FACE_FLAGS_APPFACE_CONS; +#endif get_two_ip6_addresses (&(if_ip.ip6), nh_addr6); - ip6_add_del_interface_address (vm, - swif, - &(if_ip.ip6), - ADDR_MGR_IP6_CONS_LEN, 0 /* is_del */ ); + ip6_add_del_interface_address (vm, swif, &(if_ip.ip6), ADDR_MGR_IP6_CONS_LEN, + 0 /* is_del */); - adj_index = adj_nbr_find(FIB_PROTOCOL_IP6, VNET_LINK_IP6, &nh_addr, swif); + ip46_address_t nh_addr = to_ip46 (0, (u8 *) nh_addr6); + index_t adj_index = adj_nbr_find (FIB_PROTOCOL_IP6, VNET_LINK_IP6, &nh_addr, swif); - hicn_iface_add ((ip46_address_t *) nh_addr6, swif, faceid2, DPO_PROTO_IP6, adj_index); + hicn_iface_add ((ip46_address_t *) nh_addr6, swif, faceid2, DPO_PROTO_IP6, + adj_index); - face = hicn_dpoi_get_from_idx (*faceid2); + hicn_face_t *face = hicn_dpoi_get_from_idx (*faceid2); face->flags |= HICN_FACE_FLAGS_APPFACE_CONS; return HICN_ERROR_NONE; @@ -99,7 +99,7 @@ hicn_face_cons_del (hicn_face_id_t face_id) } u8 * -format_hicn_face_cons (u8 * s, va_list * args) +format_hicn_face_cons (u8 *s, va_list *args) { CLIB_UNUSED (index_t index) = va_arg (*args, index_t); CLIB_UNUSED (u32 indent) = va_arg (*args, u32); diff --git a/hicn-plugin/src/faces/app/face_cons.h b/hicn-plugin/src/faces/app/face_cons.h index 5f8f5dde8..3ff246f4f 100644 --- a/hicn-plugin/src/faces/app/face_cons.h +++ b/hicn-plugin/src/faces/app/face_cons.h @@ -28,8 +28,8 @@ * consumer application (co-located with the forwarder) that acts as a * consumer. The interface used by the consumer application face is * assumed to be reserved only for hICN traffic (e.g., dedicated memif that - * connects the applictation to the forwarder). Only one application face can be - * assigned to an interface. + * connects the applictation to the forwarder). Only one application face can + * be assigned to an interface. * * In the vlib graph a consumer application face directly connect the * device-input node to the hicn-vface-ip node. @@ -38,17 +38,17 @@ /** * @brief Add a new consumer application face * - * The method creates the internal ip face and set the ip address to the interface. - * @param nh_addr4 ipv4 address to assign to interface used by the application to - * send interest to the consumer face - * @param nh_addr6 ipv6 address to assign to interface used by the application to - * send interest to the consumer face + * The method creates the internal ip face and set the ip address to the + * interface. + * @param nh_addr4 ipv4 address to assign to interface used by the application + * to send interest to the consumer face + * @param nh_addr6 ipv6 address to assign to interface used by the application + * to send interest to the consumer face * @param swif interface associated to the face */ -int -hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6, - u32 swif, hicn_face_id_t * faceid1, - hicn_face_id_t * faceid2); +int hicn_face_cons_add (ip4_address_t *nh_addr4, ip6_address_t *nh_addr6, + u32 swif, hicn_face_id_t *faceid1, + hicn_face_id_t *faceid2); /** * @brief Delete an existing consumer application face @@ -64,8 +64,7 @@ int hicn_face_cons_del (hicn_face_id_t face_id); * @param args Array storing input values. Expected u32 face_id and u32 indent * @return String with the formatted face */ -u8 *format_hicn_face_cons (u8 * s, va_list * args); - +u8 *format_hicn_face_cons (u8 *s, va_list *args); #endif /* _FACE_CONSUMER_H_ */ diff --git a/hicn-plugin/src/faces/app/face_prod.h b/hicn-plugin/src/faces/app/face_prod.h index 4cb2e3fbf..4acf89dfc 100644 --- a/hicn-plugin/src/faces/app/face_prod.h +++ b/hicn-plugin/src/faces/app/face_prod.h @@ -25,12 +25,12 @@ * @brief Producer application face. * * A producer application face is built upon an ip face and identify a local - * producer application (co-located with the forwarder) that acts as a producer. In the - * current design an application face is either a face towards a consumer face - * or towards a producer. The interface used by the producer application face is - * assumed to be reserved only for hICN traffic (e.g., dedicated memif that - * connects the applictation to the forwarder). Only one application face can be - * assigned to an interface. + * producer application (co-located with the forwarder) that acts as a + * producer. In the current design an application face is either a face towards + * a consumer face or towards a producer. The interface used by the producer + * application face is assumed to be reserved only for hICN traffic (e.g., + * dedicated memif that connects the applictation to the forwarder). Only one + * application face can be assigned to an interface. * * To each producer application face it is assigned a portion of the CS. Every * data arriving to a producer application will be stored in the portion of the @@ -38,13 +38,13 @@ * face. Available eviction faces are list in the /cache_policy folder. * * In the vlib graph a producer application face is directly connected to the - * device-input node (with the node hicn-face-prod-input) and passes every packet to - * the hicn-face-ip node. + * device-input node (with the node hicn-face-prod-input) and passes every + * packet to the hicn-face-ip node. */ /** - * @brief Producer application face state that refer to the hICN producer socket - * created by the application. + * @brief Producer application face state that refer to the hICN producer + * socket created by the application. * */ typedef struct @@ -69,9 +69,8 @@ extern hicn_face_prod_state_t *face_state_vec; * @param prod_addr address to assign to interface used by the appliction to * send data to the producer face */ -int -hicn_face_prod_add (fib_prefix_t * prefix, u32 swif, u32 * cs_reserved, - ip46_address_t * prod_addr, hicn_face_id_t * faceid); +int hicn_face_prod_add (fib_prefix_t *prefix, u32 swif, u32 *cs_reserved, + ip46_address_t *prod_addr, hicn_face_id_t *faceid); /** * @brief Delete an existing application face @@ -85,7 +84,7 @@ int hicn_face_prod_del (hicn_face_id_t faceid); * * @param face_id Id of the producer application face */ -int hicn_face_prod_set_lru_max (hicn_face_id_t face_id, u32 * requested_size); +int hicn_face_prod_set_lru_max (hicn_face_id_t face_id, u32 *requested_size); /** * @brief Format an application producer face @@ -94,8 +93,7 @@ int hicn_face_prod_set_lru_max (hicn_face_id_t face_id, u32 * requested_size); * @param args Array storing input values. Expected u32 face_id and u32 indent * @return String with the formatted face */ -u8 *format_hicn_face_prod (u8 * s, va_list * args); - +u8 *format_hicn_face_prod (u8 *s, va_list *args); #endif /* _FACE_PROD_H_ */ diff --git a/hicn-plugin/src/faces/app/face_prod_node.c b/hicn-plugin/src/faces/app/face_prod_node.c index a843a01ef..c4c9edc32 100644 --- a/hicn-plugin/src/faces/app/face_prod_node.c +++ b/hicn-plugin/src/faces/app/face_prod_node.c @@ -114,7 +114,7 @@ hicn_face_prod_next_from_data_hdr (vlib_node_runtime_t *node, vlib_buffer_t *b, } return match_res ? HICN_FACE_PROD_NEXT_DATA_IP4 + (v == 0x60) : - HICN_FACE_PROD_NEXT_ERROR_DROP; + HICN_FACE_PROD_NEXT_ERROR_DROP; } static_always_inline void @@ -291,7 +291,7 @@ VLIB_REGISTER_NODE(hicn_face_prod_input_node) = [HICN_FACE_PROD_NEXT_ERROR_DROP] = "error-drop", }, }; - + /* * fd.io coding-style-patch-verification: ON * diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index 95c78b206..cb706eeca 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -25,7 +25,6 @@ #include #include - #include "../error.h" typedef u8 hicn_face_flags_t; typedef index_t hicn_face_id_t; @@ -35,38 +34,43 @@ typedef index_t hicn_face_id_t; * * This file implements a general face type. The purpose of a face is to * carry the needed information to forward interest and data packets to the - * next node in the network. There are two type of faces: complete faces (in short - * faces), and incomplete faces (in short ifaces). + * next node in the network. There are two type of faces: complete faces (in + * short faces), and incomplete faces (in short ifaces). * * A face that does not contain the indication of the adjacency is an - * incomplete face (iface), otherwise it is considered to be complete. Ifaces are - * used to forward data back to the previous hICN hop from which we received an - * interest, while faces are used to forward interest packets to the next hicn node. - * Faces and ifaces are created at two different points in time. Faces are created - * when a route is added, while ifaces are created when an interest is received. - * In details, faces and ifaces carry the following information: - * - nat_addr: the ip address to perform src nat or dst nat on interest and data packets, respectively; + * incomplete face (iface), otherwise it is considered to be complete. Ifaces + * are used to forward data back to the previous hICN hop from which we + * received an interest, while faces are used to forward interest packets to + * the next hicn node. Faces and ifaces are created at two different points in + * time. Faces are created when a route is added, while ifaces are created when + * an interest is received. In details, faces and ifaces carry the following + * information: + * - nat_addr: the ip address to perform src nat or dst nat on interest and + * data packets, respectively; * - pl_id: the path label - * - locks: the number of entities using this face. When 0 the face can be deallocated - * - dpo: the dpo that identifies the next node in the vlib graph for processing the vlib - * buffer. The dpo contains the dpo.dpoi_next field that points to the next node - * in the vlib graph and the dpo.dpoi_index which is an index to adj used by the next node - * to perform the l2 rewrite. In case of ifaces, it is likely we don't know the - * adjacency when creting the face. In this case, the next node in the vlib graph - * will be the node that performs a lookup in the fib. Only in case of udp tunnels, - * which are bidirectional tunnel we know that the incoming tunnel is also the outgoing - * one, therefore in this case we store the tunnel in the dpo.dpoi_index fields. For - * all the other tunnels (which are most likely unidirectional), the source address of - * the interest will be used to retrieve the outgoing tunnel when sending the corresponding - * data back. + * - locks: the number of entities using this face. When 0 the face can be + * deallocated + * - dpo: the dpo that identifies the next node in the vlib graph for + * processing the vlib buffer. The dpo contains the dpo.dpoi_next field that + * points to the next node in the vlib graph and the dpo.dpoi_index which is an + * index to adj used by the next node to perform the l2 rewrite. In case of + * ifaces, it is likely we don't know the adjacency when creting the face. In + * this case, the next node in the vlib graph will be the node that performs a + * lookup in the fib. Only in case of udp tunnels, which are bidirectional + * tunnel we know that the incoming tunnel is also the outgoing one, therefore + * in this case we store the tunnel in the dpo.dpoi_index fields. For all the + * other tunnels (which are most likely unidirectional), the source address of + * the interest will be used to retrieve the outgoing tunnel when sending the + * corresponding data back. * - sw_if: the incoming interface of the interest - * - fib_node, fib_entry_index and fib_sibling are information used to be notified of - * changes in the adjacency pointed by the dpo. - * - * We maintain two hash tables to retrieve faces and ifaces. In particular one hash table which - * index faces and ifaces for nat_address, sw_if and dpo. This is used to retrieve existing faces - * or ifaces when an interest is received and when an new face is created. A second hash table that - * indexes vectors of faces for nat_address and sw_if. This is used to retrieve a list of possible + * - fib_node, fib_entry_index and fib_sibling are information used to be + * notified of changes in the adjacency pointed by the dpo. + * + * We maintain two hash tables to retrieve faces and ifaces. In particular one + * hash table which index faces and ifaces for nat_address, sw_if and dpo. This + * is used to retrieve existing faces or ifaces when an interest is received + * and when an new face is created. A second hash table that indexes vectors of + * faces for nat_address and sw_if. This is used to retrieve a list of possible * incoming faces when a data is received. */ @@ -91,7 +95,8 @@ typedef struct __attribute__ ((packed)) hicn_face_s u32 locks; /* Dpo for the adjacency (8B) */ - union { + union + { dpo_id_t dpo; u64 align_dpo; }; @@ -116,71 +121,74 @@ extern hicn_face_t *hicn_dpoi_face_pool; /* A face is complete and it stores all the information. A iface lacks of the adj index, therefore sending a packet through a iface require a lookup in the FIB. */ -#define HICN_FACE_FLAGS_DEFAULT 0x00 -#define HICN_FACE_FLAGS_FACE 0x01 -#define HICN_FACE_FLAGS_IFACE 0x02 -#define HICN_FACE_FLAGS_APPFACE_PROD 0x04 /* Currently only IP face can be appface */ -#define HICN_FACE_FLAGS_APPFACE_CONS 0x08 /* Currently only IP face can be appface */ -#define HICN_FACE_FLAGS_DELETED 0x10 +#define HICN_FACE_FLAGS_DEFAULT 0x00 +#define HICN_FACE_FLAGS_FACE 0x01 +#define HICN_FACE_FLAGS_IFACE 0x02 +#define HICN_FACE_FLAGS_APPFACE_PROD \ + 0x04 /* Currently only IP face can be appface */ +#define HICN_FACE_FLAGS_APPFACE_CONS \ + 0x08 /* Currently only IP face can be appface */ +#define HICN_FACE_FLAGS_DELETED 0x10 #define HICN_FACE_NULL (hicn_face_id_t) ~0 #define HICN_FACE_FLAGS_APPFACE_PROD_BIT 2 #define HICN_FACE_FLAGS_APPFACE_CONS_BIT 3 - -#define HICN_BUFFER_FLAGS_DEFAULT 0x00 +#define HICN_BUFFER_FLAGS_DEFAULT 0x00 #define HICN_BUFFER_FLAGS_FACE_IS_APP 0x01 STATIC_ASSERT ((1 << HICN_FACE_FLAGS_APPFACE_PROD_BIT) == - HICN_FACE_FLAGS_APPFACE_PROD, - "HICN_FACE_FLAGS_APPFACE_PROD_BIT and HICN_FACE_FLAGS_APPFACE_PROD must correspond"); + HICN_FACE_FLAGS_APPFACE_PROD, + "HICN_FACE_FLAGS_APPFACE_PROD_BIT and " + "HICN_FACE_FLAGS_APPFACE_PROD must correspond"); STATIC_ASSERT ((1 << HICN_FACE_FLAGS_APPFACE_CONS_BIT) == - HICN_FACE_FLAGS_APPFACE_CONS, - "HICN_FACE_FLAGS_APPFACE_CONS_BIT and HICN_FACE_FLAGS_APPFACE_CONS must correspond"); + HICN_FACE_FLAGS_APPFACE_CONS, + "HICN_FACE_FLAGS_APPFACE_CONS_BIT and " + "HICN_FACE_FLAGS_APPFACE_CONS must correspond"); -STATIC_ASSERT ((HICN_FACE_FLAGS_APPFACE_PROD >> - HICN_FACE_FLAGS_APPFACE_PROD_BIT) == - HICN_BUFFER_FLAGS_FACE_IS_APP, - "hicn buffer app flag does not correspond to HICN_FACE_FLAGS_APPFACE_PROD"); +STATIC_ASSERT ( + (HICN_FACE_FLAGS_APPFACE_PROD >> HICN_FACE_FLAGS_APPFACE_PROD_BIT) == + HICN_BUFFER_FLAGS_FACE_IS_APP, + "hicn buffer app flag does not correspond to HICN_FACE_FLAGS_APPFACE_PROD"); -STATIC_ASSERT ((HICN_FACE_FLAGS_APPFACE_CONS >> - HICN_FACE_FLAGS_APPFACE_CONS_BIT) == - HICN_BUFFER_FLAGS_FACE_IS_APP, - "hicn buffer app flag does not correspond to HICN_FACE_FLAGS_APPFACE_PROD"); +STATIC_ASSERT ( + (HICN_FACE_FLAGS_APPFACE_CONS >> HICN_FACE_FLAGS_APPFACE_CONS_BIT) == + HICN_BUFFER_FLAGS_FACE_IS_APP, + "hicn buffer app flag does not correspond to HICN_FACE_FLAGS_APPFACE_PROD"); /** * @brief Definition of the virtual functin table for an hICN FACE DPO. */ typedef struct hicn_face_vft_s { - u8 *(*format_face) (u8 * s, va_list * args); + u8 *(*format_face) (u8 *s, va_list *args); /**< Format an hICN face dpo*/ int (*hicn_face_del) (hicn_face_id_t face_id); - void (*hicn_face_get_dpo) (hicn_face_t * face, dpo_id_t * dpo); + void (*hicn_face_get_dpo) (hicn_face_t *face, dpo_id_t *dpo); } hicn_face_vft_t; -#define foreach_hicn_face_counter \ - _(INTEREST_RX, 0, "Interest rx") \ - _(INTEREST_TX, 1, "Interest tx") \ - _(DATA_RX, 2, "Data rx") \ - _(DATA_TX, 3, "Data tx") \ +#define foreach_hicn_face_counter \ + _ (INTEREST_RX, 0, "Interest rx") \ + _ (INTEREST_TX, 1, "Interest tx") \ + _ (DATA_RX, 2, "Data rx") \ + _ (DATA_TX, 3, "Data tx") typedef enum { -#define _(a,b,c) HICN_FACE_COUNTERS_##a = (b), +#define _(a, b, c) HICN_FACE_COUNTERS_##a = (b), foreach_hicn_face_counter #undef _ - HICN_N_COUNTER + HICN_N_COUNTER } hicn_face_counters_t; extern mhash_t hicn_face_hashtb; extern const char *HICN_FACE_CTRX_STRING[]; -#define get_face_counter_string(ctrxno) (char *)(HICN_FACE_CTRX_STRING[ctrxno]) - +#define get_face_counter_string(ctrxno) \ + (char *) (HICN_FACE_CTRX_STRING[ctrxno]) /* Vector maintaining a dpo per face */ extern dpo_id_t *face_dpo_vec; @@ -205,7 +213,7 @@ extern vlib_combined_counter_main_t *counters; * @return face id */ always_inline hicn_face_id_t -hicn_dpoi_get_index (hicn_face_t * face_dpoi) +hicn_dpoi_get_index (hicn_face_t *face_dpoi) { return face_dpoi - hicn_dpoi_face_pool; } @@ -220,7 +228,7 @@ hicn_dpoi_get_index (hicn_face_t * face_dpoi) always_inline hicn_face_t * hicn_dpoi_get_from_idx_safe (hicn_face_id_t dpoi_index) { - if (!pool_is_free_index(hicn_dpoi_face_pool, dpoi_index)) + if (!pool_is_free_index (hicn_dpoi_face_pool, dpoi_index)) return (hicn_face_t *) pool_elt_at_index (hicn_dpoi_face_pool, dpoi_index); else return NULL; @@ -244,11 +252,10 @@ hicn_dpoi_get_from_idx (hicn_face_id_t dpoi_index) always_inline int hicn_dpoi_idx_is_valid (hicn_face_id_t face_id) { - return pool_len (hicn_dpoi_face_pool) > face_id - && !pool_is_free_index (hicn_dpoi_face_pool, face_id); + return pool_len (hicn_dpoi_face_pool) > face_id && + !pool_is_free_index (hicn_dpoi_face_pool, face_id); } - /** * @brief Add a lock to the face dpo * @@ -281,32 +288,31 @@ hicn_face_unlock_with_id (hicn_face_id_t face_id) * @param dpo Pointer to the face dpo */ always_inline void -hicn_face_lock (dpo_id_t * dpo) +hicn_face_lock (dpo_id_t *dpo) { - hicn_face_lock_with_id(dpo->dpoi_index); + hicn_face_lock_with_id (dpo->dpoi_index); } /** - * @brief Remove a lock to the face through its dpo. Deallocate the face id locks == 0 + * @brief Remove a lock to the face through its dpo. Deallocate the face id + * locks == 0 * * @param dpo Pointer to the face dpo */ always_inline void -hicn_face_unlock (dpo_id_t * dpo) +hicn_face_unlock (dpo_id_t *dpo) { hicn_face_unlock_with_id (dpo->dpoi_index); } - /** * @brief Init the internal structures of the face module * * Must be called before processing any packet */ -void hicn_face_module_init (vlib_main_t * vm); - -u8 * format_hicn_face (u8 * s, va_list * args); +void hicn_face_module_init (vlib_main_t *vm); +u8 *format_hicn_face (u8 *s, va_list *args); /** * @brief Format all the existing faces @@ -315,7 +321,7 @@ u8 * format_hicn_face (u8 * s, va_list * args); * @param n Number of input parameters * @return String with the faces formatted */ -u8 *format_hicn_face_all (u8 * s, int n, ...); +u8 *format_hicn_face_all (u8 *s, int n, ...); /** * @brief Delete a face @@ -337,9 +343,12 @@ typedef struct hicn_input_faces_s_ /* Vector of all possible input faces */ u32 vec_id; - /* Preferred face. If an prod_app face is in the vector it will be the preferred one. */ - /* It's not possible to have multiple prod_app face in the same vector, they would have */ - /* the same local address. Every prod_app face is a point-to-point face between the forwarder */ + /* Preferred face. If an prod_app face is in the vector it will be the + * preferred one. */ + /* It's not possible to have multiple prod_app face in the same vector, they + * would have */ + /* the same local address. Every prod_app face is a point-to-point face + * between the forwarder */ /* and the application. */ hicn_face_id_t face_id; @@ -356,15 +365,14 @@ extern hicn_face_vec_t *hicn_vec_pool; */ extern mhash_t hicn_face_vec_hashtb; - /** * Key definition for the mhash table. An face is uniquely identified by ip - * address, the interface id and a dpo pointing to the next node in the vlib graph. - * The ip address can correspond to the remote ip address of the next hicn hop, - * or to the local address of the receiving interface. The former is used to - * retrieve the incoming face when an interest is received, the latter when - * the arring packet is a data. If the face is a regular face - * In case of iface, the following structure can be filled in different ways: + * address, the interface id and a dpo pointing to the next node in the vlib + * graph. The ip address can correspond to the remote ip address of the next + * hicn hop, or to the local address of the receiving interface. The former is + * used to retrieve the incoming face when an interest is received, the latter + * when the arring packet is a data. If the face is a regular face In case of + * iface, the following structure can be filled in different ways: * - dpo equal to DPO_INVALID when the iface is a regular hICN iface * - in case of udp_tunnel dpo = * { @@ -380,7 +388,8 @@ extern mhash_t hicn_face_vec_hashtb; typedef struct __attribute__ ((packed)) hicn_face_key_s { ip46_address_t addr; - union { + union + { dpo_id_t dpo; u64 align_dpo; }; @@ -396,8 +405,8 @@ typedef struct __attribute__ ((packed)) hicn_face_key_s * @param key Pointer to an allocated hicn_face_ip_key_t object */ always_inline void -hicn_face_get_key (const ip46_address_t * addr, - u32 sw_if, const dpo_id_t * dpo, hicn_face_key_t * key) +hicn_face_get_key (const ip46_address_t *addr, u32 sw_if, const dpo_id_t *dpo, + hicn_face_key_t *key) { key->dpo = *dpo; key->addr = *addr; @@ -408,13 +417,15 @@ hicn_face_get_key (const ip46_address_t * addr, * @brief Get the face obj from the nat address. Does not add any lock. * * @param addr Ip v4 address used to create the key for the hash table. - * @param sw_if Software interface id used to create the key for the hash table. + * @param sw_if Software interface id used to create the key for the hash + * table. * @param hashtb Hash table (remote or local) where to perform the lookup. * * @result Pointer to the face. */ always_inline hicn_face_t * -hicn_face_get (const ip46_address_t * addr, u32 sw_if, mhash_t * hashtb, index_t adj_index) +hicn_face_get (const ip46_address_t *addr, u32 sw_if, mhash_t *hashtb, + index_t adj_index) { hicn_face_key_t key; @@ -424,12 +435,11 @@ hicn_face_get (const ip46_address_t * addr, u32 sw_if, mhash_t * hashtb, index_t hicn_face_get_key (addr, sw_if, &dpo, &key); - hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb, - &key); + hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb, &key); - if ( dpoi_index != NULL) + if (dpoi_index != NULL) { - hicn_face_lock_with_id(*dpoi_index); + hicn_face_lock_with_id (*dpoi_index); return hicn_dpoi_get_from_idx (*dpoi_index); } @@ -437,27 +447,29 @@ hicn_face_get (const ip46_address_t * addr, u32 sw_if, mhash_t * hashtb, index_t } /** - * @brief Get the face obj from the nat address and the dpo. Does not add any lock. + * @brief Get the face obj from the nat address and the dpo. Does not add any + * lock. * * @param addr Ip v4 address used to create the key for the hash table. - * @param sw_if Software interface id used to create the key for the hash table. + * @param sw_if Software interface id used to create the key for the hash + * table. * @param hashtb Hash table (remote or local) where to perform the lookup. * * @result Pointer to the face. */ always_inline hicn_face_t * -hicn_face_get_with_dpo (const ip46_address_t * addr, u32 sw_if, const dpo_id_t * dpo, mhash_t * hashtb) +hicn_face_get_with_dpo (const ip46_address_t *addr, u32 sw_if, + const dpo_id_t *dpo, mhash_t *hashtb) { hicn_face_key_t key; hicn_face_get_key (addr, sw_if, dpo, &key); - hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb, - &key); + hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb, &key); - if ( dpoi_index != NULL) + if (dpoi_index != NULL) { - hicn_face_lock_with_id(*dpoi_index); + hicn_face_lock_with_id (*dpoi_index); return hicn_dpoi_get_from_idx (*dpoi_index); } @@ -465,17 +477,18 @@ hicn_face_get_with_dpo (const ip46_address_t * addr, u32 sw_if, const dpo_id_t * } /** - * @brief Get the vector of faces from the ip v4 address. Does not add any lock. + * @brief Get the vector of faces from the ip v4 address. Does not add any + * lock. * * @param addr Ip v4 address used to create the key for the hash table. - * @param sw_if Software interface id used to create the key for the hash table. + * @param sw_if Software interface id used to create the key for the hash + * table. * @param hashtb Hash table (remote or local) where to perform the lookup. * * @result Pointer to the face. */ always_inline hicn_face_input_faces_t * -hicn_face_get_vec (const ip46_address_t * addr, - mhash_t * hashtb) +hicn_face_get_vec (const ip46_address_t *addr, mhash_t *hashtb) { hicn_face_key_t key; @@ -493,15 +506,13 @@ hicn_face_get_vec (const ip46_address_t * addr, * @param nat_addr nat ip v4 or v6 address of the face * @param sw_if interface associated to the face * @param pfaceid Pointer to return the face id - * @param is_app_prod if HICN_FACE_FLAGS_APPFACE_PROD the face is a local application face, all other values are ignored + * @param is_app_prod if HICN_FACE_FLAGS_APPFACE_PROD the face is a local + * application face, all other values are ignored * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally * reachable ip address, otherwise HICN_ERROR_NONE */ -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); +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); /** * @brief Create a new incomplete face ip. (Meant to be used by the data plane) @@ -514,15 +525,13 @@ int hicn_face_add (const dpo_id_t * dpo_nh, * reachable ip address, otherwise HICN_ERROR_NONE */ always_inline void -hicn_iface_add (ip46_address_t * nat_address, int sw_if, - hicn_face_id_t * pfaceid, dpo_proto_t proto, - u32 adj_index) +hicn_iface_add (ip46_address_t *nat_address, int sw_if, + hicn_face_id_t *pfaceid, dpo_proto_t proto, u32 adj_index) { hicn_face_t *face; pool_get (hicn_dpoi_face_pool, face); - clib_memcpy (&(face->nat_addr), nat_address, - sizeof (ip46_address_t)); + clib_memcpy (&(face->nat_addr), nat_address, sizeof (ip46_address_t)); face->sw_if = sw_if; face->dpo.dpoi_type = DPO_FIRST; @@ -547,27 +556,29 @@ hicn_iface_add (ip46_address_t * nat_address, int sw_if, } } -/**** Helpers to manipulate faces and ifaces from the face/iface input nodes ****/ +/**** Helpers to manipulate faces and ifaces from the face/iface input nodes + * ****/ /** - * @brief Retrieve a vector of faces from the ip4 local address and returns its index. + * @brief Retrieve a vector of faces from the ip4 local address and returns its + * index. * - * @param vec: Result of the lookup. If no face exists for the local address vec = NULL + * @param vec: Result of the lookup. If no face exists for the local address + * vec = NULL * @param hicnb_flags: Flags that indicate whether the face is an application * face or not * @param local_addr: Ip v4 nat address of the face * @param sw_if: software interface id of the face * - * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE. + * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise + * HICN_ERROR_NONE. */ always_inline int -hicn_face_ip4_lock (hicn_face_id_t * face_id, - u32 * in_faces_vec_id, - u8 * hicnb_flags, - const ip4_address_t * nat_addr) +hicn_face_ip4_lock (hicn_face_id_t *face_id, u32 *in_faces_vec_id, + u8 *hicnb_flags, const ip4_address_t *nat_addr) { - ip46_address_t ip_address = {0}; - ip46_address_set_ip4(&ip_address, nat_addr); + ip46_address_t ip_address = { 0 }; + ip46_address_set_ip4 (&ip_address, nat_addr); hicn_face_input_faces_t *in_faces_vec = hicn_face_get_vec (&ip_address, &hicn_face_vec_hashtb); @@ -578,9 +589,8 @@ hicn_face_ip4_lock (hicn_face_id_t * face_id, hicn_face_t *face = hicn_dpoi_get_from_idx (in_faces_vec->face_id); *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *hicnb_flags |= - (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> - HICN_FACE_FLAGS_APPFACE_PROD_BIT; + *hicnb_flags |= (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> + HICN_FACE_FLAGS_APPFACE_PROD_BIT; *face_id = in_faces_vec->face_id; @@ -597,16 +607,15 @@ hicn_face_ip4_lock (hicn_face_id_t * face_id, * @param nat_addr: Ip v6 nat address of the face * @param sw_if: software interface id of the face * - * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE. + * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise + * HICN_ERROR_NONE. */ always_inline int -hicn_face_ip6_lock (hicn_face_id_t * face_id, - u32 * in_faces_vec_id, - u8 * hicnb_flags, - const ip6_address_t * nat_addr) +hicn_face_ip6_lock (hicn_face_id_t *face_id, u32 *in_faces_vec_id, + u8 *hicnb_flags, const ip6_address_t *nat_addr) { hicn_face_input_faces_t *in_faces_vec = - hicn_face_get_vec ((ip46_address_t *)nat_addr, &hicn_face_vec_hashtb); + hicn_face_get_vec ((ip46_address_t *) nat_addr, &hicn_face_vec_hashtb); if (PREDICT_FALSE (in_faces_vec == NULL)) return HICN_ERROR_FACE_NOT_FOUND; @@ -615,9 +624,8 @@ hicn_face_ip6_lock (hicn_face_id_t * face_id, hicn_face_t *face = hicn_dpoi_get_from_idx (in_faces_vec->face_id); *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *hicnb_flags |= - (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> - HICN_FACE_FLAGS_APPFACE_PROD_BIT; + *hicnb_flags |= (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> + HICN_FACE_FLAGS_APPFACE_PROD_BIT; *face_id = in_faces_vec->face_id; @@ -628,14 +636,13 @@ hicn_face_ip6_lock (hicn_face_id_t * face_id, * @brief Call back to get the adj of the tunnel */ static adj_walk_rc_t -hicn4_iface_adj_walk_cb (adj_index_t ai, - void *ctx) +hicn4_iface_adj_walk_cb (adj_index_t ai, void *ctx) { - hicn_face_t *face = (hicn_face_t *)ctx; + hicn_face_t *face = (hicn_face_t *) ctx; - dpo_set(&face->dpo, DPO_ADJACENCY_MIDCHAIN, DPO_PROTO_IP4, ai); - adj_nbr_midchain_stack(ai, &face->dpo); + dpo_set (&face->dpo, DPO_ADJACENCY_MIDCHAIN, DPO_PROTO_IP4, ai); + adj_nbr_midchain_stack (ai, &face->dpo); return (ADJ_WALK_RC_CONTINUE); } @@ -652,15 +659,14 @@ hicn4_iface_adj_walk_cb (adj_index_t ai, * @param node_index: vlib edge index to use in the packet processing */ always_inline void -hicn_iface_ip4_add_and_lock (hicn_face_id_t * index, - u8 * hicnb_flags, - const ip4_address_t * nat_addr, - u32 sw_if, u32 adj_index, u32 node_index) +hicn_iface_ip4_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, + const ip4_address_t *nat_addr, u32 sw_if, + u32 adj_index, u32 node_index) { /*All (complete) faces are indexed by remote addess as well */ - ip46_address_t ip_address = {0}; - ip46_address_set_ip4(&ip_address, nat_addr); + ip46_address_t ip_address = { 0 }; + ip46_address_set_ip4 (&ip_address, nat_addr); /* if the face exists, it adds a lock */ hicn_face_t *face = @@ -671,7 +677,7 @@ hicn_iface_ip4_add_and_lock (hicn_face_id_t * index, hicn_face_id_t idx; hicn_iface_add (&ip_address, sw_if, &idx, DPO_PROTO_IP4, adj_index); - face = hicn_dpoi_get_from_idx(idx); + face = hicn_dpoi_get_from_idx (idx); face->dpo.dpoi_type = DPO_FIRST; face->dpo.dpoi_proto = DPO_PROTO_IP4; @@ -680,11 +686,9 @@ hicn_iface_ip4_add_and_lock (hicn_face_id_t * index, /* if (nat_addr->as_u32 == 0) */ /* { */ - adj_nbr_walk(face->sw_if, - FIB_PROTOCOL_IP4, - hicn4_iface_adj_walk_cb, - face); - /* } */ + adj_nbr_walk (face->sw_if, FIB_PROTOCOL_IP4, hicn4_iface_adj_walk_cb, + face); + /* } */ *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; @@ -694,15 +698,14 @@ hicn_iface_ip4_add_and_lock (hicn_face_id_t * index, else { /* unlock the face. We don't take a lock on each interest we receive */ - hicn_face_id_t face_id = hicn_dpoi_get_index(face); - hicn_face_unlock_with_id(face_id); + hicn_face_id_t face_id = hicn_dpoi_get_index (face); + hicn_face_unlock_with_id (face_id); } /* Code replicated on purpose */ *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *hicnb_flags |= - (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> - HICN_FACE_FLAGS_APPFACE_PROD_BIT; + *hicnb_flags |= (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> + HICN_FACE_FLAGS_APPFACE_PROD_BIT; *index = hicn_dpoi_get_index (face); } @@ -711,24 +714,22 @@ hicn_iface_ip4_add_and_lock (hicn_face_id_t * index, * @brief Call back to get the adj of the tunnel */ static adj_walk_rc_t -hicn6_iface_adj_walk_cb (adj_index_t ai, - void *ctx) +hicn6_iface_adj_walk_cb (adj_index_t ai, void *ctx) { - hicn_face_t *face = (hicn_face_t *)ctx; + hicn_face_t *face = (hicn_face_t *) ctx; - ip_adjacency_t *adj = adj_get(ai); + ip_adjacency_t *adj = adj_get (ai); if ((adj->lookup_next_index == IP_LOOKUP_NEXT_MIDCHAIN) || (adj->lookup_next_index == IP_LOOKUP_NEXT_MCAST_MIDCHAIN)) { - dpo_set(&face->dpo, DPO_ADJACENCY_MIDCHAIN, adj->ia_nh_proto, ai); - adj_nbr_midchain_stack(ai, &face->dpo); + dpo_set (&face->dpo, DPO_ADJACENCY_MIDCHAIN, adj->ia_nh_proto, ai); + adj_nbr_midchain_stack (ai, &face->dpo); } return (ADJ_WALK_RC_CONTINUE); } - /** * @brief Retrieve, or create if it doesn't exist, a face from the ip6 local * address and returns its dpo. This method adds a lock on the face state. @@ -741,32 +742,30 @@ hicn6_iface_adj_walk_cb (adj_index_t ai, * @param node_index: vlib edge index to use in the packet processing */ always_inline void -hicn_iface_ip6_add_and_lock (hicn_face_id_t * index, - u8 * hicnb_flags, - const ip6_address_t * nat_addr, - u32 sw_if, u32 adj_index, u32 node_index) +hicn_iface_ip6_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, + const ip6_address_t *nat_addr, u32 sw_if, + u32 adj_index, u32 node_index) { /*All (complete) faces are indexed by remote addess as well */ /* if the face exists, it adds a lock */ - hicn_face_t *face = - hicn_face_get ((ip46_address_t *)nat_addr, sw_if, &hicn_face_hashtb, adj_index); + hicn_face_t *face = hicn_face_get ((ip46_address_t *) nat_addr, sw_if, + &hicn_face_hashtb, adj_index); if (face == NULL) { hicn_face_id_t idx; - hicn_iface_add ((ip46_address_t *) nat_addr, sw_if, &idx, DPO_PROTO_IP6, adj_index); + hicn_iface_add ((ip46_address_t *) nat_addr, sw_if, &idx, DPO_PROTO_IP6, + adj_index); - face = hicn_dpoi_get_from_idx(idx); + face = hicn_dpoi_get_from_idx (idx); face->dpo.dpoi_type = DPO_FIRST; face->dpo.dpoi_proto = DPO_PROTO_IP6; face->dpo.dpoi_index = adj_index; face->dpo.dpoi_next_node = node_index; - adj_nbr_walk(face->sw_if, - FIB_PROTOCOL_IP6, - hicn6_iface_adj_walk_cb, - face); + adj_nbr_walk (face->sw_if, FIB_PROTOCOL_IP6, hicn6_iface_adj_walk_cb, + face); *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; @@ -777,15 +776,14 @@ hicn_iface_ip6_add_and_lock (hicn_face_id_t * index, else { /* unlock the face. We don't take a lock on each interest we receive */ - hicn_face_id_t face_id = hicn_dpoi_get_index(face); - hicn_face_unlock_with_id(face_id); + hicn_face_id_t face_id = hicn_dpoi_get_index (face); + hicn_face_unlock_with_id (face_id); } /* Code replicated on purpose */ *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; - *hicnb_flags |= - (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> - HICN_FACE_FLAGS_APPFACE_PROD_BIT; + *hicnb_flags |= (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >> + HICN_FACE_FLAGS_APPFACE_PROD_BIT; *index = hicn_dpoi_get_index (face); } diff --git a/hicn-plugin/src/faces/face_node.h b/hicn-plugin/src/faces/face_node.h index f5a8bf5ae..3b38e71b3 100644 --- a/hicn-plugin/src/faces/face_node.h +++ b/hicn-plugin/src/faces/face_node.h @@ -31,9 +31,9 @@ * The following node to the input face nodes is the hicn-data-pcslookup. * Output face nodes follow the strategy and the hicn-interest-hitpit nodes and * they perform the src nat on each interest packet. The node following the - * output face nodes depends on the adjacency type. In case of ip, the following - * node is the ip-rewrite, in case of tunnels the next node is the one implementing - * the tunnel encapsulation (udp-encap, mpls, etc). + * output face nodes depends on the adjacency type. In case of ip, the + * following node is the ip-rewrite, in case of tunnels the next node is the + * one implementing the tunnel encapsulation (udp-encap, mpls, etc). */ extern vlib_node_registration_t hicn4_face_input_node; diff --git a/hicn-plugin/src/faces/iface_node.c b/hicn-plugin/src/faces/iface_node.c index 82c0f75b2..bf9c56515 100644 --- a/hicn-plugin/src/faces/iface_node.c +++ b/hicn-plugin/src/faces/iface_node.c @@ -538,8 +538,8 @@ hicn_rewrite_iface_data4 (vlib_main_t *vm, vlib_buffer_t *b0, u8 flags = hicn_get_buffer (b0)->flags; u8 reset_pl = flags & HICN_BUFFER_FLAGS_FROM_CS; int ret = hicn_ops_vft[type.l1]->rewrite_data ( - type, &hicn->protocol, &(iface->nat_addr), &(temp_addr), - iface->pl_id, reset_pl); + type, &hicn->protocol, &(iface->nat_addr), &(temp_addr), iface->pl_id, + reset_pl); if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED) { ensure_offload_flags (b0, 1 /* is_v4 */); @@ -573,8 +573,8 @@ hicn_rewrite_iface_data6 (vlib_main_t *vm, vlib_buffer_t *b0, u8 flags = hicn_get_buffer (b0)->flags; u8 reset_pl = flags & HICN_BUFFER_FLAGS_FROM_CS; int ret = hicn_ops_vft[type.l1]->rewrite_data ( - type, &hicn->protocol, &(iface->nat_addr), &(temp_addr), - iface->pl_id, reset_pl); + type, &hicn->protocol, &(iface->nat_addr), &(temp_addr), iface->pl_id, + reset_pl); if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED) { diff --git a/hicn-plugin/src/faces/iface_node.h b/hicn-plugin/src/faces/iface_node.h index 1a7c4291b..acb3cab0f 100644 --- a/hicn-plugin/src/faces/iface_node.h +++ b/hicn-plugin/src/faces/iface_node.h @@ -30,18 +30,17 @@ * is to create (or retrieve if already existing) the list incoming face * for each the interest packet. * The following node to the input iface nodes is the hicn-interest-pcslookup. - * Output iface nodes follow the hicn-data-fwd and the hicn-interest-hitcs nodes and - * they perform the dst nat on each data packet. The node following the - * output face nodes depends on the adjacency type. In case of ip, the following - * node is the ip4/6-lookup, in case of tunnels the next node is the one implementing - * the tunnel encapsulation (udp-encap, mpls, etc). + * Output iface nodes follow the hicn-data-fwd and the hicn-interest-hitcs + * nodes and they perform the dst nat on each data packet. The node following + * the output face nodes depends on the adjacency type. In case of ip, the + * following node is the ip4/6-lookup, in case of tunnels the next node is the + * one implementing the tunnel encapsulation (udp-encap, mpls, etc). */ - /** * @brief Initialize the ip iface module */ -void hicn_iface_init (vlib_main_t * vm); +void hicn_iface_init (vlib_main_t *vm); #endif // __HICN_IFACE_IP_NODE_H__ diff --git a/hicn-plugin/src/faces/inlines.h b/hicn-plugin/src/faces/inlines.h index bfe56c8e6..95a1c2ad2 100644 --- a/hicn-plugin/src/faces/inlines.h +++ b/hicn-plugin/src/faces/inlines.h @@ -19,23 +19,25 @@ #include always_inline void -ensure_offload_flags (vlib_buffer_t * b, int is_v4) +ensure_offload_flags (vlib_buffer_t *b, int is_v4) { - b->flags |= VNET_BUFFER_F_OFFLOAD_TCP_CKSUM; - b->flags |= is_v4 * VNET_BUFFER_F_OFFLOAD_IP_CKSUM; - size_t l3_header_size = is_v4 * sizeof(ip4_header_t) + (!is_v4) * sizeof(ip6_header_t); + vnet_buffer_offload_flags_set(b, VNET_BUFFER_OFFLOAD_F_TCP_CKSUM); + vnet_buffer_offload_flags_set(b, is_v4 * VNET_BUFFER_OFFLOAD_F_IP_CKSUM); + + size_t l3_header_size = + is_v4 * sizeof (ip4_header_t) + (!is_v4) * sizeof (ip6_header_t); /* Make sure l3_hdr_offset and l4_hdr_offset are set */ if (!(b->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID)) { b->flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID; - vnet_buffer(b)->l3_hdr_offset = b->current_data; + vnet_buffer (b)->l3_hdr_offset = b->current_data; } if (!(b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)) { b->flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID; - vnet_buffer(b)->l4_hdr_offset = - vnet_buffer(b)->l3_hdr_offset + l3_header_size; + vnet_buffer (b)->l4_hdr_offset = + vnet_buffer (b)->l3_hdr_offset + l3_header_size; } } diff --git a/hicn-plugin/src/hashtb.c b/hicn-plugin/src/hashtb.c index 6deddbd84..a74353239 100644 --- a/hicn-plugin/src/hashtb.c +++ b/hicn-plugin/src/hashtb.c @@ -27,11 +27,11 @@ #include "error.h" /* return dvd/dvr, rounded up (intended for integer values) */ -#define CEIL(dvd, dvr) \ - ({ \ - __typeof__ (dvd) _dvd = (dvd); \ - __typeof__ (dvr) _dvr = (dvr); \ - (_dvd + _dvr - 1)/_dvr; \ +#define CEIL(dvd, dvr) \ + ({ \ + __typeof__ (dvd) _dvd = (dvd); \ + __typeof__ (dvr) _dvr = (dvr); \ + (_dvd + _dvr - 1) / _dvr; \ }) #ifndef ALIGN8 @@ -39,7 +39,7 @@ #endif #ifndef ALIGNPTR8 -#define ALIGNPTR8(p) ((void *)(((u8 * )(p) + 0x7) & ~(0x7))) +#define ALIGNPTR8(p) ((void *) (((u8 *) (p) + 0x7) & ~(0x7))) #endif #ifndef ALIGN64 @@ -54,7 +54,6 @@ #define FALSE 0 #endif - /* * Offset to aligned start of additional data (PIT/CS, FIB) embedded in each * node. @@ -62,8 +61,8 @@ u32 ht_node_data_offset_aligned; /* Some support for posix vs vpp mem management */ -#define MEM_ALLOC(x) clib_mem_alloc_aligned((x), 8) -#define MEM_FREE(p) clib_mem_free((p)) +#define MEM_ALLOC(x) clib_mem_alloc_aligned ((x), 8) +#define MEM_FREE(p) clib_mem_free ((p)) /* * Internal utilities @@ -89,7 +88,7 @@ alloc_overflow_bucket (hicn_hashtb_h h) /* Free an overflow bucket; clear caller's pointer */ static void -free_overflow_bucket (hicn_hashtb_h h, hicn_hash_bucket_t ** pb) +free_overflow_bucket (hicn_hashtb_h h, hicn_hash_bucket_t **pb) { hicn_hash_bucket_t *bkt = *pb; @@ -104,7 +103,7 @@ free_overflow_bucket (hicn_hashtb_h h, hicn_hash_bucket_t ** pb) * Init, allocate a new hashtable */ int -hicn_hashtb_alloc (hicn_hashtb_h * ph, u32 max_elems, size_t app_data_size) +hicn_hashtb_alloc (hicn_hashtb_h *ph, u32 max_elems, size_t app_data_size) { int ret = HICN_ERROR_NONE; hicn_hashtb_h h = NULL; @@ -164,15 +163,17 @@ hicn_hashtb_alloc (hicn_hashtb_h * ph, u32 max_elems, size_t app_data_size) count = STRUCT_OFFSET_OF (hicn_hash_node_t, hn_data); ht_node_data_offset_aligned = ALIGN8 (count); } - //check app struct fits into space provided(HICN_HASH_NODE_APP_DATA_SIZE) + // check app struct fits into space provided(HICN_HASH_NODE_APP_DATA_SIZE) u32 ht_node_data_size; ht_node_data_size = sizeof (hicn_hash_node_t) - ht_node_data_offset_aligned; if (app_data_size > ht_node_data_size) { - clib_error - ("hicn hashtable: fatal error: requested app data size(%u) > hashtb node's configured bytes available(%u), sizeof(hicn_shared_t)=%u, sizeof(hicn_pit_entry_t)=%u, sizeof(hicn_cs_entry_t)=%u", - app_data_size, ht_node_data_size, sizeof (hicn_pcs_shared_t), - sizeof (hicn_pit_entry_t), sizeof (hicn_cs_entry_t)); + clib_error ( + "hicn hashtable: fatal error: requested app data size(%u) > hashtb " + "node's configured bytes available(%u), sizeof(hicn_shared_t)=%u, " + "sizeof(hicn_pit_entry_t)=%u, sizeof(hicn_cs_entry_t)=%u", + app_data_size, ht_node_data_size, sizeof (hicn_pcs_shared_t), + sizeof (hicn_pit_entry_t), sizeof (hicn_cs_entry_t)); } /* * Compute entry node count and size, allocate Allocate/'Hide' the @@ -185,8 +186,8 @@ hicn_hashtb_alloc (hicn_hashtb_h * ph, u32 max_elems, size_t app_data_size) goto done; } pool_get_aligned (h->ht_nodes, nodep, 8); - //alloc node 0 - nodep = nodep; /* Silence 'not used' warning */ + // alloc node 0 + nodep = nodep; /* Silence 'not used' warning */ h->ht_node_count = max_elems; h->ht_nodes_used = 1; @@ -194,7 +195,7 @@ hicn_hashtb_alloc (hicn_hashtb_h * ph, u32 max_elems, size_t app_data_size) /* * Compute overflow bucket count and size, allocate */ - //count = ALIGN8(CEIL(max_elems, HICN_HASHTB_OVERFLOW_FRACTION)); + // count = ALIGN8(CEIL(max_elems, HICN_HASHTB_OVERFLOW_FRACTION)); count = ALIGN8 (total_buckets - h->ht_bucket_count); pool_alloc_aligned (h->ht_overflow_buckets, count, 8); @@ -205,7 +206,7 @@ hicn_hashtb_alloc (hicn_hashtb_h * ph, u32 max_elems, size_t app_data_size) } /* 'Hide' the zero-th node so we can use zero as an 'empty' value */ pool_get_aligned (h->ht_overflow_buckets, bucket, 8); - bucket = bucket; /* Silence 'not used' warning */ + bucket = bucket; /* Silence 'not used' warning */ h->ht_overflow_bucket_count = count; h->ht_overflow_buckets_used = 1; @@ -230,7 +231,7 @@ done: * Free, de-allocate a hashtable */ int -hicn_hashtb_free (hicn_hashtb_h * ph) +hicn_hashtb_free (hicn_hashtb_h *ph) { int ret = 0; @@ -258,8 +259,6 @@ hicn_hashtb_free (hicn_hashtb_h * ph) return (ret); } - - /* * Basic api to lookup a specific hash+key tuple. This does the entire lookup * operation, retrieving node structs and comparing keys, so it's not @@ -268,17 +267,15 @@ hicn_hashtb_free (hicn_hashtb_h * ph) * Returns zero and mails back a node on success, errno otherwise. */ int -hicn_hashtb_lookup_node (hicn_hashtb_h h, const u8 * key, - u32 keylen, u64 hashval, u8 is_data, - u32 * node_id, index_t * dpo_ctx_id, u8 * vft_id, - u8 * is_cs, u8 * hash_entry_id, u32 * bucket_id, - u8 * bucket_is_overflow) +hicn_hashtb_lookup_node (hicn_hashtb_h h, const u8 *key, u32 keylen, + u64 hashval, u8 is_data, u32 *node_id, + index_t *dpo_ctx_id, u8 *vft_id, u8 *is_cs, + u8 *hash_entry_id, u32 *bucket_id, + u8 *bucket_is_overflow) { - return (hicn_hashtb_lookup_node_ex - (h, key, keylen, hashval, is_data, FALSE /* deleted nodes */ , - node_id, - dpo_ctx_id, vft_id, is_cs, hash_entry_id, bucket_id, - bucket_is_overflow)); + return (hicn_hashtb_lookup_node_ex ( + h, key, keylen, hashval, is_data, FALSE /* deleted nodes */, node_id, + dpo_ctx_id, vft_id, is_cs, hash_entry_id, bucket_id, bucket_is_overflow)); } /* @@ -292,12 +289,11 @@ hicn_hashtb_lookup_node (hicn_hashtb_h h, const u8 * key, * Returns zero and mails back a node on success, errno otherwise. */ int -hicn_hashtb_lookup_node_ex (hicn_hashtb_h h, const u8 * key, - u32 keylen, u64 hashval, u8 is_data, - int include_deleted_p, u32 * node_id, - index_t * dpo_ctx_id, u8 * vft_id, u8 * is_cs, - u8 * hash_entry_id, u32 * bucket_id, - u8 * bucket_is_overflow) +hicn_hashtb_lookup_node_ex (hicn_hashtb_h h, const u8 *key, u32 keylen, + u64 hashval, u8 is_data, int include_deleted_p, + u32 *node_id, index_t *dpo_ctx_id, u8 *vft_id, + u8 *is_cs, u8 *hash_entry_id, u32 *bucket_id, + u8 *bucket_is_overflow) { int i, ret = HICN_ERROR_HASHTB_HASH_NOT_FOUND; int found_p = FALSE; @@ -383,7 +379,7 @@ done: * return 1 if equals, 0 otherwise */ int -hicn_node_compare (const u8 * key, u32 keylen, hicn_hash_node_t * node) +hicn_node_compare (const u8 *key, u32 keylen, hicn_hash_node_t *node) { int ret = 0; @@ -400,8 +396,8 @@ hicn_node_compare (const u8 * key, u32 keylen, hicn_hash_node_t * node) * new a node+hash, and to clear out an entry during removal. */ void -hicn_hashtb_init_entry (hicn_hash_entry_t * entry, u32 nodeidx, - u64 hashval, u32 locks) +hicn_hashtb_init_entry (hicn_hash_entry_t *entry, u32 nodeidx, u64 hashval, + u32 locks) { entry->he_msb64 = hashval; entry->he_node = nodeidx; @@ -420,12 +416,10 @@ hicn_hashtb_init_entry (hicn_hash_entry_t * entry, u32 nodeidx, */ int -hicn_hashtb_insert (hicn_hashtb_h h, hicn_hash_node_t * node, - hicn_hash_entry_t ** hash_entry, u64 hash, - u32 * node_id, - index_t * dpo_ctx_id, u8 * vft_id, u8 * is_cs, - u8 * hash_entry_id, u32 * bucket_id, - u8 * bucket_is_overflow) +hicn_hashtb_insert (hicn_hashtb_h h, hicn_hash_node_t *node, + hicn_hash_entry_t **hash_entry, u64 hash, u32 *node_id, + index_t *dpo_ctx_id, u8 *vft_id, u8 *is_cs, + u8 *hash_entry_id, u32 *bucket_id, u8 *bucket_is_overflow) { int i, ret = HICN_ERROR_HASHTB_INVAL; u32 bidx; @@ -532,7 +526,6 @@ loop_buckets: bucket = pool_elt_at_index (h->ht_overflow_buckets, current_bucket_id); is_overflow = 1; goto loop_buckets; - } else { @@ -560,8 +553,8 @@ loop_buckets: * expect these to be properly aligned so they can be * treated as int. */ - memcpy (&(newbkt->hb_entries[0]), - &(bucket->hb_entries[i]), sizeof (hicn_hash_entry_t)); + memcpy (&(newbkt->hb_entries[0]), &(bucket->hb_entries[i]), + sizeof (hicn_hash_entry_t)); /* Update bucket id and entry_idx on the hash node */ hicn_hash_node_t *node = @@ -569,7 +562,6 @@ loop_buckets: node->bucket_id = (newbkt - h->ht_overflow_buckets); node->entry_idx = 0; node->hn_flags |= HICN_HASH_NODE_OVERFLOW_BUCKET; - } /* * Connect original bucket to the index of the new overflow @@ -625,13 +617,12 @@ done: * node. Caller's pointer is cleared on success. */ void -hicn_hashtb_delete (hicn_hashtb_h h, hicn_hash_node_t ** pnode, u64 hashval) +hicn_hashtb_delete (hicn_hashtb_h h, hicn_hash_node_t **pnode, u64 hashval) { hicn_hashtb_remove_node (h, *pnode, hashval); hicn_hashtb_free_node (h, *pnode); *pnode = NULL; - } /* @@ -640,8 +631,7 @@ hicn_hashtb_delete (hicn_hashtb_h h, hicn_hash_node_t ** pnode, u64 hashval) * node, the bucket is freed as well. */ void -hicn_hashtb_remove_node (hicn_hashtb_h h, hicn_hash_node_t * node, - u64 hashval) +hicn_hashtb_remove_node (hicn_hashtb_h h, hicn_hash_node_t *node, u64 hashval) { int i, count; u32 bidx, overflow_p; @@ -702,7 +692,7 @@ hicn_hashtb_remove_node (hicn_hashtb_h h, hicn_hash_node_t * node, if (i == (HICN_HASHTB_BUCKET_ENTRIES - 1) && (bucket->hb_entries[i].he_flags & HICN_HASH_ENTRY_FLAG_OVERFLOW)) { - count--; /* Doesn't count as a 'real' entry */ + count--; /* Doesn't count as a 'real' entry */ overflow_p = TRUE; } } @@ -747,9 +737,9 @@ hicn_hashtb_remove_node (hicn_hashtb_h h, hicn_hash_node_t * node, * Just clear the predecessor entry pointing * at 'bucket' */ - hicn_hashtb_init_entry (&parent->hb_entries - [(HICN_HASHTB_BUCKET_ENTRIES - 1)], 0, - 0LL, 0); + hicn_hashtb_init_entry ( + &parent->hb_entries[(HICN_HASHTB_BUCKET_ENTRIES - 1)], 0, 0LL, + 0); } break; @@ -775,8 +765,8 @@ done: * Prepare a hashtable node, supplying the key, and computed hash info. */ void -hicn_hashtb_init_node (hicn_hashtb_h h, hicn_hash_node_t * node, - const u8 * key, u32 keylen) +hicn_hashtb_init_node (hicn_hashtb_h h, hicn_hash_node_t *node, const u8 *key, + u32 keylen) { assert (h != NULL); assert (node != NULL); @@ -795,21 +785,20 @@ hicn_hashtb_init_node (hicn_hashtb_h h, hicn_hash_node_t * node, * Release a hashtable node back to the free list when an entry is cleared */ void -hicn_hashtb_free_node (hicn_hashtb_h h, hicn_hash_node_t * node) +hicn_hashtb_free_node (hicn_hashtb_h h, hicn_hash_node_t *node) { ASSERT (h->ht_nodes_used > 0); /* Return 'node' to the free list */ pool_put (h->ht_nodes, node); h->ht_nodes_used--; - } /* * Walk a hashtable, iterating through the nodes, keeping context in 'ctx'. */ int -hicn_hashtb_next_node (hicn_hashtb_h h, hicn_hash_node_t ** pnode, u64 * ctx) +hicn_hashtb_next_node (hicn_hashtb_h h, hicn_hash_node_t **pnode, u64 *ctx) { int i, j, ret = HICN_ERROR_HASHTB_INVAL; u32 bidx, entry; @@ -929,8 +918,8 @@ search_table: { /* Retrieve the node struct */ - *pnode = pool_elt_at_index (h->ht_nodes, - bucket->hb_entries[i].he_node); + *pnode = + pool_elt_at_index (h->ht_nodes, bucket->hb_entries[i].he_node); /* * Set 'entry' as we exit, so we can update the @@ -996,8 +985,8 @@ done: } int -hicn_hashtb_key_to_buf (u8 ** vec_res, hicn_hashtb_h h, - const hicn_hash_node_t * node) +hicn_hashtb_key_to_buf (u8 **vec_res, hicn_hashtb_h h, + const hicn_hash_node_t *node) { int ret = HICN_ERROR_NONE; u8 *vec = *vec_res; diff --git a/hicn-plugin/src/hashtb.h b/hicn-plugin/src/hashtb.h index 3c72fda65..3965ec65d 100644 --- a/hicn-plugin/src/hashtb.h +++ b/hicn-plugin/src/hashtb.h @@ -31,8 +31,8 @@ * names. Note that the intel cache line size is 64 bytes, and some platforms * load in 2 cache lines together. * - first step is to match a record at the bucket/slot level (htab has an - * array of htbucket_t/htbc_elmt, where each bucket has 7 slots to hold indices - * for entries.) Matching at this level implies + * array of htbucket_t/htbc_elmt, where each bucket has 7 slots to hold + * indices for entries.) Matching at this level implies * - the hashes of the lookup name and the record map to the same bucket * - the high 32 bits of the hashes (slot bce_hash_msb32s) match. Read * cost (on the hash table size, i.e. ignoring reading the name being @@ -44,15 +44,18 @@ * number of buckets) that more than 7 elements hash to the same bucket, * lookup may well need to look not only at the static htbc_elmt_t but at * the chain of dynamically allocated htbc_elmt_t's linked to the static - * htbc_elmt_t, where each of these holds slot entries for additional elements. + * htbc_elmt_t, where each of these holds slot entries for additional + * elements. * - Before reaching that point, it is initially required to read in the * hash table record fields (ht_bucket_buf, htnode buf, etc) holding - * pointers to the arrays, but these cache lines are common to all lookups - * so will likely already be in the cache. + * pointers to the arrays, but these cache lines are common to all + * lookups so will likely already be in the cache. * - second step is to match at the record level (htnode/htkb level) once a - * slot-level match happens. Matching at this level implies the following match + * slot-level match happens. Matching at this level implies the following + * match * - the hash values (the full 64 bits vs. bucket+32 msb, above). - * - the name which, on the hash table side, is stored as a list of htkb_t (key buffers). + * - the name which, on the hash table side, is stored as a list of htkb_t + * (key buffers). * * Some hashtables (for which rare false positives are tolerable) store hash * values but no keys. (In ISM NDN forwarder, this was used for dcm_dpf: data @@ -70,13 +73,13 @@ #define FALSE 0 #endif -#define HICN_HASH_INVALID_IDX ~0 +#define HICN_HASH_INVALID_IDX ~0 /* * for hicn_hashtb_next_node() iterator, this otherwise illegal context value * indicates first call of iteration. Note: must not be 0, which is a legal * context value. */ -#define HICN_HASH_WALK_CTX_INITIAL (~((u64)0)) +#define HICN_HASH_WALK_CTX_INITIAL (~((u64) 0)) /* * Key memory allocation scheme. @@ -98,17 +101,16 @@ */ /* Compute hash node index from node pointer */ -#define NODE_IDX_FROM_NODE(p, h) \ - (u32)((p) - ((h)->ht_nodes)) +#define NODE_IDX_FROM_NODE(p, h) (u32) ((p) - ((h)->ht_nodes)) -#define HICN_HASH_KEY_BYTES 20 +#define HICN_HASH_KEY_BYTES 20 typedef struct { struct { u8 key[HICN_HASH_KEY_BYTES]; - } ks; /* Entire key in one block */ + } ks; /* Entire key in one block */ } hicn_hash_key_t; /* @@ -123,7 +125,8 @@ typedef struct * of keys. * * The memory block for a node includes space for storing outgoing faces for - * interests, additional memory located off the end of the htnode data structure. + * interests, additional memory located off the end of the htnode data + * structure. * */ @@ -147,11 +150,11 @@ typedef struct __attribute__ ((packed)) hicn_hash_node_s /* 1 byte of flags for application use */ u8 hn_flags; - u8 _hn_reserved1; /* TBD, to align what follows back to - * 32 */ + u8 _hn_reserved1; /* TBD, to align what follows back to + * 32 */ - hicn_hash_key_t hn_key; /* Key value embedded in the node, may chain - * to more key buffers if necessary */ + hicn_hash_key_t hn_key; /* Key value embedded in the node, may chain + * to more key buffers if necessary */ /* 32B + HICN_HASH_NODE_APP_DATA_SIZE */ /* Followed by app-specific data (fib or pit or cs entry, e.g.) */ @@ -159,9 +162,9 @@ typedef struct __attribute__ ((packed)) hicn_hash_node_s } hicn_hash_node_t; -#define HICN_HASH_NODE_FLAGS_DEFAULT 0x00 -#define HICN_HASH_NODE_CS_FLAGS 0x01 -#define HICN_HASH_NODE_OVERFLOW_BUCKET 0x02 +#define HICN_HASH_NODE_FLAGS_DEFAULT 0x00 +#define HICN_HASH_NODE_CS_FLAGS 0x01 +#define HICN_HASH_NODE_OVERFLOW_BUCKET 0x02 /* * hicn_hash_entry_t Structure holding all or part of a hash value, a node @@ -198,25 +201,24 @@ typedef struct __attribute__ ((packed)) hicn_hash_entry_s */ u8 vft_id; -} hicn_hash_entry_t; //size 22B +} hicn_hash_entry_t; // size 22B STATIC_ASSERT (sizeof (index_t) <= 4, "sizeof index_t is greater than 4B"); - -#define HICN_HASH_ENTRY_FLAGS_DEFAULT 0x00 +#define HICN_HASH_ENTRY_FLAGS_DEFAULT 0x00 /* If entry is PIT this flag is 0 */ -#define HICN_HASH_ENTRY_FLAG_CS_ENTRY 0x01 +#define HICN_HASH_ENTRY_FLAG_CS_ENTRY 0x01 /* * This entry heads a chain of overflow buckets (we expect to see this only * in the last entry in a bucket.) In this case, the index is to an overflow * bucket rather than to a single node block. */ -#define HICN_HASH_ENTRY_FLAG_OVERFLOW 0x04 +#define HICN_HASH_ENTRY_FLAG_OVERFLOW 0x04 /* This entry has been marked for deletion */ -#define HICN_HASH_ENTRY_FLAG_DELETED 0x08 +#define HICN_HASH_ENTRY_FLAG_DELETED 0x08 /* Use fast he_timeout units for expiration, slow if not */ #define HICN_HASH_ENTRY_FLAG_FAST_TIMEOUT 0x10 @@ -242,10 +244,10 @@ typedef struct __attribute__ ((packed)) } hicn_hash_bucket_t; /* Overall target fill-factor for the hashtable */ -#define HICN_HASHTB_FILL_FACTOR 4 +#define HICN_HASHTB_FILL_FACTOR 4 -#define HICN_HASHTB_MIN_ENTRIES (1 << 4) // includes dummy node 0 entry -#define HICN_HASHTB_MAX_ENTRIES (1 << 24) +#define HICN_HASHTB_MIN_ENTRIES (1 << 4) // includes dummy node 0 entry +#define HICN_HASHTB_MAX_ENTRIES (1 << 24) #define HICN_HASHTB_MIN_BUCKETS (1 << 10) @@ -298,7 +300,7 @@ extern u32 ht_node_data_offset_aligned; /* Flags for hashtable */ -#define HICN_HASHTB_FLAGS_DEFAULT 0x00 +#define HICN_HASHTB_FLAGS_DEFAULT 0x00 /* * Don't use the last entry in each bucket - only use it for overflow. We use @@ -306,9 +308,9 @@ extern u32 ht_node_data_offset_aligned; * that would be difficult if there were hash entry copies as part of * overflow handling. */ -#define HICN_HASHTB_FLAG_USE_SEVEN 0x04 -#define HICN_HASHTB_FLAG_KEY_FMT_PFX 0x08 -#define HICN_HASHTB_FLAG_KEY_FMT_NAME 0x10 +#define HICN_HASHTB_FLAG_USE_SEVEN 0x04 +#define HICN_HASHTB_FLAG_KEY_FMT_PFX 0x08 +#define HICN_HASHTB_FLAG_KEY_FMT_NAME 0x10 /* * Max prefix name components we'll support in our incremental hashing; @@ -322,7 +324,7 @@ extern u32 ht_node_data_offset_aligned; /* Compute hash node index from node pointer */ static inline u32 -hicn_hashtb_node_idx_from_node (hicn_hashtb_h h, hicn_hash_node_t * p) +hicn_hashtb_node_idx_from_node (hicn_hashtb_h h, hicn_hash_node_t *p) { return (p - h->ht_nodes); } @@ -335,14 +337,13 @@ hicn_hashtb_node_from_idx (hicn_hashtb_h h, u32 idx) } /* Allocate a brand-new hashtable */ -int -hicn_hashtb_alloc (hicn_hashtb_h * ph, u32 max_elems, size_t app_data_size); +int hicn_hashtb_alloc (hicn_hashtb_h *ph, u32 max_elems, size_t app_data_size); /* Free a hashtable, including its embedded arrays */ -int hicn_hashtb_free (hicn_hashtb_h * ph); +int hicn_hashtb_free (hicn_hashtb_h *ph); /* Hash a bytestring, currently using bihash */ -u64 hicn_hashtb_hash_bytestring (const u8 * key, u32 keylen); +u64 hicn_hashtb_hash_bytestring (const u8 *key, u32 keylen); always_inline hicn_hash_entry_t * hicn_hashtb_get_entry (hicn_hashtb_h h, u32 entry_idx, u32 bucket_id, @@ -359,7 +360,7 @@ hicn_hashtb_get_entry (hicn_hashtb_h h, u32 entry_idx, u32 bucket_id, /* Hash a name, currently using bihash */ always_inline u64 -hicn_hashtb_hash_name (const u8 * key, u16 keylen) +hicn_hashtb_hash_name (const u8 *key, u16 keylen) { if (key != NULL && keylen == HICN_V4_NAME_LEN) { @@ -381,28 +382,24 @@ hicn_hashtb_hash_name (const u8 * key, u16 keylen) } } - /* * Prepare a hashtable node for insertion, supplying the key and computed * hash info. This sets up the node->key relationship, possibly allocating * overflow key buffers. */ -void -hicn_hashtb_init_node (hicn_hashtb_h h, hicn_hash_node_t * node, - const u8 * key, u32 keylen); +void hicn_hashtb_init_node (hicn_hashtb_h h, hicn_hash_node_t *node, + const u8 *key, u32 keylen); /* * Insert a node into the hashtable. We expect the caller has used the init * api to set the node key and hash info, and populated the extra data area * (if any) - or done the equivalent work itself. */ -int -hicn_hashtb_insert (hicn_hashtb_h h, hicn_hash_node_t * node, - hicn_hash_entry_t ** hash_entry, u64 hash, - u32 * node_id, - index_t * dpo_ctx_id, u8 * vft_id, u8 * is_cs, - u8 * hash_entry_id, u32 * bucket_id, - u8 * bucket_is_overflow); +int hicn_hashtb_insert (hicn_hashtb_h h, hicn_hash_node_t *node, + hicn_hash_entry_t **hash_entry, u64 hash, u32 *node_id, + index_t *dpo_ctx_id, u8 *vft_id, u8 *is_cs, + u8 *hash_entry_id, u32 *bucket_id, + u8 *bucket_is_overflow); /* * Basic api to lookup a specific hash+key tuple. This does the entire lookup @@ -411,12 +408,11 @@ hicn_hashtb_insert (hicn_hashtb_h h, hicn_hash_node_t * node, * * Returns zero and mails back a node on success, errno otherwise. */ -int -hicn_hashtb_lookup_node (hicn_hashtb_h h, const u8 * key, - u32 keylen, u64 hashval, u8 is_data, - u32 * node_id, index_t * dpo_ctx_id, u8 * vft_id, - u8 * is_cs, u8 * hash_entry_id, u32 * bucket_id, - u8 * bucket_is_overflow); +int hicn_hashtb_lookup_node (hicn_hashtb_h h, const u8 *key, u32 keylen, + u64 hashval, u8 is_data, u32 *node_id, + index_t *dpo_ctx_id, u8 *vft_id, u8 *is_cs, + u8 *hash_entry_id, u32 *bucket_id, + u8 *bucket_is_overflow); /* * Extended api to lookup a specific hash+key tuple. The implementation @@ -428,13 +424,11 @@ hicn_hashtb_lookup_node (hicn_hashtb_h h, const u8 * key, * * Returns zero and mails back a node on success, errno otherwise. */ -int -hicn_hashtb_lookup_node_ex (hicn_hashtb_h h, const u8 * key, - u32 keylen, u64 hashval, u8 is_data, - int include_deleted_p, u32 * node_id, - index_t * dpo_ctx_id, u8 * vft_id, u8 * is_cs, - u8 * hash_entry_id, u32 * bucket_id, - u8 * bucket_is_overflow); +int hicn_hashtb_lookup_node_ex (hicn_hashtb_h h, const u8 *key, u32 keylen, + u64 hashval, u8 is_data, int include_deleted_p, + u32 *node_id, index_t *dpo_ctx_id, u8 *vft_id, + u8 *is_cs, u8 *hash_entry_id, u32 *bucket_id, + u8 *bucket_is_overflow); /** * @brief Compares the key in the node with the given key @@ -443,31 +437,29 @@ hicn_hashtb_lookup_node_ex (hicn_hashtb_h h, const u8 * key, * the entire key. Useful to exploit prefertching. * @result 1 if equals, 0 otherwise */ -int hicn_node_compare (const u8 * key, u32 keylen, hicn_hash_node_t * node); +int hicn_node_compare (const u8 *key, u32 keylen, hicn_hash_node_t *node); /* * Remove a node from a hashtable using the node itself. The internal data * structs are cleaned up, but the node struct itself is not: the caller must * free the node itself. */ -void hicn_hashtb_remove_node (hicn_hashtb_h h, hicn_hash_node_t * node, +void hicn_hashtb_remove_node (hicn_hashtb_h h, hicn_hash_node_t *node, u64 hashval); /* * Delete a node from a hashtable using the node itself, and delete/free the * node. Caller's pointer is cleared on success. */ -void hicn_hashtb_delete (hicn_hashtb_h h, hicn_hash_node_t ** pnode, +void hicn_hashtb_delete (hicn_hashtb_h h, hicn_hash_node_t **pnode, u64 hashval); /* * Utility to init a new entry in a hashtable bucket/row. We use this to add * new a node+hash, and to clear out an entry during removal. */ -void -hicn_hashtb_init_entry (hicn_hash_entry_t * entry, - u32 nodeidx, u64 hashval, u32 locks); - +void hicn_hashtb_init_entry (hicn_hash_entry_t *entry, u32 nodeidx, + u64 hashval, u32 locks); /* * Return data area embedded in a hash node struct. We maintain an 'offset' @@ -475,7 +467,7 @@ hicn_hashtb_init_entry (hicn_hash_entry_t * entry, * aligned properly. */ static inline void * -hicn_hashtb_node_data (hicn_hash_node_t * node) +hicn_hashtb_node_data (hicn_hash_node_t *node) { return ((u8 *) (node) + ht_node_data_offset_aligned); } @@ -510,7 +502,7 @@ hicn_hashtb_alloc_node (hicn_hashtb_h h) /* * Release a hashtable node back to the free list when an entry is cleared */ -void hicn_hashtb_free_node (hicn_hashtb_h h, hicn_hash_node_t * node); +void hicn_hashtb_free_node (hicn_hashtb_h h, hicn_hash_node_t *node); /* * Walk a hashtable, iterating through the nodes, keeping context in 'ctx' @@ -518,20 +510,18 @@ void hicn_hashtb_free_node (hicn_hashtb_h h, hicn_hash_node_t * node); * * Set the context value to HICN_HASH_WALK_CTX_INITIAL to start an iteration. */ -int -hicn_hashtb_next_node (hicn_hashtb_h h, hicn_hash_node_t ** pnode, u64 * ctx); - +int hicn_hashtb_next_node (hicn_hashtb_h h, hicn_hash_node_t **pnode, + u64 *ctx); -int -hicn_hashtb_key_to_str (hicn_hashtb_h h, const hicn_hash_node_t * node, - char *buf, int bufsize, int must_fit); +int hicn_hashtb_key_to_str (hicn_hashtb_h h, const hicn_hash_node_t *node, + char *buf, int bufsize, int must_fit); /* * single hash full name can pass offset for two hashes calculation in case * we use CS and PIT in a two steps hashes (prefix + seqno) */ always_inline int -hicn_hashtb_fullhash (const u8 * name, u16 namelen, u64 * name_hash) +hicn_hashtb_fullhash (const u8 *name, u16 namelen, u64 *name_hash) { *name_hash = hicn_hashtb_hash_name (name, namelen); return (*name_hash != (-1LL) ? HICN_ERROR_NONE : HICN_ERROR_HASHTB_INVAL); diff --git a/hicn-plugin/src/hicn.c b/hicn-plugin/src/hicn.c index f66514dbf..9bec91455 100644 --- a/hicn-plugin/src/hicn.c +++ b/hicn-plugin/src/hicn.c @@ -149,8 +149,8 @@ hicn_infra_plugin_enable_disable (int enable_disable, int pit_size_req, // check if CS is bugger tha PIT or bigger than the available // vlib_buffers uword cs_buffers = (n_buffers > HICN_PARAM_CS_MIN_MBUF) ? - n_buffers - HICN_PARAM_CS_MIN_MBUF : - 0; + n_buffers - HICN_PARAM_CS_MIN_MBUF : + 0; if (cs_size_req > (pit_size_req / 2) || cs_size_req > cs_buffers) { diff --git a/hicn-plugin/src/hicn.h b/hicn-plugin/src/hicn.h index 437f91144..4ff4f6ae6 100644 --- a/hicn-plugin/src/hicn.h +++ b/hicn-plugin/src/hicn.h @@ -16,10 +16,10 @@ #ifndef __HICN_H__ #define __HICN_H__ -#define ip_address_t hicn_ip_address_t +#define ip_address_t hicn_ip_address_t #define ip_address_cmp hicn_ip_address_cmp -#define ip_prefix_t hicn_ip_prefix_t -#define ip_prefix_cmp hicn_ip_prefix_cmp +#define ip_prefix_t hicn_ip_prefix_t +#define ip_prefix_cmp hicn_ip_prefix_cmp #undef ip_prefix_len #define ip_prefix_len hicn_ip_prefix_len #include @@ -43,10 +43,6 @@ * @file */ -/* Helper for avoiding warnings about type-punning */ -#define UNION_CAST(x, destType) \ - (((union {__typeof__(x) a; destType b;})x).b) - /* * Update CMakeLists.txt as we have to manually replace the type for * vppapigen @@ -54,18 +50,21 @@ typedef u8 weight_t; #define ISV6(isv6, dov6, dov4) isv6 ? dov6 : dov4 -#define HICN_IS_NAMEHASH_CACHED(b) (((u64)(b->opaque2)[0] != 0) || ((u64)(b->opaque2)[1] != 0)) +#define HICN_IS_NAMEHASH_CACHED(b) \ + (((u64) (b->opaque2)[0] != 0) || ((u64) (b->opaque2)[1] != 0)) #ifndef VLIB_BUFFER_MIN_CHAIN_SEG_SIZE #define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE (128) #endif -/* vlib_buffer cloning utilities impose that current_lentgh is more that 2*CLIB_CACHE_LINE_BYTES. */ -/* This flag is used to mark packets whose lenght is less that 2*CLIB_CACHE_LINE_BYTES. */ -#define HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL 0x02 +/* vlib_buffer cloning utilities impose that current_lentgh is more that + * 2*CLIB_CACHE_LINE_BYTES. */ +/* This flag is used to mark packets whose lenght is less that + * 2*CLIB_CACHE_LINE_BYTES. */ +#define HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL 0x02 #define HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL 0x04 #define HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL 0x08 -#define HICN_BUFFER_FLAGS_FROM_CS 0x10 +#define HICN_BUFFER_FLAGS_FROM_CS 0x10 /* The following is stored in the opaque2 field in the vlib_buffer_t */ typedef struct @@ -80,35 +79,33 @@ typedef struct u8 hash_bucket_flags; u8 flags; - u8 dpo_ctx_id; /* used for data path */ - u8 vft_id; /* " */ + u8 dpo_ctx_id; /* used for data path */ + u8 vft_id; /* " */ - hicn_face_id_t face_id; /* ingress iface, sizeof(u32) */ - u32 in_faces_vec_id; /* vector of possible input face for a data packet */ + hicn_face_id_t face_id; /* ingress iface, sizeof(u32) */ + u32 in_faces_vec_id; /* vector of possible input face for a data packet */ hicn_type_t type; } hicn_buffer_t; STATIC_ASSERT (sizeof (hicn_buffer_t) <= - STRUCT_SIZE_OF (vlib_buffer_t, opaque2), + STRUCT_SIZE_OF (vlib_buffer_t, opaque2), "hICN buffer opaque2 meta-data too large for vlib_buffer"); - always_inline hicn_buffer_t * -hicn_get_buffer (vlib_buffer_t * b0) +hicn_get_buffer (vlib_buffer_t *b0) { - return (hicn_buffer_t *) & (b0->opaque2[0]); + return (hicn_buffer_t *) &(b0->opaque2[0]); } always_inline u8 -hicn_is_v6 (hicn_header_t * pkt_hdr) +hicn_is_v6 (hicn_header_t *pkt_hdr) { return ((pkt_hdr->v4.ip.version_ihl >> 4) != 4); } #endif /* __HICN_H__ */ - /* * fd.io coding-style-patch-verification: ON * diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c index f26af1e82..b72675f63 100644 --- a/hicn-plugin/src/hicn_api.c +++ b/hicn-plugin/src/hicn_api.c @@ -79,8 +79,8 @@ vl_api_hicn_api_node_params_set_t_handler ( 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 / SEC_MS : - pit_max_lifetime_sec; + 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; diff --git a/hicn-plugin/src/hicn_api.h b/hicn-plugin/src/hicn_api.h index ec10a6bbd..e32b785b6 100644 --- a/hicn-plugin/src/hicn_api.h +++ b/hicn-plugin/src/hicn_api.h @@ -20,9 +20,8 @@ * @file */ - #define HICN_STRATEGY_NULL ~0 -#define HICN_FIB_TABLE 10 +#define HICN_FIB_TABLE 10 /* define message structures */ #define vl_typedefs diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c index e4704e8ea..04e216e38 100644 --- a/hicn-plugin/src/hicn_api_test.c +++ b/hicn-plugin/src/hicn_api_test.c @@ -34,13 +34,12 @@ #include #include "error.h" - /* Declare message IDs */ #include "hicn_msg_enum.h" /* SUPPORTING FUNCTIONS NOT LOADED BY VPP_API_TEST */ uword -unformat_ip46_address (unformat_input_t * input, va_list * args) +unformat_ip46_address (unformat_input_t *input, va_list *args) { ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); ip46_type_t type = va_arg (*args, ip46_type_t); @@ -59,8 +58,8 @@ unformat_ip46_address (unformat_input_t * input, va_list * args) } static ip46_type_t -ip_address_union_decode (const vl_api_address_union_t * in, - vl_api_address_family_t af, ip46_address_t * out) +ip_address_union_decode (const vl_api_address_union_t *in, + vl_api_address_family_t af, ip46_address_t *out) { ip46_type_t type; @@ -85,33 +84,32 @@ ip_address_union_decode (const vl_api_address_union_t * in, } void -ip6_address_encode (const ip6_address_t * in, vl_api_ip6_address_t out) +ip6_address_encode (const ip6_address_t *in, vl_api_ip6_address_t out) { clib_memcpy (out, in, sizeof (*in)); } void -ip6_address_decode (const vl_api_ip6_address_t in, ip6_address_t * out) +ip6_address_decode (const vl_api_ip6_address_t in, ip6_address_t *out) { clib_memcpy (out, in, sizeof (*out)); } void -ip4_address_encode (const ip4_address_t * in, vl_api_ip4_address_t out) +ip4_address_encode (const ip4_address_t *in, vl_api_ip4_address_t out) { clib_memcpy (out, in, sizeof (*in)); } void -ip4_address_decode (const vl_api_ip4_address_t in, ip4_address_t * out) +ip4_address_decode (const vl_api_ip4_address_t in, ip4_address_t *out) { clib_memcpy (out, in, sizeof (*out)); } static void -ip_address_union_encode (const ip46_address_t * in, - vl_api_address_family_t af, - vl_api_address_union_t * out) +ip_address_union_encode (const ip46_address_t *in, vl_api_address_family_t af, + vl_api_address_union_t *out) { if (ADDRESS_IP6 == clib_net_to_host_u32 (af)) ip6_address_encode (&in->ip6, out->ip6); @@ -120,14 +118,14 @@ ip_address_union_encode (const ip46_address_t * in, } ip46_type_t -ip_address_decode (const vl_api_address_t * in, ip46_address_t * out) +ip_address_decode (const vl_api_address_t *in, ip46_address_t *out) { return (ip_address_union_decode (&in->un, in->af, out)); } void -ip_address_encode (const ip46_address_t * in, ip46_type_t type, - vl_api_address_t * out) +ip_address_encode (const ip46_address_t *in, ip46_type_t type, + vl_api_address_t *out) { switch (type) { @@ -182,7 +180,7 @@ fib_proto_to_ip46 (fib_protocol_t fproto) } void -ip_prefix_decode (const vl_api_prefix_t * in, fib_prefix_t * out) +ip_prefix_decode (const vl_api_prefix_t *in, fib_prefix_t *out) { switch (clib_net_to_host_u32 (in->address.af)) { @@ -199,11 +197,11 @@ ip_prefix_decode (const vl_api_prefix_t * in, fib_prefix_t * out) } void -ip_prefix_encode (const fib_prefix_t * in, vl_api_prefix_t * out) +ip_prefix_encode (const fib_prefix_t *in, vl_api_prefix_t *out) { out->len = in->fp_len; - ip_address_encode (&in->fp_addr, - fib_proto_to_ip46 (in->fp_proto), &out->address); + ip_address_encode (&in->fp_addr, fib_proto_to_ip46 (in->fp_proto), + &out->address); } ///////////////////////////////////////////////////// @@ -220,24 +218,26 @@ typedef struct hicn_test_main_t hicn_test_main; -#define foreach_standard_reply_retval_handler \ -_(hicn_api_node_params_set_reply) \ -_(hicn_api_enable_disable_reply) - -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = hicn_test_main.vat_main; \ - i32 retval = ntohl(mp->retval); \ - if (vam->async_mode) { \ - vam->async_errors += (retval < 0); \ - } else { \ - fformat (vam->ofp,"%s\n", get_error_string(retval));\ - vam->retval = retval; \ - vam->result_ready = 1; \ - } \ - } +#define foreach_standard_reply_retval_handler \ + _ (hicn_api_node_params_set_reply) \ + _ (hicn_api_enable_disable_reply) + +#define _(n) \ + static void vl_api_##n##_t_handler (vl_api_##n##_t *mp) \ + { \ + vat_main_t *vam = hicn_test_main.vat_main; \ + i32 retval = ntohl (mp->retval); \ + if (vam->async_mode) \ + { \ + vam->async_errors += (retval < 0); \ + } \ + else \ + { \ + fformat (vam->ofp, "%s\n", get_error_string (retval)); \ + vam->retval = retval; \ + vam->result_ready = 1; \ + } \ + } foreach_standard_reply_retval_handler; #undef _ @@ -245,23 +245,23 @@ foreach_standard_reply_retval_handler; * Table of message reply handlers, must include boilerplate handlers we just * generated */ -#define foreach_vpe_api_reply_msg \ -_(HICN_API_NODE_PARAMS_SET_REPLY, hicn_api_node_params_set_reply) \ -_(HICN_API_NODE_PARAMS_GET_REPLY, hicn_api_node_params_get_reply) \ -_(HICN_API_NODE_STATS_GET_REPLY, hicn_api_node_stats_get_reply) \ -_(HICN_API_FACE_GET_REPLY, hicn_api_face_get_reply) \ -_(HICN_API_FACES_DETAILS, hicn_api_faces_details) \ -_(HICN_API_FACE_STATS_DETAILS, hicn_api_face_stats_details) \ -_(HICN_API_FACE_PARAMS_GET_REPLY, hicn_api_face_params_get_reply) \ -_(HICN_API_ROUTE_GET_REPLY, hicn_api_route_get_reply) \ -_(HICN_API_ROUTES_DETAILS, hicn_api_routes_details) \ -_(HICN_API_STRATEGIES_GET_REPLY, hicn_api_strategies_get_reply) \ -_(HICN_API_STRATEGY_GET_REPLY, hicn_api_strategy_get_reply) \ -_(HICN_API_ENABLE_DISABLE_REPLY, hicn_api_enable_disable_reply) \ -_(HICN_API_UDP_TUNNEL_ADD_DEL_REPLY, hicn_api_udp_tunnel_add_del_reply) +#define foreach_vpe_api_reply_msg \ + _ (HICN_API_NODE_PARAMS_SET_REPLY, hicn_api_node_params_set_reply) \ + _ (HICN_API_NODE_PARAMS_GET_REPLY, hicn_api_node_params_get_reply) \ + _ (HICN_API_NODE_STATS_GET_REPLY, hicn_api_node_stats_get_reply) \ + _ (HICN_API_FACE_GET_REPLY, hicn_api_face_get_reply) \ + _ (HICN_API_FACES_DETAILS, hicn_api_faces_details) \ + _ (HICN_API_FACE_STATS_DETAILS, hicn_api_face_stats_details) \ + _ (HICN_API_FACE_PARAMS_GET_REPLY, hicn_api_face_params_get_reply) \ + _ (HICN_API_ROUTE_GET_REPLY, hicn_api_route_get_reply) \ + _ (HICN_API_ROUTES_DETAILS, hicn_api_routes_details) \ + _ (HICN_API_STRATEGIES_GET_REPLY, hicn_api_strategies_get_reply) \ + _ (HICN_API_STRATEGY_GET_REPLY, hicn_api_strategy_get_reply) \ + _ (HICN_API_ENABLE_DISABLE_REPLY, hicn_api_enable_disable_reply) \ + _ (HICN_API_UDP_TUNNEL_ADD_DEL_REPLY, hicn_api_udp_tunnel_add_del_reply) static int -api_hicn_api_node_params_set (vat_main_t * vam) +api_hicn_api_node_params_set (vat_main_t *vam) { unformat_input_t *input = vam->input; int enable_disable = 1; @@ -279,13 +279,16 @@ api_hicn_api_node_params_set (vat_main_t * vam) enable_disable = 0; } else if (unformat (input, "PIT size %d", &pit_size)) - {; + { + ; } else if (unformat (input, "CS size %d", &cs_size)) - {; + { + ; } else if (unformat (input, "PIT maxlife %f", &pit_max_lifetime_sec)) - {; + { + ; } else { @@ -295,7 +298,7 @@ api_hicn_api_node_params_set (vat_main_t * vam) /* Construct the API message */ M (HICN_API_NODE_PARAMS_SET, mp); - mp->enable_disable = clib_host_to_net_u32(enable_disable); + mp->enable_disable = clib_host_to_net_u32 (enable_disable); mp->pit_max_size = clib_host_to_net_i32 (pit_size); mp->cs_max_size = clib_host_to_net_i32 (cs_size); mp->pit_max_lifetime_sec = pit_max_lifetime_sec; @@ -310,12 +313,12 @@ api_hicn_api_node_params_set (vat_main_t * vam) } static int -api_hicn_api_node_params_get (vat_main_t * vam) +api_hicn_api_node_params_get (vat_main_t *vam) { vl_api_hicn_api_node_params_get_t *mp; int ret; - //Construct the API message + // Construct the API message M (HICN_API_NODE_PARAMS_GET, mp); /* send it... */ @@ -328,8 +331,8 @@ api_hicn_api_node_params_get (vat_main_t * vam) } static void - vl_api_hicn_api_node_params_get_reply_t_handler - (vl_api_hicn_api_node_params_get_reply_t * mp) +vl_api_hicn_api_node_params_get_reply_t_handler ( + vl_api_hicn_api_node_params_get_reply_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (mp->retval); @@ -344,7 +347,7 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } @@ -354,14 +357,13 @@ static void " PIT size %d\n" " PIT lifetime dflt %.3f, min %.3f, max %.3f\n" " CS size %d\n", - mp->is_enabled, - mp->feature_cs, - clib_net_to_host_u32 (mp->pit_max_size), - mp->pit_max_lifetime_sec, clib_net_to_host_u32 (mp->cs_max_size)); + mp->is_enabled, mp->feature_cs, + clib_net_to_host_u32 (mp->pit_max_size), mp->pit_max_lifetime_sec, + clib_net_to_host_u32 (mp->cs_max_size)); } static int -api_hicn_api_node_stats_get (vat_main_t * vam) +api_hicn_api_node_stats_get (vat_main_t *vam) { vl_api_hicn_api_node_stats_get_t *mp; int ret; @@ -379,8 +381,8 @@ api_hicn_api_node_stats_get (vat_main_t * vam) } static void - vl_api_hicn_api_node_stats_get_reply_t_handler - (vl_api_hicn_api_node_stats_get_reply_t * rmp) +vl_api_hicn_api_node_stats_get_reply_t_handler ( + vl_api_hicn_api_node_stats_get_reply_t *rmp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (rmp->retval); @@ -395,13 +397,13 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } else { - fformat (vam->ofp, //compare hicn_cli_show_command_fn block:should match + fformat (vam->ofp, // compare hicn_cli_show_command_fn block:should match " PIT entries (now): %d\n" " CS entries (now): %d\n" " Forwarding statistics:" @@ -437,7 +439,7 @@ static void } static int -api_hicn_api_face_params_get (vat_main_t * vam) +api_hicn_api_face_params_get (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_face_params_get_t *mp; @@ -446,7 +448,8 @@ api_hicn_api_face_params_get (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "face %d", &faceid)) - {; + { + ; } else { @@ -454,28 +457,28 @@ api_hicn_api_face_params_get (vat_main_t * vam) } } - //Check for presence of face ID + // Check for presence of face ID if (faceid == HICN_FACE_NULL) { clib_warning ("Please specify face ID"); return 1; } - //Construct the API message + // Construct the API message M (HICN_API_FACE_PARAMS_GET, mp); mp->faceid = clib_host_to_net_u32 (faceid); - //send it... + // send it... S (mp); - //Wait for a reply... + // Wait for a reply... W (ret); return ret; } static void - vl_api_hicn_api_face_params_get_reply_t_handler - (vl_api_hicn_api_face_params_get_reply_t * rmp) +vl_api_hicn_api_face_params_get_reply_t_handler ( + vl_api_hicn_api_face_params_get_reply_t *rmp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (rmp->retval); @@ -492,24 +495,22 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } vec_reset_length (sbuf); ip_address_decode (&rmp->nat_addr, &nat_addr); - sbuf = - format (0, "nat_addr %U", format_ip46_address, - &nat_addr, 0 /*IP46_ANY_TYPE */); + sbuf = format (0, "nat_addr %U", format_ip46_address, &nat_addr, + 0 /*IP46_ANY_TYPE */); - fformat (vam->ofp, "%s swif %d flags %d\n", - sbuf, + fformat (vam->ofp, "%s swif %d flags %d\n", sbuf, clib_net_to_host_u32 (rmp->swif), clib_net_to_host_i32 (rmp->flags)); } static void -format_face (vl_api_hicn_face_t * rmp) +format_face (vl_api_hicn_face_t *rmp) { vat_main_t *vam = hicn_test_main.vat_main; u8 *sbuf = 0; @@ -519,18 +520,16 @@ format_face (vl_api_hicn_face_t * rmp) vec_reset_length (sbuf); ip_address_decode (&rmp->nat_addr, &nat_addr); - sbuf = - format (0, "nat_addr %U", format_ip46_address, - &local_addr, 0 /*IP46_ANY_TYPE */); + sbuf = format (0, "nat_addr %U", format_ip46_address, &local_addr, + 0 /*IP46_ANY_TYPE */); - fformat (vam->ofp, "%s swif %d flags %d name %s\n", - sbuf, - clib_net_to_host_u32 (rmp->swif), - clib_net_to_host_i32 (rmp->flags), rmp->if_name); + fformat (vam->ofp, "%s swif %d flags %d name %s\n", sbuf, + clib_net_to_host_u32 (rmp->swif), clib_net_to_host_i32 (rmp->flags), + rmp->if_name); } static int -api_hicn_api_faces_dump (vat_main_t * vam) +api_hicn_api_faces_dump (vat_main_t *vam) { hicn_test_main_t *hm = &hicn_test_main; vl_api_hicn_api_faces_dump_t *mp; @@ -564,14 +563,13 @@ api_hicn_api_faces_dump (vat_main_t * vam) } static void - vl_api_hicn_api_faces_details_t_handler - (vl_api_hicn_api_faces_details_t * mp) +vl_api_hicn_api_faces_details_t_handler (vl_api_hicn_api_faces_details_t *mp) { format_face (&(mp->face)); } static int -api_hicn_api_face_get (vat_main_t * vam) +api_hicn_api_face_get (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_face_get_t *mp; @@ -580,7 +578,8 @@ api_hicn_api_face_get (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "face %d", &faceid)) - {; + { + ; } else { @@ -588,29 +587,28 @@ api_hicn_api_face_get (vat_main_t * vam) } } - //Check for presence of face ID + // Check for presence of face ID if (faceid == HICN_FACE_NULL) { clib_warning ("Please specify face ID"); return 1; } - //Construct the API message + // Construct the API message M (HICN_API_FACE_GET, mp); mp->faceid = clib_host_to_net_u32 (faceid); - //send it... + // send it... S (mp); - //Wait for a reply... + // Wait for a reply... W (ret); return ret; } - static void - vl_api_hicn_api_face_get_reply_t_handler - (vl_api_hicn_api_face_get_reply_t * rmp) +vl_api_hicn_api_face_get_reply_t_handler ( + vl_api_hicn_api_face_get_reply_t *rmp) { vat_main_t *vam = hicn_test_main.vat_main; @@ -626,17 +624,15 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } format_face (&(rmp->face)); } - - static int -api_hicn_api_face_stats_dump (vat_main_t * vam) +api_hicn_api_face_stats_dump (vat_main_t *vam) { hicn_test_main_t *hm = &hicn_test_main; vl_api_hicn_api_face_stats_dump_t *mp; @@ -671,12 +667,13 @@ api_hicn_api_face_stats_dump (vat_main_t * vam) /* face_stats-details message handler */ static void - vl_api_hicn_api_face_stats_details_t_handler - (vl_api_hicn_api_face_stats_details_t * mp) +vl_api_hicn_api_face_stats_details_t_handler ( + vl_api_hicn_api_face_stats_details_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; - fformat (vam->ofp, "face id %d\n" + fformat (vam->ofp, + "face id %d\n" " interest rx packets %16Ld\n" " bytes %16Ld\n" " interest tx packets %16Ld\n" @@ -697,7 +694,7 @@ static void } static int -api_hicn_api_route_get (vat_main_t * vam) +api_hicn_api_route_get (vat_main_t *vam) { unformat_input_t *input = vam->input; @@ -709,7 +706,8 @@ api_hicn_api_route_get (vat_main_t * vam) { if (unformat (input, "prefix %U/%d", unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len)) - {; + { + ; } else { @@ -718,29 +716,29 @@ api_hicn_api_route_get (vat_main_t * vam) } /* Check parse */ - if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0)) - || (prefix.fp_len == 0)) + if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0)) || + (prefix.fp_len == 0)) { clib_warning ("Please specify a valid prefix..."); return 1; } - //Construct the API message + // Construct the API message M (HICN_API_ROUTE_GET, mp); if (!ip46_address_is_ip4 (&(prefix.fp_addr))) prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6); ip_prefix_encode (&prefix, &mp->prefix); - //send it... + // send it... S (mp); - //Wait for a reply... + // Wait for a reply... W (ret); return ret; } static int -api_hicn_api_routes_dump (vat_main_t * vam) +api_hicn_api_routes_dump (vat_main_t *vam) { hicn_test_main_t *hm = &hicn_test_main; @@ -775,8 +773,8 @@ api_hicn_api_routes_dump (vat_main_t * vam) } static void -vl_api_hicn_api_route_get_reply_t_handler (vl_api_hicn_api_route_get_reply_t * - rmp) +vl_api_hicn_api_route_get_reply_t_handler ( + vl_api_hicn_api_route_get_reply_t *rmp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (rmp->retval); @@ -792,7 +790,7 @@ vl_api_hicn_api_route_get_reply_t_handler (vl_api_hicn_api_route_get_reply_t * if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } @@ -808,8 +806,7 @@ vl_api_hicn_api_route_get_reply_t_handler (vl_api_hicn_api_route_get_reply_t * if (faceid != HICN_FACE_NULL) { sbuf = - format (sbuf, "faceid %d", - clib_net_to_host_u32 (rmp->faceids[i])); + format (sbuf, "faceid %d", clib_net_to_host_u32 (rmp->faceids[i])); i++; } else @@ -818,14 +815,13 @@ vl_api_hicn_api_route_get_reply_t_handler (vl_api_hicn_api_route_get_reply_t * } } - fformat (vam->ofp, "%s\n Strategy: %d\n", - sbuf, clib_net_to_host_u32 (rmp->strategy_id)); + fformat (vam->ofp, "%s\n Strategy: %d\n", sbuf, + clib_net_to_host_u32 (rmp->strategy_id)); } /* face_stats-details message handler */ static void - vl_api_hicn_api_routes_details_t_handler - (vl_api_hicn_api_routes_details_t * mp) +vl_api_hicn_api_routes_details_t_handler (vl_api_hicn_api_routes_details_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; fib_prefix_t prefix; @@ -834,9 +830,8 @@ static void vec_reset_length (sbuf); ip_prefix_decode (&mp->prefix, &prefix); - sbuf = - format (sbuf, "Prefix: %U/%u\n", format_ip46_address, &prefix.fp_addr, 0, - prefix.fp_len); + sbuf = format (sbuf, "Prefix: %U/%u\n", format_ip46_address, &prefix.fp_addr, + 0, prefix.fp_len); sbuf = format (sbuf, "Faces: \n"); for (int i = 0; i < mp->nfaces; i++) @@ -845,17 +840,17 @@ static void sbuf = format (sbuf, " faceid %d\n", faceid); } - fformat (vam->ofp, "%sStrategy: %d\n", - sbuf, clib_net_to_host_u32 (mp->strategy_id)); + fformat (vam->ofp, "%sStrategy: %d\n", sbuf, + clib_net_to_host_u32 (mp->strategy_id)); } static int -api_hicn_api_strategies_get (vat_main_t * vam) +api_hicn_api_strategies_get (vat_main_t *vam) { vl_api_hicn_api_strategies_get_t *mp; int ret; - //TODO + // TODO /* Construct the API message */ M (HICN_API_STRATEGIES_GET, mp); @@ -869,8 +864,8 @@ api_hicn_api_strategies_get (vat_main_t * vam) } static void - vl_api_hicn_api_strategies_get_reply_t_handler - (vl_api_hicn_api_strategies_get_reply_t * mp) +vl_api_hicn_api_strategies_get_reply_t_handler ( + vl_api_hicn_api_strategies_get_reply_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (mp->retval); @@ -886,7 +881,7 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } @@ -905,7 +900,7 @@ static void } static int -api_hicn_api_strategy_get (vat_main_t * vam) +api_hicn_api_strategy_get (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_strategy_get_t *mp; @@ -916,7 +911,8 @@ api_hicn_api_strategy_get (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "strategy %d", strategy_id)) - {; + { + ; } else { @@ -944,8 +940,8 @@ api_hicn_api_strategy_get (vat_main_t * vam) } static void - vl_api_hicn_api_strategy_get_reply_t_handler - (vl_api_hicn_api_strategy_get_reply_t * mp) +vl_api_hicn_api_strategy_get_reply_t_handler ( + vl_api_hicn_api_strategy_get_reply_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (mp->retval); @@ -960,7 +956,7 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } @@ -968,7 +964,7 @@ static void } static int -api_hicn_api_enable_disable (vat_main_t * vam) +api_hicn_api_enable_disable (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_enable_disable_t *mp; @@ -981,12 +977,14 @@ api_hicn_api_enable_disable (vat_main_t * vam) { if (unformat (input, "prefix %U/%d", unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len)) - {; + { + ; } else if (unformat (input, "disable")) - {; - en_dis = HICN_DISABLE; - } + { + ; + en_dis = HICN_DISABLE; + } else { break; @@ -994,33 +992,34 @@ api_hicn_api_enable_disable (vat_main_t * vam) } /* Check parse */ - if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0)) - || (prefix.fp_len == 0)) + if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0)) || + (prefix.fp_len == 0)) { clib_warning ("Please specify a valid prefix..."); return 1; } - prefix.fp_proto = ip46_address_is_ip4 (&(prefix.fp_addr)) ? FIB_PROTOCOL_IP4 : - FIB_PROTOCOL_IP6; + prefix.fp_proto = ip46_address_is_ip4 (&(prefix.fp_addr)) ? + FIB_PROTOCOL_IP4 : + FIB_PROTOCOL_IP6; - //Construct the API message + // Construct the API message M (HICN_API_ENABLE_DISABLE, mp); ip_prefix_encode (&prefix, &mp->prefix); mp->enable_disable = en_dis; - //send it... + // send it... S (mp); - //Wait for a reply... + // Wait for a reply... W (ret); return ret; } static int -api_hicn_api_register_prod_app (vat_main_t * vam) +api_hicn_api_register_prod_app (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_register_prod_app_t *mp; @@ -1032,10 +1031,12 @@ api_hicn_api_register_prod_app (vat_main_t * vam) { if (unformat (input, "prefix %U/%d", unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len)) - {; + { + ; } else if (unformat (input, "id %d", &swif)) - {; + { + ; } else { @@ -1044,16 +1045,16 @@ api_hicn_api_register_prod_app (vat_main_t * vam) } /* Check parse */ - if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0)) - || (prefix.fp_len == 0)) + if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0)) || + (prefix.fp_len == 0)) { clib_warning ("Please specify prefix..."); return 1; } - prefix.fp_proto = - ip46_address_is_ip4 (&(prefix.fp_addr)) ? FIB_PROTOCOL_IP4 : - FIB_PROTOCOL_IP6; + prefix.fp_proto = ip46_address_is_ip4 (&(prefix.fp_addr)) ? + FIB_PROTOCOL_IP4 : + FIB_PROTOCOL_IP6; /* Construct the API message */ M (HICN_API_REGISTER_PROD_APP, mp); ip_prefix_encode (&prefix, &mp->prefix); @@ -1070,8 +1071,8 @@ api_hicn_api_register_prod_app (vat_main_t * vam) } static void - vl_api_hicn_api_register_prod_app_reply_t_handler - (vl_api_hicn_api_register_prod_app_reply_t * mp) +vl_api_hicn_api_register_prod_app_reply_t_handler ( + vl_api_hicn_api_register_prod_app_reply_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (mp->retval); @@ -1086,14 +1087,14 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } } static int -api_hicn_api_face_prod_del (vat_main_t * vam) +api_hicn_api_face_prod_del (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_face_prod_del_t *mp; @@ -1102,7 +1103,8 @@ api_hicn_api_face_prod_del (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "face %d", &faceid)) - {; + { + ; } else { @@ -1110,27 +1112,27 @@ api_hicn_api_face_prod_del (vat_main_t * vam) } } - //Check for presence of face ID + // Check for presence of face ID if (faceid == ~0) { clib_warning ("Please specify face ID"); return 1; } - //Construct the API message + // Construct the API message M (HICN_API_FACE_PROD_DEL, mp); mp->faceid = clib_host_to_net_u32 (faceid); - //send it... + // send it... S (mp); - //Wait for a reply... + // Wait for a reply... W (ret); return ret; } static int -api_hicn_api_register_cons_app (vat_main_t * vam) +api_hicn_api_register_cons_app (vat_main_t *vam) { vl_api_hicn_api_register_cons_app_t *mp; int ret; @@ -1148,7 +1150,7 @@ api_hicn_api_register_cons_app (vat_main_t * vam) } static int -api_hicn_api_face_cons_del (vat_main_t * vam) +api_hicn_api_face_cons_del (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_face_cons_del_t *mp; @@ -1157,7 +1159,8 @@ api_hicn_api_face_cons_del (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "face %d", &faceid)) - {; + { + ; } else { @@ -1165,28 +1168,28 @@ api_hicn_api_face_cons_del (vat_main_t * vam) } } - //Check for presence of face ID + // Check for presence of face ID if (faceid == ~0) { clib_warning ("Please specify face ID"); return 1; } - //Construct the API message + // Construct the API message M (HICN_API_FACE_CONS_DEL, mp); mp->faceid = clib_host_to_net_u32 (faceid); - //send it... + // send it... S (mp); - //Wait for a reply... + // Wait for a reply... W (ret); return ret; } static void - vl_api_hicn_api_register_cons_app_reply_t_handler - (vl_api_hicn_api_register_cons_app_reply_t * mp) +vl_api_hicn_api_register_cons_app_reply_t_handler ( + vl_api_hicn_api_register_cons_app_reply_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (mp->retval); @@ -1201,7 +1204,7 @@ static void if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } @@ -1213,12 +1216,12 @@ static void fformat (vam->ofp, "ip4 address %U\n" "ip6 address :%U\n", - format_ip46_address, IP46_TYPE_ANY, &src_addr4, - format_ip46_address, IP46_TYPE_ANY, &src_addr6); + format_ip46_address, IP46_TYPE_ANY, &src_addr4, format_ip46_address, + IP46_TYPE_ANY, &src_addr6); } static int -api_hicn_api_udp_tunnel_add_del (vat_main_t * vam) +api_hicn_api_udp_tunnel_add_del (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_hicn_api_udp_tunnel_add_del_t *mp; @@ -1236,26 +1239,23 @@ api_hicn_api_udp_tunnel_add_del (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "add")) - is_del = 0; + is_del = 0; else if (unformat (input, "del")) - is_del = 1; - else if (unformat (input, "%U %U", - unformat_ip4_address, - &src_ip.ip4, unformat_ip4_address, &dst_ip.ip4)) - fproto = FIB_PROTOCOL_IP4; - else if (unformat (input, "%U %U", - unformat_ip6_address, - &src_ip.ip6, unformat_ip6_address, &dst_ip.ip6)) - fproto = FIB_PROTOCOL_IP6; + is_del = 1; + else if (unformat (input, "%U %U", unformat_ip4_address, &src_ip.ip4, + unformat_ip4_address, &dst_ip.ip4)) + fproto = FIB_PROTOCOL_IP4; + else if (unformat (input, "%U %U", unformat_ip6_address, &src_ip.ip6, + unformat_ip6_address, &dst_ip.ip6)) + fproto = FIB_PROTOCOL_IP6; else if (unformat (input, "%d %d", &src_port, &dst_port)) - ; + ; else - { - break; - } + { + break; + } } - if (fproto == FIB_PROTOCOL_MAX) { clib_warning ("Please specify face ID"); @@ -1264,10 +1264,14 @@ api_hicn_api_udp_tunnel_add_del (vat_main_t * vam) /* Construct the API message */ M (HICN_API_UDP_TUNNEL_ADD_DEL, mp); - ip_address_encode (&src_ip, fproto == FIB_PROTOCOL_IP4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6 ,&mp->src_addr); - ip_address_encode (&dst_ip, fproto == FIB_PROTOCOL_IP4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6 ,&mp->dst_addr); - mp->src_port = clib_host_to_net_u16(src_port); - mp->dst_port = clib_host_to_net_u16(dst_port); + ip_address_encode ( + &src_ip, fproto == FIB_PROTOCOL_IP4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6, + &mp->src_addr); + ip_address_encode ( + &dst_ip, fproto == FIB_PROTOCOL_IP4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6, + &mp->dst_addr); + mp->src_port = clib_host_to_net_u16 (src_port); + mp->dst_port = clib_host_to_net_u16 (dst_port); mp->is_add = !is_del; /* send it... */ @@ -1280,8 +1284,8 @@ api_hicn_api_udp_tunnel_add_del (vat_main_t * vam) } static void -vl_api_hicn_api_udp_tunnel_add_del_reply_t_handler -(vl_api_hicn_api_udp_tunnel_add_del_reply_t * mp) +vl_api_hicn_api_udp_tunnel_add_del_reply_t_handler ( + vl_api_hicn_api_udp_tunnel_add_del_reply_t *mp) { vat_main_t *vam = hicn_test_main.vat_main; i32 retval = ntohl (mp->retval); @@ -1296,20 +1300,16 @@ vl_api_hicn_api_udp_tunnel_add_del_reply_t_handler if (vam->retval < 0) { - //vpp_api_test infra will also print out string form of error + // vpp_api_test infra will also print out string form of error fformat (vam->ofp, " (API call error: %d)\n", vam->retval); return; } - index_t uei = clib_net_to_host_u32(mp->uei); + index_t uei = clib_net_to_host_u32 (mp->uei); - fformat (vam->ofp, - "udp-encap %d\n", - uei); + fformat (vam->ofp, "udp-encap %d\n", uei); } - - #include /* diff --git a/hicn-plugin/src/infra.h b/hicn-plugin/src/infra.h index ff76de4e4..900ecedde 100644 --- a/hicn-plugin/src/infra.h +++ b/hicn-plugin/src/infra.h @@ -64,19 +64,17 @@ u32 hicn_infra_cs_size; * @brief Enable and disable the hicn plugin * * Enable the time the hICN plugin and set the forwarder parameters. - * @param enable_disable 1 if to enable, 0 otherwisw (currently only enable is supported) + * @param enable_disable 1 if to enable, 0 otherwisw (currently only enable is + * supported) * @param pit_max_size Max size of the PIT - * @param pit_max_lifetime_sec_req Maximum timeout allowed for a PIT entry lifetime + * @param pit_max_lifetime_sec_req Maximum timeout allowed for a PIT entry + * lifetime * @param cs_max_size CS size. Must be <= than pit_max_size * @param cs_reserved_app Amount of CS reserved for application faces */ -int -hicn_infra_plugin_enable_disable (int enable_disable, - int pit_max_size, - f64 pit_max_lifetime_sec_req, - int cs_max_size, - vnet_link_t link); - +int hicn_infra_plugin_enable_disable (int enable_disable, int pit_max_size, + f64 pit_max_lifetime_sec_req, + int cs_max_size, vnet_link_t link); /* vlib nodes that compose the hICN forwarder */ extern vlib_node_registration_t hicn_interest_pcslookup_node; @@ -91,8 +89,6 @@ extern vlib_node_registration_t hicn_pg_server_node; extern vlib_node_registration_t hicn_data_input_ip6_node; extern vlib_node_registration_t hicn_data_input_ip4_node; - - #endif /* // __HICN_INFRA_H__ */ /* diff --git a/hicn-plugin/src/interest_hitcs.h b/hicn-plugin/src/interest_hitcs.h index 94fa3e6f5..05a790688 100644 --- a/hicn-plugin/src/interest_hitcs.h +++ b/hicn-plugin/src/interest_hitcs.h @@ -24,11 +24,12 @@ /** * @file interest_hitcs.h * - * This is the node encoutered by interest packets after the hicn-interest-pcslookup. - * This node satisfies an interest with a data stored in the CS and send the data back - * from the incoming iface of the interest (i.e., the vlib buffer is sent to the - * hicn6-iface-output or hicn4-iface-output node). In case the data is expired, the - * vlib buffer is sent to the hicn-strategy node. + * This is the node encoutered by interest packets after the + * hicn-interest-pcslookup. This node satisfies an interest with a data stored + * in the CS and send the data back from the incoming iface of the interest + * (i.e., the vlib buffer is sent to the hicn6-iface-output or + * hicn4-iface-output node). In case the data is expired, the vlib buffer is + * sent to the hicn-strategy node. */ /* diff --git a/hicn-plugin/src/interest_hitcs_node.c b/hicn-plugin/src/interest_hitcs_node.c index 0212fa5f9..e29b173a9 100644 --- a/hicn-plugin/src/interest_hitcs_node.c +++ b/hicn-plugin/src/interest_hitcs_node.c @@ -189,7 +189,7 @@ hicn_interest_hitcs_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, * the data through it */ next0 = isv6 ? HICN_INTEREST_HITCS_NEXT_IFACE6_OUT : - HICN_INTEREST_HITCS_NEXT_IFACE4_OUT; + HICN_INTEREST_HITCS_NEXT_IFACE4_OUT; vnet_buffer (b0)->ip.adj_index[VLIB_TX] = hicnb0->face_id; clone_from_cs (vm, &pitp->u.cs.cs_pkt_buf, b0, isv6); diff --git a/hicn-plugin/src/interest_hitpit.h b/hicn-plugin/src/interest_hitpit.h index ffdc61c8f..44cf2c879 100644 --- a/hicn-plugin/src/interest_hitpit.h +++ b/hicn-plugin/src/interest_hitpit.h @@ -24,14 +24,14 @@ /** * @file interest_hitpit.h * - * This is the node encoutered by interest packets after the hicn-interest-pcslookup. - * This node aggregates an interest in the PIT or forward it in case of a retransmission. - * If the interest must be retransmitted the next vlib node will be on of the - * hicn6-face-output or hicn4-face-output nodes. If the pit entry is expired the next vlib node - * will be the hicn-strategy node, otherwise the vlib buffer is dropped. + * This is the node encoutered by interest packets after the + * hicn-interest-pcslookup. This node aggregates an interest in the PIT or + * forward it in case of a retransmission. If the interest must be + * retransmitted the next vlib node will be on of the hicn6-face-output or + * hicn4-face-output nodes. If the pit entry is expired the next vlib node will + * be the hicn-strategy node, otherwise the vlib buffer is dropped. */ - /* * Node context data; we think this is per-thread/instance */ diff --git a/hicn-plugin/src/interest_hitpit_node.c b/hicn-plugin/src/interest_hitpit_node.c index 5367c71f8..837eddca7 100644 --- a/hicn-plugin/src/interest_hitpit_node.c +++ b/hicn-plugin/src/interest_hitpit_node.c @@ -179,7 +179,7 @@ hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, * forwarding */ next0 = isv6 ? HICN_INTEREST_HITPIT_NEXT_FACE6_OUTPUT : - HICN_INTEREST_HITPIT_NEXT_FACE4_OUTPUT; + HICN_INTEREST_HITPIT_NEXT_FACE4_OUTPUT; vnet_buffer (b0)->ip.adj_index[VLIB_TX] = outface; /* diff --git a/hicn-plugin/src/interest_pcslookup.h b/hicn-plugin/src/interest_pcslookup.h index cbc9dde51..87d093e91 100644 --- a/hicn-plugin/src/interest_pcslookup.h +++ b/hicn-plugin/src/interest_pcslookup.h @@ -24,12 +24,12 @@ /** * @file interest_pcslookup.h * - * This is the node encoutered by interest packets after the hicn6-iface-input or - * hicn4-iface-input. This node performs a lookup in the pit and content store and - * if there is a hit in the PIT, the vlib buffer is passed to the hicn-interest-hitcs - * while if there is a hit in the CS the vlib buffer is passed to the - * hicn-interest-hitpit. If there isn't any hit, the vlib buffer is passed to the - * hicn-strategy node. + * This is the node encoutered by interest packets after the hicn6-iface-input + * or hicn4-iface-input. This node performs a lookup in the pit and content + * store and if there is a hit in the PIT, the vlib buffer is passed to the + * hicn-interest-hitcs while if there is a hit in the CS the vlib buffer is + * passed to the hicn-interest-hitpit. If there isn't any hit, the vlib buffer + * is passed to the hicn-strategy node. */ /* diff --git a/hicn-plugin/src/mapme.h b/hicn-plugin/src/mapme.h index 17bd9a766..63bd42610 100644 --- a/hicn-plugin/src/mapme.h +++ b/hicn-plugin/src/mapme.h @@ -23,7 +23,7 @@ #include "hicn.h" #include "route.h" #include "strategy_dpo_ctx.h" -#include "strategy_dpo_manager.h" // dpo_is_hicn +#include "strategy_dpo_manager.h" // dpo_is_hicn /** * @file @@ -32,36 +32,35 @@ * * Mapme implementation follows the "Anchorless mobility through hICN" document * specification. In particular, the implementation is made of: - * - two internal nodes: hicn-mapme-ctrl and hicn-mapme-ack. The former processes - * IU and the latter IU acknowledgment. - * - a process node, mapme-eventmgr-process, that is signaled every time a face is - * added or deleted, as well as when a new next hop is added to a fib entry as a - * result of a mobility event. + * - two internal nodes: hicn-mapme-ctrl and hicn-mapme-ack. The former + * processes IU and the latter IU acknowledgment. + * - a process node, mapme-eventmgr-process, that is signaled every time a + * face is added or deleted, as well as when a new next hop is added to a fib + * entry as a result of a mobility event. * - * TFIB implementation is done as an extension of an hICN fib entry. In particular, - * the list of next hops hold the list of next hops in the tfib as well (stored at the - * end of the list of regualt next hops). Mapme implementation follows the hICN vrf - * implementation and consider the vrf 0 (default fib) as the control-plane fib to - * update every time a new next hop must be added or removed. + * TFIB implementation is done as an extension of an hICN fib entry. In + * particular, the list of next hops hold the list of next hops in the tfib as + * well (stored at the end of the list of regualt next hops). Mapme + * implementation follows the hICN vrf implementation and consider the vrf 0 + * (default fib) as the control-plane fib to update every time a new next hop + * must be added or removed. */ - #define HICN_MAPME_ALLOW_LOCATORS 1 //#define HICN_MAPME_NOTIFICATIONS 1 #define NOT_A_NOTIFICATION false -#define TIMER_NO_REPEAT false +#define TIMER_NO_REPEAT false #define INVALID_SEQ 0 -STATIC_ASSERT (sizeof(u32) == sizeof(seq_t), - "seq_t is not 4 bytes"); +STATIC_ASSERT (sizeof (u32) == sizeof (seq_t), "seq_t is not 4 bytes"); typedef struct hicn_mapme_conf_s { hicn_mapme_conf_t conf; - bool remove_dpo; // FIXME used ? + bool remove_dpo; // FIXME used ? vlib_main_t *vm; vlib_log_class_t log_class; @@ -70,15 +69,15 @@ typedef struct hicn_mapme_conf_s /** * @brief List of event to signat to the procesing node (eventmgr) */ -#define foreach_hicn_mapme_event \ - _(FACE_ADD) \ - _(FACE_DEL) \ - _(FACE_APP_ADD) \ - _(FACE_APP_DEL) \ - _(FACE_NH_SET) \ - _(FACE_NH_ADD) \ - _(FACE_PH_ADD) \ - _(FACE_PH_DEL) +#define foreach_hicn_mapme_event \ + _ (FACE_ADD) \ + _ (FACE_DEL) \ + _ (FACE_APP_ADD) \ + _ (FACE_APP_DEL) \ + _ (FACE_NH_SET) \ + _ (FACE_NH_ADD) \ + _ (FACE_PH_ADD) \ + _ (FACE_PH_DEL) typedef enum { @@ -99,24 +98,27 @@ typedef hicn_dpo_ctx_t hicn_mapme_tfib_t; STATIC_ASSERT (sizeof (hicn_mapme_tfib_t) <= sizeof (hicn_dpo_ctx_t), "hicn_mapme_tfib_t is greater than hicn_dpo_ctx_t"); -#define TFIB(dpo_ctx) ((hicn_mapme_tfib_t*)(dpo_ctx)) +#define TFIB(dpo_ctx) ((hicn_mapme_tfib_t *) (dpo_ctx)) static_always_inline int -hicn_mapme_nh_set (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) +hicn_mapme_nh_set (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) { - hicn_dpo_ctx_t * strategy_ctx = (hicn_dpo_ctx_t *)tfib; - const fib_prefix_t * prefix = fib_entry_get_prefix(strategy_ctx->fib_entry_index); + hicn_dpo_ctx_t *strategy_ctx = (hicn_dpo_ctx_t *) tfib; + const fib_prefix_t *prefix = + fib_entry_get_prefix (strategy_ctx->fib_entry_index); u32 n_entries = tfib->entry_count; /* Remove all the existing next hops and set the new one */ for (int i = 0; i < n_entries; i++) { - hicn_face_t * face = hicn_dpoi_get_from_idx(strategy_ctx->next_hops[0]); - ip_adjacency_t * adj = adj_get (face->dpo.dpoi_index); - ip_nh_del_helper(face->dpo.dpoi_proto, prefix, &adj->sub_type.nbr.next_hop, face->sw_if); + hicn_face_t *face = hicn_dpoi_get_from_idx (strategy_ctx->next_hops[0]); + ip_adjacency_t *adj = adj_get (face->dpo.dpoi_index); + ip_nh_del_helper (face->dpo.dpoi_proto, prefix, + &adj->sub_type.nbr.next_hop, face->sw_if); } - hicn_face_t * face = hicn_dpoi_get_from_idx(face_id); - ip_nh_add_helper(face->dpo.dpoi_proto, prefix, &face->nat_addr, face->sw_if); + hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); + ip_nh_add_helper (face->dpo.dpoi_proto, prefix, &face->nat_addr, + face->sw_if); return 0; } @@ -124,17 +126,20 @@ hicn_mapme_nh_set (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) * @brief Add a next hop iif it is not already a next hops */ static_always_inline int -hicn_mapme_nh_add (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) +hicn_mapme_nh_add (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) { for (u8 pos = 0; pos < tfib->entry_count; pos++) if (tfib->next_hops[pos] == face_id) return 0; - /* Add the next hop in the vrf 0 which will add it to the entry in the hICN vrf */ - hicn_dpo_ctx_t * strategy_ctx = (hicn_dpo_ctx_t *)tfib; - const fib_prefix_t * prefix = fib_entry_get_prefix(strategy_ctx->fib_entry_index); - hicn_face_t * face = hicn_dpoi_get_from_idx(face_id); - ip_nh_add_helper(face->dpo.dpoi_proto, prefix, &face->nat_addr, face->sw_if); + /* Add the next hop in the vrf 0 which will add it to the entry in the hICN + * vrf */ + hicn_dpo_ctx_t *strategy_ctx = (hicn_dpo_ctx_t *) tfib; + const fib_prefix_t *prefix = + fib_entry_get_prefix (strategy_ctx->fib_entry_index); + hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); + ip_nh_add_helper (face->dpo.dpoi_proto, prefix, &face->nat_addr, + face->sw_if); return 0; } @@ -145,17 +150,17 @@ hicn_mapme_nh_add (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) * XXX we should have the for look in the reverse order for simpler code. */ static_always_inline int -hicn_mapme_tfib_add (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) +hicn_mapme_tfib_add (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) { u8 pos = HICN_PARAM_FIB_ENTRY_NHOPS_MAX - tfib->tfib_entry_count; - //XXX don 't add if it already exist + // XXX don 't add if it already exist // eg.an old IU received on a face on which we are retransmitting for (u8 pos2 = pos; pos2 < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; pos2++) if (tfib->next_hops[pos2] == face_id) return 0; - //Make sure we have enough room + // Make sure we have enough room if (pos <= tfib->entry_count) return -1; @@ -166,13 +171,13 @@ hicn_mapme_tfib_add (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) * Take a lock on the face as if it will be removed from the next_hops a * lock will be removed. */ - hicn_face_lock_with_id(face_id); + hicn_face_lock_with_id (face_id); return 0; } static_always_inline int -hicn_mapme_tfib_clear (hicn_mapme_tfib_t * tfib) +hicn_mapme_tfib_clear (hicn_mapme_tfib_t *tfib) { hicn_face_id_t invalid = NEXT_HOP_INVALID; /* @@ -182,11 +187,11 @@ hicn_mapme_tfib_clear (hicn_mapme_tfib_t * tfib) u8 start_pos = HICN_PARAM_FIB_ENTRY_NHOPS_MAX - tfib->tfib_entry_count; u8 pos = ~0; for (pos = start_pos; pos < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; pos++) - { - hicn_face_unlock_with_id (tfib->next_hops[pos]); - tfib->next_hops[pos] = invalid; - break; - } + { + hicn_face_unlock_with_id (tfib->next_hops[pos]); + tfib->next_hops[pos] = invalid; + break; + } tfib->tfib_entry_count = 0; @@ -194,7 +199,7 @@ hicn_mapme_tfib_clear (hicn_mapme_tfib_t * tfib) } static_always_inline int -hicn_mapme_tfib_del (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) +hicn_mapme_tfib_del (hicn_mapme_tfib_t *tfib, hicn_face_id_t face_id) { hicn_face_id_t invalid = NEXT_HOP_INVALID; /* @@ -218,7 +223,7 @@ hicn_mapme_tfib_del (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) /* Likely we won't receive a new IU twice from the same face */ if (PREDICT_TRUE (pos > start_pos)) - memmove (tfib->next_hops + start_pos +1 , tfib->next_hops + start_pos, + memmove (tfib->next_hops + start_pos + 1, tfib->next_hops + start_pos, (pos - start_pos) * sizeof (hicn_face_id_t)); return 0; @@ -228,8 +233,8 @@ hicn_mapme_tfib_del (hicn_mapme_tfib_t * tfib, hicn_face_id_t face_id) * @brief Performs an Exact Prefix Match lookup on the FIB * @returns the corresponding DPO (hICN or IP LB), or NULL */ -static_always_inline - dpo_id_t * fib_epm_lookup (ip46_address_t * addr, u8 plen) +static_always_inline dpo_id_t * +fib_epm_lookup (ip46_address_t *addr, u8 plen) { fib_prefix_t fib_pfx; fib_node_index_t fib_entry_index; @@ -294,14 +299,15 @@ extern u32 strategy_face_ip6_vlib_edge; extern u32 strategy_face_udp4_vlib_edge; extern u32 strategy_face_udp6_vlib_edge; - /** - * @brief Returns the next hop vlib edge on which we can send an Interest packet. + * @brief Returns the next hop vlib edge on which we can send an Interest + * packet. * - * This is both used to preprocess a dpo that will be stored as a next hop in the FIB, and to determine on which node to send an Interest Update. + * This is both used to preprocess a dpo that will be stored as a next hop in + * the FIB, and to determine on which node to send an Interest Update. */ always_inline u32 -hicn_mapme_get_dpo_vlib_edge (dpo_id_t * dpo) +hicn_mapme_get_dpo_vlib_edge (dpo_id_t *dpo) { if (dpo->dpoi_type == hicn_face_ip_type) { @@ -339,7 +345,7 @@ hicn_mapme_get_dpo_vlib_edge (dpo_id_t * dpo) always_inline char * hicn_mapme_get_dpo_face_node (hicn_face_id_t face_id) { - hicn_face_t * face = hicn_dpoi_get_from_idx(face_id); + hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); switch (face->dpo.dpoi_proto) { @@ -352,9 +358,9 @@ hicn_mapme_get_dpo_face_node (hicn_face_id_t face_id) } } -#define DEBUG(...) //vlib_log_debug(mapme_main.log_class, __VA_ARGS__) -#define WARN(...) //vlib_log_warn(mapme_main.log_class, __VA_ARGS__) -#define ERROR(...) //vlib_log_err(mapme_main.log_class, __VA_ARGS__) +#define DEBUG(...) // vlib_log_debug(mapme_main.log_class, __VA_ARGS__) +#define WARN(...) // vlib_log_warn(mapme_main.log_class, __VA_ARGS__) +#define ERROR(...) // vlib_log_err(mapme_main.log_class, __VA_ARGS__) #endif /* __HICN_MAPME__ */ diff --git a/hicn-plugin/src/mapme_ctrl.h b/hicn-plugin/src/mapme_ctrl.h index 9af4beccc..a40a969b0 100644 --- a/hicn-plugin/src/mapme_ctrl.h +++ b/hicn-plugin/src/mapme_ctrl.h @@ -56,7 +56,7 @@ typedef enum always_inline hicn_mapme_ctrl_next_t hicn_mapme_ctrl_get_iface_node (hicn_face_id_t face_id) { - hicn_face_t * face = hicn_dpoi_get_from_idx(face_id); + hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); switch (face->dpo.dpoi_proto) { diff --git a/hicn-plugin/src/mapme_eventmgr.c b/hicn-plugin/src/mapme_eventmgr.c index 69740ba0a..49a9b5c57 100644 --- a/hicn-plugin/src/mapme_eventmgr.c +++ b/hicn-plugin/src/mapme_eventmgr.c @@ -257,7 +257,7 @@ hicn_mapme_send_message (vlib_main_t *vm, const hicn_prefix_t *prefix, u8 *buffer = get_packet_buffer ( vm, node_index, face, (ip46_address_t *) prefix, (params->protocol == IPPROTO_IPV6) ? HICN_TYPE_IPV6_ICMP : - HICN_TYPE_IPV4_ICMP); + HICN_TYPE_IPV4_ICMP); n = hicn_mapme_create_packet (buffer, prefix, params); if (n <= 0) { @@ -337,7 +337,7 @@ hicn_mapme_eventmgr_process (vlib_main_t *vm, vlib_node_runtime_t *rt, * Also, we only run a timer when there are pending retransmissions. */ timeout = (due_time > current_time) ? due_time - current_time : - DEFAULT_TIMEOUT; + DEFAULT_TIMEOUT; due_time = current_time + timeout; } else diff --git a/hicn-plugin/src/mapme_eventmgr.h b/hicn-plugin/src/mapme_eventmgr.h index b63d16805..2100a6f90 100644 --- a/hicn-plugin/src/mapme_eventmgr.h +++ b/hicn-plugin/src/mapme_eventmgr.h @@ -13,7 +13,7 @@ * limitations under the License. */ -#include // vlib_node_registration_t (vlib/node.h) +#include // vlib_node_registration_t (vlib/node.h) #include @@ -34,7 +34,7 @@ typedef struct u8 rtx_count; // Number of retransmissions since last tfib addition } retx_t; -#define HASH32(x) ((u16)x ^ (x << 16)) +#define HASH32(x) ((u16) x ^ (x << 16)) /** * @brief This is a process node reacting to face events. @@ -46,7 +46,7 @@ vlib_node_registration_t hicn_mapme_eventmgr_process_node; * @brief Initialize MAP-Me on forwarder * @params vm - vlib_main_t pointer */ -void hicn_mapme_init (vlib_main_t * vm); +void hicn_mapme_init (vlib_main_t *vm); /* * fd.io coding-style-patch-verification: ON diff --git a/hicn-plugin/src/mgmt.c b/hicn-plugin/src/mgmt.c index cfeef6cb6..b820a378f 100644 --- a/hicn-plugin/src/mgmt.c +++ b/hicn-plugin/src/mgmt.c @@ -25,7 +25,7 @@ /* shared routine betweeen API and CLI, leveraging API message structure */ int -hicn_mgmt_node_stats_get (vl_api_hicn_api_node_stats_get_reply_t * rmp) +hicn_mgmt_node_stats_get (vl_api_hicn_api_node_stats_get_reply_t *rmp) { rmp->pkts_processed = 0; rmp->pkts_interest_count = 0; @@ -46,46 +46,31 @@ hicn_mgmt_node_stats_get (vl_api_hicn_api_node_stats_get_reply_t * rmp) vlib_error_main_t *em; vlib_node_t *n; - foreach_vlib_main (( - { - em = &this_vlib_main->error_main; - n = - vlib_get_node (this_vlib_main, - hicn_interest_pcslookup_node.index); - u32 node_cntr_base_idx = n->error_heap_index; - rmp->pkts_processed += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_PROCESSED]); - rmp->pkts_interest_count += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_INTERESTS]); - n = - vlib_get_node (this_vlib_main, - hicn_data_pcslookup_node.index); - node_cntr_base_idx = n->error_heap_index; - rmp->pkts_processed += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_PROCESSED]); - rmp->pkts_data_count += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_DATAS]); - n = - vlib_get_node (this_vlib_main, - hicn_interest_hitcs_node.index); - node_cntr_base_idx = n->error_heap_index; - rmp->pkts_from_cache_count += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_CACHED]); - n = - vlib_get_node (this_vlib_main, - hicn_interest_hitpit_node.index); - node_cntr_base_idx = n->error_heap_index; - rmp->interests_aggregated += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_INTEREST_AGG]); - rmp->interests_retx += - clib_host_to_net_u64 (em->counters[node_cntr_base_idx + - HICNFWD_ERROR_INT_RETRANS]);})); + foreach_vlib_main() { + em = &this_vlib_main->error_main; + n = vlib_get_node (this_vlib_main, hicn_interest_pcslookup_node.index); + u32 node_cntr_base_idx = n->error_heap_index; + rmp->pkts_processed += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_PROCESSED]); + rmp->pkts_interest_count += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_INTERESTS]); + n = vlib_get_node (this_vlib_main, hicn_data_pcslookup_node.index); + node_cntr_base_idx = n->error_heap_index; + rmp->pkts_processed += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_PROCESSED]); + rmp->pkts_data_count += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_DATAS]); + n = vlib_get_node (this_vlib_main, hicn_interest_hitcs_node.index); + node_cntr_base_idx = n->error_heap_index; + rmp->pkts_from_cache_count += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_CACHED]); + n = vlib_get_node (this_vlib_main, hicn_interest_hitpit_node.index); + node_cntr_base_idx = n->error_heap_index; + rmp->interests_aggregated += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_INTEREST_AGG]); + rmp->interests_retx += clib_host_to_net_u64 ( + em->counters[node_cntr_base_idx + HICNFWD_ERROR_INT_RETRANS]); + } return (HICN_ERROR_NONE); } diff --git a/hicn-plugin/src/mgmt.h b/hicn-plugin/src/mgmt.h index 6db0fe0c1..8eaa18fa8 100644 --- a/hicn-plugin/src/mgmt.h +++ b/hicn-plugin/src/mgmt.h @@ -70,7 +70,7 @@ typedef enum * Utility to update error counters in all hICN nodes */ always_inline void -update_node_counter (vlib_main_t * vm, u32 node_idx, u32 counter_idx, u64 val) +update_node_counter (vlib_main_t *vm, u32 node_idx, u32 counter_idx, u64 val) { vlib_node_t *node = vlib_get_node (vm, node_idx); vlib_error_main_t *em = &(vm->error_main); @@ -79,29 +79,28 @@ update_node_counter (vlib_main_t * vm, u32 node_idx, u32 counter_idx, u64 val) em->counters[base_idx + counter_idx] = val; } - /* * Stats for the forwarding node, which end up called "error" even though * they aren't... */ -#define foreach_hicnfwd_error \ - _(PROCESSED, "hICN packets processed") \ - _(INTERESTS, "hICN interests forwarded") \ - _(DATAS, "hICN data msgs forwarded") \ - _(CACHED, "Cached data ") \ - _(NO_PIT, "hICN no PIT entry drops") \ - _(PIT_EXPIRED, "hICN expired PIT entries") \ - _(CS_EXPIRED, "hICN expired CS entries") \ - _(CS_LRU, "hICN LRU CS entries freed") \ - _(NO_BUFS, "No packet buffers") \ - _(INTEREST_AGG, "Interests aggregated") \ - _(INTEREST_AGG_ENTRY, "Interest aggregated per entry") \ - _(INT_RETRANS, "Interest retransmissions") \ - _(INT_COUNT, "Interests in PIT") \ - _(CS_COUNT, "CS total entries") \ - _(CS_NTW_COUNT, "CS ntw entries") \ - _(CS_APP_COUNT, "CS app entries") \ - _(HASH_COLL_HASHTB_COUNT, "Collisions in Hash table") +#define foreach_hicnfwd_error \ + _ (PROCESSED, "hICN packets processed") \ + _ (INTERESTS, "hICN interests forwarded") \ + _ (DATAS, "hICN data msgs forwarded") \ + _ (CACHED, "Cached data ") \ + _ (NO_PIT, "hICN no PIT entry drops") \ + _ (PIT_EXPIRED, "hICN expired PIT entries") \ + _ (CS_EXPIRED, "hICN expired CS entries") \ + _ (CS_LRU, "hICN LRU CS entries freed") \ + _ (NO_BUFS, "No packet buffers") \ + _ (INTEREST_AGG, "Interests aggregated") \ + _ (INTEREST_AGG_ENTRY, "Interest aggregated per entry") \ + _ (INT_RETRANS, "Interest retransmissions") \ + _ (INT_COUNT, "Interests in PIT") \ + _ (CS_COUNT, "CS total entries") \ + _ (CS_NTW_COUNT, "CS ntw entries") \ + _ (CS_APP_COUNT, "CS app entries") \ + _ (HASH_COLL_HASHTB_COUNT, "Collisions in Hash table") typedef enum { @@ -114,9 +113,9 @@ typedef enum /* * Declarations */ -clib_error_t *hicn_api_plugin_hookup (vlib_main_t * vm); +clib_error_t *hicn_api_plugin_hookup (vlib_main_t *vm); -int hicn_mgmt_node_stats_get (vl_api_hicn_api_node_stats_get_reply_t * rmp); +int hicn_mgmt_node_stats_get (vl_api_hicn_api_node_stats_get_reply_t *rmp); #endif /* // __HICN_MGMT_H__ */ diff --git a/hicn-plugin/src/params.h b/hicn-plugin/src/params.h index 606d50771..7c7850d30 100644 --- a/hicn-plugin/src/params.h +++ b/hicn-plugin/src/params.h @@ -23,11 +23,10 @@ * */ - /* * Features */ -#define HICN_FEATURE_CS 1 //1 enable 0 disable +#define HICN_FEATURE_CS 1 // 1 enable 0 disable /* * Face compile-time parameters @@ -40,21 +39,21 @@ STATIC_ASSERT ((HICN_PARAM_FACES_MAX & (HICN_PARAM_FACES_MAX - 1)) == 0, /* * Max length for hICN names */ -#define HICN_PARAM_HICN_NAME_LEN_MAX 20 //bytes +#define HICN_PARAM_HICN_NAME_LEN_MAX 20 // bytes // Max next - hops supported in a FIB entry -#define HICN_PARAM_FIB_ENTRY_NHOPS_MAX 10 +#define HICN_PARAM_FIB_ENTRY_NHOPS_MAX 10 // Default and limit on weight, whatever weight means -#define HICN_PARAM_FIB_ENTRY_NHOP_WGHT_DFLT 0x10 -#define HICN_PARAM_FIB_ENTRY_NHOP_WGHT_MAX 0xff +#define HICN_PARAM_FIB_ENTRY_NHOP_WGHT_DFLT 0x10 +#define HICN_PARAM_FIB_ENTRY_NHOP_WGHT_MAX 0xff /* * PIT compile-time parameters */ -#define HICN_PARAM_PIT_ENTRIES_MIN 1024 -#define HICN_PARAM_PIT_ENTRIES_DFLT 1024 * 128 -#define HICN_PARAM_PIT_ENTRIES_MAX 2 * 1024 * 1024 +#define HICN_PARAM_PIT_ENTRIES_MIN 1024 +#define HICN_PARAM_PIT_ENTRIES_DFLT 1024 * 128 +#define HICN_PARAM_PIT_ENTRIES_MAX 2 * 1024 * 1024 // aggregation limit(interest previous hops) // Supported up to 516. For more than 4 faces this param must @@ -62,59 +61,62 @@ STATIC_ASSERT ((HICN_PARAM_FACES_MAX & (HICN_PARAM_FACES_MAX - 1)) == 0, #define HICN_PARAM_PIT_ENTRY_PHOPS_MAX 20 STATIC_ASSERT ((ceil (log2 ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4)))) == - (floor (log2 ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4)))), + (floor (log2 ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4)))), "HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4 must be a power of two"); -STATIC_ASSERT ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX <= HICN_PARAM_FACES_MAX), - "HICN_PARAM_PIT_ENTRY_PHOP_MAX must be <= than HICN_PARAM_FACES_MAX"); +STATIC_ASSERT ( + (HICN_PARAM_PIT_ENTRY_PHOPS_MAX <= HICN_PARAM_FACES_MAX), + "HICN_PARAM_PIT_ENTRY_PHOP_MAX must be <= than HICN_PARAM_FACES_MAX"); -//tFIB parameters +// tFIB parameters #define HICN_PARAM_RTX_MAX 10 // PIT lifetime limits on API override this(in seconds, integer type) -#define HICN_PARAM_PIT_LIFETIME_BOUND_MIN_SEC 0 -#define HICN_PARAM_PIT_LIFETIME_BOUND_MAX_SEC 200 +#define HICN_PARAM_PIT_LIFETIME_BOUND_MIN_SEC 0 +#define HICN_PARAM_PIT_LIFETIME_BOUND_MAX_SEC 200 -//PIT lifetime params if not set at API(in mseconds, integer type) -#define HICN_PARAM_PIT_LIFETIME_DFLT_MAX_MS 20000 +// PIT lifetime params if not set at API(in mseconds, integer type) +#define HICN_PARAM_PIT_LIFETIME_DFLT_MAX_MS 20000 // Face CS reservation params -#define HICN_PARAM_FACE_MAX_CS_RESERVED 20000 //packets -#define HICN_PARAM_FACE_MIN_CS_RESERVED 0 //packets -#define HICN_PARAM_FACE_DFT_CS_RESERVED 20000 //packets +#define HICN_PARAM_FACE_MAX_CS_RESERVED 20000 // packets +#define HICN_PARAM_FACE_MIN_CS_RESERVED 0 // packets +#define HICN_PARAM_FACE_DFT_CS_RESERVED 20000 // packets /* * CS compile-time parameters */ -#define HICN_PARAM_CS_ENTRIES_MIN 0 // can disable CS -#define HICN_PARAM_CS_ENTRIES_DFLT 4 * 1024 -#define HICN_PARAM_CS_ENTRIES_MAX 1024 * 1024 +#define HICN_PARAM_CS_ENTRIES_MIN 0 // can disable CS +#define HICN_PARAM_CS_ENTRIES_DFLT 4 * 1024 +#define HICN_PARAM_CS_ENTRIES_MAX 1024 * 1024 -#define HICN_PARAM_CS_LRU_DEFAULT (16 * 1024) +#define HICN_PARAM_CS_LRU_DEFAULT (16 * 1024) /* CS lifetime defines, in mseconds, integer type */ -#define HICN_PARAM_CS_LIFETIME_MIN 0 -#define HICN_PARAM_CS_LIFETIME_DFLT (5 * 60 * 1000) // 300 seconds -#define HICN_PARAM_CS_LIFETIME_MAX (24 * 3600 * 1000) //24 hours... +#define HICN_PARAM_CS_LIFETIME_MIN 0 +#define HICN_PARAM_CS_LIFETIME_DFLT (5 * 60 * 1000) // 300 seconds +#define HICN_PARAM_CS_LIFETIME_MAX (24 * 3600 * 1000) // 24 hours... /* CS reserved portion for applications */ -#define HICN_PARAM_CS_RESERVED_APP 50 //% -#define HICN_PARAM_CS_MIN_MBUF 4096 //this seems to be the minumim default number of mbuf we can have in vpp +#define HICN_PARAM_CS_RESERVED_APP 50 //% +#define HICN_PARAM_CS_MIN_MBUF \ + 4096 // this seems to be the minumim default number of mbuf we can have in + // vpp /* Cloning parameters */ /* ip4 */ #define HICN_IP4_VERSION_HEADER_LENGTH 0x45 -#define HICN_IP4_PROTOCOL IP_PROTOCOL_TCP -#define HICN_IP4_TTL_DEFAULT 128 +#define HICN_IP4_PROTOCOL IP_PROTOCOL_TCP +#define HICN_IP4_TTL_DEFAULT 128 /* ip6 */ -#define IPV6_DEFAULT_VERSION 6 -#define IPV6_DEFAULT_TRAFFIC_CLASS 0 -#define IPV6_DEFAULT_FLOW_LABEL 0 -#define HCIN_IP6_VERSION_TRAFFIC_FLOW (IPV6_DEFAULT_VERSION << 28) | \ - (IPV6_DEFAULT_TRAFFIC_CLASS << 20) | \ - (IPV6_DEFAULT_FLOW_LABEL & 0xfffff) -#define HICN_IP6_PROTOCOL IP_PROTOCOL_TCP +#define IPV6_DEFAULT_VERSION 6 +#define IPV6_DEFAULT_TRAFFIC_CLASS 0 +#define IPV6_DEFAULT_FLOW_LABEL 0 +#define HCIN_IP6_VERSION_TRAFFIC_FLOW \ + (IPV6_DEFAULT_VERSION << 28) | (IPV6_DEFAULT_TRAFFIC_CLASS << 20) | \ + (IPV6_DEFAULT_FLOW_LABEL & 0xfffff) +#define HICN_IP6_PROTOCOL IP_PROTOCOL_TCP #define HICN_IP6_HOP_LIMIT 0x40 #endif /* // __HICN_PARAM_H__ */ diff --git a/hicn-plugin/src/parser.h b/hicn-plugin/src/parser.h index e79d65831..5c75ce3bd 100644 --- a/hicn-plugin/src/parser.h +++ b/hicn-plugin/src/parser.h @@ -46,8 +46,8 @@ enum hicn_pkt_type_e * @param isv6 return variable that will be equale to 1 is the header is ipv6 */ always_inline int -hicn_interest_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name, - u16 * namelen, hicn_header_t ** pkt_hdrp, u8 * isv6) +hicn_interest_parse_pkt (vlib_buffer_t *pkt, hicn_name_t *name, u16 *namelen, + hicn_header_t **pkt_hdrp, u8 *isv6) { if (pkt == NULL) return HICN_ERROR_PARSER_PKT_INVAL; @@ -57,14 +57,12 @@ hicn_interest_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name, *isv6 = hicn_is_v6 (pkt_hdr); u8 ip_proto = (*isv6) * IPPROTO_IPV6; u8 next_proto_offset = 6 + (1 - *isv6) * 3; - //in the ipv6 header the next header field is at byte 6 + // in the ipv6 header the next header field is at byte 6 // in the ipv4 header the protocol field is at byte 9 - hicn_type_t type = (hicn_type_t) { { - .l4 = IPPROTO_NONE,.l3 = - IPPROTO_NONE,.l2 = - ip_pkt[next_proto_offset],.l1 = - ip_proto} - }; + hicn_type_t type = (hicn_type_t){ { .l4 = IPPROTO_NONE, + .l3 = IPPROTO_NONE, + .l2 = ip_pkt[next_proto_offset], + .l1 = ip_proto } }; hicn_get_buffer (pkt)->type = type; hicn_ops_vft[type.l1]->get_interest_name (type, &pkt_hdr->protocol, name); @@ -83,8 +81,8 @@ hicn_interest_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name, * @param isv6 return variable that will be equale to 1 is the header is ipv6 */ always_inline int -hicn_data_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name, - u16 * namelen, hicn_header_t ** pkt_hdrp, u8 * isv6) +hicn_data_parse_pkt (vlib_buffer_t *pkt, hicn_name_t *name, u16 *namelen, + hicn_header_t **pkt_hdrp, u8 *isv6) { if (pkt == NULL) return HICN_ERROR_PARSER_PKT_INVAL; @@ -99,11 +97,10 @@ hicn_data_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name, * header the protocol field is at byte 9 */ u8 next_proto_offset = 6 + (1 - *isv6) * 3; - hicn_type_t type = (hicn_type_t) { {.l4 = IPPROTO_NONE,.l3 = - IPPROTO_NONE,.l2 = - ip_pkt[next_proto_offset],.l1 = - ip_proto} - }; + hicn_type_t type = (hicn_type_t){ { .l4 = IPPROTO_NONE, + .l3 = IPPROTO_NONE, + .l2 = ip_pkt[next_proto_offset], + .l1 = ip_proto } }; hicn_get_buffer (pkt)->type = type; hicn_ops_vft[type.l1]->get_data_name (type, &pkt_hdr->protocol, name); *namelen = (1 - (*isv6)) * HICN_V4_NAME_LEN + (*isv6) * HICN_V6_NAME_LEN; @@ -111,7 +108,6 @@ hicn_data_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name, return HICN_ERROR_NONE; } - #endif /* // __HICN_PARSER_H__ */ /* diff --git a/hicn-plugin/src/pcs.c b/hicn-plugin/src/pcs.c index 6c44b9d83..d9e0baf6f 100644 --- a/hicn-plugin/src/pcs.c +++ b/hicn-plugin/src/pcs.c @@ -21,7 +21,7 @@ #include "cache_policies/cs_lru.h" int -hicn_pit_create (hicn_pit_cs_t * p, u32 num_elems) +hicn_pit_create (hicn_pit_cs_t *p, u32 num_elems) { int ret = hicn_hashtb_alloc (&p->pcs_table, num_elems, sizeof (hicn_pcs_entry_t)); @@ -45,7 +45,6 @@ hicn_pit_create (hicn_pit_cs_t * p, u32 num_elems) return (ret); } - /* * fd.io coding-style-patch-verification: ON * diff --git a/hicn-plugin/src/pg.c b/hicn-plugin/src/pg.c index 972bedc59..2f98e9c16 100644 --- a/hicn-plugin/src/pg.c +++ b/hicn-plugin/src/pg.c @@ -203,11 +203,11 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, iface = (hpgm->index_ifaces % hpgm->n_ifaces); /* Rewrite and send */ isv6_0 ? - hicn_rewrite_interestv6 ( + hicn_rewrite_interestv6 ( vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number, hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface) : - hicn_rewrite_interestv4 ( + hicn_rewrite_interestv4 ( vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number, hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface); @@ -216,7 +216,7 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hpgm->index++; next0 = isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP : - HICNPG_INTEREST_NEXT_V4_LOOKUP; + HICNPG_INTEREST_NEXT_V4_LOOKUP; } if (hicn_interest_parse_pkt (b1, &name1, &namelen1, &hicn1, &isv6_1) == HICN_ERROR_NONE) @@ -229,11 +229,11 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, iface = (hpgm->index_ifaces % hpgm->n_ifaces); /* Rewrite and send */ isv6_1 ? - hicn_rewrite_interestv6 ( + hicn_rewrite_interestv6 ( vm, b1, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number, hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface) : - hicn_rewrite_interestv4 ( + hicn_rewrite_interestv4 ( vm, b1, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number, hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface); @@ -242,7 +242,7 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hpgm->index++; next1 = isv6_1 ? HICNPG_INTEREST_NEXT_V6_LOOKUP : - HICNPG_INTEREST_NEXT_V4_LOOKUP; + HICNPG_INTEREST_NEXT_V4_LOOKUP; } /* Send pkt to next node */ vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0; @@ -320,11 +320,11 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, /* Rewrite and send */ isv6_0 ? - hicn_rewrite_interestv6 ( + hicn_rewrite_interestv6 ( vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number, hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface) : - hicn_rewrite_interestv4 ( + hicn_rewrite_interestv4 ( vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number, hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface); @@ -333,7 +333,7 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hpgm->index++; next0 = isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP : - HICNPG_INTEREST_NEXT_V4_LOOKUP; + HICNPG_INTEREST_NEXT_V4_LOOKUP; } /* Send pkt to ip lookup */ vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0; @@ -1011,10 +1011,10 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, rb = vlib_get_buffer (vm, hpgsm->pgen_svr_buffer_idx); isv6_0 ? convert_interest_to_data_v6 (vm, b0, rb, bi0) : - convert_interest_to_data_v4 (vm, b0, rb, bi0); + convert_interest_to_data_v4 (vm, b0, rb, bi0); next0 = isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP : - HICNPG_SERVER_NEXT_V4_LOOKUP; + HICNPG_SERVER_NEXT_V4_LOOKUP; } if (match1) @@ -1029,10 +1029,10 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, rb = vlib_get_buffer (vm, hpgsm->pgen_svr_buffer_idx); isv6_1 ? convert_interest_to_data_v6 (vm, b1, rb, bi1) : - convert_interest_to_data_v4 (vm, b1, rb, bi1); + convert_interest_to_data_v4 (vm, b1, rb, bi1); next1 = isv6_1 ? HICNPG_SERVER_NEXT_V6_LOOKUP : - HICNPG_SERVER_NEXT_V4_LOOKUP; + HICNPG_SERVER_NEXT_V4_LOOKUP; } pkts_processed += 2; @@ -1107,10 +1107,10 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, rb = vlib_get_buffer (vm, hpgsm->pgen_svr_buffer_idx); isv6_0 ? convert_interest_to_data_v6 (vm, b0, rb, bi0) : - convert_interest_to_data_v4 (vm, b0, rb, bi0); + convert_interest_to_data_v4 (vm, b0, rb, bi0); next0 = isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP : - HICNPG_SERVER_NEXT_V4_LOOKUP; + HICNPG_SERVER_NEXT_V4_LOOKUP; } if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && (b0->flags & VLIB_BUFFER_IS_TRACED))) diff --git a/hicn-plugin/src/pg.h b/hicn-plugin/src/pg.h index 84a391d43..059b076fb 100644 --- a/hicn-plugin/src/pg.h +++ b/hicn-plugin/src/pg.h @@ -16,7 +16,6 @@ #ifndef __HICN_PG_H__ #define __HICN_PG_H__ - /** * @file pg.h * @@ -25,25 +24,28 @@ * interest it receives with the corresponding data. * The packet generator is made of three nodes: * - hicnpg-interest that receives packets from a packet generator interface - * and manipulate them to generate interests based on the given configuration. - * This node runs at the client side. + * and manipulate them to generate interests based on the given + * configuration. This node runs at the client side. * - hicnpg-data that receives data packets at the client side and counts them. * This is useful for statistics. The "show err" command will give the number * of interest issued and data received at the client side - * - hicnpg-server that recevies and interest and replies with the corresponding - * data. The data is generated from the interest switching the src and destination - * address in the packet and appending a payload to the packet. + * - hicnpg-server that recevies and interest and replies with the + * corresponding data. The data is generated from the interest switching the + * src and destination address in the packet and appending a payload to the + * packet. * * * These three nodes are inserted in the vlib graph in the following manner: - * - hicnpg-interest is added as a possible next node of the pg-input node. The packet - * generator stream then specifies it as next node. - * - hicnpg-data is added as next hop of the ip4/6-unicast node exploiting the corresponding - * feature and it runs before the ip4/6-inacl node. In this way, every packet that is - * received through an interface on which this feature is enabled is sent to this node. - * - hicnpg-server is added as next hop of the ip4/6-unicast using the corresponding - * feature and it runs before the ip4/6-inacl node. In this way, every packet that is - * received through an interface on which this feature is enabled is sent to this node. + * - hicnpg-interest is added as a possible next node of the pg-input node. The + * packet generator stream then specifies it as next node. + * - hicnpg-data is added as next hop of the ip4/6-unicast node exploiting the + * corresponding feature and it runs before the ip4/6-inacl node. In this way, + * every packet that is received through an interface on which this feature is + * enabled is sent to this node. + * - hicnpg-server is added as next hop of the ip4/6-unicast using the + * corresponding feature and it runs before the ip4/6-inacl node. In this way, + * every packet that is received through an interface on which this feature is + * enabled is sent to this node. * * An example of how to use the pg for hicn is available in the documentation. */ @@ -55,19 +57,23 @@ */ typedef struct hicnpg_main_s { - u32 index; //used to compute the sequence number - fib_prefix_t *pgen_clt_hicn_name; //hICN name to put in the destiantion addess of an interest - u32 index_ifaces; /* used to mimic interests coming from different consumer */ - u32 n_ifaces; /* The source address will change from interest to interest */ + u32 index; // used to compute the sequence number + fib_prefix_t *pgen_clt_hicn_name; // hICN name to put in the destiantion + // addess of an interest + u32 + index_ifaces; /* used to mimic interests coming from different consumer */ + u32 n_ifaces; /* The source address will change from interest to interest */ /* index_ifaces is used to keep a global reference to the iface used */ /* and it is incremented when we want to change "consumer" */ /* n_ifaces identifies how many consumers to simulate */ - u32 max_seq_number; //Use to limit the max sequence number - u32 n_flows; //Use to simulate multiple flows (a flow always have the same hICN name) - ip46_address_t pgen_clt_src_addr; //Source addess base to use in the interest + u32 max_seq_number; // Use to limit the max sequence number + u32 n_flows; // Use to simulate multiple flows (a flow always have the same + // hICN name) + ip46_address_t pgen_clt_src_addr; // Source addess base to use in the + // interest - u16 interest_lifetime; // Interest lifetime - u32 sw_if; //Interface where to send interest and receives data + u16 interest_lifetime; // Interest lifetime + u32 sw_if; // Interface where to send interest and receives data } hicnpg_main_t; extern hicnpg_main_t hicnpg_main; diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c index 6db52f2fd..34a94936e 100644 --- a/hicn-plugin/src/route.c +++ b/hicn-plugin/src/route.c @@ -34,20 +34,20 @@ #include "infra.h" #include "udp_tunnels/udp_tunnel.h" -#define FIB_SOURCE_HICN 0x04 //Right after the FIB_SOURCE_INTERFACE priority +#define FIB_SOURCE_HICN 0x04 // Right after the FIB_SOURCE_INTERFACE priority fib_source_t hicn_fib_src; fib_node_type_t hicn_fib_node_type; -ip4_address_t localhost4 = {0}; -ip6_address_t localhost6 = {0}; +ip4_address_t localhost4 = { 0 }; +ip6_address_t localhost6 = { 0 }; int -hicn_route_get_dpo (const fib_prefix_t * prefix, - const dpo_id_t ** hicn_dpo, u32 * fib_index) +hicn_route_get_dpo (const fib_prefix_t *prefix, const dpo_id_t **hicn_dpo, + u32 *fib_index) { - //fib_prefix_t fib_pfx; + // fib_prefix_t fib_pfx; const dpo_id_t *load_balance_dpo_id; const dpo_id_t *former_dpo_id; int found = 0, ret = HICN_ERROR_ROUTE_NOT_FOUND; @@ -58,9 +58,8 @@ hicn_route_get_dpo (const fib_prefix_t * prefix, * ASSUMPTION: we use table 0 which is the default table and it is * already existing and locked */ - *fib_index = fib_table_find_or_create_and_lock (prefix->fp_proto, - HICN_FIB_TABLE, - hicn_fib_src); + *fib_index = fib_table_find_or_create_and_lock ( + prefix->fp_proto, HICN_FIB_TABLE, hicn_fib_src); fib_entry_index = fib_table_lookup_exact_match (*fib_index, prefix); if (fib_entry_index != FIB_NODE_INDEX_INVALID) @@ -103,7 +102,7 @@ hicn_route_get_dpo (const fib_prefix_t * prefix, } int -hicn_route_set_strategy (fib_prefix_t * prefix, u8 strategy_id) +hicn_route_set_strategy (fib_prefix_t *prefix, u8 strategy_id) { const dpo_id_t *hicn_dpo_id; dpo_id_t new_dpo_id = DPO_INVALID; @@ -125,16 +124,15 @@ hicn_route_set_strategy (fib_prefix_t * prefix, u8 strategy_id) return HICN_ERROR_STRATEGY_NOT_FOUND; /* Create a new dpo for the new strategy */ - new_dpo_vft->hicn_dpo_create (hicn_dpo_id->dpoi_proto, - old_hicn_dpo_ctx->next_hops, - old_hicn_dpo_ctx->entry_count, - &new_hicn_dpo_idx); + new_dpo_vft->hicn_dpo_create ( + hicn_dpo_id->dpoi_proto, old_hicn_dpo_ctx->next_hops, + old_hicn_dpo_ctx->entry_count, &new_hicn_dpo_idx); /* the value we got when we registered */ - dpo_set (&new_dpo_id, - new_dpo_vft->hicn_dpo_get_type (), + dpo_set (&new_dpo_id, new_dpo_vft->hicn_dpo_get_type (), (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 : - DPO_PROTO_IP6), new_hicn_dpo_idx); + DPO_PROTO_IP6), + new_hicn_dpo_idx); /* Here is where we create the "via" like route */ /* @@ -143,253 +141,247 @@ hicn_route_set_strategy (fib_prefix_t * prefix, u8 strategy_id) * that is adding them -- no easy explanation at this time… */ fib_node_index_t new_fib_node_index = - fib_table_entry_special_dpo_update (fib_index, - prefix, - hicn_fib_src, + fib_table_entry_special_dpo_update (fib_index, prefix, hicn_fib_src, FIB_ENTRY_FLAG_EXCLUSIVE, &new_dpo_id); dpo_unlock (&new_dpo_id); - ret = - (new_fib_node_index != - FIB_NODE_INDEX_INVALID) ? HICN_ERROR_NONE : - HICN_ERROR_ROUTE_NOT_UPDATED; + ret = (new_fib_node_index != FIB_NODE_INDEX_INVALID) ? + HICN_ERROR_NONE : + HICN_ERROR_ROUTE_NOT_UPDATED; } - //Remember to remove the lock from the table when removing the entry + // Remember to remove the lock from the table when removing the entry return ret; - } int -ip_nh_add_helper (fib_protocol_t fib_proto, const fib_prefix_t * rpfx, ip46_address_t * nh, u32 sw_if) +ip_nh_add_helper (fib_protocol_t fib_proto, const fib_prefix_t *rpfx, + ip46_address_t *nh, u32 sw_if) { fib_route_path_t *rpaths = NULL, rpath; - u32 fib_index = fib_table_find(fib_proto, 0); + u32 fib_index = fib_table_find (fib_proto, 0); - clib_memset(&rpath, 0, sizeof(rpath)); + clib_memset (&rpath, 0, sizeof (rpath)); rpath.frp_weight = 1; rpath.frp_sw_if_index = sw_if; rpath.frp_addr = *nh; - rpath.frp_proto = ip46_address_is_ip4(nh) ? DPO_PROTO_IP4 : DPO_PROTO_IP6; + rpath.frp_proto = ip46_address_is_ip4 (nh) ? DPO_PROTO_IP4 : DPO_PROTO_IP6; - vec_add1(rpaths, rpath); + vec_add1 (rpaths, rpath); - fib_table_entry_path_add2 (fib_index, - rpfx, - FIB_SOURCE_CLI, - FIB_ENTRY_FLAG_NONE, rpaths); + fib_table_entry_path_add2 (fib_index, rpfx, FIB_SOURCE_CLI, + FIB_ENTRY_FLAG_NONE, rpaths); return 0; } int -ip_nh_del_helper (fib_protocol_t fib_proto, const fib_prefix_t * rpfx, ip46_address_t * nh, u32 sw_if) +ip_nh_del_helper (fib_protocol_t fib_proto, const fib_prefix_t *rpfx, + ip46_address_t *nh, u32 sw_if) { fib_route_path_t *rpaths = NULL, rpath; - u32 fib_index = fib_table_find(fib_proto, 0); + u32 fib_index = fib_table_find (fib_proto, 0); - clib_memset(&rpath, 0, sizeof(rpath)); + clib_memset (&rpath, 0, sizeof (rpath)); rpath.frp_weight = 1; rpath.frp_sw_if_index = sw_if; rpath.frp_addr = *nh; - rpath.frp_proto = ip46_address_is_ip4(nh) ? DPO_PROTO_IP4 : DPO_PROTO_IP6; + rpath.frp_proto = ip46_address_is_ip4 (nh) ? DPO_PROTO_IP4 : DPO_PROTO_IP6; - vec_add1(rpaths, rpath); + vec_add1 (rpaths, rpath); - fib_table_entry_path_remove2 (fib_index, - rpfx, - FIB_SOURCE_CLI, - rpaths); + fib_table_entry_path_remove2 (fib_index, rpfx, FIB_SOURCE_CLI, rpaths); return 0; } - -static ip46_address_t * get_address(ip46_address_t * nh, u32 sw_if, fib_protocol_t proto) +static ip46_address_t * +get_address (ip46_address_t *nh, u32 sw_if, fib_protocol_t proto) { - ip46_address_t * local_address = calloc(1, sizeof(ip46_address_t)); + ip46_address_t *local_address = calloc (1, sizeof (ip46_address_t)); if (proto == FIB_PROTOCOL_IP4) { ip_interface_address_t *interface_address; - ip4_address_t *addr = - ip4_interface_address_matching_destination (&ip4_main, - &nh->ip4, - sw_if, - &interface_address); + ip4_address_t *addr = ip4_interface_address_matching_destination ( + &ip4_main, &nh->ip4, sw_if, &interface_address); if (addr == NULL) - addr = ip4_interface_first_address (&ip4_main, - sw_if, - &interface_address); + addr = + ip4_interface_first_address (&ip4_main, sw_if, &interface_address); if (addr != NULL) - ip46_address_set_ip4 (local_address, addr); + ip46_address_set_ip4 (local_address, addr); } else if (proto == FIB_PROTOCOL_IP6) { ip_interface_address_t *interface_address; - ip6_interface_address_matching_destination (&ip6_main, - &nh->ip6, - sw_if, - &interface_address); + ip6_interface_address_matching_destination (&ip6_main, &nh->ip6, sw_if, + &interface_address); ip6_address_t *addr = NULL; if (interface_address != NULL) - addr = - (ip6_address_t *) - ip_interface_address_get_address (&ip6_main.lookup_main, - interface_address); + addr = (ip6_address_t *) ip_interface_address_get_address ( + &ip6_main.lookup_main, interface_address); if (addr == NULL) - addr = ip6_interface_first_address (&ip6_main, sw_if); + addr = ip6_interface_first_address (&ip6_main, sw_if); if (addr != NULL) - ip46_address_set_ip6 (local_address, addr); + ip46_address_set_ip6 (local_address, addr); } return local_address; } static void -sync_hicn_fib_entry(hicn_dpo_ctx_t *fib_entry) +sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry) { - const dpo_id_t * dpo_loadbalance = fib_entry_contribute_ip_forwarding (fib_entry->fib_entry_index); - const load_balance_t *lb0 = load_balance_get(dpo_loadbalance->dpoi_index); - index_t hicn_fib_entry_index = hicn_strategy_dpo_ctx_get_index(fib_entry); - hicn_face_id_t * vec_faces = 0; + const dpo_id_t *dpo_loadbalance = + fib_entry_contribute_ip_forwarding (fib_entry->fib_entry_index); + const load_balance_t *lb0 = load_balance_get (dpo_loadbalance->dpoi_index); + index_t hicn_fib_entry_index = hicn_strategy_dpo_ctx_get_index (fib_entry); + hicn_face_id_t *vec_faces = 0; dpo_id_t temp = DPO_INVALID; const dpo_id_t *former_dpo = &temp; int index = 0; -#define ADD_FACE(nh) \ - do { \ - /* Careful, this adds a lock on the face if it exists */ \ - hicn_face_add(dpo, nh, sw_if, &face_id, 0); \ - vec_validate(vec_faces, index); \ - vec_faces[index] = face_id; \ - (index)++; \ - \ - /* Face creation can realloc load_balance_t? Seem the fib_tracking does so. */ \ - dpo_loadbalance = fib_entry_contribute_ip_forwarding (fib_entry->fib_entry_index); \ - lb0 = load_balance_get(dpo_loadbalance->dpoi_index); \ - } while (0) \ - - for (int j = 0; j < lb0->lb_n_buckets; j++) { - const dpo_id_t * dpo = load_balance_get_bucket_i(lb0,j); - - int dpo_comparison = dpo_cmp(former_dpo, dpo); - former_dpo = dpo; - /* - * Loadbalancing in ip replicate the dpo in multiple buckets - * in order to honor the assigned weights. - */ - if (dpo_comparison == 0) - continue; - - u32 sw_if = ~0; - ip46_address_t * nh = NULL; - hicn_face_id_t face_id = HICN_FACE_NULL; - - if (dpo_is_adj(dpo)) - { - ip_adjacency_t * adj = adj_get (dpo->dpoi_index); - sw_if = adj->rewrite_header.sw_if_index; - nh = get_address (&(adj->sub_type.nbr.next_hop), sw_if, fib_entry->proto); - ADD_FACE(nh); - } - else if (dpo->dpoi_type == dpo_type_udp_ip4 || dpo->dpoi_type == dpo_type_udp_ip6) - { - u8 proto = dpo->dpoi_type == dpo_type_udp_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6; - ip46_address_t _nh = {0}; - nh = &_nh; - switch (dpo->dpoi_proto) - { - case FIB_PROTOCOL_IP6: - case FIB_PROTOCOL_IP4: - /** - * Independently of the type of tunnel, encapsulated packet - * can be either v6 or v4, so we need to create 2 faces for each - * version. Tunneled hicn packet MUST have locator set to the loopback - * address, so ::1 for IPv6 and 127.0.0.1 for IPv4. - */ - ip46_address_set_ip6(nh, &localhost6); - ADD_FACE(nh); - ip46_address_set_ip4(nh, &localhost4); - ADD_FACE(nh); - break; - default: - continue; - } - udp_tunnel_add_existing (dpo->dpoi_index, proto); - } - } - - const hicn_dpo_vft_t * strategy_vft = hicn_dpo_get_vft(fib_entry->dpo_type); +#define ADD_FACE(nh) \ + do \ + { \ + /* Careful, this adds a lock on the face if it exists */ \ + hicn_face_add (dpo, nh, sw_if, &face_id, 0); \ + vec_validate (vec_faces, index); \ + vec_faces[index] = face_id; \ + (index)++; \ + \ + /* Face creation can realloc load_balance_t? Seem the fib_tracking does \ + * so. */ \ + dpo_loadbalance = \ + fib_entry_contribute_ip_forwarding (fib_entry->fib_entry_index); \ + lb0 = load_balance_get (dpo_loadbalance->dpoi_index); \ + } \ + while (0) + + for (int j = 0; j < lb0->lb_n_buckets; j++) + { + const dpo_id_t *dpo = load_balance_get_bucket_i (lb0, j); + + int dpo_comparison = dpo_cmp (former_dpo, dpo); + former_dpo = dpo; + /* + * Loadbalancing in ip replicate the dpo in multiple buckets + * in order to honor the assigned weights. + */ + if (dpo_comparison == 0) + continue; + + u32 sw_if = ~0; + ip46_address_t *nh = NULL; + hicn_face_id_t face_id = HICN_FACE_NULL; + + if (dpo_is_adj (dpo)) + { + ip_adjacency_t *adj = adj_get (dpo->dpoi_index); + sw_if = adj->rewrite_header.sw_if_index; + nh = get_address (&(adj->sub_type.nbr.next_hop), sw_if, + fib_entry->proto); + ADD_FACE (nh); + } + else if (dpo->dpoi_type == dpo_type_udp_ip4 || + dpo->dpoi_type == dpo_type_udp_ip6) + { + u8 proto = dpo->dpoi_type == dpo_type_udp_ip4 ? FIB_PROTOCOL_IP4 : + FIB_PROTOCOL_IP6; + ip46_address_t _nh = { 0 }; + nh = &_nh; + switch (dpo->dpoi_proto) + { + case FIB_PROTOCOL_IP6: + case FIB_PROTOCOL_IP4: + /** + * Independently of the type of tunnel, encapsulated packet + * can be either v6 or v4, so we need to create 2 faces for each + * version. Tunneled hicn packet MUST have locator set to the + * loopback address, so ::1 for IPv6 and 127.0.0.1 for IPv4. + */ + ip46_address_set_ip6 (nh, &localhost6); + ADD_FACE (nh); + ip46_address_set_ip4 (nh, &localhost4); + ADD_FACE (nh); + break; + default: + continue; + } + udp_tunnel_add_existing (dpo->dpoi_index, proto); + } + } + + const hicn_dpo_vft_t *strategy_vft = hicn_dpo_get_vft (fib_entry->dpo_type); int i = 0; while (i < fib_entry->entry_count) { - u32 idx_nh = vec_search(vec_faces, fib_entry->next_hops[i]); + u32 idx_nh = vec_search (vec_faces, fib_entry->next_hops[i]); if (idx_nh == ~0) - { - strategy_vft->hicn_dpo_del_nh(fib_entry->next_hops[i], hicn_fib_entry_index); - } + { + strategy_vft->hicn_dpo_del_nh (fib_entry->next_hops[i], + hicn_fib_entry_index); + } else - { - vec_del1(vec_faces, idx_nh); + { + vec_del1 (vec_faces, idx_nh); - /* Remove the lock added by hicn_face_add */ - hicn_face_unlock_with_id (fib_entry->next_hops[i]); - i++; - } + /* Remove the lock added by hicn_face_add */ + hicn_face_unlock_with_id (fib_entry->next_hops[i]); + i++; + } } hicn_face_id_t *face_id; - vec_foreach(face_id, vec_faces) + vec_foreach (face_id, vec_faces) { - strategy_vft->hicn_dpo_add_update_nh(*face_id, hicn_fib_entry_index); + strategy_vft->hicn_dpo_add_update_nh (*face_id, hicn_fib_entry_index); /* Remove the lock added by hicn_face_add */ hicn_face_unlock_with_id (*face_id); - } - vec_free(vec_faces); + vec_free (vec_faces); } static void enable_disable_data_receiving (fib_protocol_t proto, u32 sw_if, u8 is_enable) { if (proto == FIB_PROTOCOL_IP4 && sw_if != ~0) - vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4", - sw_if, is_enable, 0, 0); + vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4", sw_if, + is_enable, 0, 0); else if (proto == FIB_PROTOCOL_IP6 && sw_if != ~0) - vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6", - sw_if, is_enable, 0, 0); - + vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6", sw_if, + is_enable, 0, 0); } -walk_rc_t enable_data_receiving_new_fib_entry (vnet_main_t * vnm, - vnet_sw_interface_t * si, - void *ctx) +walk_rc_t +enable_data_receiving_new_fib_entry (vnet_main_t *vnm, vnet_sw_interface_t *si, + void *ctx) { fib_protocol_t *proto = (fib_protocol_t *) ctx; - enable_disable_data_receiving(*proto, si->sw_if_index, 1); + enable_disable_data_receiving (*proto, si->sw_if_index, 1); return (WALK_CONTINUE); } -walk_rc_t disable_data_receiving_rm_fib_entry (vnet_main_t * vnm, - vnet_sw_interface_t * si, - void *ctx) +walk_rc_t +disable_data_receiving_rm_fib_entry (vnet_main_t *vnm, vnet_sw_interface_t *si, + void *ctx) { fib_protocol_t *proto = (fib_protocol_t *) ctx; - enable_disable_data_receiving(*proto, si->sw_if_index, 0); + enable_disable_data_receiving (*proto, si->sw_if_index, 0); return (WALK_CONTINUE); - } +} int -hicn_route_enable (fib_prefix_t *prefix) { +hicn_route_enable (fib_prefix_t *prefix) +{ int ret = HICN_ERROR_NONE; fib_node_index_t fib_entry_index; @@ -399,7 +391,7 @@ hicn_route_enable (fib_prefix_t *prefix) { * ASSUMPTION: we use table 0 which is the default table and it is * already existing and locked */ - u32 fib_index = fib_table_find(prefix->fp_proto, 0); + u32 fib_index = fib_table_find (prefix->fp_proto, 0); fib_entry_index = fib_table_lookup_exact_match (fib_index, prefix); @@ -407,43 +399,43 @@ hicn_route_enable (fib_prefix_t *prefix) { { fib_entry_index = fib_table_lookup (fib_index, prefix); - fib_route_path_t * paths = fib_entry_encode(fib_entry_index); + fib_route_path_t *paths = fib_entry_encode (fib_entry_index); - fib_table_entry_path_add2(fib_index, prefix, FIB_SOURCE_CLI, FIB_ENTRY_FLAG_NONE, paths); + fib_table_entry_path_add2 (fib_index, prefix, FIB_SOURCE_CLI, + FIB_ENTRY_FLAG_NONE, paths); } /* Check if the prefix is already enabled */ - u32 fib_hicn_index = fib_table_find(prefix->fp_proto, HICN_FIB_TABLE); + u32 fib_hicn_index = fib_table_find (prefix->fp_proto, HICN_FIB_TABLE); - fib_node_index_t fib_hicn_entry_index = fib_table_lookup_exact_match (fib_hicn_index, prefix); + fib_node_index_t fib_hicn_entry_index = + fib_table_lookup_exact_match (fib_hicn_index, prefix); if (fib_hicn_entry_index == FIB_NODE_INDEX_INVALID) { dpo_id_t dpo = DPO_INVALID; index_t dpo_idx; default_dpo.hicn_dpo_create (prefix->fp_proto, 0, NEXT_HOP_INVALID, - &dpo_idx); + &dpo_idx); /* the value we got when we registered */ /* * This should be taken from the name?!? the index of the * object */ - dpo_set (&dpo, - default_dpo.hicn_dpo_get_type (), - (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 : - DPO_PROTO_IP6), dpo_idx); + dpo_set (&dpo, default_dpo.hicn_dpo_get_type (), + (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 : + DPO_PROTO_IP6), + dpo_idx); - hicn_dpo_ctx_t * fib_entry = hicn_strategy_dpo_ctx_get(dpo_idx); + hicn_dpo_ctx_t *fib_entry = hicn_strategy_dpo_ctx_get (dpo_idx); fib_node_init (&fib_entry->fib_node, hicn_fib_node_type); fib_node_lock (&fib_entry->fib_node); - fib_entry->fib_entry_index = fib_entry_track (fib_index, - prefix, - hicn_fib_node_type, - dpo_idx, &fib_entry->fib_sibling); - + fib_entry->fib_entry_index = + fib_entry_track (fib_index, prefix, hicn_fib_node_type, dpo_idx, + &fib_entry->fib_sibling); /* Here is where we create the "via" like route */ /* @@ -452,27 +444,27 @@ hicn_route_enable (fib_prefix_t *prefix) { * that is adding them -- no easy explanation at this time… */ CLIB_UNUSED (fib_node_index_t new_fib_node_index) = - fib_table_entry_special_dpo_add (fib_hicn_index, - prefix, - hicn_fib_src, - (FIB_ENTRY_FLAG_EXCLUSIVE | - FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT), - &dpo); + fib_table_entry_special_dpo_add ( + fib_hicn_index, prefix, hicn_fib_src, + (FIB_ENTRY_FLAG_EXCLUSIVE | FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT), &dpo); - sync_hicn_fib_entry(fib_entry); + sync_hicn_fib_entry (fib_entry); /* We added a route, therefore add one lock to the table */ fib_table_lock (fib_index, prefix->fp_proto, hicn_fib_src); - /* Enable the feature to punt data packet every time we enable a new hicn route - * For each enable there must be a disable to defenitely disable the feature + /* Enable the feature to punt data packet every time we enable a new hicn + * route For each enable there must be a disable to defenitely disable + * the feature * - * We cannot enable only the interfaces on which we send out interest because - * Data packet might be coming on in different interfaces, as in che case of mpls - * tunnels (packets are received from the physical nic, not the mpls tunnel interface). + * We cannot enable only the interfaces on which we send out interest + * because Data packet might be coming on in different interfaces, as in + * che case of mpls tunnels (packets are received from the physical nic, + * not the mpls tunnel interface). */ - vnet_main_t * vnm = vnet_get_main (); - vnet_sw_interface_walk(vnm, enable_data_receiving_new_fib_entry, &(prefix->fp_proto)); + vnet_main_t *vnm = vnet_get_main (); + vnet_sw_interface_walk (vnm, enable_data_receiving_new_fib_entry, + &(prefix->fp_proto)); dpo_unlock (&dpo); } @@ -487,48 +479,51 @@ hicn_route_enable (fib_prefix_t *prefix) { /* The dpo is not a load balance dpo as expected */ if (load_balance_dpo_id->dpoi_type != DPO_LOAD_BALANCE) - { - ret = HICN_ERROR_ROUTE_NO_LD; - goto done; - } + { + ret = HICN_ERROR_ROUTE_NO_LD; + goto done; + } else { load_balance_t *lb = load_balance_get (load_balance_dpo_id->dpoi_index); - strategy_dpo_id = load_balance_get_bucket_i (lb, 0); + strategy_dpo_id = load_balance_get_bucket_i (lb, 0); - if (!dpo_is_hicn (strategy_dpo_id)) - { - ret = HICN_ERROR_ROUTE_DPO_NO_HICN; - goto done; - } + if (!dpo_is_hicn (strategy_dpo_id)) + { + ret = HICN_ERROR_ROUTE_DPO_NO_HICN; + goto done; + } - if (lb->lb_n_buckets > 1) - { - ret = HICN_ERROR_ROUTE_MLT_LD; - goto done; - } + if (lb->lb_n_buckets > 1) + { + ret = HICN_ERROR_ROUTE_MLT_LD; + goto done; + } - hicn_dpo_ctx_t * hicn_fib_entry = hicn_strategy_dpo_ctx_get(strategy_dpo_id->dpoi_index); + hicn_dpo_ctx_t *hicn_fib_entry = + hicn_strategy_dpo_ctx_get (strategy_dpo_id->dpoi_index); - sync_hicn_fib_entry(hicn_fib_entry); - } + sync_hicn_fib_entry (hicn_fib_entry); + } } - done: +done: return ret; } int -hicn_route_disable (fib_prefix_t *prefix) { +hicn_route_disable (fib_prefix_t *prefix) +{ int ret = HICN_ERROR_NONE; /* Check if the prefix is already enabled */ - u32 fib_hicn_index = fib_table_find(prefix->fp_proto, HICN_FIB_TABLE); + u32 fib_hicn_index = fib_table_find (prefix->fp_proto, HICN_FIB_TABLE); - fib_node_index_t fib_hicn_entry_index = fib_table_lookup_exact_match (fib_hicn_index, prefix); + fib_node_index_t fib_hicn_entry_index = + fib_table_lookup_exact_match (fib_hicn_index, prefix); if (fib_hicn_entry_index == FIB_NODE_INDEX_INVALID) { @@ -538,7 +533,7 @@ hicn_route_disable (fib_prefix_t *prefix) { { const dpo_id_t *load_balance_dpo_id; const dpo_id_t *strategy_dpo_id; - hicn_dpo_ctx_t * hicn_fib_entry; + hicn_dpo_ctx_t *hicn_fib_entry; /* Route already existing. We need to update the dpo. */ load_balance_dpo_id = @@ -546,57 +541,61 @@ hicn_route_disable (fib_prefix_t *prefix) { /* The dpo is not a load balance dpo as expected */ if (load_balance_dpo_id->dpoi_type != DPO_LOAD_BALANCE) - { - ret = HICN_ERROR_ROUTE_NO_LD; - goto done; - } + { + ret = HICN_ERROR_ROUTE_NO_LD; + goto done; + } else { load_balance_t *lb = load_balance_get (load_balance_dpo_id->dpoi_index); - strategy_dpo_id = load_balance_get_bucket_i (lb, 0); + strategy_dpo_id = load_balance_get_bucket_i (lb, 0); - if (!dpo_is_hicn (strategy_dpo_id)) - { - ret = HICN_ERROR_ROUTE_DPO_NO_HICN; - goto done; - } + if (!dpo_is_hicn (strategy_dpo_id)) + { + ret = HICN_ERROR_ROUTE_DPO_NO_HICN; + goto done; + } - if (lb->lb_n_buckets > 1) - { - ret = HICN_ERROR_ROUTE_MLT_LD; - goto done; - } + if (lb->lb_n_buckets > 1) + { + ret = HICN_ERROR_ROUTE_MLT_LD; + goto done; + } - hicn_fib_entry = hicn_strategy_dpo_ctx_get(strategy_dpo_id->dpoi_index); + hicn_fib_entry = + hicn_strategy_dpo_ctx_get (strategy_dpo_id->dpoi_index); - for (int i = 0; i < hicn_fib_entry->entry_count; i++) - { - hicn_strategy_dpo_ctx_del_nh(hicn_fib_entry->next_hops[i], hicn_fib_entry); - } - } + for (int i = 0; i < hicn_fib_entry->entry_count; i++) + { + hicn_strategy_dpo_ctx_del_nh (hicn_fib_entry->next_hops[i], + hicn_fib_entry); + } + } - fib_entry_untrack(hicn_fib_entry->fib_entry_index, hicn_fib_entry->fib_sibling); + fib_entry_untrack (hicn_fib_entry->fib_entry_index, + hicn_fib_entry->fib_sibling); fib_table_entry_special_remove (fib_hicn_index, prefix, hicn_fib_src); - /* Disable the feature to punt data packet every time we enable a new hicn route */ - vnet_main_t * vnm = vnet_get_main (); - vnet_sw_interface_walk(vnm, disable_data_receiving_rm_fib_entry, &(prefix->fp_proto)); + /* Disable the feature to punt data packet every time we enable a new + * hicn route */ + vnet_main_t *vnm = vnet_get_main (); + vnet_sw_interface_walk (vnm, disable_data_receiving_rm_fib_entry, + &(prefix->fp_proto)); } - done: +done: return ret; } - static fib_node_t * hicn_ctx_node_get (fib_node_index_t index) { - hicn_dpo_ctx_t * hicn_ctx; + hicn_dpo_ctx_t *hicn_ctx; - hicn_ctx = hicn_strategy_dpo_ctx_get(index); + hicn_ctx = hicn_strategy_dpo_ctx_get (index); return (&hicn_ctx->fib_node); } @@ -607,20 +606,19 @@ hicn_fib_last_lock_gone (fib_node_t *node) } static hicn_dpo_ctx_t * -hicn_ctx_from_fib_node (fib_node_t * node) +hicn_ctx_from_fib_node (fib_node_t *node) { return ((hicn_dpo_ctx_t *) (((char *) node) - - STRUCT_OFFSET_OF (hicn_dpo_ctx_t, fib_node))); + STRUCT_OFFSET_OF (hicn_dpo_ctx_t, fib_node))); } static fib_node_back_walk_rc_t -hicn_fib_back_walk_notify (fib_node_t *node, - fib_node_back_walk_ctx_t *ctx) +hicn_fib_back_walk_notify (fib_node_t *node, fib_node_back_walk_ctx_t *ctx) { hicn_dpo_ctx_t *fib_entry = hicn_ctx_from_fib_node (node); - sync_hicn_fib_entry(fib_entry); + sync_hicn_fib_entry (fib_entry); return (FIB_NODE_BACK_WALK_CONTINUE); } @@ -630,25 +628,22 @@ hicn_fib_show_memory (void) { } - -static const fib_node_vft_t hicn_fib_vft = -{ - .fnv_get = hicn_ctx_node_get, - .fnv_last_lock = hicn_fib_last_lock_gone, - .fnv_back_walk = hicn_fib_back_walk_notify, - .fnv_mem_show = hicn_fib_show_memory, +static const fib_node_vft_t hicn_fib_vft = { + .fnv_get = hicn_ctx_node_get, + .fnv_last_lock = hicn_fib_last_lock_gone, + .fnv_back_walk = hicn_fib_back_walk_notify, + .fnv_mem_show = hicn_fib_show_memory, }; -fib_table_walk_rc_t enable_data_on_existing_hicn(fib_node_index_t fei, - void *ctx) +fib_table_walk_rc_t +enable_data_on_existing_hicn (fib_node_index_t fei, void *ctx) { - u32 sw_if = *(u32 *)ctx; + u32 sw_if = *(u32 *) ctx; const dpo_id_t *load_balance_dpo_id; const dpo_id_t *strategy_dpo_id; /* Route already existing. We need to update the dpo. */ - load_balance_dpo_id = - fib_entry_contribute_ip_forwarding (fei); + 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) @@ -657,25 +652,24 @@ fib_table_walk_rc_t enable_data_on_existing_hicn(fib_node_index_t fei, } else { - 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); strategy_dpo_id = load_balance_get_bucket_i (lb, 0); if (!dpo_is_hicn (strategy_dpo_id)) - { - goto done; - } + { + goto done; + } enable_disable_data_receiving (strategy_dpo_id->dpoi_proto, sw_if, 1); } - done: +done: return (FIB_TABLE_WALK_CONTINUE); } static clib_error_t * -set_table_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add) +set_table_interface_add_del (vnet_main_t *vnm, u32 sw_if_index, u32 is_add) { if (!is_add) @@ -688,37 +682,32 @@ set_table_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add) rv = ip_table_bind (FIB_PROTOCOL_IP6, sw_if_index, HICN_FIB_TABLE, 1); if (rv) - { - /* An error occurred. Bind the interface back to the default fib */ - ip_table_bind (FIB_PROTOCOL_IP4, sw_if_index, 0, 1); - } + { + /* An error occurred. Bind the interface back to the default fib */ + ip_table_bind (FIB_PROTOCOL_IP4, sw_if_index, 0, 1); + } } - u32 fib_index = fib_table_find(FIB_PROTOCOL_IP4, - HICN_FIB_TABLE); + u32 fib_index = fib_table_find (FIB_PROTOCOL_IP4, HICN_FIB_TABLE); if (fib_index != ~0) { /* * Walk the ip4 and ip6 fib tables to discover existing hicn fib entries. * For each of them we need to enable the feature to punt data packets. */ - fib_table_walk(fib_index, - FIB_PROTOCOL_IP4, - enable_data_on_existing_hicn, - &sw_if_index); + fib_table_walk (fib_index, FIB_PROTOCOL_IP4, + enable_data_on_existing_hicn, &sw_if_index); } - fib_index = fib_table_find(FIB_PROTOCOL_IP6, - HICN_FIB_TABLE); + fib_index = fib_table_find (FIB_PROTOCOL_IP6, HICN_FIB_TABLE); if (fib_index != ~0) { - fib_table_walk(fib_index, - FIB_PROTOCOL_IP6, - enable_data_on_existing_hicn, - &sw_if_index); + fib_table_walk (fib_index, FIB_PROTOCOL_IP6, + enable_data_on_existing_hicn, &sw_if_index); } - return rv ? clib_error_return (0, "unable to add hicn table to interface") : 0; + return rv ? clib_error_return (0, "unable to add hicn table to interface") : + 0; } VNET_SW_INTERFACE_ADD_DEL_FUNCTION (set_table_interface_add_del); @@ -726,23 +715,23 @@ VNET_SW_INTERFACE_ADD_DEL_FUNCTION (set_table_interface_add_del); void hicn_route_init () { - vnet_main_t * vnm = vnet_get_main (); - vlib_main_t * vm = vlib_get_main (); - hicn_fib_src = fib_source_allocate ("hicn", - FIB_SOURCE_HICN, FIB_SOURCE_BH_API); + vnet_main_t *vnm = vnet_get_main (); + vlib_main_t *vm = vlib_get_main (); + hicn_fib_src = + fib_source_allocate ("hicn", FIB_SOURCE_HICN, FIB_SOURCE_BH_API); - hicn_fib_node_type = fib_node_register_new_type(&hicn_fib_vft); + hicn_fib_node_type = fib_node_register_new_type (&hicn_fib_vft); - ip_table_create(FIB_PROTOCOL_IP4, HICN_FIB_TABLE, 1, (const u8 *)"hicn4"); - ip_table_create(FIB_PROTOCOL_IP6, HICN_FIB_TABLE, 1, (const u8 *)"hicn6"); + ip_table_create (FIB_PROTOCOL_IP4, HICN_FIB_TABLE, 1, (const u8 *) "hicn4"); + ip_table_create (FIB_PROTOCOL_IP6, HICN_FIB_TABLE, 1, (const u8 *) "hicn6"); u32 sw_if_index; u8 mac_address[6]; u8 is_specified = 0; u32 user_instance = 0; - vnet_create_loopback_interface (&sw_if_index, mac_address, - is_specified, user_instance); + vnet_create_loopback_interface (&sw_if_index, mac_address, is_specified, + user_instance); localhost4.as_u8[0] = 127; localhost4.as_u8[3] = 1; @@ -750,8 +739,10 @@ hicn_route_init () localhost6.as_u8[15] = 1; - ip4_add_del_interface_address (vm, sw_if_index, &localhost4, length4, is_del); - ip6_add_del_interface_address (vm, sw_if_index, &localhost6, length6, is_del); + ip4_add_del_interface_address (vm, sw_if_index, &localhost4, length4, + is_del); + ip6_add_del_interface_address (vm, sw_if_index, &localhost6, length6, + is_del); flags |= VNET_SW_INTERFACE_FLAG_ADMIN_UP; vnet_sw_interface_set_flags (vnm, sw_if_index, flags); diff --git a/hicn-plugin/src/route.h b/hicn-plugin/src/route.h index a1ba86b3d..19b18b8c6 100644 --- a/hicn-plugin/src/route.h +++ b/hicn-plugin/src/route.h @@ -24,27 +24,30 @@ /** * @file route.h * - * hICN uses a specific vrf to install the routes for a prefix has been enabled to - * be hicn. It considers the vrf 0 (the default vrf) as the dominating vrf on - * which every route is stored. Enabling a prefix to be hICN will copy all the routes - * in the vrf 0 for the given prefi, in the vrf HICN. Every modification made on the - * vrf 0 on an hICN enabled prefix is reflected in the vrf hICN (through the use of - * the fib entry tracking functionality). Moreover, we use the lookup in the vrf hICN - * as a way for punting packet that must be processed as hICN. The implementation will - * install a special dpo as a single next hop for the vpp load balancer for each entry - * in the vrf hICN that we enabled. Such dpo will have two purposes: 1) to punt packets - * to the hICN forwarding pipeline, 2) to point to the righe strategy (the dpoi_index will - * be an index to the strategy context while the dpoi_type will be an index to the strategy vft). + * hICN uses a specific vrf to install the routes for a prefix has been enabled + * to be hicn. It considers the vrf 0 (the default vrf) as the dominating vrf + * on which every route is stored. Enabling a prefix to be hICN will copy all + * the routes in the vrf 0 for the given prefi, in the vrf HICN. Every + * modification made on the vrf 0 on an hICN enabled prefix is reflected in the + * vrf hICN (through the use of the fib entry tracking functionality). + * Moreover, we use the lookup in the vrf hICN as a way for punting packet that + * must be processed as hICN. The implementation will install a special dpo as + * a single next hop for the vpp load balancer for each entry in the vrf hICN + * that we enabled. Such dpo will have two purposes: 1) to punt packets to the + * hICN forwarding pipeline, 2) to point to the righe strategy (the dpoi_index + * will be an index to the strategy context while the dpoi_type will be an + * index to the strategy vft). * - * Additionally, hICN assign each interface to the vrf hICN; this is required for - * the interest lookup. Vpp performs a lookup in the vrf assigned to the interface, - * therefore if an interface is not assigned to the hICN vrf, the lookup will be done - * on the vrf 0 and the packet won't be processed through the hicn forwarding pipeline. + * Additionally, hICN assign each interface to the vrf hICN; this is required + * for the interest lookup. Vpp performs a lookup in the vrf assigned to the + * interface, therefore if an interface is not assigned to the hICN vrf, the + * lookup will be done on the vrf 0 and the packet won't be processed through + * the hicn forwarding pipeline. */ /* - * Adding each interface to the vrf hICN has the side effect that to ping you need to - * specify the vrf hICN in the command. + * Adding each interface to the vrf hICN has the side effect that to ping you + * need to specify the vrf hICN in the command. */ extern fib_source_t hicn_fib_src; @@ -58,10 +61,8 @@ extern dpo_type_t udp_encap_dpo_types[FIB_PROTOCOL_MAX]; * @param hicn_dpo return value with the hicn_dpo * @param fib_index return value with the fib index corresponding to the prefix */ -int -hicn_route_get_dpo (const fib_prefix_t * prefix, - const dpo_id_t ** hicn_dpo, u32 * fib_index); - +int hicn_route_get_dpo (const fib_prefix_t *prefix, const dpo_id_t **hicn_dpo, + u32 *fib_index); /** * @Brief Set the strategy for a given prefix @@ -69,8 +70,7 @@ hicn_route_get_dpo (const fib_prefix_t * prefix, * @param prefix Prefix for which we set the strategy * @param stretegy_id Index of the strategy to set */ -int -hicn_route_set_strategy (fib_prefix_t * prefix, u32 strategy_id); +int hicn_route_set_strategy (fib_prefix_t *prefix, u32 strategy_id); /** * @Brief Helper to add a nex hop in the vrf 0. If there are no entries in the @@ -81,32 +81,32 @@ hicn_route_set_strategy (fib_prefix_t * prefix, u32 strategy_id); * @param nh Next hop to add * @param sw_if Software interface index to add in the next hop */ -int -ip_nh_add_helper (fib_protocol_t fib_proto, const fib_prefix_t * pfx, ip46_address_t * nh, u32 sw_if); +int ip_nh_add_helper (fib_protocol_t fib_proto, const fib_prefix_t *pfx, + ip46_address_t *nh, u32 sw_if); /** - * @Brief Helper to remove a nex hop in the vrf 0. If there are no entries in the - * vrf 0 nothing happens. + * @Brief Helper to remove a nex hop in the vrf 0. If there are no entries in + * the vrf 0 nothing happens. * * @param fib_proto FIB_PROTOCOL_IP6 or FIB_PROTOCOL_IP4 (mpls not supported) * @param pfx Prefix for which to remove a next hop * @param nh Next hop to remove * @param sw_if Software interface index in the next hop definition */ -int -ip_nh_del_helper (fib_protocol_t fib_proto, const fib_prefix_t * rpfx, ip46_address_t * nh, u32 sw_if); +int ip_nh_del_helper (fib_protocol_t fib_proto, const fib_prefix_t *rpfx, + ip46_address_t *nh, u32 sw_if); /** * @Brief Enable an hICN for an ip prefix * * @param prefix Prefix for which we enable hICN * @return HICN_ERROR_NONE if hICN was enabled on the prefix - * HICN_ERROR_ROUTE_NO_LD if the first dpo for the fib entry corresponding to the prefix is not a load_balancer - * HICN_ERROR_ROUTE_DPO_NO_HICN if the loadbalancer in the vrf HICN already contains a dpo which is not an hICN one + * HICN_ERROR_ROUTE_NO_LD if the first dpo for the fib entry corresponding to + * the prefix is not a load_balancer HICN_ERROR_ROUTE_DPO_NO_HICN if the + * loadbalancer in the vrf HICN already contains a dpo which is not an hICN one * HICN_ERROR_ROUTE_MLT_LD if there are more than a dpo in the vpp loadbalancer */ -int -hicn_route_enable (fib_prefix_t *prefix); +int hicn_route_enable (fib_prefix_t *prefix); /** * @Brief Disable an hICN for an ip prefix. If hICN wasn't enable on the prefix @@ -114,13 +114,10 @@ hicn_route_enable (fib_prefix_t *prefix); * * @param prefix Prefix for which we disable hICN */ -int -hicn_route_disable (fib_prefix_t *prefix); - +int hicn_route_disable (fib_prefix_t *prefix); /* Init route internal strustures */ -void -hicn_route_init(); +void hicn_route_init (); #endif /* //__HICN_ROUTE__ */ /* diff --git a/hicn-plugin/src/state.h b/hicn-plugin/src/state.h index 37003d0ae..561aef2db 100644 --- a/hicn-plugin/src/state.h +++ b/hicn-plugin/src/state.h @@ -29,11 +29,12 @@ /** * @file plugin_state * - * Helper functions to hicn state (hash node, hash entry, strategy vft, dpo vft and dpo context id) + * Helper functions to hicn state (hash node, hash entry, strategy vft, dpo vft + * and dpo context id) * */ -//TODO exploit this state to prefetch hash nodes and entries. +// TODO exploit this state to prefetch hash nodes and entries. /** * @brief Retrieve the hicn state @@ -41,17 +42,20 @@ * @param hicnb hicn buffer used to retrieve the hicn state * @param pitcs pointer to PIT/CS * @param node node in the hash table referring to the buffer - * @param strategy_vft return value pointing to the strategy vft corresponding to the buffer - * @param dpo_vft return value pointing to the dpo vft corresponding to the buffer - * @param dpo_ctx_id return value pointing to the dpo context id corresponding to the buffer + * @param strategy_vft return value pointing to the strategy vft corresponding + * to the buffer + * @param dpo_vft return value pointing to the dpo vft corresponding to the + * buffer + * @param dpo_ctx_id return value pointing to the dpo context id corresponding + * to the buffer * @param hash_entry entry in the hash table referring to the buffer */ always_inline void -hicn_get_internal_state (hicn_buffer_t * hicnb, hicn_pit_cs_t * pitcs, - hicn_hash_node_t ** node, - const hicn_strategy_vft_t ** strategy_vft, - const hicn_dpo_vft_t ** dpo_vft, u8 * dpo_ctx_id, - hicn_hash_entry_t ** hash_entry) +hicn_get_internal_state (hicn_buffer_t *hicnb, hicn_pit_cs_t *pitcs, + hicn_hash_node_t **node, + const hicn_strategy_vft_t **strategy_vft, + const hicn_dpo_vft_t **dpo_vft, u8 *dpo_ctx_id, + hicn_hash_entry_t **hash_entry) { *node = pool_elt_at_index (pitcs->pcs_table->ht_nodes, hicnb->node_id); *strategy_vft = hicn_dpo_get_strategy_vft (hicnb->vft_id); @@ -60,13 +64,11 @@ hicn_get_internal_state (hicn_buffer_t * hicnb, hicn_pit_cs_t * pitcs, hicn_hash_bucket_t *bucket; if (hicnb->hash_bucket_flags & HICN_HASH_NODE_OVERFLOW_BUCKET) - bucket = - pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets, - hicnb->bucket_id); + bucket = pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets, + hicnb->bucket_id); else bucket = - (hicn_hash_bucket_t *) (pitcs->pcs_table->ht_buckets + - hicnb->bucket_id); + (hicn_hash_bucket_t *) (pitcs->pcs_table->ht_buckets + hicnb->bucket_id); *hash_entry = &(bucket->hb_entries[hicnb->hash_entry_id]); } @@ -85,13 +87,14 @@ hicn_get_internal_state (hicn_buffer_t * hicnb, hicn_pit_cs_t * pitcs, * @param node_id id of the node in the hash table referring to the buffer * @param dpo_ctx_id id of the dpo context id corresponding to the buffer * @param vft_id id of the strategy vft corresponding to the buffer - * @param hash_entry_id id of the entry in the hash table referring to the buffer + * @param hash_entry_id id of the entry in the hash table referring to the + * buffer * @param bucket_id id of the hasth table bucket that holds the hash entry - * @param bucket_is_overflow 1 if the bucket is from the ht_overflow_buckets pool - * 0 if the bucket is from the ht_buckets pool + * @param bucket_is_overflow 1 if the bucket is from the ht_overflow_buckets + * pool 0 if the bucket is from the ht_buckets pool */ always_inline void -hicn_store_internal_state (vlib_buffer_t * b, u64 name_hash, u32 node_id, +hicn_store_internal_state (vlib_buffer_t *b, u64 name_hash, u32 node_id, u8 dpo_ctx_id, u8 vft_id, u8 hash_entry_id, u32 bucket_id, u8 bucket_is_overflow) { 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) diff --git a/hicn-plugin/src/strategy.h b/hicn-plugin/src/strategy.h index d949f38a4..28af55f01 100644 --- a/hicn-plugin/src/strategy.h +++ b/hicn-plugin/src/strategy.h @@ -24,18 +24,18 @@ /** * @file strategy.h * - * A strategy is defined as a dpo and a set of function (vft) that will be called - * during the packet processing. A strategy is associated to an entry in the fib by - * assigning the corresponding dpo to the fib entry. The dpo points to a hICN dpo - * context (ctx) which contains the information needed by the strategy to compute - * the next hop. Each strategy hash its own dpo type, which means that the dpo_type - * uniquely identifies a strategy and its vft. The strategy node will use the dpo_type - * to retrieve the corresponding vft. - * Here we provide: - * - a template for the callbacks to implement in order to create a new strategy - * (hicn_fwd_strategy_t) - * - a default implementation for the strategy node which will call the strategy - * functions while processing the interest packets + * A strategy is defined as a dpo and a set of function (vft) that will be + * called during the packet processing. A strategy is associated to an entry in + * the fib by assigning the corresponding dpo to the fib entry. The dpo points + * to a hICN dpo context (ctx) which contains the information needed by the + * strategy to compute the next hop. Each strategy hash its own dpo type, which + * means that the dpo_type uniquely identifies a strategy and its vft. The + * strategy node will use the dpo_type to retrieve the corresponding vft. Here + * we provide: + * - a template for the callbacks to implement in order to create a new + * strategy (hicn_fwd_strategy_t) + * - a default implementation for the strategy node which will call the + * strategy functions while processing the interest packets */ /* Trace context struct */ @@ -51,11 +51,11 @@ typedef struct hicn_strategy_vft_s { void (*hicn_receive_data) (index_t dpo_idx, int nh_idx); void (*hicn_on_interest_timeout) (index_t dpo_idx); - void (*hicn_add_interest) (index_t dpo_idx, hicn_hash_entry_t * pit_entry); - u32 (*hicn_select_next_hop) (index_t dpo_idx, int *nh_idx, - hicn_face_id_t* outface); + void (*hicn_add_interest) (index_t dpo_idx, hicn_hash_entry_t *pit_entry); + u32 (*hicn_select_next_hop) (index_t dpo_idx, int *nh_idx, + hicn_face_id_t *outface); u8 *(*hicn_format_strategy_trace) (u8 *, hicn_strategy_trace_t *); - u8 *(*hicn_format_strategy) (u8 * s, va_list * ap); + u8 *(*hicn_format_strategy) (u8 *s, va_list *ap); /**< Format an hICN dpo*/ } hicn_strategy_vft_t; @@ -69,25 +69,23 @@ typedef enum HICN_STRATEGY_N_NEXT, } hicn_strategy_next_t; -const static char *const hicn_ip6_nodes[] = -{ - "hicn6-iface-input", // this is the name you give your node in VLIB_REGISTER_NODE - NULL, +const static char *const hicn_ip6_nodes[] = { + "hicn6-iface-input", // this is the name you give your node in + // VLIB_REGISTER_NODE + NULL, }; -const static char *const hicn_ip4_nodes[] = -{ - "hicn4-iface-input", // this is the name you give your node in VLIB_REGISTER_NODE - NULL, +const static char *const hicn_ip4_nodes[] = { + "hicn4-iface-input", // this is the name you give your node in + // VLIB_REGISTER_NODE + NULL, }; -const static char *const *const hicn_nodes_strategy[DPO_PROTO_NUM] = -{ - [DPO_PROTO_IP6] = hicn_ip6_nodes, - [DPO_PROTO_IP4] = hicn_ip4_nodes, +const static char *const *const hicn_nodes_strategy[DPO_PROTO_NUM] = { + [DPO_PROTO_IP6] = hicn_ip6_nodes, + [DPO_PROTO_IP4] = hicn_ip4_nodes, }; - extern vlib_node_registration_t hicn_strategy_node; #endif /* //__HICN_STRATEGY__ */ diff --git a/hicn-plugin/src/strategy_dpo_ctx.c b/hicn-plugin/src/strategy_dpo_ctx.c index 342c78bb5..edfe75aa8 100644 --- a/hicn-plugin/src/strategy_dpo_ctx.c +++ b/hicn-plugin/src/strategy_dpo_ctx.c @@ -22,11 +22,10 @@ void hicn_strategy_init_dpo_ctx_pool () { pool_init_fixed (hicn_strategy_dpo_ctx_pool, 256); - } void -hicn_strategy_dpo_ctx_lock (dpo_id_t * dpo) +hicn_strategy_dpo_ctx_lock (dpo_id_t *dpo) { hicn_dpo_ctx_t *dpo_ctx = hicn_strategy_dpo_ctx_get (dpo->dpoi_index); @@ -37,7 +36,7 @@ hicn_strategy_dpo_ctx_lock (dpo_id_t * dpo) } void -hicn_strategy_dpo_ctx_unlock (dpo_id_t * dpo) +hicn_strategy_dpo_ctx_unlock (dpo_id_t *dpo) { hicn_dpo_ctx_t *hicn_strategy_dpo_ctx = (hicn_dpo_ctx_t *) hicn_strategy_dpo_ctx_get (dpo->dpoi_index); @@ -54,7 +53,7 @@ hicn_strategy_dpo_ctx_unlock (dpo_id_t * dpo) } u8 * -hicn_strategy_dpo_format_ctx (u8 * s, va_list * ap) +hicn_strategy_dpo_format_ctx (u8 *s, va_list *ap) { index_t index = va_arg (*ap, index_t); hicn_dpo_ctx_t *dpo = NULL; @@ -70,7 +69,7 @@ hicn_strategy_dpo_format_ctx (u8 * s, va_list * ap) } index_t -hicn_strategy_dpo_ctx_get_index (hicn_dpo_ctx_t * cd) +hicn_strategy_dpo_ctx_get_index (hicn_dpo_ctx_t *cd) { return (cd - hicn_strategy_dpo_ctx_pool); } @@ -97,20 +96,20 @@ hicn_strategy_dpo_ctx_alloc () } int -hicn_strategy_dpo_ctx_add_nh (hicn_face_id_t nh, hicn_dpo_ctx_t * dpo_ctx, - u8 * pos) +hicn_strategy_dpo_ctx_add_nh (hicn_face_id_t nh, hicn_dpo_ctx_t *dpo_ctx, + u8 *pos) { int empty = dpo_ctx->entry_count; - /* Iterate through the list of faces to find if the face is already a next hop */ + /* Iterate through the list of faces to find if the face is already a next + * hop */ for (int i = 0; i < dpo_ctx->entry_count; i++) { if (nh == dpo_ctx->next_hops[i]) { /* If face is marked as deleted, ignore it */ - hicn_face_t *face = - hicn_dpoi_get_from_idx (dpo_ctx->next_hops[i]); + hicn_face_t *face = hicn_dpoi_get_from_idx (dpo_ctx->next_hops[i]); if (face->flags & HICN_FACE_FLAGS_DELETED) { continue; @@ -134,8 +133,7 @@ hicn_strategy_dpo_ctx_add_nh (hicn_face_id_t nh, hicn_dpo_ctx_t * dpo_ctx, } int -hicn_strategy_dpo_ctx_del_nh (hicn_face_id_t face_id, - hicn_dpo_ctx_t * dpo_ctx) +hicn_strategy_dpo_ctx_del_nh (hicn_face_id_t face_id, hicn_dpo_ctx_t *dpo_ctx) { int ret = HICN_ERROR_DPO_CTX_NOT_FOUND; hicn_face_id_t invalid = NEXT_HOP_INVALID; @@ -154,7 +152,6 @@ hicn_strategy_dpo_ctx_del_nh (hicn_face_id_t face_id, } return ret; - } /* diff --git a/hicn-plugin/src/strategy_dpo_ctx.h b/hicn-plugin/src/strategy_dpo_ctx.h index 214ed88ad..fe63a4258 100644 --- a/hicn-plugin/src/strategy_dpo_ctx.h +++ b/hicn-plugin/src/strategy_dpo_ctx.h @@ -25,16 +25,19 @@ /** * @file strategy_dpo_ctx.h * - * This file implements the general hICN DPO ctx (shared among all the strategies). + * This file implements the general hICN DPO ctx (shared among all the + * strategies). * - * An hICN DPO ctx contains the list of next hops, auxiliaries fields to maintain the dpo, map-me - * specifics (tfib_entry_count and seq), the dpo_type and 64B to let each strategy to store additional - * information. Each next hop is an hicn_face_id_t that refers to an index for an hICN face. The - * dpo_type is used to identify the strategy and to retrieve the vft corresponding to the strategy - * (see strategy.h) and to the dpo ctx (see strategy_dpo_manager.h) + * An hICN DPO ctx contains the list of next hops, auxiliaries fields to + * maintain the dpo, map-me specifics (tfib_entry_count and seq), the dpo_type + * and 64B to let each strategy to store additional information. Each next hop + * is an hicn_face_id_t that refers to an index for an hICN face. The dpo_type + * is used to identify the strategy and to retrieve the vft corresponding to + * the strategy (see strategy.h) and to the dpo ctx (see + * strategy_dpo_manager.h) */ -//FIB table for hicn. 0 is the default one used by ip +// FIB table for hicn. 0 is the default one used by ip #define HICN_FIB_TABLE 10 #define NEXT_HOP_INVALID ~0 @@ -57,7 +60,7 @@ typedef struct __attribute__ ((packed)) hicn_dpo_ctx_s dpo_type_t dpo_type; /* 46B + 2B = 48B */ - u8 padding; /* To align to 8B */ + u8 padding; /* To align to 8B */ /* 48 + 4B = 52; last sequence number */ u32 seq; @@ -92,7 +95,7 @@ extern hicn_dpo_ctx_t *hicn_strategy_dpo_ctx_pool; * @param dpo_type Type of dpo. It identifies the strategy. */ always_inline void -init_dpo_ctx (hicn_dpo_ctx_t * dpo_ctx, const hicn_face_id_t * next_hop, +init_dpo_ctx (hicn_dpo_ctx_t *dpo_ctx, const hicn_face_id_t *next_hop, int nh_len, dpo_type_t dpo_type, dpo_proto_t proto) { hicn_face_id_t invalid = NEXT_HOP_INVALID; @@ -113,12 +116,10 @@ init_dpo_ctx (hicn_dpo_ctx_t * dpo_ctx, const hicn_face_id_t * next_hop, dpo_ctx->entry_count++; } - for (int i = nh_len; i < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; i++) { dpo_ctx->next_hops[i] = invalid; } - } /** @@ -140,27 +141,27 @@ hicn_dpo_ctx_t *hicn_strategy_dpo_ctx_get (index_t index); /** * @brief Retrieve the index of the hICN dpo ctx */ -index_t hicn_strategy_dpo_ctx_get_index (hicn_dpo_ctx_t * cd); +index_t hicn_strategy_dpo_ctx_get_index (hicn_dpo_ctx_t *cd); /** * @brief Lock the dpo of a strategy ctx * * @param dpo Identifier of the dpo of the strategy ctx */ -void hicn_strategy_dpo_ctx_lock (dpo_id_t * dpo); +void hicn_strategy_dpo_ctx_lock (dpo_id_t *dpo); /** * @brief Unlock the dpo of a strategy ctx * * @param dpo Identifier of the dpo of the strategy ctx */ -void hicn_strategy_dpo_ctx_unlock (dpo_id_t * dpo); +void hicn_strategy_dpo_ctx_unlock (dpo_id_t *dpo); /** * @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_ctx Dpo ctx to update with the new or updated next hop @@ -168,9 +169,8 @@ void hicn_strategy_dpo_ctx_unlock (dpo_id_t * dpo); * @return HICN_ERROR_NONE if the update or insert was fine, * otherwise HICN_ERROR_DPO_CTX_NOT_FOUND */ -int -hicn_strategy_dpo_ctx_add_nh (hicn_face_id_t nh, hicn_dpo_ctx_t * dpo_ctx, - u8 * pos); +int hicn_strategy_dpo_ctx_add_nh (hicn_face_id_t nh, hicn_dpo_ctx_t *dpo_ctx, + u8 *pos); /** * @brief Delete a next hop in the dpo ctx. @@ -180,10 +180,8 @@ hicn_strategy_dpo_ctx_add_nh (hicn_face_id_t nh, hicn_dpo_ctx_t * dpo_ctx, * @return HICN_ERROR_NONE if the update or insert was fine, * otherwise HICN_ERROR_DPO_CTS_NOT_FOUND */ -int -hicn_strategy_dpo_ctx_del_nh (hicn_face_id_t face_id, - hicn_dpo_ctx_t * dpo_ctx); - +int hicn_strategy_dpo_ctx_del_nh (hicn_face_id_t face_id, + hicn_dpo_ctx_t *dpo_ctx); STATIC_ASSERT (sizeof (hicn_dpo_ctx_t) <= 2 * CLIB_CACHE_LINE_BYTES, "sizeof hicn_dpo_ctx_t is greater than 128B"); diff --git a/hicn-plugin/src/strategy_dpo_manager.c b/hicn-plugin/src/strategy_dpo_manager.c index f8d41a372..3c441ccac 100644 --- a/hicn-plugin/src/strategy_dpo_manager.c +++ b/hicn-plugin/src/strategy_dpo_manager.c @@ -33,9 +33,9 @@ hicn_dpo_vft_t default_dpo; dpo_type_t hicn_dpo_register_new_type (const char *const *const *hicn_nodes, - const hicn_dpo_vft_t * hicn_dpo_vft, - const hicn_strategy_vft_t * hicn_strategy_vft, - const dpo_vft_t * dpo_ctx_vft) + const hicn_dpo_vft_t *hicn_dpo_vft, + const hicn_strategy_vft_t *hicn_strategy_vft, + const dpo_vft_t *dpo_ctx_vft) { dpo_type_t dpo_type = dpo_register_new_type (dpo_ctx_vft, hicn_nodes); vec_validate (hicn_dpo_vfts, dpo_type); @@ -52,7 +52,7 @@ hicn_dpo_register_new_type (const char *const *const *hicn_nodes, } u32 -dpo_is_hicn (const dpo_id_t * dpo) +dpo_is_hicn (const dpo_id_t *dpo) { for (int i = 0; i < hicn_strategies; i++) { @@ -63,7 +63,7 @@ dpo_is_hicn (const dpo_id_t * dpo) } dpo_type_t -hicn_dpo_get_vft_id (const dpo_id_t * dpo) +hicn_dpo_get_vft_id (const dpo_id_t *dpo) { return dpo->dpoi_type; } @@ -109,7 +109,7 @@ hicn_dpos_init (void) } u8 * -format_hicn_strategy_list (u8 * s, int n, ...) +format_hicn_strategy_list (u8 *s, int n, ...) { va_list ap; va_start (ap, n); @@ -120,10 +120,10 @@ format_hicn_strategy_list (u8 * s, int n, ...) indent += 4; int i; vec_foreach_index (i, strategies_id) - { - s = format (s, "%U (%d) ", format_white_space, indent, i); - s = hicn_strategy_vfts[strategies_id[i]]->hicn_format_strategy (s, &ap); - } + { + s = format (s, "%U (%d) ", format_white_space, indent, i); + s = hicn_strategy_vfts[strategies_id[i]]->hicn_format_strategy (s, &ap); + } return (s); } @@ -132,7 +132,8 @@ u8 hicn_dpo_strategy_id_is_valid (int strategy_id) { return vec_len (strategies_id) > strategy_id ? - HICN_ERROR_NONE : HICN_ERROR_DPO_MGR_ID_NOT_VALID; + HICN_ERROR_NONE : + HICN_ERROR_DPO_MGR_ID_NOT_VALID; } int @@ -148,7 +149,7 @@ hicn_strategy_get_all_available (void) * time. */ void -hicn_dpo_register (const hicn_dpo_vft_t * hicn_dpo) +hicn_dpo_register (const hicn_dpo_vft_t *hicn_dpo) { hicn_dpo->hicn_dpo_module_init (); } diff --git a/hicn-plugin/src/strategy_dpo_manager.h b/hicn-plugin/src/strategy_dpo_manager.h index e96e050d9..7a2ce3fee 100644 --- a/hicn-plugin/src/strategy_dpo_manager.h +++ b/hicn-plugin/src/strategy_dpo_manager.h @@ -28,34 +28,37 @@ * information to choose the next hop, * - a dpo vft that specify how to update the hICN DPO ctx when a next hop is * added, deleted or updated, - * - a strategy containing (see strategy.h): (i) the vpp node that processes Interest packets - * subjected to such strategy, (ii) the definition of the vft that defines - * the hICN strategy functions - * An hICN DPO is places as the sole next hop in the vpp loadbalancer, and it containes - * a list of next hops that will be used by the associated strategy when forwarding - * interest packets. + * - a strategy containing (see strategy.h): (i) the vpp node that processes + * Interest packets subjected to such strategy, (ii) the definition of the vft + * that defines the hICN strategy functions An hICN DPO is places as the sole + * next hop in the vpp loadbalancer, and it containes a list of next hops that + * will be used by the associated strategy when forwarding interest packets. */ /** * @brief Definition of the virtual function table for a hICN DPO. * * The following virtual function table - * template that glues together the fuction to interact with the context and the - * creating the dpo + * template that glues together the fuction to interact with the context and + * the creating the dpo */ typedef struct hicn_dpo_vft_s { - int (*hicn_dpo_is_type) (const dpo_id_t * dpo); - /**< Check if the type of the - hICN DPO is the expected */ - dpo_type_t (*hicn_dpo_get_type) (void); - /**< Return the type of the hICN dpo */ - void (*hicn_dpo_module_init) (void); /**< Initialize the hICN dpo */ - void (*hicn_dpo_create) (fib_protocol_t proto, const hicn_face_id_t * nh, int nh_len, index_t * dpo_idx); /**< Create the context of the hICN dpo */ - int (*hicn_dpo_add_update_nh) (hicn_face_id_t nh, index_t dpo_idx); /**< Add a next hop to the hICN dpo context */ + int (*hicn_dpo_is_type) (const dpo_id_t *dpo); + /**< Check if the type of the + hICN DPO is the expected */ + dpo_type_t (*hicn_dpo_get_type) (void); + /**< Return the type of the hICN dpo */ + void (*hicn_dpo_module_init) (void); /**< Initialize the hICN dpo */ + void (*hicn_dpo_create) ( + fib_protocol_t proto, const hicn_face_id_t *nh, int nh_len, + index_t *dpo_idx); /**< Create the context of the hICN dpo */ + int (*hicn_dpo_add_update_nh) ( + hicn_face_id_t nh, + index_t dpo_idx); /**< Add a next hop to the hICN dpo context */ int (*hicn_dpo_del_nh) (hicn_face_id_t face_id, index_t dpo_idx); - u8 *(*hicn_dpo_format) (u8 * s, int, ...); - /**< Format an hICN dpo*/ + u8 *(*hicn_dpo_format) (u8 *s, int, ...); + /**< Format an hICN dpo*/ } hicn_dpo_vft_t; /* @@ -74,19 +77,17 @@ extern hicn_dpo_vft_t default_dpo; * the FIB entry to which the hICN DPO is applied. This list must contain the * name of the strategy node (or nodes in case of differentiation between IPv4 * and IPv6). Unless really needed otherwise (i.e., different implementation of - * iface input), the list of node to use should be one provided in the strategy.h - * (hicn_nodes_strategy) + * iface input), the list of node to use should be one provided in the + * strategy.h (hicn_nodes_strategy) * @param hicn_dpo_vft The structure holding the virtual function table to * interact with the hICN dpo and its context. * @param hicn_strategy_vft The structure holding the virtual function table * containing the hICN strategy functions. * @return the dpo type registered in the VPP Data plane graph. */ -dpo_type_t -hicn_dpo_register_new_type (const char *const *const *hicn_nodes, - const hicn_dpo_vft_t * hicn_dpo_vft, - const hicn_strategy_vft_t * - hicn_strategy_vft, const dpo_vft_t * dpo_ctx_vft); +dpo_type_t hicn_dpo_register_new_type ( + const char *const *const *hicn_nodes, const hicn_dpo_vft_t *hicn_dpo_vft, + const hicn_strategy_vft_t *hicn_strategy_vft, const dpo_vft_t *dpo_ctx_vft); /** * @brief Check if the type of the dpo is among the list of hicn dpo types @@ -96,7 +97,7 @@ hicn_dpo_register_new_type (const char *const *const *hicn_nodes, * @param dpo The id of the dpo to which check the type * @return 1 if there is a match, 0 otherwise. */ -u32 dpo_is_hicn (const dpo_id_t * dpo); +u32 dpo_is_hicn (const dpo_id_t *dpo); /** * @brief Return the dpo_vtf and strategy_vtf identifier @@ -105,9 +106,10 @@ u32 dpo_is_hicn (const dpo_id_t * dpo); * retrieve the corresponding dpo_vtf/strategy_vtf identifier. * * @param dpo The id of the dpo to which check the type - * @return the dpo_vft/strategy_vft id or HICN_ERROR_DPO_NOT_FOUND in case the dpo is not an hICN dpo. + * @return the dpo_vft/strategy_vft id or HICN_ERROR_DPO_NOT_FOUND in case the + * dpo is not an hICN dpo. */ -u8 hicn_dpo_get_vft_id (const dpo_id_t * dpo); +u8 hicn_dpo_get_vft_id (const dpo_id_t *dpo); /** * @brief Get the vft to manage the dpo context. @@ -159,10 +161,11 @@ void hicn_dpos_init (void); * * @result The string with the list of hICN DPO (strategies) */ -u8 *format_hicn_strategy_list (u8 * s, int n, ...); +u8 *format_hicn_strategy_list (u8 *s, int n, ...); /** - * @brief Check if a given id points to a strategy and the corresponding dpo ctx + * @brief Check if a given id points to a strategy and the corresponding dpo + * ctx * * @param The id of the strategy to check. * @@ -182,7 +185,7 @@ int hicn_strategy_get_all_available (void); * @brief Registers a module at compilation time to be initialized as part of * the ctor. */ -void hicn_dpo_register (const hicn_dpo_vft_t * hicn_dpo); +void hicn_dpo_register (const hicn_dpo_vft_t *hicn_dpo); #endif /* // __HICN_STRATEGY_DPO_MANAGER_H__ */ diff --git a/hicn-plugin/src/strategy_node.c b/hicn-plugin/src/strategy_node.c index 39232be73..ec57d76e2 100644 --- a/hicn-plugin/src/strategy_node.c +++ b/hicn-plugin/src/strategy_node.c @@ -121,7 +121,7 @@ hicn_new_interest (hicn_strategy_runtime_t *rt, vlib_buffer_t *b0, u32 *next, hicn_face_db_add_face (hicnb0->face_id, &(pitp->u.pit.faces)); *next = isv6 ? HICN_STRATEGY_NEXT_INTEREST_FACE6 : - HICN_STRATEGY_NEXT_INTEREST_FACE4; + HICN_STRATEGY_NEXT_INTEREST_FACE4; vnet_buffer (b0)->ip.adj_index[VLIB_TX] = outface; stats->pkts_interest_count++; @@ -139,7 +139,7 @@ hicn_new_interest (hicn_strategy_runtime_t *rt, vlib_buffer_t *b0, u32 *next, // entry because it is a CS entry (hash_insert function). hash_entry->locks++; *next = is_cs0 ? HICN_STRATEGY_NEXT_INTEREST_HITCS : - HICN_STRATEGY_NEXT_INTEREST_HITPIT; + HICN_STRATEGY_NEXT_INTEREST_HITPIT; } else { diff --git a/hicn-plugin/src/udp_tunnels/udp_decap_node.c b/hicn-plugin/src/udp_tunnels/udp_decap_node.c index 84e4e5234..06eb8da71 100644 --- a/hicn-plugin/src/udp_tunnels/udp_decap_node.c +++ b/hicn-plugin/src/udp_tunnels/udp_decap_node.c @@ -223,7 +223,7 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip4_header_t *) outer_ptr0)->dst_address); udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip4_header_t)); next0 = v0 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 : - UDP4_DECAP_NEXT_LOOKUP_IP6; + UDP4_DECAP_NEXT_LOOKUP_IP6; ip46_address_set_ip4 (&src1, &((ip4_header_t *) outer_ptr1)->src_address); @@ -231,7 +231,7 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip4_header_t *) outer_ptr1)->dst_address); udp1 = (udp_header_t *) (outer_ptr1 + sizeof (ip4_header_t)); next1 = v1 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 : - UDP4_DECAP_NEXT_LOOKUP_IP6; + UDP4_DECAP_NEXT_LOOKUP_IP6; ip46_address_set_ip4 (&src2, &((ip4_header_t *) outer_ptr2)->src_address); @@ -239,7 +239,7 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip4_header_t *) outer_ptr2)->dst_address); udp2 = (udp_header_t *) (outer_ptr2 + sizeof (ip4_header_t)); next2 = v2 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 : - UDP4_DECAP_NEXT_LOOKUP_IP6; + UDP4_DECAP_NEXT_LOOKUP_IP6; ip46_address_set_ip4 (&src3, &((ip4_header_t *) outer_ptr3)->src_address); @@ -247,7 +247,7 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip4_header_t *) outer_ptr3)->dst_address); udp3 = (udp_header_t *) (outer_ptr3 + sizeof (ip4_header_t)); next3 = v3 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 : - UDP4_DECAP_NEXT_LOOKUP_IP6; + UDP4_DECAP_NEXT_LOOKUP_IP6; hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3; hicnb0 = hicn_get_buffer (b0); @@ -269,22 +269,22 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb0->flags |= (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); if (vnet_buffer (b1)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb1->flags |= (outer_v1 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); if (vnet_buffer (b2)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb2->flags |= (outer_v2 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); if (vnet_buffer (b3)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb3->flags |= (outer_v3 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); udp_decap_trace_buffer (vm, node, 1, b0); udp_decap_trace_buffer (vm, node, 1, b1); @@ -346,7 +346,7 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip4_header_t *) outer_ptr0)->dst_address); udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip4_header_t)); next0 = v0 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 : - UDP4_DECAP_NEXT_LOOKUP_IP6; + UDP4_DECAP_NEXT_LOOKUP_IP6; hicn_buffer_t *hicnb0 = hicn_get_buffer (b0); @@ -356,7 +356,7 @@ udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb0->flags |= (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); udp_decap_trace_buffer (vm, node, 1, b0); @@ -488,7 +488,7 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip6_header_t *) outer_ptr0)->dst_address); udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip6_header_t)); next0 = v0 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : - UDP6_DECAP_NEXT_LOOKUP_IP6; + UDP6_DECAP_NEXT_LOOKUP_IP6; ip46_address_set_ip6 (&src1, &((ip6_header_t *) outer_ptr1)->src_address); @@ -496,7 +496,7 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip6_header_t *) outer_ptr1)->dst_address); udp1 = (udp_header_t *) (outer_ptr1 + sizeof (ip6_header_t)); next1 = v1 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : - UDP6_DECAP_NEXT_LOOKUP_IP6; + UDP6_DECAP_NEXT_LOOKUP_IP6; ip46_address_set_ip6 (&src2, &((ip6_header_t *) outer_ptr2)->src_address); @@ -504,7 +504,7 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip6_header_t *) outer_ptr2)->dst_address); udp2 = (udp_header_t *) (outer_ptr2 + sizeof (ip6_header_t)); next2 = v2 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : - UDP6_DECAP_NEXT_LOOKUP_IP6; + UDP6_DECAP_NEXT_LOOKUP_IP6; ip46_address_set_ip6 (&src3, &((ip6_header_t *) outer_ptr3)->src_address); @@ -512,7 +512,7 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip6_header_t *) outer_ptr3)->dst_address); udp3 = (udp_header_t *) (outer_ptr3 + sizeof (ip6_header_t)); next3 = v3 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : - UDP6_DECAP_NEXT_LOOKUP_IP6; + UDP6_DECAP_NEXT_LOOKUP_IP6; hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3; hicnb0 = hicn_get_buffer (b0); @@ -534,22 +534,22 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb0->flags |= (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); if (vnet_buffer (b1)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb1->flags |= (outer_v1 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); if (vnet_buffer (b2)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb2->flags |= (outer_v2 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); if (vnet_buffer (b3)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb3->flags |= (outer_v3 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); udp_decap_trace_buffer (vm, node, 0, b0); udp_decap_trace_buffer (vm, node, 0, b1); @@ -610,7 +610,7 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, &((ip6_header_t *) outer_ptr0)->dst_address); udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip6_header_t)); next0 = v0 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : - UDP6_DECAP_NEXT_LOOKUP_IP6; + UDP6_DECAP_NEXT_LOOKUP_IP6; hicn_buffer_t *hicnb0 = hicn_get_buffer (b0); @@ -620,7 +620,7 @@ udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID) hicnb0->flags |= (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : - HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); + HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL); udp_decap_trace_buffer (vm, node, 0, b0); diff --git a/hicn-plugin/src/udp_tunnels/udp_tunnel.c b/hicn-plugin/src/udp_tunnels/udp_tunnel.c index 58694d8e9..8ea2cb503 100644 --- a/hicn-plugin/src/udp_tunnels/udp_tunnel.c +++ b/hicn-plugin/src/udp_tunnels/udp_tunnel.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../error.h" #include "../strategy_dpo_ctx.h" @@ -254,8 +255,8 @@ udp_tunnel_command_fn (vlib_main_t *vm, unformat_input_t *main_input, int ret = udp_tunnel_del (fproto, fib_index, &src_ip, &dst_ip, src_port, dst_port, UDP_ENCAP_FIXUP_NONE); error = (ret == HICN_ERROR_NONE) ? - 0 : - clib_error_return (0, "%s\n", get_error_string (ret)); + 0 : + clib_error_return (0, "%s\n", get_error_string (ret)); } else { @@ -271,7 +272,7 @@ VLIB_CLI_COMMAND (udp_tunnel_command, static) = { .path = "udp tunnel", .short_help = "udp tunnel [add/del] src_address dst_address src_port dst_port", - .function = udp_tunnel_command_fn, + .function = udp_tunnel_command_fn, }; /* diff --git a/hicn-plugin/src/udp_tunnels/udp_tunnel.h b/hicn-plugin/src/udp_tunnels/udp_tunnel.h index 2ec92056c..2e57b7857 100644 --- a/hicn-plugin/src/udp_tunnels/udp_tunnel.h +++ b/hicn-plugin/src/udp_tunnels/udp_tunnel.h @@ -26,9 +26,9 @@ * This file implements bidirectional udp tunnels. Udp tunnels exploit * the udp encap functionality in vpp. In particular, a udp tunnel creates * an udp encap object with the information for encapsulating packets and it - * implements the udp decap node. The udp decap node checks if a udp tunnel exists - * before performing the decapsulation. If the tunnel does not exist the packet - * is dropped. + * implements the udp decap node. The udp decap node checks if a udp tunnel + * exists before performing the decapsulation. If the tunnel does not exist the + * packet is dropped. */ #define UDP_TUNNEL_INVALID ~0 @@ -52,13 +52,9 @@ extern vlib_node_registration_t udp6_decap_node; * * @return return the id of the tunnel */ -u32 udp_tunnel_add (fib_protocol_t proto, - index_t fib_index, - const ip46_address_t * src_ip, - const ip46_address_t * dst_ip, - u16 src_port, - u16 dst_port, - udp_encap_fixup_flags_t flags); +u32 udp_tunnel_add (fib_protocol_t proto, index_t fib_index, + const ip46_address_t *src_ip, const ip46_address_t *dst_ip, + u16 src_port, u16 dst_port, udp_encap_fixup_flags_t flags); /** * @brief Retrieve the index of a udp tunnel (same id of the udp encap) @@ -70,10 +66,8 @@ u32 udp_tunnel_add (fib_protocol_t proto, * * @return id of the udp tunnel/encap */ -u32 udp_tunnel_get(const ip46_address_t * src_ip, - const ip46_address_t * dst_ip, - u16 src_port, - u16 dst_port); +u32 udp_tunnel_get (const ip46_address_t *src_ip, const ip46_address_t *dst_ip, + u16 src_port, u16 dst_port); /** * @brief Delete a udp tunnel @@ -89,13 +83,9 @@ u32 udp_tunnel_get(const ip46_address_t * src_ip, * @return HICN_ERROR_UDP_TUNNEL_NOT_FOUND if the tunnel was not found * or HICN_ERROR_NONE if the tunnel has been deleted */ -int udp_tunnel_del (fib_protocol_t proto, - index_t fib_index, - const ip46_address_t * src_ip, - const ip46_address_t * dst_ip, - u16 src_port, - u16 dst_port, - udp_encap_fixup_flags_t flags); +int udp_tunnel_del (fib_protocol_t proto, index_t fib_index, + const ip46_address_t *src_ip, const ip46_address_t *dst_ip, + u16 src_port, u16 dst_port, udp_encap_fixup_flags_t flags); /** * @brief Add a udp tunnel from an existing udp encap @@ -109,6 +99,6 @@ void udp_tunnel_add_existing (index_t uei, dpo_proto_t proto); * @brief Init the udp tunnel module * */ -void udp_tunnel_init(); +void udp_tunnel_init (); #endif diff --git a/hicn-plugin/src/utils.h b/hicn-plugin/src/utils.h index 689942ab6..847f2f388 100644 --- a/hicn-plugin/src/utils.h +++ b/hicn-plugin/src/utils.h @@ -30,7 +30,7 @@ * @param name hicn name to print */ always_inline void -hicn_print_name6 (hicn_name_t * name) +hicn_print_name6 (hicn_name_t *name) { u8 *s0; s0 = format (0, "Source addr %U, seq_number %u", format_ip6_address, @@ -46,14 +46,13 @@ hicn_print_name6 (hicn_name_t * name) * @param hicn0 hICN header to print */ always_inline void -hicn_print6 (hicn_header_t * hicn0) +hicn_print6 (hicn_header_t *hicn0) { vlib_main_t *vm = vlib_get_main (); u8 *s0; s0 = format (0, "Source addr %U:%u, dest addr %U:%u", format_ip6_address, - &(hicn0->v6.ip.saddr), - clib_net_to_host_u32 (hicn0->v6.tcp.seq), format_ip6_address, - &(hicn0->v6.ip.daddr), + &(hicn0->v6.ip.saddr), clib_net_to_host_u32 (hicn0->v6.tcp.seq), + format_ip6_address, &(hicn0->v6.ip.daddr), clib_net_to_host_u32 (hicn0->v6.tcp.seq)); vlib_cli_output (vm, "%s\n", s0); @@ -65,13 +64,12 @@ hicn_print6 (hicn_header_t * hicn0) * @param hicn0 hICN header to print */ always_inline void -hicn_print4 (hicn_header_t * hicn0) +hicn_print4 (hicn_header_t *hicn0) { u8 *s0; s0 = format (0, "Source addr %U:%u, dest addr %U:%u", format_ip4_address, - &(hicn0->v4.ip.saddr), - clib_net_to_host_u32 (hicn0->v4.tcp.seq), format_ip4_address, - &(hicn0->v4.ip.daddr), + &(hicn0->v4.ip.saddr), clib_net_to_host_u32 (hicn0->v4.tcp.seq), + format_ip4_address, &(hicn0->v4.ip.daddr), clib_net_to_host_u32 (hicn0->v4.tcp.seq)); printf ("%s\n", s0); @@ -79,7 +77,6 @@ hicn_print4 (hicn_header_t * hicn0) #endif /* // __HICN_UTILS_H__ */ - /* * fd.io coding-style-patch-verification: ON * -- cgit 1.2.3-korg