diff options
Diffstat (limited to 'hicn-plugin/src/faces')
-rw-r--r-- | hicn-plugin/src/faces/app/address_mgr.c | 62 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/address_mgr.h | 8 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_app_cli.c | 8 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_cons.c | 32 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_cons.h | 25 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_prod.h | 30 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_prod_node.c | 4 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.h | 366 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face_node.h | 6 | ||||
-rw-r--r-- | hicn-plugin/src/faces/iface_node.c | 8 | ||||
-rw-r--r-- | hicn-plugin/src/faces/iface_node.h | 13 | ||||
-rw-r--r-- | hicn-plugin/src/faces/inlines.h | 16 |
12 files changed, 284 insertions, 294 deletions
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 <vnet/ip/ip6_packet.h> #include <vnet/ip/ip4.h> //ip4_add_del_ip_address #include <vnet/ip/ip6.h> //ip6_add_del_ip_address -#include <vnet/fib/fib_types.h> //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID -#include <vnet/fib/fib_entry.h> //FIB_SOURCE_PRIORITY_HI +#include <vnet/fib/fib_types.h> //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID +#include <vnet/fib/fib_entry.h> //FIB_SOURCE_PRIORITY_HI #include <vnet/fib/fib_table.h> #include <vppinfra/format.h> -#include <vnet/interface.h> //appif_flags -#include <vnet/interface_funcs.h> //vnet_sw_interface_set_flags +#include <vnet/interface.h> //appif_flags +#include <vnet/interface_funcs.h> //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 <vppinfra/bihash_8_8.h> #include <vnet/adj/adj_midchain.h> - #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 <vlib/buffer.h> 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; } } |