diff options
author | Alberto Compagno <acompagn+fdio@cisco.com> | 2020-04-22 18:29:52 +0200 |
---|---|---|
committer | Alberto Compagno <acompagn+fdio@cisco.com> | 2020-05-04 11:32:01 +0200 |
commit | c1b56d5861829a23289f42cecd716e681b520cf0 (patch) | |
tree | 05a78211549d5581c4f50f6e9647467cbebe548a /hicn-plugin/src/faces | |
parent | 0c7f490009e8633e015b5cba48b78cc243254953 (diff) |
[HICN-602] Added bidirectional udp tunnels
- Implemented a udp decapsulation node
- Added a hash table to identify the incoming udp tunnel when
an interest or data packets are received
- Added udp punting through udp_register_dst_port
Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Change-Id: Iffea4d81c5ea8ce8ccbbfd749113f06a698a2afe
Diffstat (limited to 'hicn-plugin/src/faces')
-rw-r--r-- | hicn-plugin/src/faces/app/face_cons.c | 8 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_prod.c | 11 | ||||
-rw-r--r-- | hicn-plugin/src/faces/dpo_face.h | 32 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.c | 24 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.h | 9 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face_node.c | 19 | ||||
-rw-r--r-- | hicn-plugin/src/faces/iface_node.c | 44 |
7 files changed, 101 insertions, 46 deletions
diff --git a/hicn-plugin/src/faces/app/face_cons.c b/hicn-plugin/src/faces/app/face_cons.c index 3cd3da78c..d44ba1a2b 100644 --- a/hicn-plugin/src/faces/app/face_cons.c +++ b/hicn-plugin/src/faces/app/face_cons.c @@ -57,7 +57,9 @@ hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6, ip46_address_t nh_addr = to_ip46 (0, (u8 *) nh_addr4); - hicn_iface_add (&nh_addr, swif, faceid1, DPO_PROTO_IP4); + 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; @@ -68,7 +70,9 @@ hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6, &(if_ip.ip6), ADDR_MGR_IP6_CONS_LEN, 0 /* is_del */ ); - hicn_iface_add ((ip46_address_t *) nh_addr6, swif, faceid2, DPO_PROTO_IP6); + 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); face = hicn_dpoi_get_from_idx (*faceid2); face->flags |= HICN_FACE_FLAGS_APPFACE_CONS; diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c index c5b9f93dd..645154325 100644 --- a/hicn-plugin/src/faces/app/face_prod.c +++ b/hicn-plugin/src/faces/app/face_prod.c @@ -161,12 +161,16 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved, { return HICN_ERROR_APPFACE_PROD_PREFIX_NULL; } + + u8 isv6 = ip46_address_is_ip4(prod_addr); + index_t adj_index = adj_nbr_find(isv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4, isv6 ? VNET_LINK_IP6 : VNET_LINK_IP4, prod_addr, sw_if); + /* * Check if a producer face is already existing for the same prefix * and sw_if */ face = hicn_face_get (&(prefix->fp_addr), sw_if, - &hicn_face_hashtb); + &hicn_face_hashtb, adj_index); if (face != NULL) { @@ -208,6 +212,8 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved, &local_app_ip4, 31, 0 /* is_del */ ); local_app_ip = to_ip46 ( /* isv6 */ 0, local_app_ip4.as_u8); remote_app_ip = to_ip46 ( /* isv6 */ 0, remote_app_ip4.as_u8); + + vnet_build_rewrite_for_sw_interface(vnm, sw_if, VNET_LINK_IP4, &remote_app_ip4); } else { @@ -279,7 +285,8 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved, hicn_app_state_create (sw_if, prefix); } - face = hicn_face_get(&local_app_ip, sw_if, &hicn_face_hashtb);//HICN_FACE_FLAGS_APPFACE_PROD); + adj_index = adj_nbr_find(isv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4, isv6 ? VNET_LINK_IP6 : VNET_LINK_IP4, prod_addr, sw_if); + face = hicn_face_get(&local_app_ip, sw_if, &hicn_face_hashtb, adj_index);//HICN_FACE_FLAGS_APPFACE_PROD); *faceid = hicn_dpoi_get_index (face); diff --git a/hicn-plugin/src/faces/dpo_face.h b/hicn-plugin/src/faces/dpo_face.h index 736c5c926..3bb99ecdb 100644 --- a/hicn-plugin/src/faces/dpo_face.h +++ b/hicn-plugin/src/faces/dpo_face.h @@ -135,7 +135,7 @@ always_inline void hicn_dpo_iface_ip4_add_and_lock (hicn_face_id_t * index, u8 * hicnb_flags, const ip4_address_t * nat_addr, - u32 sw_if, u32 node_index) + u32 sw_if, u32 adj_index, u32 node_index) { /*All (complete) faces are indexed by remote addess as well */ @@ -144,29 +144,27 @@ hicn_dpo_iface_ip4_add_and_lock (hicn_face_id_t * index, /* if the face exists, it adds a lock */ hicn_face_t *face = - hicn_face_get (&ip_address, sw_if, &hicn_face_hashtb); + hicn_face_get (&ip_address, sw_if, &hicn_face_hashtb, adj_index); if (face == NULL) { hicn_face_id_t idx; - hicn_iface_add (&ip_address, sw_if, &idx, DPO_PROTO_IP4); + hicn_iface_add (&ip_address, sw_if, &idx, DPO_PROTO_IP4, adj_index); face = hicn_dpoi_get_from_idx(idx); - if (nat_addr->as_u32 == 0) - { + face->dpo.dpoi_type = DPO_FIRST; + face->dpo.dpoi_proto = DPO_PROTO_IP4; + face->dpo.dpoi_index = adj_index; + face->dpo.dpoi_next_node = node_index; + + /* if (nat_addr->as_u32 == 0) */ + /* { */ adj_nbr_walk(face->sw_if, FIB_PROTOCOL_IP4, hicn4_iface_adj_walk_cb, face); - } - else - { - face->dpo.dpoi_type = DPO_FIRST; - face->dpo.dpoi_proto = DPO_PROTO_IP4; - face->dpo.dpoi_index = ~0; - face->dpo.dpoi_next_node = node_index; - } + /* } */ *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT; @@ -226,23 +224,23 @@ always_inline void hicn_dpo_iface_ip6_add_and_lock (hicn_face_id_t * index, u8 * hicnb_flags, const ip6_address_t * nat_addr, - u32 sw_if, u32 node_index) + 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); + 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); + hicn_iface_add ((ip46_address_t *) nat_addr, sw_if, &idx, DPO_PROTO_IP6, adj_index); face = hicn_dpoi_get_from_idx(idx); face->dpo.dpoi_type = DPO_FIRST; face->dpo.dpoi_proto = DPO_PROTO_IP6; - face->dpo.dpoi_index = ~0; + face->dpo.dpoi_index = adj_index; face->dpo.dpoi_next_node = node_index; //if (ip46_address_is_zero((ip46_address_t *)nat_addr)) diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c index 652a4a8e2..1abbf8887 100644 --- a/hicn-plugin/src/faces/face.c +++ b/hicn-plugin/src/faces/face.c @@ -341,19 +341,19 @@ hicn_iface_to_face(hicn_face_t *face, const dpo_id_t * dpo) ip46_address_t * nh = &(adj->sub_type.nbr.next_hop); fib_prefix_t prefix; - fib_prefix_from_ip46_addr(nh, &prefix); + if (!ip46_address_is_zero(nh)) + { + fib_prefix_from_ip46_addr(nh, &prefix); - u32 fib_index = fib_table_find(prefix.fp_proto, HICN_FIB_TABLE); + u32 fib_index = fib_table_find(prefix.fp_proto, HICN_FIB_TABLE); - face->fib_entry_index = fib_entry_track (fib_index, - &prefix, - hicn_face_fib_node_type, - hicn_dpoi_get_index(face), &face->fib_sibling); + face->fib_entry_index = fib_entry_track (fib_index, + &prefix, + hicn_face_fib_node_type, + hicn_dpoi_get_index(face), &face->fib_sibling); + } } } - - - //adj_child_add(face->dpo.dpoi_index, hicn_face_fib_node_type, hicn_dpoi_get_index(face)); } /* @@ -382,16 +382,17 @@ hicn_face_add (const dpo_id_t * dpo_nh, ip46_address_t * nat_address, face = hicn_face_get (nat_address, sw_if, - &hicn_face_hashtb); + &hicn_face_hashtb, dpo_nh->dpoi_index); dpo_id_t temp_dpo = DPO_INVALID; + temp_dpo.dpoi_index = dpo_nh->dpoi_index; hicn_face_key_t key; hicn_face_get_key (nat_address, sw_if, dpo_nh, &key); if (face == NULL) { - hicn_iface_add (nat_address, sw_if, pfaceid, dpo_nh->dpoi_proto); + hicn_iface_add (nat_address, sw_if, pfaceid, dpo_nh->dpoi_proto, dpo_nh->dpoi_index); face = hicn_dpoi_get_from_idx (*pfaceid); mhash_set_mem (&hicn_face_hashtb, &key, (uword *) pfaceid, @@ -411,6 +412,7 @@ hicn_face_add (const dpo_id_t * dpo_nh, ip46_address_t * nat_address, hicn_iface_to_face(face, dpo_nh); + temp_dpo.dpoi_index = ~0; hicn_face_input_faces_t *in_faces = hicn_face_get_vec (nat_address, &hicn_face_vec_hashtb); diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index 54f2eab31..a9a565a5a 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -379,12 +379,14 @@ hicn_face_get_key (const ip46_address_t * addr, * @result Pointer to the face. */ always_inline hicn_face_t * -hicn_face_get (const ip46_address_t * addr, u32 sw_if, mhash_t * hashtb) +hicn_face_get (const ip46_address_t * addr, u32 sw_if, mhash_t * hashtb, index_t adj_index) { hicn_face_key_t key; dpo_id_t dpo = DPO_INVALID; + dpo.dpoi_index = adj_index; + hicn_face_get_key (addr, sw_if, &dpo, &key); hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb, @@ -478,7 +480,8 @@ int hicn_face_add (const dpo_id_t * dpo_nh, */ always_inline void hicn_iface_add (ip46_address_t * nat_address, int sw_if, - hicn_face_id_t * pfaceid, dpo_proto_t proto) + hicn_face_id_t * pfaceid, dpo_proto_t proto, + u32 adj_index) { hicn_face_t *face; pool_get (hicn_dpoi_face_pool, face); @@ -489,7 +492,7 @@ hicn_iface_add (ip46_address_t * nat_address, int sw_if, face->dpo.dpoi_type = DPO_FIRST; face->dpo.dpoi_proto = DPO_PROTO_NONE; - face->dpo.dpoi_index = INDEX_INVALID; + face->dpo.dpoi_index = adj_index; face->dpo.dpoi_next_node = 0; face->pl_id = (u16) 0; face->flags = HICN_FACE_FLAGS_IFACE; diff --git a/hicn-plugin/src/faces/face_node.c b/hicn-plugin/src/faces/face_node.c index a52967dae..5b42f0dde 100644 --- a/hicn-plugin/src/faces/face_node.c +++ b/hicn-plugin/src/faces/face_node.c @@ -18,7 +18,6 @@ #include "face.h" #include "face_node.h" #include "dpo_face.h" -//#include "app/face_prod.h" #include "../strategy_dpo_manager.h" #include "face.h" #include "../cache_policies/cs_lru.h" @@ -465,12 +464,16 @@ VLIB_REGISTER_NODE(hicn6_face_input_node) = typedef enum { HICN4_FACE_OUTPUT_NEXT_ECHO_REPLY, + HICN4_FACE_OUTPUT_NEXT_UDP4_ENCAP, + HICN4_FACE_OUTPUT_NEXT_UDP6_ENCAP, HICN4_FACE_OUTPUT_N_NEXT, } hicn4_face_output_next_t; typedef enum { HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY, + HICN6_FACE_OUTPUT_NEXT_UDP4_ENCAP, + HICN6_FACE_OUTPUT_NEXT_UDP6_ENCAP, HICN6_FACE_OUTPUT_N_NEXT, } hicn6_face_output_next_t; @@ -563,7 +566,7 @@ hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0, ip46_address_reset (&temp_addr); hicn_type_t type = hicn_get_buffer (b0)->type; hicn_ops_vft[type.l1]->rewrite_interest (type, &hicn->protocol, - &face->nat_addr, &temp_addr); + &face->nat_addr, &temp_addr); if (ip46_address_is_ip4(&face->nat_addr)) b0->flags |= VNET_BUFFER_F_OFFLOAD_IP_CKSUM; @@ -616,7 +619,7 @@ hicn6_face_output_trace_t; do { \ vlib_buffer_t *b0; \ u32 bi0; \ - u32 next0 = IP_LOOKUP_NEXT_DROP; \ + u32 next0 = ~0; \ hicn_face_t * face; \ \ /* Prefetch for next iteration. */ \ @@ -678,8 +681,8 @@ hicn6_face_output_trace_t; do { \ vlib_buffer_t *b0, *b1; \ u32 bi0, bi1; \ - u32 next0 = IP_LOOKUP_NEXT_DROP; \ - u32 next1 = IP_LOOKUP_NEXT_DROP; \ + u32 next0 = ~0; \ + u32 next1 = ~0; \ hicn_face_t *face0, *face1; \ \ /* Prefetch for next iteration. */ \ @@ -844,6 +847,8 @@ VLIB_REGISTER_NODE(hicn4_face_output_node) = .next_nodes = { [HICN4_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn4-face-input", + [HICN4_FACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap", + [HICN4_FACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" } }; /* *INDENT-ON* */ @@ -920,7 +925,9 @@ VLIB_REGISTER_NODE(hicn6_face_output_node) = /* Reusing the list of nodes from lookup to be compatible with neighbour discovery */ .next_nodes = { - [HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn6-face-input" + [HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn6-face-input", + [HICN6_FACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap", + [HICN6_FACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" } }; /* *INDENT-ON* */ diff --git a/hicn-plugin/src/faces/iface_node.c b/hicn-plugin/src/faces/iface_node.c index fbc573088..d42d0114e 100644 --- a/hicn-plugin/src/faces/iface_node.c +++ b/hicn-plugin/src/faces/iface_node.c @@ -135,6 +135,8 @@ typedef struct typedef enum { HICN4_IFACE_OUTPUT_NEXT_LOOKUP, + HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP, + HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP, HICN4_IFACE_OUTPUT_N_NEXT, } hicn4_iface_output_next_t; @@ -150,6 +152,8 @@ typedef struct typedef enum { HICN6_IFACE_OUTPUT_NEXT_LOOKUP, + HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP, + HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP, HICN6_IFACE_OUTPUT_N_NEXT, } hicn6_iface_output_next_t; @@ -159,6 +163,9 @@ typedef enum #define NEXT_DATA_LOOKUP_IP4 HICN4_IFACE_OUTPUT_NEXT_LOOKUP #define NEXT_DATA_LOOKUP_IP6 HICN6_IFACE_OUTPUT_NEXT_LOOKUP +#define NEXT_UDP_ENCAP_IP4 HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP +#define NEXT_UDP_ENCAP_IP6 HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP + #define HICN_REWRITE_DATA_IP4 hicn_rewrite_iface_data4 #define HICN_REWRITE_DATA_IP6 hicn_rewrite_iface_data6 @@ -170,7 +177,7 @@ typedef enum #define iface_input_x1(ipv) \ do { \ vlib_buffer_t *b0; \ - u32 bi0, next0; \ + u32 bi0, next0, next_iface0; \ IP_HEADER_##ipv * ip_hdr = NULL; \ hicn_buffer_t * hicnb0; \ /* Prefetch for next iteration. */ \ @@ -200,13 +207,20 @@ typedef enum next0 = is_icmp*NEXT_MAPME_IP##ipv + \ (1-is_icmp)*NEXT_INTEREST_IP##ipv; \ \ + next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \ + \ + if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \ + next_iface0 = NEXT_UDP_ENCAP_IP4; \ + else if(hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \ + next_iface0 = NEXT_UDP_ENCAP_IP6; \ \ DPO_ADD_LOCK_IFACE_IP##ipv \ (&(hicnb0->face_id), \ &hicnb0->flags, \ &(ip_hdr->src_address), \ vnet_buffer(b0)->sw_if_index[VLIB_RX], \ - NEXT_DATA_LOOKUP_IP##ipv); \ + vnet_buffer(b0)->ip.adj_index[VLIB_RX], \ + next_iface0); \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ (b0->flags & VLIB_BUFFER_IS_TRACED))) \ @@ -239,7 +253,7 @@ typedef enum #define iface_input_x2(ipv) \ do { \ vlib_buffer_t *b0, *b1; \ - u32 bi0, bi1, next0, next1; \ + u32 bi0, bi1, next0, next1, next_iface0, next_iface1; \ IP_HEADER_##ipv * ip_hdr0 = NULL; \ IP_HEADER_##ipv * ip_hdr1 = NULL; \ hicn_buffer_t *hicnb0, *hicnb1; \ @@ -281,20 +295,35 @@ typedef enum next1 = is_icmp1*NEXT_MAPME_IP##ipv + \ (1-is_icmp1)*NEXT_INTEREST_IP##ipv; \ \ + next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \ + \ + if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \ + next_iface0 = NEXT_UDP_ENCAP_IP4; \ + else if(hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \ + next_iface0 = NEXT_UDP_ENCAP_IP6; \ \ + next_iface1 = NEXT_DATA_LOOKUP_IP##ipv; \ + \ + if (hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \ + next_iface1 = NEXT_UDP_ENCAP_IP4; \ + else if(hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \ + next_iface1 = NEXT_UDP_ENCAP_IP6; \ + \ DPO_ADD_LOCK_IFACE_IP##ipv \ (&(hicnb0->face_id), \ &hicnb0->flags, \ &(ip_hdr0->src_address), \ vnet_buffer(b0)->sw_if_index[VLIB_RX], \ - NEXT_DATA_LOOKUP_IP##ipv); \ + vnet_buffer(b0)->ip.adj_index[VLIB_RX], \ + next_iface0); \ \ DPO_ADD_LOCK_IFACE_IP##ipv \ (&(hicnb1->face_id), \ &hicnb1->flags, \ &(ip_hdr1->src_address), \ vnet_buffer(b1)->sw_if_index[VLIB_RX], \ - NEXT_DATA_LOOKUP_IP##ipv); \ + vnet_buffer(b1)->ip.adj_index[VLIB_RX], \ + next_iface1); \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ (b0->flags & VLIB_BUFFER_IS_TRACED))) \ @@ -794,6 +823,8 @@ VLIB_REGISTER_NODE (hicn4_iface_output_node) = .next_nodes = { [HICN4_IFACE_OUTPUT_NEXT_LOOKUP] = "ip4-lookup", + [HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap", + [HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" }, }; /* *INDENT-ON* */ @@ -869,6 +900,9 @@ VLIB_REGISTER_NODE (hicn6_iface_output_node) = .next_nodes = { [HICN6_IFACE_OUTPUT_NEXT_LOOKUP] = "ip6-lookup", + [HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap", + [HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" + }, }; /* *INDENT-ON* */ |