From c1b56d5861829a23289f42cecd716e681b520cf0 Mon Sep 17 00:00:00 2001 From: Alberto Compagno Date: Wed, 22 Apr 2020 18:29:52 +0200 Subject: [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 Change-Id: Iffea4d81c5ea8ce8ccbbfd749113f06a698a2afe --- hicn-plugin/src/route.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'hicn-plugin/src/route.c') diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c index 0cefe6bda..0096edb2b 100644 --- a/hicn-plugin/src/route.c +++ b/hicn-plugin/src/route.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include "strategy_dpo_ctx.h" @@ -29,6 +31,8 @@ #include "faces/face.h" #include "error.h" #include "strategies/dpo_mw.h" +#include "infra.h" +#include "udp_tunnels/udp_tunnel.h" #define FIB_SOURCE_HICN 0x04 //Right after the FIB_SOURCE_INTERFACE priority @@ -36,6 +40,9 @@ fib_source_t hicn_fib_src; fib_node_type_t hicn_fib_node_type; +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) @@ -508,6 +515,25 @@ sync_hicn_fib_entry(hicn_dpo_ctx_t *fib_entry) sw_if = adj->rewrite_header.sw_if_index; nh = get_address (&(adj->sub_type.nbr.next_hop), sw_if, fib_entry->proto); } + 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; + nh = calloc (1, sizeof(ip46_address_t)); + switch (dpo->dpoi_proto) + { + case FIB_PROTOCOL_IP6: + nh = calloc (1, sizeof(ip46_address_t)); + ip46_address_set_ip6(nh, &localhost6); + break; + case FIB_PROTOCOL_IP4: + nh = calloc (1, sizeof(ip46_address_t)); + ip46_address_set_ip4(nh, &localhost4); + break; + default: + nh = calloc (1, sizeof(ip46_address_t)); + } + udp_tunnel_add_existing (dpo->dpoi_index, proto); + } else //if (dpo_is_drop(dpo)) { sw_if = dpo_get_urpf(dpo); @@ -927,6 +953,8 @@ 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); @@ -934,6 +962,26 @@ hicn_route_init () 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); + + localhost4.as_u8[0] = 127; + localhost4.as_u8[3] = 1; + u32 length4 = 32, length6 = 128, is_del = 0, flags = 0; + + 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); + + flags |= VNET_SW_INTERFACE_FLAG_ADMIN_UP; + vnet_sw_interface_set_flags (vnm, sw_if_index, flags); } /* -- cgit 1.2.3-korg