diff options
-rw-r--r-- | hicn-plugin/src/faces/app/face_app_cli.c | 1 | ||||
-rw-r--r-- | hicn-plugin/src/faces/app/face_prod.c | 4 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.h | 47 | ||||
-rw-r--r-- | hicn-plugin/src/faces/iface_node.c | 25 | ||||
-rw-r--r-- | hicn-plugin/src/faces/iface_node.h | 20 | ||||
-rw-r--r-- | hicn-plugin/src/route.c | 8 | ||||
-rw-r--r-- | hicn-plugin/src/udp_tunnels/udp_tunnel.c | 13 | ||||
-rw-r--r-- | hicn-plugin/src/udp_tunnels/udp_tunnel.h | 20 |
8 files changed, 67 insertions, 71 deletions
diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c index 0c00eb28d..50e6ae71b 100644 --- a/hicn-plugin/src/faces/app/face_app_cli.c +++ b/hicn-plugin/src/faces/app/face_app_cli.c @@ -17,6 +17,7 @@ #include <vnet/dpo/dpo.h> #include <vlib/vlib.h> #include <vnet/ip/ip6_packet.h> +#include <vnet/ip/format.h> #include "../../params.h" #include "../face.h" diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c index 54fbd418a..4b7a5a2f6 100644 --- a/hicn-plugin/src/faces/app/face_prod.c +++ b/hicn-plugin/src/faces/app/face_prod.c @@ -263,7 +263,7 @@ hicn_face_prod_add (fib_prefix_t *prefix, u32 sw_if, u32 *cs_reserved, } u32 fib_index = fib_table_find (prefix->fp_proto, 0); - fib_table_entry_path_add2 (fib_index, prefix, FIB_SOURCE_CLI, + fib_table_entry_path_add2 (fib_index, prefix, FIB_SOURCE_API, FIB_ENTRY_FLAG_NONE, rpaths); HICN_DEBUG ("Calling hicn enable for producer face"); @@ -322,7 +322,7 @@ hicn_face_prod_del (hicn_face_id_t face_id) } /* Also remove it from main fib, as we sre the owners of this prefix */ u32 fib_index = fib_table_find (prefix->fp_proto, 0); - fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_CLI); + fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_API); ret = hicn_app_state_del (face->sw_if); if (ret) { diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index 5ebec216c..99e3071af 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -29,7 +29,6 @@ #include "face_flags.h" #include "../hicn_buffer_flags.h" -#include "../udp_tunnels/udp_tunnel.h" #include "../hicn_logging.h" typedef u8 hicn_face_flags_t; @@ -88,7 +87,7 @@ typedef struct __attribute__ ((packed)) hicn_face_s hicn_face_flags_t flags; /* Align the upcoming fields */ - u8 align; + u8 iface_next; /* Path label (2B) */ u16 pl_id; @@ -482,7 +481,7 @@ hicn_iface_add (const ip46_address_t *nat_address, int sw_if, hicn_face_key_t key; hicn_face_get_key (nat_address, sw_if, &face->dpo, &key); - face->dpo.dpoi_next_node = 1; + face->iface_next = 1; face->pl_id = pl_index++; face->flags = HICN_FACE_FLAGS_IFACE; @@ -554,26 +553,7 @@ hicn_face_ip4_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, face = hicn_dpoi_get_from_idx (idx); - if (*hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL && - adj_index != ADJ_INDEX_INVALID) - { - face->dpo.dpoi_type = dpo_type_udp_ip6; - face->dpo.dpoi_proto = DPO_PROTO_IP6; - } - else if (*hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL && - adj_index != ADJ_INDEX_INVALID) - { - face->dpo.dpoi_type = dpo_type_udp_ip4; - face->dpo.dpoi_proto = DPO_PROTO_IP4; - } - else - { - 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; + face->iface_next = node_index; /* if (nat_addr->as_u32 == 0) */ /* { */ @@ -652,26 +632,7 @@ hicn_face_ip6_add_and_lock (hicn_face_id_t *index, u8 *hicnb_flags, adj_index, face_flags); face = hicn_dpoi_get_from_idx (idx); - - if (*hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL && - adj_index != ADJ_INDEX_INVALID) - { - face->dpo.dpoi_type = dpo_type_udp_ip6; - face->dpo.dpoi_proto = DPO_PROTO_IP6; - } - else if (*hicnb_flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL && - adj_index != ADJ_INDEX_INVALID) - { - face->dpo.dpoi_type = dpo_type_udp_ip4; - face->dpo.dpoi_proto = DPO_PROTO_IP4; - } - else - { - 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; + face->iface_next = node_index; adj_nbr_walk (face->sw_if, FIB_PROTOCOL_IP6, hicn6_iface_adj_walk_cb, face); diff --git a/hicn-plugin/src/faces/iface_node.c b/hicn-plugin/src/faces/iface_node.c index edfd2cd63..fba7e97e6 100644 --- a/hicn-plugin/src/faces/iface_node.c +++ b/hicn-plugin/src/faces/iface_node.c @@ -20,6 +20,7 @@ #include "../infra.h" #include "../cache_policies/cs_lru.h" #include "../parser.h" +#include "iface_node.h" #include <hicn/error.h> #include <hicn/util/ip_address.h> @@ -126,16 +127,6 @@ typedef struct u8 packet_data[60]; } hicn4_iface_output_trace_t; -typedef enum -{ - HICN4_IFACE_OUTPUT_NEXT_DROP, - HICN4_IFACE_OUTPUT_NEXT_LOOKUP, - HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP, - HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP, - HICN4_IFACE_OUTPUT_NEXT_PG, - HICN4_IFACE_OUTPUT_N_NEXT, -} hicn4_iface_output_next_t; - /* Trace context struct */ typedef struct { @@ -145,16 +136,6 @@ typedef struct u8 packet_data[60]; } hicn6_iface_output_trace_t; -typedef enum -{ - HICN6_IFACE_OUTPUT_NEXT_DROP, - HICN6_IFACE_OUTPUT_NEXT_LOOKUP, - HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP, - HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP, - HICN6_IFACE_OUTPUT_NEXT_PG, - HICN6_IFACE_OUTPUT_N_NEXT, -} hicn6_iface_output_next_t; - //#define ERROR_OUTPUT_IP4 HICN4_IFACE_OUTPUT_NEXT_ERROR_DROP //#define ERROR_OUTPUT_IP6 HICN6_IFACE_OUTPUT_NEXT_ERROR_DROP @@ -667,7 +648,7 @@ hicn_rewrite_iface_data4 (vlib_main_t *vm, vlib_buffer_t *b0, ip0->ttl = 254; // FIXME TTL vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index; - *next = iface->dpo.dpoi_next_node; + *next = iface->iface_next; hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; @@ -706,7 +687,7 @@ hicn_rewrite_iface_data6 (vlib_main_t *vm, vlib_buffer_t *b0, ip0->hop_limit = HICN_IP6_HOP_LIMIT; vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index; - *next = iface->dpo.dpoi_next_node; + *next = iface->iface_next; hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; diff --git a/hicn-plugin/src/faces/iface_node.h b/hicn-plugin/src/faces/iface_node.h index 3fa6bb484..d580c9e31 100644 --- a/hicn-plugin/src/faces/iface_node.h +++ b/hicn-plugin/src/faces/iface_node.h @@ -37,6 +37,26 @@ * one implementing the tunnel encapsulation (udp-encap, mpls, etc). */ +typedef enum +{ + HICN4_IFACE_OUTPUT_NEXT_DROP, + HICN4_IFACE_OUTPUT_NEXT_LOOKUP, + HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP, + HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP, + HICN4_IFACE_OUTPUT_NEXT_PG, + HICN4_IFACE_OUTPUT_N_NEXT, +} hicn4_iface_output_next_t; + +typedef enum +{ + HICN6_IFACE_OUTPUT_NEXT_DROP, + HICN6_IFACE_OUTPUT_NEXT_LOOKUP, + HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP, + HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP, + HICN6_IFACE_OUTPUT_NEXT_PG, + HICN6_IFACE_OUTPUT_N_NEXT, +} hicn6_iface_output_next_t; + /** * @brief Initialize the ip iface module */ diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c index a2e72b9c1..059d506e0 100644 --- a/hicn-plugin/src/route.c +++ b/hicn-plugin/src/route.c @@ -236,6 +236,7 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) { \ /* Careful, this adds a lock on the face if it exists */ \ hicn_face_add (dpo, nh, sw_if, &face_id); \ + ASSERT (face_id != HICN_FACE_NULL); \ vec_validate (vec_faces, index); \ vec_faces[index] = face_id; \ (index)++; \ @@ -275,11 +276,9 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) HICN_DEBUG ("Added new HICN face: %d because of route prefix %U", face_id, format_fib_prefix, &_fib_entry->fe_prefix); } - else if (dpo->dpoi_type == dpo_type_udp_ip4 || - dpo->dpoi_type == dpo_type_udp_ip6) + else if (dpo_is_udp_encap (dpo)) { - dpo_proto_t proto = - dpo->dpoi_type == dpo_type_udp_ip4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6; + dpo_proto_t proto = dpo_udp_encap_get_proto (dpo); ip46_address_t _nh = { 0 }; nh = &_nh; switch (_fib_entry->fe_prefix.fp_proto) @@ -298,6 +297,7 @@ sync_hicn_fib_entry (hicn_dpo_ctx_t *fib_entry, hicn_face_id_t **pvec_faces) HICN_DEBUG ("Added new UDP face: %d because of route prefix %U", face_id, format_ip_prefix, &_fib_entry->fe_prefix); udp_tunnel_add_existing (dpo->dpoi_index, proto); + udp_tunnel_set_face (face_id, proto == DPO_PROTO_IP4); } else if (dpo_is_pgserver (dpo)) { diff --git a/hicn-plugin/src/udp_tunnels/udp_tunnel.c b/hicn-plugin/src/udp_tunnels/udp_tunnel.c index d03d6a74e..5b0c0a9ef 100644 --- a/hicn-plugin/src/udp_tunnels/udp_tunnel.c +++ b/hicn-plugin/src/udp_tunnels/udp_tunnel.c @@ -17,6 +17,7 @@ #include <vppinfra/bihash_40_8.h> #include <vnet/fib/fib_table.h> #include <vnet/udp/udp_local.h> +#include "../faces/iface_node.h" #include "../error.h" #include "../strategy_dpo_ctx.h" @@ -178,6 +179,18 @@ udp_tunnel_get_create (const ip46_address_t *src_ip, } void +udp_tunnel_set_face (hicn_face_id_t face_id, int isv4) +{ + hicn_face_t *face = NULL; + face = hicn_dpoi_get_from_idx (face_id); + ASSERT (face); + ASSERT (dpo_is_udp_encap (&face->dpo)); + + face->iface_next = isv4 ? HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP : + HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP; +} + +void udp_tunnel_init () { clib_bihash_init_40_8 (&udp_tunnels_hashtb, "udp encap table", 2048, diff --git a/hicn-plugin/src/udp_tunnels/udp_tunnel.h b/hicn-plugin/src/udp_tunnels/udp_tunnel.h index 376adf5fa..f7865f58a 100644 --- a/hicn-plugin/src/udp_tunnels/udp_tunnel.h +++ b/hicn-plugin/src/udp_tunnels/udp_tunnel.h @@ -20,6 +20,8 @@ #include <vppinfra/error.h> #include <vnet/udp/udp_encap.h> +#include "../faces/face.h" + /** * @file udp_tunnel.h * @@ -109,6 +111,24 @@ int udp_tunnel_del (fib_protocol_t proto, index_t fib_index, void udp_tunnel_add_existing (index_t uei, dpo_proto_t proto); /** + * @brief Check if DPO is UDP encap + */ +always_inline int +dpo_is_udp_encap (const dpo_id_t *dpo) +{ + return dpo->dpoi_type == dpo_type_udp_ip4 || + dpo->dpoi_type == dpo_type_udp_ip6; +} + +always_inline dpo_proto_t +dpo_udp_encap_get_proto (const dpo_id_t *dpo) +{ + return dpo->dpoi_type == dpo_type_udp_ip4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6; +} + +void udp_tunnel_set_face (hicn_face_id_t face_id, int isv4); + +/** * @brief Init the udp tunnel module * */ |