diff options
-rw-r--r-- | hicn-plugin/src/data_fwd.h | 1 | ||||
-rw-r--r-- | hicn-plugin/src/data_fwd_node.c | 7 | ||||
-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/interest_pcslookup_node.c | 53 | ||||
-rw-r--r-- | hicn-plugin/src/route.c | 8 | ||||
-rw-r--r-- | hicn-plugin/src/strategy_node.c | 53 | ||||
-rw-r--r-- | hicn-plugin/src/udp_tunnels/udp_tunnel.c | 13 | ||||
-rw-r--r-- | hicn-plugin/src/udp_tunnels/udp_tunnel.h | 20 |
12 files changed, 139 insertions, 113 deletions
diff --git a/hicn-plugin/src/data_fwd.h b/hicn-plugin/src/data_fwd.h index 129ca5b73..4acfdea4d 100644 --- a/hicn-plugin/src/data_fwd.h +++ b/hicn-plugin/src/data_fwd.h @@ -50,6 +50,7 @@ typedef struct u32 sw_if_index; u8 pkt_type; u8 packet_data[64]; + u32 face; } hicn_data_fwd_trace_t; typedef enum diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c index 981dc2c5e..dc1510fae 100644 --- a/hicn-plugin/src/data_fwd_node.c +++ b/hicn-plugin/src/data_fwd_node.c @@ -162,6 +162,7 @@ hicn_satisfy_faces (vlib_main_t *vm, u32 bi0, hicn_pcs_entry_t *pitp, { hicn_data_fwd_trace_t *t = vlib_add_trace (vm, node, h0, sizeof (*t)); + t->face = face0; t->pkt_type = HICN_PACKET_TYPE_DATA; t->sw_if_index = vnet_buffer (h0)->sw_if_index[VLIB_RX]; t->next_index = next0; @@ -173,6 +174,7 @@ hicn_satisfy_faces (vlib_main_t *vm, u32 bi0, hicn_pcs_entry_t *pitp, { hicn_data_fwd_trace_t *t = vlib_add_trace (vm, node, h1, sizeof (*t)); + t->face = face1; t->pkt_type = HICN_PACKET_TYPE_DATA; t->sw_if_index = vnet_buffer (h1)->sw_if_index[VLIB_RX]; t->next_index = next1; @@ -212,6 +214,7 @@ hicn_satisfy_faces (vlib_main_t *vm, u32 bi0, hicn_pcs_entry_t *pitp, { hicn_data_fwd_trace_t *t = vlib_add_trace (vm, node, h0, sizeof (*t)); + t->face = face0; t->pkt_type = HICN_PACKET_TYPE_DATA; t->sw_if_index = vnet_buffer (h0)->sw_if_index[VLIB_RX]; t->next_index = next0; @@ -284,8 +287,8 @@ hicn_data_fwd_format_trace (u8 *s, va_list *args) hicn_data_fwd_trace_t *t = va_arg (*args, hicn_data_fwd_trace_t *); u32 indent = format_get_indent (s); - s = format (s, "DATAFWD: pkt: %d, sw_if_index %d, next index %d\n", - (int) t->pkt_type, t->sw_if_index, t->next_index); + s = format (s, "DATAFWD: pkt: %d, sw_if_index %d, next index %d, face %d\n", + (int) t->pkt_type, t->sw_if_index, t->next_index, t->face); s = format (s, "%U%U", format_white_space, indent, format_ip6_header, t->packet_data, sizeof (t->packet_data)); 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/interest_pcslookup_node.c b/hicn-plugin/src/interest_pcslookup_node.c index e3668c565..a0b2ee3f0 100644 --- a/hicn-plugin/src/interest_pcslookup_node.c +++ b/hicn-plugin/src/interest_pcslookup_node.c @@ -47,6 +47,20 @@ static char *hicn_interest_pcslookup_error_strings[] = { vlib_node_registration_t hicn_interest_pcslookup_node; +always_inline void +drop_packet (vlib_main_t *vm, u32 bi0, u32 *n_left_to_next, u32 *next0, + u32 **to_next, u32 *next_index, vlib_node_runtime_t *node) +{ + *next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; + + (*to_next)[0] = bi0; + *to_next += 1; + *n_left_to_next -= 1; + + vlib_validate_buffer_enqueue_x1 (vm, node, *next_index, *to_next, + *n_left_to_next, bi0, *next0); +} + /* * ICN forwarder node for interests. */ @@ -64,6 +78,8 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm, u32 bi0; u32 next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; hicn_pcs_entry_t *pcs_entry = NULL; + f64 tnow; + hicn_buffer_t *hicnb0; rt = vlib_node_get_runtime_data (vm, hicn_interest_pcslookup_node.index); @@ -75,6 +91,8 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; + tnow = vlib_time_now (vm); + while (n_left_from > 0) { u32 n_left_to_next; @@ -105,9 +123,11 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm, // Update stats stats.pkts_processed++; + hicnb0 = hicn_get_buffer (b0); + // Check if the interest is in the PCS already hicn_name_t name; - hicn_packet_get_name (&hicn_get_buffer (b0)->pkbuf, &name); + hicn_packet_get_name (&hicnb0->pkbuf, &name); ret = hicn_pcs_lookup_one (rt->pitcs, &name, &pcs_entry); if (ret == HICN_ERROR_NONE) @@ -124,7 +144,38 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm, if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; } + else + { + // No entry in PCS. Let's create one now + pcs_entry = hicn_pcs_entry_pit_get ( + rt->pitcs, tnow, hicn_buffer_get_lifetime (b0)); + + ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name); + + if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) + { + next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; + goto end; + } + + // Store internal state + ret = hicn_store_internal_state ( + b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry), + vnet_buffer (b0)->ip.adj_index[VLIB_TX]); + + if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) + { + hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry); + drop_packet (vm, bi0, &n_left_from, &next0, &to_next, + &next_index, node); + continue; + } + + // Add face + hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); + } + end: stats.pkts_interest_count++; // Interest manifest? diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c index f89d40211..ff96e5cd7 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_fib_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/strategy_node.c b/hicn-plugin/src/strategy_node.c index 67ac1c140..6c98f3b06 100644 --- a/hicn-plugin/src/strategy_node.c +++ b/hicn-plugin/src/strategy_node.c @@ -64,12 +64,26 @@ always_inline void drop_packet (vlib_main_t *vm, u32 bi0, u32 *n_left_to_next, u32 *next0, u32 **to_next, u32 *next_index, vlib_node_runtime_t *node) { + vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); + *next0 = HICN_STRATEGY_NEXT_ERROR_DROP; (*to_next)[0] = bi0; *to_next += 1; *n_left_to_next -= 1; + // Maybe trace + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && + (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + hicn_strategy_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); + t->pkt_type = HICN_PACKET_TYPE_INTEREST; + t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->next_index = *next0; + t->dpo_type = hicn_get_buffer (b0)->vft_id; + t->out_face = -1; + } + vlib_validate_buffer_enqueue_x1 (vm, node, *next_index, *to_next, *n_left_to_next, bi0, *next0); } @@ -95,10 +109,8 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u32 clones[MAX_OUT_FACES]; u16 outfaces_len; u32 next0; - const hicn_dpo_ctx_t *dpo_ctx; const hicn_strategy_vft_t *strategy; hicn_buffer_t *hicnb0; - hicn_pcs_entry_t *pcs_entry = NULL; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -111,7 +123,6 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node, while (n_left_from > 0) { - vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); while (n_left_from > 0 && n_left_to_next > 0) { @@ -138,11 +149,7 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hicnb0 = hicn_get_buffer (b0); // Get the strategy VFT - hicnb0->dpo_ctx_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; - dpo_ctx = hicn_strategy_dpo_ctx_get (hicnb0->dpo_ctx_id); - hicnb0->vft_id = dpo_ctx->dpo_type; strategy = hicn_dpo_get_strategy_vft (hicnb0->vft_id); - strategy->hicn_add_interest (hicnb0->dpo_ctx_id); // Check we have at least one next hop for the packet ret = strategy->hicn_select_next_hop ( @@ -155,38 +162,6 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node, continue; } - // Create a new PIT entry - pcs_entry = hicn_pcs_entry_pit_get (rt->pitcs, tnow, - hicn_buffer_get_lifetime (b0)); - - // Add entry to PIT table - hicn_name_t name; - hicn_packet_get_name (&hicnb0->pkbuf, &name); - ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name); - - if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) - { - drop_packet (vm, bi0, &n_left_from, &next0, &to_next, - &next_index, node); - continue; - } - - // Store internal state - ret = hicn_store_internal_state ( - b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry), - vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - - if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) - { - hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry); - drop_packet (vm, bi0, &n_left_from, &next0, &to_next, - &next_index, node); - continue; - } - - // Add face - hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); - // Set next node next0 = hicn_buffer_is_v6 (b0) ? HICN_STRATEGY_NEXT_INTEREST_FACE6 : HICN_STRATEGY_NEXT_INTEREST_FACE4; 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 * */ |