diff options
author | Alberto Compagno <acompagn+fdio@cisco.com> | 2019-05-07 12:06:04 +0200 |
---|---|---|
committer | Alberto Compagno <acompagn+fdio@cisco.com> | 2019-05-07 12:06:04 +0200 |
commit | cd48bbd9685f042a2f1f90678f8fa98a5175ea4d (patch) | |
tree | 8412a4f3d56c451250ccb4ea1b687d51ccbb214b /hicn-plugin/src/faces/udp | |
parent | 113e0af25e5a802eccac1fc4521f096a2e1bd199 (diff) |
[HICN-189] In case the adj is not complete, we look if a better one exists and we follow the new adjacency. The adj in the face is updated accordingly.
Change-Id: Ieb5c02ee66146475d54ee99a77fc795c9bdf3130
Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src/faces/udp')
-rw-r--r-- | hicn-plugin/src/faces/udp/dpo_udp.h | 61 | ||||
-rw-r--r-- | hicn-plugin/src/faces/udp/face_udp.h | 104 | ||||
-rw-r--r-- | hicn-plugin/src/faces/udp/face_udp_node.c | 49 |
3 files changed, 159 insertions, 55 deletions
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.h b/hicn-plugin/src/faces/udp/dpo_udp.h index 3d74a1884..42b9864df 100644 --- a/hicn-plugin/src/faces/udp/dpo_udp.h +++ b/hicn-plugin/src/faces/udp/dpo_udp.h @@ -127,33 +127,10 @@ hicn_dpo_udp4_add_and_lock (dpo_id_t * dpo, if (face == NULL) { - pool_get (hicn_dpoi_face_pool, face); - hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data; - - clib_memcpy (&(udp_face->hdrs.ip4.ip), &ip4_header_skl, - sizeof (ip4_header_t)); - clib_memcpy (&(udp_face->hdrs.ip4.ip.src_address), local_addr, - sizeof (ip4_address_t)); - clib_memcpy (&(udp_face->hdrs.ip4.ip.dst_address), remote_addr, - sizeof (ip4_address_t)); - - udp_face->hdrs.ip4.udp.src_port = local_port; - udp_face->hdrs.ip4.udp.dst_port = remote_port; - - face->shared.adj = ADJ_INDEX_INVALID; - face->shared.pl_id = (u16) 0; - face->shared.face_type = hicn_face_udp_type; - face->shared.flags = HICN_FACE_FLAGS_IFACE; - face->shared.locks = 0; - face->shared.sw_if = sw_if; - - hicn_face_udp_key_t key; - hicn_face_udp4_get_key (local_addr, remote_addr, local_port, - remote_port, &key); - hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face); - - mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0); + hicn_face_id_t dpoi_index; + hicn_iface_udp4_add (local_addr, remote_addr, local_port, remote_port, + sw_if, &dpoi_index); *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index); @@ -230,7 +207,7 @@ hicn_dpo_udp6_lock (dpo_id_t * dpo, return HICN_ERROR_FACE_NOT_FOUND; hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face); - dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index); + dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP6, dpoi_index); dpo->dpoi_next_node = ~0; dpo_lock (dpo); *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; @@ -269,33 +246,9 @@ hicn_dpo_udp6_add_and_lock (dpo_id_t * dpo, if (face == NULL) { - pool_get (hicn_dpoi_face_pool, face); - - hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data; - - clib_memcpy (&(udp_face->hdrs.ip6.ip), &ip6_header_skl, - sizeof (ip6_header_t)); - clib_memcpy (&(udp_face->hdrs.ip6.ip.src_address), local_addr, - sizeof (ip6_address_t)); - clib_memcpy (&(udp_face->hdrs.ip6.ip.dst_address), remote_addr, - sizeof (ip6_address_t)); - - udp_face->hdrs.ip6.udp.src_port = local_port; - udp_face->hdrs.ip6.udp.dst_port = remote_port; - - face->shared.adj = ADJ_INDEX_INVALID; - face->shared.pl_id = (u16) 0; - face->shared.face_type = hicn_face_udp_type; - face->shared.flags = HICN_FACE_FLAGS_IFACE; - face->shared.locks = 0; - face->shared.sw_if = sw_if; - - hicn_face_udp_key_t key; - hicn_face_udp6_get_key (local_addr, remote_addr, local_port, - remote_port, &key); - hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face); - - mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0); + hicn_face_id_t dpoi_index; + hicn_iface_udp6_add (local_addr, remote_addr, local_port, remote_port, + sw_if, &dpoi_index); *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP6, dpoi_index); diff --git a/hicn-plugin/src/faces/udp/face_udp.h b/hicn-plugin/src/faces/udp/face_udp.h index 8694bad5c..2bd420b55 100644 --- a/hicn-plugin/src/faces/udp/face_udp.h +++ b/hicn-plugin/src/faces/udp/face_udp.h @@ -207,6 +207,110 @@ int hicn_face_udp_add (const ip46_address_t * local_addr, u16 remote_port, u32 swif, hicn_face_id_t * pfaceid); /** + * @brief Create a new incomplete face udp. (Meant to be used by the data plane) + * + * @param local_addr Local ip v6 address of the face + * @param remote_addr Remote ip v6 address of the face + * @param sw_if interface associated to the face + * @param pfaceid Pointer to return the face id + * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally + * reachable ip address, otherwise HICN_ERROR_NONE + */ +always_inline void +hicn_iface_udp6_add (const ip6_address_t * local_addr, + const ip6_address_t * remote_addr, u16 local_port, + u16 remote_port, int sw_if, hicn_face_id_t * pfaceid) +{ + hicn_face_t *face; + pool_get (hicn_dpoi_face_pool, face); + + hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data; + + clib_memcpy (&(udp_face->hdrs.ip6.ip), &ip6_header_skl, + sizeof (ip6_header_t)); + clib_memcpy (&(udp_face->hdrs.ip6.ip.src_address), local_addr, + sizeof (ip6_address_t)); + clib_memcpy (&(udp_face->hdrs.ip6.ip.dst_address), remote_addr, + sizeof (ip6_address_t)); + + udp_face->hdrs.ip6.udp.src_port = local_port; + udp_face->hdrs.ip6.udp.dst_port = remote_port; + + face->shared.adj = ADJ_INDEX_INVALID; + face->shared.pl_id = (u16) 0; + face->shared.face_type = hicn_face_udp_type; + face->shared.flags = HICN_FACE_FLAGS_IFACE; + face->shared.locks = 0; + face->shared.sw_if = sw_if; + + hicn_face_udp_key_t key; + hicn_face_udp6_get_key (local_addr, remote_addr, local_port, + remote_port, &key); + *pfaceid = hicn_dpoi_get_index (face); + + mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & pfaceid, 0); + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_validate_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], + i); + vlib_zero_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], i); + } +} + +/** + * @brief Create a new incomplete face udp. (Meant to be used by the data plane) + * + * @param local_addr Local ip v4 address of the face + * @param remote_addr Remote ip v4 address of the face + * @param sw_if interface associated to the face + * @param pfaceid Pointer to return the face id + * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally + * reachable ip address, otherwise HICN_ERROR_NONE + */ +always_inline void +hicn_iface_udp4_add (const ip4_address_t * local_addr, + const ip4_address_t * remote_addr, u16 local_port, + u16 remote_port, int sw_if, hicn_face_id_t * pfaceid) +{ + hicn_face_t *face; + pool_get (hicn_dpoi_face_pool, face); + + hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data; + + clib_memcpy (&(udp_face->hdrs.ip4.ip), &ip4_header_skl, + sizeof (ip4_header_t)); + clib_memcpy (&(udp_face->hdrs.ip4.ip.src_address), local_addr, + sizeof (ip4_address_t)); + clib_memcpy (&(udp_face->hdrs.ip4.ip.dst_address), remote_addr, + sizeof (ip4_address_t)); + + udp_face->hdrs.ip4.udp.src_port = local_port; + udp_face->hdrs.ip4.udp.dst_port = remote_port; + + face->shared.adj = ADJ_INDEX_INVALID; + face->shared.pl_id = (u16) 0; + face->shared.face_type = hicn_face_udp_type; + face->shared.flags = HICN_FACE_FLAGS_IFACE; + face->shared.locks = 0; + face->shared.sw_if = sw_if; + + hicn_face_udp_key_t key; + hicn_face_udp4_get_key (local_addr, remote_addr, local_port, + remote_port, &key); + *pfaceid = hicn_dpoi_get_index (face); + + mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & pfaceid, 0); + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_validate_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], + i); + vlib_zero_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], i); + } +} + +/** * @brief Delete an ip face * * @param face_id Id of the face to delete diff --git a/hicn-plugin/src/faces/udp/face_udp_node.c b/hicn-plugin/src/faces/udp/face_udp_node.c index df24c477f..184fea679 100644 --- a/hicn-plugin/src/faces/udp/face_udp_node.c +++ b/hicn-plugin/src/faces/udp/face_udp_node.c @@ -535,8 +535,31 @@ hicn_face_udp4_encap (vlib_main_t * vm, length /* changed member */ ); ip0->checksum = sum0; - vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj; + /* In case the adj is not complete, we look if a better one exists, otherwise we send an arp request + * This is necessary to account for the case in which when we create a face, there isn't a /128(/32) adjacency and we match with a more general route which is in glean state + * In this case in fact, the general route will not be update upone receiving of a arp or neighbour responde, but a new /128(/32) will be created + */ + if (PREDICT_FALSE (adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE)) + { + fib_prefix_t fib_pfx; + fib_node_index_t fib_entry_index; + ip46_address_t ip46 = + to_ip46 (0, (u8 *) & (face_udp->hdrs.ip4.ip.dst_address)); + fib_prefix_from_ip46_addr (&ip46, &fib_pfx); + fib_pfx.fp_len = 32; + + u32 fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, + HICN_FIB_TABLE, + FIB_SOURCE_PLUGIN_HI); + + fib_entry_index = fib_table_lookup (fib_index, &fib_pfx); + face->shared.adj = fib_entry_get_adj (fib_entry_index); + + adj = adj_get (face->shared.adj); + } + + vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj; *next = adj->lookup_next_index; } @@ -572,6 +595,30 @@ hicn_face_udp6_encap (vlib_main_t * vm, if (udp0->checksum == 0) udp0->checksum = 0xffff; + /* In case the adj is not complete, we look if a better one exists, otherwise we send an arp request + * This is necessary to account for the case in which when we create a face, there isn't a /128(/32) adjacency and we match with a more general route which is in glean state + * In this case in fact, the general route will not be update upone receiving of a arp or neighbour responde, but a new /128(/32) will be created + */ + if (PREDICT_FALSE (adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE)) + { + fib_prefix_t fib_pfx; + fib_node_index_t fib_entry_index; + ip46_address_t ip46 = + to_ip46 (1, (u8 *) & (face_udp->hdrs.ip6.ip.dst_address)); + fib_prefix_from_ip46_addr (&ip46, &fib_pfx); + fib_pfx.fp_len = 128; + + u32 fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, + HICN_FIB_TABLE, + FIB_SOURCE_PLUGIN_HI); + + fib_entry_index = fib_table_lookup (fib_index, &fib_pfx); + + face->shared.adj = fib_entry_get_adj (fib_entry_index); + + adj = adj_get (face->shared.adj); + } + vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj; *next = adj->lookup_next_index; |