aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/faces')
-rw-r--r--hicn-plugin/src/faces/app/address_mgr.c20
-rw-r--r--hicn-plugin/src/faces/app/face_app_cli.c7
-rw-r--r--hicn-plugin/src/faces/app/face_cons.c14
-rw-r--r--hicn-plugin/src/faces/app/face_prod.c176
-rw-r--r--hicn-plugin/src/faces/app/face_prod.h13
-rw-r--r--hicn-plugin/src/faces/app/face_prod_node.c6
-rw-r--r--hicn-plugin/src/faces/dpo_face.h (renamed from hicn-plugin/src/faces/ip/dpo_ip.h)231
-rw-r--r--hicn-plugin/src/faces/face.c377
-rw-r--r--hicn-plugin/src/faces/face.h310
-rw-r--r--hicn-plugin/src/faces/face_cli.c20
-rw-r--r--hicn-plugin/src/faces/face_node.c (renamed from hicn-plugin/src/faces/ip/face_ip_node.c)457
-rw-r--r--hicn-plugin/src/faces/face_node.h (renamed from hicn-plugin/src/faces/udp/face_udp_node.h)16
-rw-r--r--hicn-plugin/src/faces/iface_node.c (renamed from hicn-plugin/src/faces/ip/iface_ip_node.c)387
-rw-r--r--hicn-plugin/src/faces/iface_node.h (renamed from hicn-plugin/src/faces/ip/iface_ip_node.h)2
-rw-r--r--hicn-plugin/src/faces/ip/dpo_ip.c90
-rw-r--r--hicn-plugin/src/faces/ip/face_ip.c571
-rw-r--r--hicn-plugin/src/faces/ip/face_ip.h310
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_cli.c208
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_node.h40
-rw-r--r--hicn-plugin/src/faces/udp/dpo_udp.c157
-rw-r--r--hicn-plugin/src/faces/udp/dpo_udp.h289
-rw-r--r--hicn-plugin/src/faces/udp/face_udp.c456
-rw-r--r--hicn-plugin/src/faces/udp/face_udp.h356
-rw-r--r--hicn-plugin/src/faces/udp/face_udp_cli.c164
-rw-r--r--hicn-plugin/src/faces/udp/face_udp_node.c1030
-rw-r--r--hicn-plugin/src/faces/udp/iface_udp_node.c987
-rw-r--r--hicn-plugin/src/faces/udp/iface_udp_node.h36
27 files changed, 1217 insertions, 5513 deletions
diff --git a/hicn-plugin/src/faces/app/address_mgr.c b/hicn-plugin/src/faces/app/address_mgr.c
index 1674379c4..2d5894ab8 100644
--- a/hicn-plugin/src/faces/app/address_mgr.c
+++ b/hicn-plugin/src/faces/app/address_mgr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -36,7 +36,6 @@
#include "../../infra.h"
#include "../../error.h"
#include "../face.h"
-#include "../ip/face_ip.h"
#include "../../strategy_dpo_ctx.h"
#include "../../route.h"
@@ -134,26 +133,25 @@ get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr)
fib_pfx.fp_proto = FIB_PROTOCOL_IP6;
fib_pfx.fp_len = ADDR_MGR_IP6_LEN;
+
+ fib_index = fib_table_find (fib_pfx.fp_proto, 0);
+
/* At this point the face exists in the face table */
do
{
/* Check if the route already exist in the fib */
fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, appif_addr->as_u8);
- fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
- HICN_FIB_TABLE,
- FIB_SOURCE_PRIORITY_HI);
+
fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx);
- fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI);
+ //fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI);
if (fib_entry_index != FIB_NODE_INDEX_INVALID)
{
fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8);
- fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
- HICN_FIB_TABLE,
- FIB_SOURCE_PRIORITY_HI);
+
fib_entry_index =
fib_table_lookup_exact_match (fib_index, &fib_pfx);
- fib_table_unlock (fib_index, fib_pfx.fp_proto,
- FIB_SOURCE_PRIORITY_HI);
+ // fib_table_unlock (fib_index, fib_pfx.fp_proto,
+ // FIB_SOURCE_PRIORITY_HI);
}
if (fib_entry_index != FIB_NODE_INDEX_INVALID)
{
diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c
index 1e8eb6a5b..1aa27adc7 100644
--- a/hicn-plugin/src/faces/app/face_app_cli.c
+++ b/hicn-plugin/src/faces/app/face_app_cli.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -18,8 +18,7 @@
#include <vlib/vlib.h>
#include <vnet/ip/ip6_packet.h>
-#include "../ip/face_ip.h"
-#include "../ip/dpo_ip.h"
+//#include "../face_dpo.h"
#include "../face.h"
#include "face_prod.h"
#include "face_cons.h"
@@ -164,7 +163,7 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
{
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id1);
- if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
+ if (face->flags & HICN_FACE_FLAGS_APPFACE_CONS)
rv = hicn_face_cons_del (face_id1);
else
rv = hicn_face_prod_del (face_id1);
diff --git a/hicn-plugin/src/faces/app/face_cons.c b/hicn-plugin/src/faces/app/face_cons.c
index e51201c21..3cd3da78c 100644
--- a/hicn-plugin/src/faces/app/face_cons.c
+++ b/hicn-plugin/src/faces/app/face_cons.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -57,10 +57,10 @@ 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_ip_add (&if_ip, &nh_addr, swif, faceid1);
+ hicn_iface_add (&nh_addr, swif, faceid1, DPO_PROTO_IP4);
hicn_face_t *face = hicn_dpoi_get_from_idx (*faceid1);
- face->shared.flags |= HICN_FACE_FLAGS_APPFACE_CONS;
+ face->flags |= HICN_FACE_FLAGS_APPFACE_CONS;
get_two_ip6_addresses (&(if_ip.ip6), nh_addr6);
ip6_add_del_interface_address (vm,
@@ -68,10 +68,10 @@ 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_ip_add (&if_ip, (ip46_address_t *) nh_addr6, swif, faceid2);
+ hicn_iface_add ((ip46_address_t *) nh_addr6, swif, faceid2, DPO_PROTO_IP6);
face = hicn_dpoi_get_from_idx (*faceid2);
- face->shared.flags |= HICN_FACE_FLAGS_APPFACE_CONS;
+ face->flags |= HICN_FACE_FLAGS_APPFACE_CONS;
return HICN_ERROR_NONE;
}
@@ -84,9 +84,9 @@ hicn_face_cons_del (hicn_face_id_t face_id)
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
+ if (face->flags & HICN_FACE_FLAGS_APPFACE_CONS)
{
- return hicn_face_ip_del (face_id);
+ return hicn_face_del (face_id);
}
else
{
diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c
index ae59719ce..5aed8c11e 100644
--- a/hicn-plugin/src/faces/app/face_prod.c
+++ b/hicn-plugin/src/faces/app/face_prod.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -98,10 +98,11 @@ hicn_app_state_del (u32 swif)
);
/* *INDENT-ON* */
- prefix = &(face_state_vec[swif].prefix);
if (!found)
return HICN_ERROR_APPFACE_NOT_FOUND;
+ prefix = &(face_state_vec[swif].prefix);
+
int ret = HICN_ERROR_NONE;
if (ip46_address_is_ip4 (&prefix->fp_addr))
{
@@ -132,7 +133,7 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
hicn_main_t *hm = &hicn_main;
ip46_address_t local_app_ip;
- ip46_address_t remote_app_ip;
+ CLIB_UNUSED(ip46_address_t remote_app_ip);
u32 if_flags = 0;
if (!hm->is_enabled)
@@ -164,24 +165,12 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
* Check if a producer face is already existing for the same prefix
* and sw_if
*/
- if (ip46_address_is_ip4 (&prefix->fp_addr))
- {
- face =
- hicn_face_ip4_get (&(prefix->fp_addr.ip4), sw_if,
- &hicn_face_ip_remote_hashtb);
- }
- else
- {
- face =
- hicn_face_ip6_get (&(prefix->fp_addr.ip6), sw_if,
- &hicn_face_ip_remote_hashtb);
- if (face != NULL)
- return HICN_ERROR_FACE_ALREADY_CREATED;
- }
+ face = hicn_face_get (&(prefix->fp_addr), sw_if,
+ &hicn_face_hashtb);
if (face != NULL)
{
- if (!(face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ if (!(face->flags & HICN_FACE_FLAGS_DELETED))
return HICN_ERROR_FACE_ALREADY_CREATED;
/*
@@ -189,19 +178,17 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
* producer's prefix.
*/
/* It should never happens, this is a safety check. */
- if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
+ if (face->flags & HICN_FACE_FLAGS_APPFACE_CONS)
return HICN_ERROR_FACE_ALREADY_CREATED;
/* If the face exists but is marked as deleted, undelete it */
- if (face->shared.flags & HICN_FACE_FLAGS_DELETED)
+ if (face->flags & HICN_FACE_FLAGS_DELETED)
{
/*
* remove the deleted flag and retrieve the face
* local addr
*/
- face->shared.flags &= HICN_FACE_FLAGS_DELETED;
- hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
- local_app_ip = prod_face->ip_face.local_addr;
+ face->flags &= HICN_FACE_FLAGS_DELETED;
}
}
else
@@ -221,10 +208,6 @@ 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);
-
- ret =
- hicn_face_ip_add (&local_app_ip, &remote_app_ip, sw_if, faceid,
- HICN_FACE_FLAGS_APPFACE_PROD);
}
else
{
@@ -242,41 +225,29 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
0 /* is_del */ );
local_app_ip = to_ip46 ( /* isv6 */ 1, local_app_ip6.as_u8);
remote_app_ip = to_ip46 ( /* isv6 */ 1, remote_app_ip6.as_u8);
-
- ret =
- hicn_face_ip_add (&local_app_ip, &remote_app_ip, sw_if, faceid,
- HICN_FACE_FLAGS_APPFACE_PROD);
}
-
- face = hicn_dpoi_get_from_idx (*faceid);
-
- face->shared.flags |= HICN_FACE_FLAGS_APPFACE_PROD;
-
- hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
-
- /*
- * For the moment we keep them here although it would be good
- * to create a different face for appface
- */
- prod_face->policy_vft.hicn_cs_insert = hicn_cs_lru.hicn_cs_insert;
- prod_face->policy_vft.hicn_cs_update = hicn_cs_lru.hicn_cs_update;
- prod_face->policy_vft.hicn_cs_dequeue = hicn_cs_lru.hicn_cs_dequeue;
- prod_face->policy_vft.hicn_cs_delete_get =
- hicn_cs_lru.hicn_cs_delete_get;
- prod_face->policy_vft.hicn_cs_trim = hicn_cs_lru.hicn_cs_trim;
- prod_face->policy_vft.hicn_cs_flush = hicn_cs_lru.hicn_cs_flush;
-
}
- if (ret == HICN_ERROR_NONE
- && hicn_face_prod_set_lru_max (*faceid, cs_reserved) == HICN_ERROR_NONE)
+ if (ret == HICN_ERROR_NONE)
+ // && hicn_face_prod_set_lru_max (*faceid, cs_reserved) == HICN_ERROR_NONE)
{
+ fib_route_path_t rpath = {0};
+ fib_route_path_t * rpaths = NULL;
+
if (ip46_address_is_ip4(&(prefix->fp_addr)))
{
ip4_address_t mask;
ip4_preflen_to_mask (prefix->fp_len, &mask);
prefix->fp_addr.ip4.as_u32 = prefix->fp_addr.ip4.as_u32 & mask.as_u32;
prefix->fp_proto = FIB_PROTOCOL_IP4;
+
+ rpath.frp_weight = 1;
+ rpath.frp_sw_if_index = ~0;
+ rpath.frp_addr.ip4.as_u32 = remote_app_ip.ip4.as_u32;
+ rpath.frp_sw_if_index = sw_if;
+ rpath.frp_proto = DPO_PROTO_IP4;
+
+ vec_add1 (rpaths, rpath);
}
else
{
@@ -287,21 +258,40 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
prefix->fp_addr.ip6.as_u64[1] =
prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
prefix->fp_proto = FIB_PROTOCOL_IP6;
+
+ rpath.frp_weight = 1;
+ rpath.frp_sw_if_index = ~0;
+ rpath.frp_addr.ip6.as_u64[0] = remote_app_ip.ip6.as_u64[0];
+ rpath.frp_addr.ip6.as_u64[1] = remote_app_ip.ip6.as_u64[1];
+ rpath.frp_sw_if_index = sw_if;
+ rpath.frp_proto = DPO_PROTO_IP6;
+
+ vec_add1 (rpaths, rpath);
}
+ u32 fib_index = fib_table_find (prefix->fp_proto, 0);
+ fib_table_entry_path_add2 (fib_index,
+ prefix,
+ FIB_SOURCE_CLI,
+ FIB_ENTRY_FLAG_NONE, rpaths);
+
hicn_app_state_create (sw_if, prefix);
- ret = hicn_route_add (faceid, 1, prefix);
}
+ face = hicn_face_get(&local_app_ip, sw_if, &hicn_face_hashtb);//HICN_FACE_FLAGS_APPFACE_PROD);
+
+ *faceid = hicn_dpoi_get_index (face);
+
+ face->flags |= HICN_FACE_FLAGS_APPFACE_PROD;
+
+ hicn_face_unlock_with_id(*faceid);
+
*prod_addr = local_app_ip;
/* Cleanup in case of something went wrong. */
if (ret)
{
hicn_app_state_del (sw_if);
-
- if (*faceid != HICN_FACE_NULL)
- hicn_face_ip_del (*faceid);
}
return ret;
}
@@ -314,88 +304,32 @@ hicn_face_prod_del (hicn_face_id_t face_id)
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD)
+ if (face->flags & HICN_FACE_FLAGS_APPFACE_PROD)
{
- hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
- /* Free the CS reserved for the face */
- hicn_main.pitcs.pcs_app_count -= prod_face->policy.max;
- prod_face->policy.max = 0;
-
/* Remove the face from the fib */
- hicn_route_del_nhop (&(face_state_vec[face->shared.sw_if].prefix),
- face_id);
+ //hicn_route_del_nhop (&(face_state_vec[face->sw_if].prefix),
+ // face_id);
- /*
- * Delete the content in the CS before deleting the face.
- * Mandatory to prevent hitting the CS and not having the lru list
- * due to a early deletion of the face.
- */
- vlib_main_t *vm = vlib_get_main ();
- prod_face->policy_vft.hicn_cs_flush (vm, &(hicn_main.pitcs),
- &(prod_face->policy));
-
- int ret = hicn_face_ip_del (face_id);
- return ret ==
- HICN_ERROR_NONE ? hicn_app_state_del (face->shared.sw_if) : ret;
+ //int ret = hicn_face_del (face_id);
+ return hicn_app_state_del (face->sw_if);
+ //ret == HICN_ERROR_NONE ? hicn_app_state_del (face->sw_if) : ret;
}
else
{
return HICN_ERROR_APPFACE_NOT_FOUND;
}
-}
-int
-hicn_face_prod_set_lru_max (hicn_face_id_t face_id, u32 * requested_size)
-{
- int ret = HICN_ERROR_NONE;
- vlib_main_t *vm = vlib_get_main ();
- hicn_face_t *face;
- hicn_face_prod_t *face_prod;
-
- if (!hicn_infra_fwdr_initialized)
- {
- ret = HICN_ERROR_FWD_NOT_ENABLED;
- vlib_cli_output (vm, "hicn: %s\n", get_error_string (ret));
- return ret;
- }
- face = hicn_dpoi_get_from_idx (face_id);
- face_prod = (hicn_face_prod_t *) face->data;
-
- if (face == NULL)
- return HICN_ERROR_FACE_NOT_FOUND;
-
- if (*requested_size > HICN_PARAM_FACE_MAX_CS_RESERVED)
- *requested_size = HICN_PARAM_FACE_MAX_CS_RESERVED;
-
- uint32_t available =
- hicn_main.pitcs.pcs_app_max - hicn_main.pitcs.pcs_app_count;
-
- if (*requested_size > available)
- *requested_size = available;
-
- face_prod->policy.max = *requested_size;
- face_prod->policy.count = 0;
- face_prod->policy.head = face_prod->policy.tail = 0;
-
- hicn_main.pitcs.pcs_app_count += *requested_size;
-
- return ret;
+ return HICN_ERROR_NONE;
}
u8 *
format_hicn_face_prod (u8 * s, va_list * args)
{
- index_t index = va_arg (*args, index_t);
+ CLIB_UNUSED (index_t index) = va_arg (*args, index_t);
CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
- hicn_face_t *face;
- hicn_face_prod_t *prod_face;
-
- face = hicn_dpoi_get_from_idx (index);
- prod_face = (hicn_face_prod_t *) face->data;
s =
- format (s, " (producer face: CS size %d, data cached %d)",
- prod_face->policy.max, prod_face->policy.count);
+ format (s, " (producer)");
return s;
}
diff --git a/hicn-plugin/src/faces/app/face_prod.h b/hicn-plugin/src/faces/app/face_prod.h
index 33e2a4199..4cb2e3fbf 100644
--- a/hicn-plugin/src/faces/app/face_prod.h
+++ b/hicn-plugin/src/faces/app/face_prod.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -17,7 +17,7 @@
#define _FACE_PRODUCER_H_
#include "../../cache_policies/cs_policy.h"
-#include "../ip/face_ip.h"
+#include "../face.h"
/**
* @file
@@ -56,15 +56,6 @@ extern hicn_face_prod_state_t *face_state_vec;
#define DEFAULT_PROBING_PORT 3784
-typedef struct __attribute__ ((packed)) hicn_face_prod_t_
-{
- hicn_face_ip_t ip_face;
-
- hicn_cs_policy_t policy;
- hicn_cs_policy_vft_t policy_vft;
-
-} hicn_face_prod_t;
-
/**
* @brief Add a new producer application face
*
diff --git a/hicn-plugin/src/faces/app/face_prod_node.c b/hicn-plugin/src/faces/app/face_prod_node.c
index 0ef25fe94..80c3e124c 100644
--- a/hicn-plugin/src/faces/app/face_prod_node.c
+++ b/hicn-plugin/src/faces/app/face_prod_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -300,8 +300,8 @@ VLIB_REGISTER_NODE(hicn_face_prod_input_node) =
.n_next_nodes = HICN_FACE_PROD_N_NEXT,
.next_nodes =
{
- [HICN_FACE_PROD_NEXT_DATA_IP4] = "hicn-face-ip4-input",
- [HICN_FACE_PROD_NEXT_DATA_IP6] = "hicn-face-ip6-input",
+ [HICN_FACE_PROD_NEXT_DATA_IP4] = "hicn4-face-input",
+ [HICN_FACE_PROD_NEXT_DATA_IP6] = "hicn6-face-input",
[HICN_FACE_PROD_NEXT_ERROR_DROP] = "error-drop",
},
};
diff --git a/hicn-plugin/src/faces/ip/dpo_ip.h b/hicn-plugin/src/faces/dpo_face.h
index c893c8be4..736c5c926 100644
--- a/hicn-plugin/src/faces/ip/dpo_ip.h
+++ b/hicn-plugin/src/faces/dpo_face.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -13,19 +13,20 @@
* limitations under the License.
*/
-#ifndef __HICN_DPO_IP_H__
-#define __HICN_DPO_IP_H__
+#ifndef __HICN_DPO_H__
+#define __HICN_DPO_H__
#include <vnet/vnet.h>
#include <vnet/ip/ip4_packet.h>
+#include <vnet/adj/adj_midchain.h>
-#include "face_ip.h"
-#include "../face.h"
+#include "face.h"
+#include "../error.h"
/**
* @brief Initialize the internal structures of the dpo ip face module.
*/
-void hicn_dpo_ip_module_init (void);
+//void hicn_dpo_ip_module_init (void);
/**
@@ -34,23 +35,21 @@ void hicn_dpo_ip_module_init (void);
* @param vec: Result of the lookup. If no face exists for the local address vec = NULL
* @param hicnb_flags: Flags that indicate whether the face is an application
* face or not
- * @param local_addr: Ip v4 local address of the face
+ * @param local_addr: Ip v4 nat address of the face
* @param sw_if: software interface id of the face
*
* @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
*/
always_inline int
-hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
- u32 * in_faces_vec_id,
- u8 * hicnb_flags,
- const ip4_address_t * local_addr, u32 sw_if)
+hicn_dpo_face_ip4_lock (hicn_face_id_t * face_id,
+ u32 * in_faces_vec_id,
+ u8 * hicnb_flags,
+ const ip4_address_t * nat_addr)
{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
- hicn_face_ip_input_faces_t *in_faces_vec =
- hicn_face_ip4_get_vec (local_addr, sw_if, &hicn_face_ip_local_hashtb);
+ ip46_address_t ip_address = {0};
+ ip46_address_set_ip4(&ip_address, nat_addr);
+ hicn_face_input_faces_t *in_faces_vec =
+ hicn_face_get_vec (&ip_address, &hicn_face_vec_hashtb);
if (PREDICT_FALSE (in_faces_vec == NULL))
return HICN_ERROR_FACE_NOT_FOUND;
@@ -60,12 +59,10 @@ hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
*hicnb_flags |=
- (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
+ (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
HICN_FACE_FLAGS_APPFACE_PROD_BIT;
- dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, in_faces_vec->face_id);
- dpo->dpoi_next_node = ~0;
- dpo_unlock (dpo);
+ *face_id = in_faces_vec->face_id;
return HICN_ERROR_NONE;
}
@@ -77,23 +74,19 @@ hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
* @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
* @param hicnb_flags: Flags that indicate whether the face is an application
* face or not
- * @param local_addr: Ip v6 local address of the face
+ * @param nat_addr: Ip v6 nat address of the face
* @param sw_if: software interface id of the face
*
* @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
*/
always_inline int
-hicn_dpo_ip6_lock_from_local (dpo_id_t * dpo,
- u32 * in_faces_vec_id,
- u8 * hicnb_flags,
- const ip6_address_t * local_addr, u32 sw_if)
+hicn_dpo_face_ip6_lock (hicn_face_id_t * face_id,
+ u32 * in_faces_vec_id,
+ u8 * hicnb_flags,
+ const ip6_address_t * nat_addr)
{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
- hicn_face_ip_input_faces_t *in_faces_vec =
- hicn_face_ip6_get_vec (local_addr, sw_if, &hicn_face_ip_local_hashtb);
+ hicn_face_input_faces_t *in_faces_vec =
+ hicn_face_get_vec ((ip46_address_t *)nat_addr, &hicn_face_vec_hashtb);
if (PREDICT_FALSE (in_faces_vec == NULL))
return HICN_ERROR_FACE_NOT_FOUND;
@@ -103,16 +96,29 @@ hicn_dpo_ip6_lock_from_local (dpo_id_t * dpo,
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
*hicnb_flags |=
- (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
+ (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
HICN_FACE_FLAGS_APPFACE_PROD_BIT;
- dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP6, in_faces_vec->face_id);
- dpo->dpoi_next_node = ~0;
- dpo_unlock (dpo);
+ *face_id = in_faces_vec->face_id;
return HICN_ERROR_NONE;
}
+/**
+ * @brief Call back to get the adj of the tunnel
+ */
+static adj_walk_rc_t
+hicn4_iface_adj_walk_cb (adj_index_t ai,
+ void *ctx)
+{
+
+ hicn_face_t *face = (hicn_face_t *)ctx;
+
+ dpo_set(&face->dpo, DPO_ADJACENCY_MIDCHAIN, DPO_PROTO_IP4, ai);
+ adj_nbr_midchain_stack(ai, &face->dpo);
+
+ return (ADJ_WALK_RC_CONTINUE);
+}
/**
* @brief Retrieve, or create if it doesn't exist, a face from the ip6 local
@@ -121,105 +127,152 @@ hicn_dpo_ip6_lock_from_local (dpo_id_t * dpo,
* @param dpo: Result of the lookup
* @param hicnb_flags: Flags that indicate whether the face is an application
* face or not
- * @param local_addr: Ip v4 local address of the face
- * @param remote_addr: Ip v4 remote address of the face
+ * @param nat_addr: Ip v4 remote address of the face
* @param sw_if: software interface id of the face
* @param node_index: vlib edge index to use in the packet processing
*/
always_inline void
-hicn_dpo_ip4_add_and_lock_from_remote (dpo_id_t * dpo,
- u8 * hicnb_flags,
- const ip4_address_t * local_addr,
- const ip4_address_t * remote_addr,
- u32 sw_if, u32 node_index)
+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)
{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
/*All (complete) faces are indexed by remote addess as well */
+
+ ip46_address_t ip_address = {0};
+ ip46_address_set_ip4(&ip_address, nat_addr);
+
+ /* if the face exists, it adds a lock */
hicn_face_t *face =
- hicn_face_ip4_get (remote_addr, sw_if, &hicn_face_ip_remote_hashtb);
+ hicn_face_get (&ip_address, sw_if, &hicn_face_hashtb);
if (face == NULL)
{
- hicn_face_id_t dpoi_index;
- ip46_address_t local_addr46 = to_ip46 (0, (u8 *) local_addr);
- ip46_address_t remote_addr46 = to_ip46 (0, (u8 *) remote_addr);
- hicn_iface_ip_add (&local_addr46, &remote_addr46, sw_if, &dpoi_index);
+ hicn_face_id_t idx;
+ hicn_iface_add (&ip_address, sw_if, &idx, DPO_PROTO_IP4);
+
+ face = hicn_dpoi_get_from_idx(idx);
+
+ 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;
- dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
-
+ *index = idx;
return;
}
+ else
+ {
+ /* unlock the face. We don't take a lock on each interest we receive */
+ hicn_face_id_t face_id = hicn_dpoi_get_index(face);
+ hicn_face_unlock_with_id(face_id);
+ }
/* Code replicated on purpose */
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
*hicnb_flags |=
- (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
+ (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
HICN_FACE_FLAGS_APPFACE_PROD_BIT;
- hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
- dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
+ *index = hicn_dpoi_get_index (face);
}
/**
+ * @brief Call back to get the adj of the tunnel
+ */
+static adj_walk_rc_t
+hicn6_iface_adj_walk_cb (adj_index_t ai,
+ void *ctx)
+{
+
+ hicn_face_t *face = (hicn_face_t *)ctx;
+
+ ip_adjacency_t *adj = adj_get(ai);
+ if ((adj->lookup_next_index == IP_LOOKUP_NEXT_MIDCHAIN) ||
+ (adj->lookup_next_index == IP_LOOKUP_NEXT_MCAST_MIDCHAIN))
+ {
+ dpo_set(&face->dpo, DPO_ADJACENCY_MIDCHAIN, adj->ia_nh_proto, ai);
+ adj_nbr_midchain_stack(ai, &face->dpo);
+ }
+
+ return (ADJ_WALK_RC_CONTINUE);
+}
+
+
+/**
* @brief Retrieve, or create if it doesn't exist, a face from the ip6 local
* address and returns its dpo. This method adds a lock on the face state.
*
* @param dpo: Result of the lookup
* @param hicnb_flags: Flags that indicate whether the face is an application
* face or not
- * @param local_addr: Ip v6 local address of the face
- * @param remote_addr: Ip v6 remote address of the face
+ * @param nat_addr: Ip v6 remote address of the face
* @param sw_if: software interface id of the face
* @param node_index: vlib edge index to use in the packet processing
*/
always_inline void
-hicn_dpo_ip6_add_and_lock_from_remote (dpo_id_t * dpo,
- u8 * hicnb_flags,
- const ip6_address_t * local_addr,
- const ip6_address_t * remote_addr,
- u32 sw_if, u32 node_index)
+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)
{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
/*All (complete) faces are indexed by remote addess as well */
+ /* if the face exists, it adds a lock */
hicn_face_t *face =
- hicn_face_ip6_get (remote_addr, sw_if, &hicn_face_ip_remote_hashtb);
+ hicn_face_get ((ip46_address_t *)nat_addr, sw_if, &hicn_face_hashtb);
if (face == NULL)
{
- hicn_face_id_t dpoi_index;
- hicn_iface_ip_add ((ip46_address_t *) local_addr,
- (ip46_address_t *) remote_addr, sw_if, &dpoi_index);
+ hicn_face_id_t idx;
+ hicn_iface_add ((ip46_address_t *) nat_addr, sw_if, &idx, DPO_PROTO_IP6);
+
+ 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_next_node = node_index;
+
+ //if (ip46_address_is_zero((ip46_address_t *)nat_addr))
+ // {
+ adj_nbr_walk(face->sw_if,
+ FIB_PROTOCOL_IP6,
+ hicn6_iface_adj_walk_cb,
+ face);
+ // }
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
- dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
+ *index = idx;
return;
}
+ else
+ {
+ /* unlock the face. We don't take a lock on each interest we receive */
+ hicn_face_id_t face_id = hicn_dpoi_get_index(face);
+ hicn_face_unlock_with_id(face_id);
+ }
+
/* Code replicated on purpose */
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
*hicnb_flags |=
- (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
+ (face->flags & HICN_FACE_FLAGS_APPFACE_PROD) >>
HICN_FACE_FLAGS_APPFACE_PROD_BIT;
- index_t dpoi_index = hicn_dpoi_get_index (face);
- dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP6, dpoi_index);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
+ *index = hicn_dpoi_get_index (face);
}
@@ -267,16 +320,6 @@ hicn_dpo_ip6_add_and_lock_from_remote (dpo_id_t * dpo,
/* u32 node_index, */
/* hicn_face_flags_t flags, hicn_face_id_t * face_id); */
-/**
- * @brief Create a dpo from an ip face
- *
- * @param face Face from which to create the dpo
- * @param dpoi_next_node Edge index that connects a node to the iface or face nodes
- * @return the dpo
- */
-void hicn_dpo_ip_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
- u16 dpoi_next_node);
-
#endif // __HICN_DPO_IP_H__
/*
diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c
index f2dcdd151..f8ea61819 100644
--- a/hicn-plugin/src/faces/face.c
+++ b/hicn-plugin/src/faces/face.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -14,14 +14,11 @@
*/
#include "face.h"
-#include "ip/face_ip.h"
-#include "ip/face_ip_node.h"
-#include "ip/iface_ip_node.h"
-#include "ip/dpo_ip.h"
-#include "udp/face_udp.h"
-#include "udp/face_udp_node.h"
-#include "udp/iface_udp_node.h"
-#include "udp/dpo_udp.h"
+#include "../hicn.h"
+#include "../params.h"
+#include "../error.h"
+/* #include "../mapme.h" */
+/* #include "../mapme_eventmgr.h" */
dpo_id_t *face_dpo_vec;
hicn_face_vft_t *face_vft_vec;
@@ -33,6 +30,8 @@ dpo_type_t first_type = DPO_FIRST;
vlib_combined_counter_main_t *counters;
+dpo_type_t hicn_face_type;
+
const char *HICN_FACE_CTRX_STRING[] = {
#define _(a,b,c) c,
foreach_hicn_face_counter
@@ -56,24 +55,58 @@ face_show (u8 * s, int face_id, u32 indent)
}
-void
-register_face_type (hicn_face_type_t face_type, hicn_face_vft_t * vft,
- char *name)
+/* void */
+/* register_face_type (hicn_face_type_t face_type, hicn_face_vft_t * vft, */
+/* char *name) */
+/* { */
+/* if (first_type == DPO_FIRST) */
+/* first_type = face_type; */
+
+/* int idx = face_type - first_type; */
+/* ASSERT (idx >= 0); */
+/* vec_validate (face_vft_vec, idx); */
+/* vec_validate (face_type_names_vec, idx); */
+
+/* /\* Copy the null char as well *\/ */
+/* char *name_str = (char *) malloc ((strlen (name) + 1) * sizeof (char)); */
+/* strcpy (name_str, name); */
+/* face_vft_vec[idx] = *vft; */
+/* face_type_names_vec[idx] = name_str; */
+/* } */
+
+mhash_t hicn_face_vec_hashtb;
+mhash_t hicn_face_hashtb;
+
+hicn_face_vec_t * hicn_vec_pool;
+
+const static char *const hicn_face6_nodes[] =
+ {
+ "hicn6-face-output", // this is the name you give your node in VLIB_REGISTER_NODE
+ "hicn6-iface-output", // this is the name you give your node in VLIB_REGISTER_NODE
+ NULL,
+};
+
+const static char *const hicn_face4_nodes[] =
+ {
+ "hicn4-face-output", // this is the name you give your node in VLIB_REGISTER_NODE
+ "hicn4-iface-output", // this is the name you give your node in VLIB_REGISTER_NODE
+ NULL,
+};
+
+
+const static char *const *const hicn_ip_nodes[DPO_PROTO_NUM] =
{
- if (first_type == DPO_FIRST)
- first_type = face_type;
-
- int idx = face_type - first_type;
- ASSERT (idx >= 0);
- vec_validate (face_vft_vec, idx);
- vec_validate (face_type_names_vec, idx);
-
- /* Copy the null char as well */
- char *name_str = (char *) malloc ((strlen (name) + 1) * sizeof (char));
- strcpy (name_str, name);
- face_vft_vec[idx] = *vft;
- face_type_names_vec[idx] = name_str;
-}
+ [DPO_PROTO_IP4] = hicn_face4_nodes,
+ [DPO_PROTO_IP6] = hicn_face6_nodes
+};
+
+const static dpo_vft_t hicn_face_ip_vft =
+{
+ .dv_lock = hicn_face_lock,
+ .dv_unlock = hicn_face_unlock,
+ .dv_format = format_hicn_face,
+};
+
// Make this more flexible for future types face
void
@@ -81,15 +114,77 @@ hicn_face_module_init (vlib_main_t * vm)
{
pool_validate (hicn_dpoi_face_pool);
pool_alloc (hicn_dpoi_face_pool, 1024);
- hicn_face_ip_init (vm);
- hicn_iface_ip_init (vm);
- hicn_face_udp_init (vm);
- hicn_iface_udp_init (vm);
counters =
vec_new (vlib_combined_counter_main_t,
HICN_PARAM_FACES_MAX * HICN_N_COUNTER);
+
+ mhash_init (&hicn_face_vec_hashtb,
+ sizeof (hicn_face_input_faces_t) /* value */ ,
+ sizeof (hicn_face_key_t) /* key */ );
+ mhash_init (&hicn_face_hashtb,
+ sizeof (hicn_face_id_t) /* value */ ,
+ sizeof (hicn_face_key_t) /* key */ );
+
+ pool_alloc(hicn_vec_pool, 100);
+
+ /*
+ * How much useful is the following registration?
+ * So far it seems that we need it only for setting the dpo_type.
+ */
+ hicn_face_type =
+ dpo_register_new_type (&hicn_face_ip_vft, hicn_ip_nodes);
+}
+
+u8 *
+format_hicn_face (u8 * s, va_list * args)
+{
+ index_t index = va_arg (*args, index_t);
+ u32 indent = va_arg (*args, u32);
+ hicn_face_t *face;
+
+ face = hicn_dpoi_get_from_idx (index);
+
+ if (face->flags & HICN_FACE_FLAGS_FACE)
+ {
+ hicn_face_id_t face_id = hicn_dpoi_get_index (face);
+ s = format (s, "%U Face %d: ", format_white_space, indent, face_id);
+ s = format (s, "nat address %U locks %u, path_label %u",
+ format_ip46_address, &face->nat_addr, IP46_TYPE_ANY,
+ face->locks, face->pl_id);
+
+ if ((face->flags & HICN_FACE_FLAGS_APPFACE_PROD))
+ s = format (s, " (producer)");
+ else if ((face->flags & HICN_FACE_FLAGS_APPFACE_CONS))
+ s = format (s, " (consumer)");
+
+ if ((face->flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+
+ s = format (s, "\n%U%U",
+ format_white_space, indent + 2,
+ format_dpo_id, &face->dpo, indent + 3);
+ }
+ else
+ {
+ hicn_face_id_t face_id = hicn_dpoi_get_index (face);
+ s = format (s, "%U iFace %d: ", format_white_space, indent, face_id);
+ s = format (s, "nat address %U locks %u, path_label %u",
+ format_ip46_address, &face->nat_addr, IP46_TYPE_ANY,
+ face->locks, face->pl_id);
+
+ if ((face->flags & HICN_FACE_FLAGS_APPFACE_PROD))
+ s = format (s, " (producer)");
+ else if ((face->flags & HICN_FACE_FLAGS_APPFACE_CONS))
+ s = format (s, " (consumer)");
+
+ if ((face->flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+
+ return s;
}
+
u8 *
format_hicn_face_all (u8 * s, int n, ...)
{
@@ -104,46 +199,238 @@ format_hicn_face_all (u8 * s, int n, ...)
/* *INDENT-OFF* */
pool_foreach ( face, hicn_dpoi_face_pool,
{
- hicn_face_vft_t * vft = hicn_face_get_vft(face->shared.face_type);
- hicn_face_id_t face_id = hicn_dpoi_get_index(face);
- s = format(s, "%U\n", vft->format_face, face_id, indent);
+ s = format(s, "%U\n", format_hicn_face, hicn_dpoi_get_index(face), indent);
});
/* *INDENT-ON* */
return s;
}
-hicn_face_vft_t *
-hicn_face_get_vft (hicn_face_type_t face_type)
-{
- int idx = face_type - first_type;
- if (idx >= 0)
- return &face_vft_vec[idx];
- else
- return NULL;
+/* hicn_face_vft_t * */
+/* hicn_face_get_vft (hicn_face_type_t face_type) */
+/* { */
+/* int idx = face_type - first_type; */
+/* if (idx >= 0) */
+/* return &face_vft_vec[idx]; */
+/* else */
+/* return NULL; */
-}
+/* } */
+
+/* FACE IP CODE */
int
hicn_face_del (hicn_face_id_t face_id)
{
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+ hicn_face_key_t key;
+ hicn_face_key_t old_key;
+ hicn_face_key_t old_key2;
+
+ hicn_face_get_key (&(face->nat_addr), face->sw_if, &(face->dpo),
+ &key);
+ hicn_face_input_faces_t *in_faces_vec =
+ hicn_face_get_vec (&(face->nat_addr),
+ &hicn_face_vec_hashtb);
+ if (in_faces_vec != NULL)
+ {
+ hicn_face_vec_t *vec =
+ pool_elt_at_index (hicn_vec_pool, in_faces_vec->vec_id);
+ u32 index_face = vec_search (*vec, face_id);
+ vec_del1 (*vec, index_face);
+
+ if (vec_len (*vec) == 0)
+ {
+ pool_put_index (hicn_vec_pool, in_faces_vec->vec_id);
+ mhash_unset (&hicn_face_vec_hashtb, &key,
+ (uword *) & old_key);
+ vec_free (*vec);
+ }
+ else
+ {
+ /* Check if the face we are deleting is the preferred one. */
+ /* If so, repleace with another. */
+ if (in_faces_vec->face_id == face_id)
+ {
+ in_faces_vec->face_id = (*vec)[0];
+ }
+ }
+
+ mhash_unset (&hicn_face_hashtb, &key,
+ (uword *) & old_key2);
+ }
+
int ret = HICN_ERROR_NONE;
if (hicn_dpoi_idx_is_valid (face_id))
{
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- face->shared.locks--;
- if (face->shared.locks == 0)
+ face->locks--;
+ if (face->locks == 0)
pool_put_index (hicn_dpoi_face_pool, face_id);
else
- face->shared.flags |= HICN_FACE_FLAGS_DELETED;
+ face->flags |= HICN_FACE_FLAGS_DELETED;
}
else
ret = HICN_ERROR_FACE_NOT_FOUND;
+
return ret;
}
+static void
+hicn_iface_to_face(hicn_face_t *face, const dpo_id_t * dpo)
+{
+ dpo_stack(hicn_face_type, dpo->dpoi_proto, &face->dpo, dpo);
+
+ face->flags &= ~HICN_FACE_FLAGS_IFACE;
+ face->flags |= HICN_FACE_FLAGS_FACE;
+}
+
+/*
+ * Utility that adds a new face cache entry. For the moment we assume that
+ * the ip_adjacency has already been set up.
+ */
+int
+hicn_face_add (const dpo_id_t * dpo_nh, ip46_address_t * nat_address,
+ int sw_if, hicn_face_id_t * pfaceid, u8 is_app_prod)
+{
+ // dpo_proto_t dpo_proto;
+
+ hicn_face_flags_t flags = (hicn_face_flags_t) 0;
+ flags |= HICN_FACE_FLAGS_FACE;
+
+ hicn_face_t *face;
+
+ face =
+ hicn_face_get_with_dpo (nat_address, sw_if, dpo_nh,
+ &hicn_face_hashtb);
+
+ if (face != NULL)
+ {
+ *pfaceid = hicn_dpoi_get_index (face);
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+ }
+
+ face =
+ hicn_face_get (nat_address, sw_if,
+ &hicn_face_hashtb);
+
+ dpo_id_t temp_dpo = DPO_INVALID;
+ 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);
+ face = hicn_dpoi_get_from_idx (*pfaceid);
+
+ mhash_set_mem (&hicn_face_hashtb, &key, (uword *) pfaceid,
+ 0);
+
+ hicn_face_get_key (nat_address, sw_if, &temp_dpo, &key);
+ mhash_set_mem (&hicn_face_hashtb, &key, (uword *) pfaceid,
+ 0);
+ }
+ else
+ {
+ /* *We found an iface and we convert it to a face */
+ *pfaceid = hicn_dpoi_get_index (face);
+ mhash_set_mem (&hicn_face_hashtb, &key, (uword *) pfaceid,
+ 0);
+ }
+
+ hicn_iface_to_face(face, dpo_nh);
+
+
+ hicn_face_input_faces_t *in_faces =
+ hicn_face_get_vec (nat_address, &hicn_face_vec_hashtb);
+
+ if (in_faces == NULL)
+ {
+ hicn_face_input_faces_t in_faces_temp;
+ hicn_face_vec_t *vec;
+ pool_get (hicn_vec_pool, vec);
+ *vec = vec_new (hicn_face_vec_t, 0);
+ u32 index = vec - hicn_vec_pool;
+ in_faces_temp.vec_id = index;
+ vec_add1 (*vec, *pfaceid);
+
+
+ // dpo_proto = DPO_PROTO_IP4;
+
+ in_faces_temp.face_id = *pfaceid;
+
+ hicn_face_get_key (nat_address, 0, &temp_dpo, &key);
+
+ mhash_set_mem (&hicn_face_vec_hashtb, &key,
+ (uword *) & in_faces_temp, 0);
+ }
+ else
+ {
+ hicn_face_vec_t *vec =
+ pool_elt_at_index (hicn_vec_pool, in_faces->vec_id);
+
+ /* */
+ if (vec_search (*vec, *pfaceid) != ~0)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ vec_add1 (*vec, *pfaceid);
+
+ hicn_iface_to_face(face, dpo_nh);
+
+ // dpo_proto = DPO_PROTO_IP4;
+
+ hicn_face_get_key (nat_address, 0, &temp_dpo, &key);
+
+ mhash_set_mem (&hicn_face_vec_hashtb, &key, (uword *) in_faces,
+ 0);
+
+ /* If the face is an application producer face, we set it as the preferred incoming face. */
+ /* This is required to handle the CS separation, and the push api in a lightway */
+ if (is_app_prod)
+ {
+ in_faces->face_id = *pfaceid;
+ }
+ }
+
+ /* retx_t *retx = vlib_process_signal_event_data (vlib_get_main (), */
+ /* hicn_mapme_eventmgr_process_node.index, */
+ /* HICN_MAPME_EVENT_FACE_ADD, 1, */
+ /* sizeof (retx_t)); */
+
+ /* /\* *INDENT-OFF* *\/ */
+ /* *retx = (retx_t) */
+ /* { */
+ /* .prefix = 0, */
+ /* .dpo = (dpo_id_t) */
+ /* { */
+ /* .dpoi_type = 0, */
+ /* .dpoi_proto = dpo_proto, */
+ /* .dpoi_next_node = 0, */
+ /* .dpoi_index = *pfaceid, */
+ /* } */
+ /* }; */
+ /* /\* *INDENT-ON* *\/ */
+
+ return HICN_ERROR_NONE;
+}
+
+/* void */
+/* hicn_face_get_dpo (hicn_face_t * face, dpo_id_t * dpo) */
+/* { */
+
+/* hicn_face_ip_t *face_ip = (hicn_face_ip_t *) face->data; */
+/* return hicn_dpo_ip_create_from_face (face, dpo, */
+/* ip46_address_is_ip4 */
+/* (&face_ip->remote_addr) ? */
+/* strategy_face_ip4_vlib_edge : */
+/* strategy_face_ip6_vlib_edge); */
+/* } */
+
+
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h
index b758ece06..1c829d2c2 100644
--- a/hicn-plugin/src/faces/face.h
+++ b/hicn-plugin/src/faces/face.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -18,13 +18,14 @@
#include <vnet/vnet.h>
#include <vlib/vlib.h>
+#include <vnet/ip/ip46_address.h>
#include <vnet/dpo/dpo.h>
#include <vnet/adj/adj_types.h>
-#include "../hicn.h"
+#include <vppinfra/bihash_8_8.h>
typedef u8 hicn_face_flags_t;
typedef index_t hicn_face_id_t;
-typedef dpo_type_t hicn_face_type_t;
+//typedef dpo_type_t hicn_face_type_t;
/**
* @file
@@ -42,9 +43,11 @@ typedef dpo_type_t hicn_face_type_t;
*/
/**
- * @brief Fields shared among all the different types of faces
+ * @brief Structure holding the face state. It containes the fields shared among
+ * all the types of faces as well it leaves some space for storing additional
+ * information specific to each type.
*/
-typedef struct __attribute__ ((packed)) hicn_face_shared_s
+typedef struct __attribute__ ((packed)) hicn_face_s
{
/* Flags to idenfity if the face is incomplete (iface), complete (face) */
/* And a network or application face (1B) */
@@ -59,38 +62,28 @@ typedef struct __attribute__ ((packed)) hicn_face_shared_s
/* Number of dpo holding a reference to the dpoi (4B) */
u32 locks;
- /* Adjacency for the neighbor (4B) */
- adj_index_t adj;
+ /* Dpo for the adjacency (8B) */
+ union {
+ dpo_id_t dpo;
+ u64 align_dpo;
+ };
+
+ /* Local address of the interface sw_if */
+ ip46_address_t nat_addr;
/* local interface for the local ip address */
u32 sw_if;
- /* Face id corresponding to the global face pool (4B) */
- union
- {
- hicn_face_type_t face_type;
- u32 int_face_type; //To force the face_type_t to be 4B
- };
-
-} hicn_face_shared_t;
+ /* To align a face to 8 bytes */
+ u32 padding;
-/**
- * @brief Structure holding the face state. It containes the fields shared among
- * all the types of faces as well it leaves some space for storing additional
- * information specific to each type.
- */
-typedef struct __attribute__ ((packed)) hicn_face_s
-{
- /* Additional space to fill with face_type specific information */
- u8 data[2 * CLIB_CACHE_LINE_BYTES - sizeof (hicn_face_shared_t)];
- hicn_face_shared_t shared;
-}
-
-hicn_face_t;
+} hicn_face_t;
/* Pool of faces */
extern hicn_face_t *hicn_dpoi_face_pool;
+//extern dpo_type_t hicn_face_type;
+
/* Flags */
/* A face is complete and it stores all the information. A iface lacks of the
adj index, therefore sending a packet through a iface require a lookup in
@@ -107,6 +100,10 @@ extern hicn_face_t *hicn_dpoi_face_pool;
#define HICN_FACE_FLAGS_APPFACE_PROD_BIT 2
#define HICN_FACE_FLAGS_APPFACE_CONS_BIT 3
+
+#define HICN_BUFFER_FLAGS_DEFAULT 0x00
+#define HICN_BUFFER_FLAGS_FACE_IS_APP 0x01
+
STATIC_ASSERT ((1 << HICN_FACE_FLAGS_APPFACE_PROD_BIT) ==
HICN_FACE_FLAGS_APPFACE_PROD,
"HICN_FACE_FLAGS_APPFACE_PROD_BIT and HICN_FACE_FLAGS_APPFACE_PROD must correspond");
@@ -155,6 +152,8 @@ typedef enum
HICN_N_COUNTER
} hicn_face_counters_t;
+extern mhash_t hicn_face_hashtb;
+
extern const char *HICN_FACE_CTRX_STRING[];
#define get_face_counter_string(ctrxno) (char *)(HICN_FACE_CTRX_STRING[ctrxno])
@@ -192,6 +191,21 @@ hicn_dpoi_get_index (hicn_face_t * face_dpoi)
* @return Pointer to the face
*/
always_inline hicn_face_t *
+hicn_dpoi_get_from_idx_safe (hicn_face_id_t dpoi_index)
+{
+ if (!pool_is_free_index(hicn_dpoi_face_pool, dpoi_index))
+ return (hicn_face_t *) pool_elt_at_index (hicn_dpoi_face_pool, dpoi_index);
+ else
+ return NULL;
+}
+
+/**
+ * @brief Return the face from the face id. Face id must be valid.
+ *
+ * @param dpoi_index Face identifier
+ * @return Pointer to the face
+ */
+always_inline hicn_face_t *
hicn_dpoi_get_from_idx (hicn_face_id_t dpoi_index)
{
return (hicn_face_t *) pool_elt_at_index (hicn_dpoi_face_pool, dpoi_index);
@@ -207,17 +221,18 @@ hicn_dpoi_idx_is_valid (hicn_face_id_t face_id)
&& !pool_is_free_index (hicn_dpoi_face_pool, face_id);
}
+
/**
* @brief Add a lock to the face dpo
*
* @param dpo Pointer to the face dpo
*/
always_inline void
-hicn_face_lock (dpo_id_t * dpo)
+hicn_face_lock_with_id (hicn_face_id_t face_id)
{
hicn_face_t *face;
- face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
- face->shared.locks++;
+ face = hicn_dpoi_get_from_idx (face_id);
+ face->locks++;
}
/**
@@ -226,13 +241,36 @@ hicn_face_lock (dpo_id_t * dpo)
* @param dpo Pointer to the face dpo
*/
always_inline void
-hicn_face_unlock (dpo_id_t * dpo)
+hicn_face_unlock_with_id (hicn_face_id_t face_id)
{
hicn_face_t *face;
- face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
- face->shared.locks--;
+ face = hicn_dpoi_get_from_idx (face_id);
+ face->locks--;
+}
+
+/**
+ * @brief Add a lock to the face dpo
+ *
+ * @param dpo Pointer to the face dpo
+ */
+always_inline void
+hicn_face_lock (dpo_id_t * dpo)
+{
+ hicn_face_lock_with_id(dpo->dpoi_index);
+}
+
+/**
+ * @brief Remove a lock to the face dpo. Deallocate the face id locks == 0
+ *
+ * @param dpo Pointer to the face dpo
+ */
+always_inline void
+hicn_face_unlock (dpo_id_t * dpo)
+{
+ hicn_face_unlock_with_id (dpo->dpoi_index);
}
+
/**
* @brief Init the internal structures of the face module
*
@@ -240,6 +278,9 @@ hicn_face_unlock (dpo_id_t * dpo)
*/
void hicn_face_module_init (vlib_main_t * vm);
+u8 * format_hicn_face (u8 * s, va_list * args);
+
+
/**
* @brief Format all the existing faces
*
@@ -258,22 +299,205 @@ u8 *format_hicn_face_all (u8 * s, int n, ...);
*/
int hicn_face_del (hicn_face_id_t face_id);
+/* FACE IP CODE */
+
+/**
+ * @bried vector of faces used to collect faces having the same local address
+ *
+ */
+typedef hicn_face_id_t *hicn_face_vec_t;
+
+typedef struct hicn_input_faces_s_
+{
+ /* Vector of all possible input faces */
+ u32 vec_id;
+
+ /* Preferred face. If an prod_app face is in the vector it will be the preferred one. */
+ /* It's not possible to have multiple prod_app face in the same vector, they would have */
+ /* the same local address. Every prod_app face is a point-to-point face between the forwarder */
+ /* and the application. */
+ hicn_face_id_t face_id;
+
+} hicn_face_input_faces_t;
+
+/**
+ * Pool containing the vector of possible incoming faces.
+ */
+extern hicn_face_vec_t *hicn_vec_pool;
+
/**
- * @brief Return the virtual function table corresponding to the face type
+ * Hash tables that indexes a face by remote address. For fast lookup when an
+ * interest arrives.
+ */
+extern mhash_t hicn_face_vec_hashtb;
+
+
+/**
+ * Key definition for the mhash table. An ip face is uniquely identified by ip
+ * address and the interface id. The ip address can correspond to the remote ip
+ * address of the next hicn hop, or to the local address of the receiving
+ * interface. The former is used to retrieve the incoming face when an interest
+ * is received, the latter when the arring packet is a data.
+ */
+typedef struct hicn_face_key_s
+{
+ ip46_address_t addr;
+ union {
+ dpo_id_t dpo;
+ u64 align_dpo;
+ };
+ u32 sw_if;
+} hicn_face_key_t;
+
+/**
+ * @brief Create the key object for the mhash. Fill in the key object with the
+ * expected values.
*
- * @param face_type Type of the face
- * @return NULL if the face type does not exist
+ * @param addr nat address of the face
+ * @param sw_if interface associated to the face
+ * @param key Pointer to an allocated hicn_face_ip_key_t object
*/
-hicn_face_vft_t *hicn_face_get_vft (hicn_face_type_t face_type);
+always_inline void
+hicn_face_get_key (const ip46_address_t * addr,
+ u32 sw_if, const dpo_id_t * dpo, hicn_face_key_t * key)
+{
+ key->dpo = *dpo;
+ key->addr = *addr;
+ key->sw_if = sw_if;
+}
/**
- * @brief Register a new face type
+ * @brief Get the dpoi from the nat address. Does not add any lock.
+ *
+ * @param addr Ip v4 address used to create the key for the hash table.
+ * @param sw_if Software interface id used to create the key for the hash table.
+ * @param hashtb Hash table (remote or local) where to perform the lookup.
*
- * @param face_type Type of the face
- * @param vft Virtual Function table for the new face type
+ * @result Pointer to the face.
*/
-void register_face_type (hicn_face_type_t face_type, hicn_face_vft_t * vft,
- char *name);
+always_inline hicn_face_t *
+hicn_face_get (const ip46_address_t * addr, u32 sw_if, mhash_t * hashtb)
+{
+ hicn_face_key_t key;
+
+ dpo_id_t dpo = DPO_INVALID;
+
+ hicn_face_get_key (addr, sw_if, &dpo, &key);
+
+ hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb,
+ &key);
+
+ if ( dpoi_index != NULL)
+ {
+ hicn_face_lock_with_id(*dpoi_index);
+ return hicn_dpoi_get_from_idx (*dpoi_index);
+ }
+
+ return NULL;
+}
+
+always_inline hicn_face_t *
+hicn_face_get_with_dpo (const ip46_address_t * addr, u32 sw_if, const dpo_id_t * dpo, mhash_t * hashtb)
+{
+ hicn_face_key_t key;
+
+ hicn_face_get_key (addr, sw_if, dpo, &key);
+
+ hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb,
+ &key);
+
+ if ( dpoi_index != NULL)
+ {
+ hicn_face_lock_with_id(*dpoi_index);
+ return hicn_dpoi_get_from_idx (*dpoi_index);
+ }
+
+ return NULL;
+}
+
+/**
+ * @brief Get the vector of faces from the ip v4 address. Does not add any lock.
+ *
+ * @param addr Ip v4 address used to create the key for the hash table.
+ * @param sw_if Software interface id used to create the key for the hash table.
+ * @param hashtb Hash table (remote or local) where to perform the lookup.
+ *
+ * @result Pointer to the face.
+ */
+always_inline hicn_face_input_faces_t *
+hicn_face_get_vec (const ip46_address_t * addr,
+ mhash_t * hashtb)
+{
+ hicn_face_key_t key;
+
+ dpo_id_t dpo = DPO_INVALID;
+
+ hicn_face_get_key (addr, 0, &dpo, &key);
+ return (hicn_face_input_faces_t *) mhash_get (hashtb, &key);
+}
+
+/**
+ * @brief Create a new face ip. API for other modules (e.g., routing)
+ *
+ * @param local_addr Local ip v4 or v6 address of the face
+ * @param remote_addr Remote ip v4 or v6 address of the face
+ * @param sw_if interface associated to the face
+ * @param is_app_face Boolean to set the face as an application face
+ * @param pfaceid Pointer to return the face id
+ * @param is_app_prod if HICN_FACE_FLAGS_APPFACE_PROD the face is a local application face, all other values are ignored
+ * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally
+ * reachable ip address, otherwise HICN_ERROR_NONE
+ */
+int hicn_face_add (const dpo_id_t * dpo_nh,
+ ip46_address_t * nat_address,
+ int sw_if,
+ hicn_face_id_t * pfaceid,
+ u8 is_app_prod);
+
+/**
+ * @brief Create a new incomplete face ip. (Meant to be used by the data plane)
+ *
+ * @param local_addr Local ip v4 or v6 address of the face
+ * @param remote_addr Remote ip v4 or 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_add (ip46_address_t * nat_address, int sw_if,
+ hicn_face_id_t * pfaceid, dpo_proto_t proto)
+{
+ hicn_face_t *face;
+ pool_get (hicn_dpoi_face_pool, face);
+
+ clib_memcpy (&(face->nat_addr), nat_address,
+ sizeof (ip46_address_t));
+ face->sw_if = sw_if;
+
+ face->dpo.dpoi_type = DPO_FIRST;
+ face->dpo.dpoi_proto = DPO_PROTO_NONE;
+ face->dpo.dpoi_index = INDEX_INVALID;
+ face->dpo.dpoi_next_node = 0;
+ face->pl_id = (u16) 0;
+ face->flags = HICN_FACE_FLAGS_IFACE;
+ face->locks = 1;
+
+ hicn_face_key_t key;
+ hicn_face_get_key (nat_address, sw_if, &face->dpo, &key);
+ *pfaceid = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_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);
+ }
+}
+
+
#endif // __HICN_FACE_H__
/*
diff --git a/hicn-plugin/src/faces/face_cli.c b/hicn-plugin/src/faces/face_cli.c
index b0ed7ddae..e9e516cc6 100644
--- a/hicn-plugin/src/faces/face_cli.c
+++ b/hicn-plugin/src/faces/face_cli.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -74,8 +74,7 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
(HICN_ERROR_FACE_NOT_FOUND));
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- hicn_face_vft_t *vft = hicn_face_get_vft (face->shared.face_type);
- vlib_cli_output (vm, "%U\n", vft->format_face, face_id, 0 /*indent */ );
+ vlib_cli_output (vm, "%U\n", format_hicn_face, face_id, 0 /*indent */ );
u32 indent = 3;
@@ -107,16 +106,14 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
if (found != ~0)
{
hicn_face_t *face;
- dpo_type_t type = (dpo_type_t) (found + first_type);
- hicn_face_vft_t *vft = hicn_face_get_vft (type);
/* *INDENT-OFF* */
pool_foreach(face, hicn_dpoi_face_pool,
{
- if (!((face->shared.flags & HICN_FACE_FLAGS_DELETED) && !deleted))
+ if (!((face->flags & HICN_FACE_FLAGS_DELETED) && !deleted))
{
- if ((face->shared.face_type == type) && (face->shared.flags))
+ if (face->flags)
{
- vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ vlib_cli_output(vm, "%U\n", format_hicn_face, hicn_dpoi_get_index(face), 0);
u8 * s = 0;
u32 indent = 3;
@@ -147,10 +144,9 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
pool_foreach(face, hicn_dpoi_face_pool,
{
- if (!((face->shared.flags & HICN_FACE_FLAGS_DELETED) && !deleted))
+ if (!((face->flags & HICN_FACE_FLAGS_DELETED) && !deleted))
{
- hicn_face_vft_t * vft = hicn_face_get_vft(face->shared.face_type);
- vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ vlib_cli_output(vm, "%U\n", format_hicn_face, hicn_dpoi_get_index(face), 0);
u32 indent = 3;
u8 * s = 0;
@@ -184,7 +180,7 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm,
VLIB_CLI_COMMAND (hicn_face_cli_show_command, static) =
{
.path = "hicn face show",
- .short_help = "hicn face show [<face_id>| type <ip/udp>]",
+ .short_help = "hicn face show [<face_id>]",
.function = hicn_face_cli_show_command_fn,
};
/* *INDENT-ON* */
diff --git a/hicn-plugin/src/faces/ip/face_ip_node.c b/hicn-plugin/src/faces/face_node.c
index 0eeeab6fb..b146e3a6f 100644
--- a/hicn-plugin/src/faces/ip/face_ip_node.c
+++ b/hicn-plugin/src/faces/face_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -15,15 +15,15 @@
#include <vnet/adj/adj.h>
-#include "face_ip.h"
-#include "face_ip_node.h"
-#include "dpo_ip.h"
-#include "../app/face_prod.h"
-#include "../../strategy_dpo_manager.h"
-#include "../face.h"
-#include "../../cache_policies/cs_lru.h"
-#include "../../infra.h"
-#include "../../hicn.h"
+#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"
+#include "../infra.h"
+#include "../hicn.h"
/**
* @File
@@ -31,21 +31,21 @@
* Definition of the nodes for ip incomplete faces.
*/
-vlib_node_registration_t hicn_face_ip4_input_node;
-vlib_node_registration_t hicn_face_ip4_output_node;
-vlib_node_registration_t hicn_face_ip6_input_node;
-vlib_node_registration_t hicn_face_ip6_output_node;
+vlib_node_registration_t hicn4_face_input_node;
+vlib_node_registration_t hicn4_face_output_node;
+vlib_node_registration_t hicn6_face_input_node;
+vlib_node_registration_t hicn6_face_output_node;
#define ip_v4 4
#define ip_v6 6
-static char *hicn_face_ip4_input_error_strings[] = {
+static char *hicn4_face_input_error_strings[] = {
#define _(sym, string) string,
foreach_hicnfwd_error
#undef _
};
-static char *hicn_face_ip6_input_error_strings[] = {
+static char *hicn6_face_input_error_strings[] = {
#define _(sym, string) string,
foreach_hicnfwd_error
#undef _
@@ -59,15 +59,15 @@ typedef struct
u8 pkt_type;
u8 packet_data[60];
}
-hicn_face_ip4_input_trace_t;
+hicn4_face_input_trace_t;
typedef enum
{
- HICN_FACE_IP4_INPUT_NEXT_DATA,
- HICN_FACE_IP4_INPUT_NEXT_MAPME,
- HICN_FACE_IP4_INPUT_NEXT_ERROR_DROP,
- HICN_FACE_IP4_INPUT_N_NEXT,
-} hicn_face_ip4_input_next_t;
+ HICN4_FACE_INPUT_NEXT_DATA,
+ //HICN4_FACE_INPUT_NEXT_MAPME,
+ HICN4_FACE_INPUT_NEXT_ERROR_DROP,
+ HICN4_FACE_INPUT_N_NEXT,
+} hicn4_face_input_next_t;
/* Trace context struct */
typedef struct
@@ -77,35 +77,35 @@ typedef struct
u8 pkt_type;
u8 packet_data[60];
}
-hicn_face_ip6_input_trace_t;
+hicn6_face_input_trace_t;
typedef enum
{
- HICN_FACE_IP6_INPUT_NEXT_DATA,
- HICN_FACE_IP6_INPUT_NEXT_MAPME,
- HICN_FACE_IP6_INPUT_NEXT_ERROR_DROP,
- HICN_FACE_IP6_INPUT_N_NEXT,
-} hicn_face_ip6_input_next_t;
+ HICN6_FACE_INPUT_NEXT_DATA,
+ //HICN6_FACE_INPUT_NEXT_MAPME,
+ HICN6_FACE_INPUT_NEXT_ERROR_DROP,
+ HICN6_FACE_INPUT_N_NEXT,
+} hicn6_face_input_next_t;
-#define NEXT_MAPME_IP4 HICN_FACE_IP4_INPUT_NEXT_MAPME
-#define NEXT_MAPME_IP6 HICN_FACE_IP6_INPUT_NEXT_MAPME
-#define NEXT_DATA_IP4 HICN_FACE_IP4_INPUT_NEXT_DATA
-#define NEXT_DATA_IP6 HICN_FACE_IP6_INPUT_NEXT_DATA
+#define NEXT_MAPME_IP4 HICN4_FACE_INPUT_NEXT_ERROR_DROP//HICN4_FACE_INPUT_NEXT_MAPME
+#define NEXT_MAPME_IP6 HICN6_FACE_INPUT_NEXT_ERROR_DROP//HICN6_FACE_INPUT_NEXT_MAPME
+#define NEXT_DATA_IP4 HICN4_FACE_INPUT_NEXT_DATA
+#define NEXT_DATA_IP6 HICN6_FACE_INPUT_NEXT_DATA
-#define NEXT_ERROR_DROP_IP4 HICN_FACE_IP4_INPUT_NEXT_ERROR_DROP
-#define NEXT_ERROR_DROP_IP6 HICN_FACE_IP6_INPUT_NEXT_ERROR_DROP
+#define NEXT_ERROR_DROP_IP4 HICN4_FACE_INPUT_NEXT_ERROR_DROP
+#define NEXT_ERROR_DROP_IP6 HICN6_FACE_INPUT_NEXT_ERROR_DROP
#define IP_HEADER_4 ip4_header_t
#define IP_HEADER_6 ip6_header_t
-#define LOCK_FROM_LOCAL_IP4 hicn_dpo_ip4_lock_from_local
-#define LOCK_FROM_LOCAL_IP6 hicn_dpo_ip6_lock_from_local
+#define LOCK_DPO_FACE_IP4 hicn_dpo_face_ip4_lock
+#define LOCK_DPO_FACE_IP6 hicn_dpo_face_ip6_lock
-#define TRACE_INPUT_PKT_IP4 hicn_face_ip4_input_trace_t
-#define TRACE_INPUT_PKT_IP6 hicn_face_ip6_input_trace_t
+#define TRACE_INPUT_PKT_IP4 hicn4_face_input_trace_t
+#define TRACE_INPUT_PKT_IP6 hicn6_face_input_trace_t
/*
- * NOTE: Both hicn_face_ip4_input_node_fn and hicn_face_ip6_input_node_fn
+ * NOTE: Both hicn4_face_input_node_fn and hicn6_face_input_node_fn
* present a similar codebase. Macro are hard to debug, although the
* followind code is pretty straighforward and most of the complexity is in
* functions that can be easily debug.
@@ -143,19 +143,18 @@ typedef enum
next0 = is_icmp*NEXT_MAPME_IP##ipv + \
(1-is_icmp)*NEXT_DATA_IP##ipv; \
\
- ret = LOCK_FROM_LOCAL_IP##ipv \
- (&(hicnb0->face_dpo_id), \
+ ret = LOCK_DPO_FACE_IP##ipv \
+ (&(hicnb0->face_id), \
&(hicnb0->in_faces_vec_id), \
&hicnb0->flags, \
- &(ip_hdr->dst_address), \
- vnet_buffer (b0)->sw_if_index[VLIB_RX]); \
+ &(ip_hdr->dst_address)); \
\
if ( PREDICT_FALSE(ret != HICN_ERROR_NONE) ) \
next0 = NEXT_ERROR_DROP_IP##ipv; \
else \
{ \
vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
+ &counters[hicnb0->face_id \
* HICN_N_COUNTER], thread_index, \
HICN_FACE_COUNTERS_DATA_RX, \
1, \
@@ -232,26 +231,24 @@ typedef enum
(1-is_icmp1)*NEXT_DATA_IP##ipv; \
\
\
- ret0 = LOCK_FROM_LOCAL_IP##ipv \
- (&(hicnb0->face_dpo_id), \
+ ret0 = LOCK_DPO_FACE_IP##ipv \
+ (&(hicnb0->face_id), \
&(hicnb0->in_faces_vec_id), \
&hicnb0->flags, \
- &(ip_hdr0->dst_address), \
- vnet_buffer (b0)->sw_if_index[VLIB_RX]); \
+ &(ip_hdr0->dst_address)); \
\
- ret1 = LOCK_FROM_LOCAL_IP##ipv \
- (&(hicnb1->face_dpo_id), \
+ ret1 = LOCK_DPO_FACE_IP##ipv \
+ (&(hicnb1->face_id), \
&(hicnb1->in_faces_vec_id), \
&hicnb1->flags, \
- &(ip_hdr1->dst_address), \
- vnet_buffer (b1)->sw_if_index[VLIB_RX]); \
+ &(ip_hdr1->dst_address)); \
\
if ( PREDICT_FALSE(ret0 != HICN_ERROR_NONE) ) \
next0 = NEXT_ERROR_DROP_IP##ipv; \
else \
{ \
vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
+ &counters[hicnb0->face_id \
* HICN_N_COUNTER], thread_index, \
HICN_FACE_COUNTERS_DATA_RX, \
1, \
@@ -264,7 +261,7 @@ typedef enum
else \
{ \
vlib_increment_combined_counter ( \
- &counters[hicnb1->face_dpo_id.dpoi_index \
+ &counters[hicnb1->face_id \
* HICN_N_COUNTER], thread_index,\
HICN_FACE_COUNTERS_DATA_RX, \
1, \
@@ -307,8 +304,8 @@ typedef enum
static uword
-hicn_face_ip4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn4_face_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -345,12 +342,12 @@ hicn_face_ip4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn_face_ip4_input_format_trace (u8 * s, va_list * args)
+hicn4_face_input_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_ip4_input_trace_t *t =
- va_arg (*args, hicn_face_ip4_input_trace_t *);
+ hicn4_face_input_trace_t *t =
+ va_arg (*args, hicn4_face_input_trace_t *);
s = format (s, "FACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
(int) t->pkt_type, t->sw_if_index, t->next_index,
@@ -363,32 +360,32 @@ hicn_face_ip4_input_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_face_ip4_input_node) =
+VLIB_REGISTER_NODE(hicn4_face_input_node) =
{
- .function = hicn_face_ip4_input_node_fn,
- .name = "hicn-face-ip4-input",
+ .function = hicn4_face_input_node_fn,
+ .name = "hicn4-face-input",
.vector_size = sizeof(u32),
- .format_trace = hicn_face_ip4_input_format_trace,
+ .format_trace = hicn4_face_input_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn_face_ip4_input_error_strings),
- .error_strings = hicn_face_ip4_input_error_strings,
- .n_next_nodes = HICN_FACE_IP4_INPUT_N_NEXT,
+ .n_errors = ARRAY_LEN(hicn4_face_input_error_strings),
+ .error_strings = hicn4_face_input_error_strings,
+ .n_next_nodes = HICN4_FACE_INPUT_N_NEXT,
/* edit / add dispositions here */
.next_nodes =
{
- [HICN_FACE_IP4_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
- [HICN_FACE_IP4_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
- [HICN_FACE_IP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ [HICN4_FACE_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
+ //[HICN4_FACE_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
+ [HICN4_FACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
/* *INDENT-ON* */
/**
* @brief IPv6 face input node function
- * @see hicn_face_ip4_input_node_fn
+ * @see hicn6_face_input_node_fn
*/
static uword
-hicn_face_ip6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+hicn6_face_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -426,12 +423,12 @@ hicn_face_ip6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn_face_ip6_input_format_trace (u8 * s, va_list * args)
+hicn6_face_input_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_ip6_input_trace_t *t =
- va_arg (*args, hicn_face_ip6_input_trace_t *);
+ hicn6_face_input_trace_t *t =
+ va_arg (*args, hicn6_face_input_trace_t *);
s = format (s, "FACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
(int) t->pkt_type, t->sw_if_index, t->next_index,
@@ -443,22 +440,22 @@ hicn_face_ip6_input_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_face_ip6_input_node) =
+VLIB_REGISTER_NODE(hicn6_face_input_node) =
{
- .function = hicn_face_ip6_input_node_fn,
- .name = "hicn-face-ip6-input",
+ .function = hicn6_face_input_node_fn,
+ .name = "hicn6-face-input",
.vector_size = sizeof(u32),
- .format_trace = hicn_face_ip6_input_format_trace,
+ .format_trace = hicn6_face_input_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn_face_ip6_input_error_strings),
- .error_strings = hicn_face_ip6_input_error_strings,
- .n_next_nodes = HICN_FACE_IP6_INPUT_N_NEXT,
+ .n_errors = ARRAY_LEN(hicn6_face_input_error_strings),
+ .error_strings = hicn6_face_input_error_strings,
+ .n_next_nodes = HICN6_FACE_INPUT_N_NEXT,
/* edit / add dispositions here */
.next_nodes =
{
- [HICN_FACE_IP6_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
- [HICN_FACE_IP6_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
- [HICN_FACE_IP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ [HICN6_FACE_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
+ //[HICN6_FACE_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
+ [HICN6_FACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
/* *INDENT-ON* */
@@ -467,87 +464,87 @@ VLIB_REGISTER_NODE(hicn_face_ip6_input_node) =
typedef enum
{
- HICN_FACE_IP4_NEXT_ECHO_REPLY = IP4_LOOKUP_N_NEXT,
- HICN_FACE_IP4_N_NEXT,
-} hicn_face_ip4_next_t;
+ HICN4_FACE_OUTPUT_NEXT_ECHO_REPLY,
+ HICN4_FACE_OUTPUT_N_NEXT,
+} hicn4_face_output_next_t;
typedef enum
{
- HICN_FACE_IP6_NEXT_ECHO_REPLY = IP6_LOOKUP_N_NEXT,
- HICN_FACE_IP6_N_NEXT,
-} hicn_face_ip6_next_t;
-
-static_always_inline void
-hicn_reply_probe_v4 (vlib_buffer_t * b, hicn_face_t * face)
-{
- hicn_header_t *h0 = vlib_buffer_get_current (b);
- hicn_face_ip_t * face_ip = (hicn_face_ip_t *)(&face->data);
- h0->v4.ip.saddr = h0->v4.ip.daddr;
- h0->v4.ip.daddr = face_ip->local_addr.ip4;
- vnet_buffer (b)->sw_if_index[VLIB_RX] = face->shared.sw_if;
-
- u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t) + sizeof(u16));
- u16 dst_port = *dst_port_ptr;
- u16 * src_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t));
-
- *dst_port_ptr = *src_port_ptr;
- *src_port_ptr = dst_port;
-
- hicn_type_t type = hicn_get_buffer (b)->type;
- hicn_ops_vft[type.l1]->set_lifetime (type, &h0->protocol, 0);
-}
-
-static_always_inline void
-hicn_reply_probe_v6 (vlib_buffer_t * b, hicn_face_t * face)
-{
- hicn_header_t *h0 = vlib_buffer_get_current (b);
- hicn_face_ip_t * face_ip = (hicn_face_ip_t *)(&face->data);
- h0->v6.ip.saddr = h0->v6.ip.daddr;
- h0->v6.ip.daddr = face_ip->local_addr.ip6;
- vnet_buffer (b)->sw_if_index[VLIB_RX] = face->shared.sw_if;
-
- u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t) + sizeof(u16));
- u16 dst_port = *dst_port_ptr;
- u16 * src_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t));
-
- *dst_port_ptr = *src_port_ptr;
- *src_port_ptr = dst_port;
-
- hicn_type_t type = hicn_get_buffer (b)->type;
- hicn_ops_vft[type.l1]->set_lifetime (type, &h0->protocol, 0);
-
-}
-
-static_always_inline u32
-hicn_face_match_probe (vlib_buffer_t * b, hicn_face_t * face, u32 * next)
-{
-
- u8 *ptr = vlib_buffer_get_current (b);
- u8 v = *ptr & 0xf0;
- u8 res = 0;
-
- if ( v == 0x40 )
- {
- u16 * dst_port = (u16 *)(ptr + sizeof(ip4_header_t) + sizeof(u16));
- if (*dst_port == clib_net_to_host_u16(DEFAULT_PROBING_PORT))
- {
- hicn_reply_probe_v6(b, face);
- *next = HICN_FACE_IP4_NEXT_ECHO_REPLY;
- res = 1;
- }
- }
- else if ( v == 0x60 )
- {
- u16 * dst_port = (u16 *)(ptr + sizeof(ip6_header_t) + sizeof(u16));
- if (*dst_port == clib_net_to_host_u16(DEFAULT_PROBING_PORT))
- {
- hicn_reply_probe_v6(b, face);
- *next = HICN_FACE_IP6_NEXT_ECHO_REPLY;
- res = 1;
- }
- }
- return res;
-}
+ HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY,
+ HICN6_FACE_OUTPUT_N_NEXT,
+} hicn6_face_output_next_t;
+
+/* static_always_inline void */
+/* hicn_reply_probe_v4 (vlib_buffer_t * b, hicn_face_t * face) */
+/* { */
+/* hicn_header_t *h0 = vlib_buffer_get_current (b); */
+/* hicn_face_ip_t * face_ip = (hicn_face_ip_t *)(&face->data); */
+/* h0->v4.ip.saddr = h0->v4.ip.daddr; */
+/* h0->v4.ip.daddr = face_ip->local_addr.ip4; */
+/* vnet_buffer (b)->sw_if_index[VLIB_RX] = face->shared.sw_if; */
+
+/* u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t) + sizeof(u16)); */
+/* u16 dst_port = *dst_port_ptr; */
+/* u16 * src_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t)); */
+
+/* *dst_port_ptr = *src_port_ptr; */
+/* *src_port_ptr = dst_port; */
+
+/* hicn_type_t type = hicn_get_buffer (b)->type; */
+/* hicn_ops_vft[type.l1]->set_lifetime (type, &h0->protocol, 0); */
+/* } */
+
+/* static_always_inline void */
+/* hicn_reply_probe_v6 (vlib_buffer_t * b, hicn_face_t * face) */
+/* { */
+/* hicn_header_t *h0 = vlib_buffer_get_current (b); */
+/* hicn_face_ip_t * face_ip = (hicn_face_ip_t *)(&face->data); */
+/* h0->v6.ip.saddr = h0->v6.ip.daddr; */
+/* h0->v6.ip.daddr = face_ip->local_addr.ip6; */
+/* vnet_buffer (b)->sw_if_index[VLIB_RX] = face->shared.sw_if; */
+
+/* u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t) + sizeof(u16)); */
+/* u16 dst_port = *dst_port_ptr; */
+/* u16 * src_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t)); */
+
+/* *dst_port_ptr = *src_port_ptr; */
+/* *src_port_ptr = dst_port; */
+
+/* hicn_type_t type = hicn_get_buffer (b)->type; */
+/* hicn_ops_vft[type.l1]->set_lifetime (type, &h0->protocol, 0); */
+
+/* } */
+
+/* static_always_inline u32 */
+/* hicn_face_match_probe (vlib_buffer_t * b, hicn_face_t * face, u32 * next) */
+/* { */
+
+/* u8 *ptr = vlib_buffer_get_current (b); */
+/* u8 v = *ptr & 0xf0; */
+/* u8 res = 0; */
+
+/* if ( v == 0x40 ) */
+/* { */
+/* u16 * dst_port = (u16 *)(ptr + sizeof(ip4_header_t) + sizeof(u16)); */
+/* if (*dst_port == clib_net_to_host_u16(DEFAULT_PROBING_PORT)) */
+/* { */
+/* hicn_reply_probe_v6(b, face); */
+/* *next = HICN4_FACE_NEXT_ECHO_REPLY; */
+/* res = 1; */
+/* } */
+/* } */
+/* else if ( v == 0x60 ) */
+/* { */
+/* u16 * dst_port = (u16 *)(ptr + sizeof(ip6_header_t) + sizeof(u16)); */
+/* if (*dst_port == clib_net_to_host_u16(DEFAULT_PROBING_PORT)) */
+/* { */
+/* hicn_reply_probe_v6(b, face); */
+/* *next = HICN6_FACE_NEXT_ECHO_REPLY; */
+/* res = 1; */
+/* } */
+/* } */
+/* return res; */
+/* } */
static inline void
@@ -555,68 +552,37 @@ hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0,
hicn_face_t * face, u32 * next)
{
- if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD) && hicn_face_match_probe(b0, face, next))
- return;
+ /* if ((face->flags & HICN_FACE_FLAGS_APPFACE_PROD) && hicn_face_match_probe(b0, face, next)) */
+ /* return; */
hicn_header_t *hicn = vlib_buffer_get_current (b0);
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ //hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
ip46_address_t temp_addr;
ip46_address_reset (&temp_addr);
hicn_type_t type = hicn_get_buffer (b0)->type;
hicn_ops_vft[type.l1]->rewrite_interest (type, &hicn->protocol,
- &ip_face->local_addr, &temp_addr);
-
- int is_iface = 0;
- ip_adjacency_t *adj;
- if (PREDICT_FALSE (face->shared.adj == ~0))
- is_iface = 1;
- else
- adj = adj_get (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
- (is_iface || adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
- {
- fib_prefix_t fib_pfx;
- fib_node_index_t fib_entry_index;
- fib_prefix_from_ip46_addr (&ip_face->remote_addr, &fib_pfx);
- fib_pfx.fp_len = ip46_address_is_ip4(&ip_face->remote_addr)? 32 : 128;
-
- u32 fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
- HICN_FIB_TABLE,
- FIB_SOURCE_PRIORITY_HI);
-
- fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
+ &face->nat_addr, &temp_addr);
- face->shared.adj = fib_entry_get_adj (fib_entry_index);
- face->shared.flags &= ~HICN_FACE_FLAGS_IFACE;
- face->shared.flags |= HICN_FACE_FLAGS_FACE;
-
- adj = adj_get (face->shared.adj);
-
- hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
- &ip_face->remote_addr, &temp_addr,
- 0);
- }
+ if (ip46_address_is_ip4(&face->nat_addr))
+ b0->flags |= VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
- vnet_buffer (b0)->ip.adj_index[VLIB_TX] = face->shared.adj;
- *next = adj->lookup_next_index;
+ b0->flags |= VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
+ ASSERT(face->flags & HICN_FACE_FLAGS_FACE);
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = face->dpo.dpoi_index;
+ *next = face->dpo.dpoi_next_node;
}
-static char *hicn_face_ip4_output_error_strings[] = {
+static char *hicn4_face_output_error_strings[] = {
#define _(sym, string) string,
foreach_hicnfwd_error
#undef _
};
-static char *hicn_face_ip6_output_error_strings[] = {
+static char *hicn6_face_output_error_strings[] = {
#define _(sym, string) string,
foreach_hicnfwd_error
#undef _
@@ -631,7 +597,7 @@ typedef struct
u8 pkt_type;
u8 packet_data[60];
}
-hicn_face_ip4_output_trace_t;
+hicn4_face_output_trace_t;
/* Trace context struct */
typedef struct
@@ -641,10 +607,10 @@ typedef struct
u8 pkt_type;
u8 packet_data[60];
}
-hicn_face_ip6_output_trace_t;
+hicn6_face_output_trace_t;
-#define TRACE_OUTPUT_PKT_IP4 hicn_face_ip4_output_trace_t
-#define TRACE_OUTPUT_PKT_IP6 hicn_face_ip6_output_trace_t
+#define TRACE_OUTPUT_PKT_IP4 hicn4_face_output_trace_t
+#define TRACE_OUTPUT_PKT_IP6 hicn6_face_output_trace_t
#define face_output_x1(ipv) \
do { \
@@ -807,7 +773,7 @@ hicn_face_ip6_output_trace_t;
static uword
-hicn_face_ip4_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+hicn4_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -846,12 +812,12 @@ hicn_face_ip4_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn_face_ip4_output_format_trace (u8 * s, va_list * args)
+hicn4_face_output_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_ip4_output_trace_t *t =
- va_arg (*args, hicn_face_ip4_output_trace_t *);
+ hicn4_face_output_trace_t *t =
+ va_arg (*args, hicn4_face_output_trace_t *);
s =
format (s, "FACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -864,38 +830,27 @@ hicn_face_ip4_output_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_face_ip4_output_node) =
+VLIB_REGISTER_NODE(hicn4_face_output_node) =
{
- .function = hicn_face_ip4_output_node_fn,
- .name = "hicn-face-ip4-output",
+ .function = hicn4_face_output_node_fn,
+ .name = "hicn4-face-output",
.vector_size = sizeof(u32),
- .format_trace = hicn_face_ip4_output_format_trace,
+ .format_trace = hicn4_face_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn_face_ip4_output_error_strings),
- .error_strings = hicn_face_ip4_output_error_strings,
- .n_next_nodes = HICN_FACE_IP4_N_NEXT,
+ .n_errors = ARRAY_LEN(hicn4_face_output_error_strings),
+ .error_strings = hicn4_face_output_error_strings,
+ .n_next_nodes = HICN4_FACE_OUTPUT_N_NEXT,
/* Reusing the list of nodes from lookup to be compatible with arp */
.next_nodes =
{
- [IP_LOOKUP_NEXT_DROP] = "ip4-drop",
- [IP_LOOKUP_NEXT_PUNT] = "ip4-punt",
- [IP_LOOKUP_NEXT_LOCAL] = "ip4-local",
- [IP_LOOKUP_NEXT_ARP] = "ip4-arp",
- [IP_LOOKUP_NEXT_GLEAN] = "ip4-glean",
- [IP_LOOKUP_NEXT_REWRITE] = "ip4-rewrite",
- [IP_LOOKUP_NEXT_MCAST] = "ip4-rewrite-mcast",
- [IP_LOOKUP_NEXT_BCAST] = "ip4-rewrite-bcast",
- [IP_LOOKUP_NEXT_MIDCHAIN] = "ip4-midchain",
- [IP_LOOKUP_NEXT_MCAST_MIDCHAIN] = "ip4-mcast-midchain",
- [IP_LOOKUP_NEXT_ICMP_ERROR] = "ip4-icmp-error",
- [HICN_FACE_IP4_NEXT_ECHO_REPLY] = "hicn-face-ip4-input",
+ [HICN4_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn4-face-input",
}
};
/* *INDENT-ON* */
static uword
-hicn_face_ip6_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+hicn6_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -934,12 +889,12 @@ hicn_face_ip6_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn_face_ip6_output_format_trace (u8 * s, va_list * args)
+hicn6_face_output_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_ip6_output_trace_t *t =
- va_arg (*args, hicn_face_ip6_output_trace_t *);
+ hicn6_face_output_trace_t *t =
+ va_arg (*args, hicn6_face_output_trace_t *);
s =
format (s, "FACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -952,34 +907,20 @@ hicn_face_ip6_output_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_face_ip6_output_node) =
+VLIB_REGISTER_NODE(hicn6_face_output_node) =
{
- .function = hicn_face_ip6_output_node_fn,
- .name = "hicn-face-ip6-output",
+ .function = hicn6_face_output_node_fn,
+ .name = "hicn6-face-output",
.vector_size = sizeof(u32),
- .format_trace = hicn_face_ip6_output_format_trace,
+ .format_trace = hicn6_face_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn_face_ip6_output_error_strings),
- .error_strings = hicn_face_ip6_output_error_strings,
- .n_next_nodes = HICN_FACE_IP6_N_NEXT,
+ .n_errors = ARRAY_LEN(hicn6_face_output_error_strings),
+ .error_strings = hicn6_face_output_error_strings,
+ .n_next_nodes = HICN6_FACE_OUTPUT_N_NEXT,
/* Reusing the list of nodes from lookup to be compatible with neighbour discovery */
.next_nodes =
{
- [IP_LOOKUP_NEXT_DROP] = "ip6-drop",
- [IP_LOOKUP_NEXT_PUNT] = "ip6-punt",
- [IP_LOOKUP_NEXT_LOCAL] = "ip6-local",
- [IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor",
- [IP_LOOKUP_NEXT_GLEAN] = "ip6-glean",
- [IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite",
- [IP_LOOKUP_NEXT_BCAST] = "ip6-rewrite-bcast",
- [IP_LOOKUP_NEXT_MCAST] = "ip6-rewrite-mcast",
- [IP_LOOKUP_NEXT_MIDCHAIN] = "ip6-midchain",
- [IP_LOOKUP_NEXT_MCAST_MIDCHAIN] = "ip6-mcast-midchain",
- [IP_LOOKUP_NEXT_ICMP_ERROR] = "ip6-icmp-error",
- [IP6_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop",
- [IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop",
- [IP6_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop",
- [HICN_FACE_IP6_NEXT_ECHO_REPLY] = "hicn-face-ip6-input"
+ [HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn6-face-input"
}
};
/* *INDENT-ON* */
diff --git a/hicn-plugin/src/faces/udp/face_udp_node.h b/hicn-plugin/src/faces/face_node.h
index c759312c8..932ee40f5 100644
--- a/hicn-plugin/src/faces/udp/face_udp_node.h
+++ b/hicn-plugin/src/faces/face_node.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -13,18 +13,18 @@
* limitations under the License.
*/
-#ifndef __HICN_FACE_UDP_NODE_H__
-#define __HICN_FACE_UDP_NODE_H__
+#ifndef __HICN_FACE_NODE_H__
+#define __HICN_FACE_NODE_H__
#include <vlib/vlib.h>
#include <vnet/vnet.h>
-extern vlib_node_registration_t hicn_face_udp4_input_node;
-extern vlib_node_registration_t hicn_face_udp6_input_node;
-extern vlib_node_registration_t hicn_face_udp4_output_node;
-extern vlib_node_registration_t hicn_face_udp6_output_node;
+extern vlib_node_registration_t hicn4_face_input_node;
+extern vlib_node_registration_t hicn4_face_output_node;
+extern vlib_node_registration_t hicn6_face_input_node;
+extern vlib_node_registration_t hicn6_face_output_node;
-#endif // __HICN_FACE_UDP_NODE_H__
+#endif // __HICN_FACE_NODE_H__
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/faces/ip/iface_ip_node.c b/hicn-plugin/src/faces/iface_node.c
index 8adef50d9..5def03417 100644
--- a/hicn-plugin/src/faces/ip/iface_ip_node.c
+++ b/hicn-plugin/src/faces/iface_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -13,13 +13,12 @@
* limitations under the License.
*/
-#include "face_ip.h"
-#include "dpo_ip.h"
-#include "../../strategy_dpo_manager.h"
-#include "../face.h"
-#include "../../hicn.h"
-#include "../../infra.h"
-#include "../../cache_policies/cs_lru.h"
+#include "face.h"
+#include "dpo_face.h"
+#include "../strategy_dpo_manager.h"
+#include "../hicn.h"
+#include "../infra.h"
+#include "../cache_policies/cs_lru.h"
/**
* @File
@@ -27,10 +26,10 @@
* Definition of the nodes for ip incomplete faces.
*/
-vlib_node_registration_t hicn_iface_ip4_input_node;
-vlib_node_registration_t hicn_iface_ip4_output_node;
-vlib_node_registration_t hicn_iface_ip6_input_node;
-vlib_node_registration_t hicn_iface_ip6_output_node;
+vlib_node_registration_t hicn4_iface_input_node;
+vlib_node_registration_t hicn4_iface_output_node;
+vlib_node_registration_t hicn6_iface_input_node;
+vlib_node_registration_t hicn6_iface_output_node;
u32 data_fwd_iface_ip4_vlib_edge;
u32 data_fwd_iface_ip6_vlib_edge;
@@ -40,30 +39,30 @@ hicn_iface_ip_init (vlib_main_t * vm)
{
u32 temp_index4 = vlib_node_add_next (vm,
hicn_interest_hitcs_node.index,
- hicn_iface_ip4_output_node.index);
+ hicn4_iface_output_node.index);
u32 temp_index6 = vlib_node_add_next (vm,
hicn_interest_hitcs_node.index,
- hicn_iface_ip6_output_node.index);
+ hicn6_iface_output_node.index);
data_fwd_iface_ip4_vlib_edge = vlib_node_add_next (vm,
hicn_data_fwd_node.index,
- hicn_iface_ip4_output_node.index);
+ hicn4_iface_output_node.index);
data_fwd_iface_ip6_vlib_edge = vlib_node_add_next (vm,
hicn_data_fwd_node.index,
- hicn_iface_ip6_output_node.index);
+ hicn6_iface_output_node.index);
ASSERT (temp_index4 == data_fwd_iface_ip4_vlib_edge);
ASSERT (temp_index6 == data_fwd_iface_ip6_vlib_edge);
}
-static char *hicn_iface_ip4_input_error_strings[] = {
+static char *hicn4_iface_input_error_strings[] = {
#define _(sym, string) string,
foreach_hicnfwd_error
#undef _
};
-static char *hicn_iface_ip6_input_error_strings[] = {
+static char *hicn6_iface_input_error_strings[] = {
#define _(sym, string) string,
foreach_hicnfwd_error
#undef _
@@ -76,15 +75,15 @@ typedef struct
u32 sw_if_index;
u8 pkt_type;
u8 packet_data[60];
-} hicn_iface_ip4_input_trace_t;
+} hicn4_iface_input_trace_t;
typedef enum
{
- HICN_IFACE_IP4_INPUT_NEXT_INTEREST,
- HICN_IFACE_IP4_INPUT_NEXT_MAPME,
- HICN_IFACE_IP4_INPUT_NEXT_ERROR_DROP,
- HICN_IFACE_IP4_INPUT_N_NEXT,
-} hicn_iface_ip4_input_next_t;
+ HICN4_IFACE_INPUT_NEXT_INTEREST,
+ //HICN4_IFACE_INPUT_NEXT_MAPME,
+ HICN4_IFACE_INPUT_NEXT_ERROR_DROP,
+ HICN4_IFACE_INPUT_N_NEXT,
+} hicn4_iface_input_next_t;
/* Trace context struct */
typedef struct
@@ -93,21 +92,21 @@ typedef struct
u32 sw_if_index;
u8 pkt_type;
u8 packet_data[60];
-} hicn_iface_ip6_input_trace_t;
+} hicn6_iface_input_trace_t;
typedef enum
{
- HICN_IFACE_IP6_INPUT_NEXT_INTEREST,
- HICN_IFACE_IP6_INPUT_NEXT_MAPME,
- HICN_IFACE_IP6_INPUT_NEXT_ERROR_DROP,
- HICN_IFACE_IP6_INPUT_N_NEXT,
-} hicn_iface_ip6_input_next_t;
+ HICN6_IFACE_INPUT_NEXT_INTEREST,
+ //HICN6_IFACE_INPUT_NEXT_MAPME,
+ HICN6_IFACE_INPUT_NEXT_ERROR_DROP,
+ HICN6_IFACE_INPUT_N_NEXT,
+} hicn6_iface_input_next_t;
-#define NEXT_MAPME_IP4 HICN_IFACE_IP4_INPUT_NEXT_MAPME
-#define NEXT_MAPME_IP6 HICN_IFACE_IP6_INPUT_NEXT_MAPME
+#define NEXT_MAPME_IP4 HICN4_IFACE_INPUT_NEXT_ERROR_DROP//HICN4_IFACE_INPUT_NEXT_MAPME
+#define NEXT_MAPME_IP6 HICN6_IFACE_INPUT_NEXT_ERROR_DROP//HICN6_IFACE_INPUT_NEXT_MAPME
-#define NEXT_INTEREST_IP4 HICN_IFACE_IP6_INPUT_NEXT_INTEREST
-#define NEXT_INTEREST_IP6 HICN_IFACE_IP6_INPUT_NEXT_INTEREST
+#define NEXT_INTEREST_IP4 HICN4_IFACE_INPUT_NEXT_INTEREST
+#define NEXT_INTEREST_IP6 HICN6_IFACE_INPUT_NEXT_INTEREST
#define ADDRESS_IP4 ip_interface_address_t *ia = 0;ip4_address_t *local_address = ip4_interface_first_address(&ip4_main, swif, &ia)
#define ADDRESS_IP6 ip6_address_t *local_address = ip6_interface_first_address(&ip6_main, swif)
@@ -119,17 +118,76 @@ typedef enum
#define ADDRESSX2_IP6 ip6_address_t *local_address0 = ip6_interface_first_address(&ip6_main, swif0); \
ip6_address_t *local_address1 = ip6_interface_first_address(&ip6_main, swif1);
-#define DPO_ADD_LOCK_IP4 hicn_dpo_ip4_add_and_lock_from_remote
-#define DPO_ADD_LOCK_IP6 hicn_dpo_ip6_add_and_lock_from_remote
+#define DPO_ADD_LOCK_IFACE_IP4 hicn_dpo_iface_ip4_add_and_lock
+#define DPO_ADD_LOCK_IFACE_IP6 hicn_dpo_iface_ip6_add_and_lock
-#define VLIB_EDGE_IP4 data_fwd_iface_ip4_vlib_edge
-#define VLIB_EDGE_IP6 data_fwd_iface_ip6_vlib_edge
+//#define VLIB_EDGE_IP4 data_fwd_iface_ip4_vlib_edge
+//#define VLIB_EDGE_IP6 data_fwd_iface_ip6_vlib_edge
#define IP_HEADER_4 ip4_header_t
#define IP_HEADER_6 ip6_header_t
-#define TRACE_INPUT_PKT_IP4 hicn_iface_ip4_input_trace_t
-#define TRACE_INPUT_PKT_IP6 hicn_iface_ip6_input_trace_t
+#define TRACE_INPUT_PKT_IP4 hicn4_iface_input_trace_t
+#define TRACE_INPUT_PKT_IP6 hicn6_iface_input_trace_t
+
+// NODE OUTPUT
+
+static char *hicn4_iface_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn6_iface_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+ u8 packet_data[60];
+} hicn4_iface_output_trace_t;
+
+typedef enum
+{
+ HICN4_IFACE_OUTPUT_NEXT_LOOKUP,
+ HICN4_IFACE_OUTPUT_N_NEXT,
+} hicn4_iface_output_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+ u8 packet_data[60];
+} hicn6_iface_output_trace_t;
+
+typedef enum
+{
+ HICN6_IFACE_OUTPUT_NEXT_LOOKUP,
+ 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
+
+#define NEXT_DATA_LOOKUP_IP4 HICN4_IFACE_OUTPUT_NEXT_LOOKUP
+#define NEXT_DATA_LOOKUP_IP6 HICN6_IFACE_OUTPUT_NEXT_LOOKUP
+
+#define HICN_REWRITE_DATA_IP4 hicn_rewrite_iface_data4
+#define HICN_REWRITE_DATA_IP6 hicn_rewrite_iface_data6
+
+#define TRACE_OUTPUT_PKT_IP4 hicn4_iface_output_trace_t
+#define TRACE_OUTPUT_PKT_IP6 hicn6_iface_output_trace_t
+
+// NODES IMPLEMENTATIONS
#define iface_input_x1(ipv) \
do { \
@@ -137,7 +195,6 @@ typedef enum
u32 bi0, next0; \
IP_HEADER_##ipv * ip_hdr = NULL; \
hicn_buffer_t * hicnb0; \
- u32 swif; \
/* Prefetch for next iteration. */ \
if (n_left_from > 1) \
{ \
@@ -165,17 +222,13 @@ typedef enum
next0 = is_icmp*NEXT_MAPME_IP##ipv + \
(1-is_icmp)*NEXT_INTEREST_IP##ipv; \
\
- swif = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- \
- ADDRESS_IP##ipv; \
\
- DPO_ADD_LOCK_IP##ipv \
- (&(hicnb0->face_dpo_id), \
- &hicnb0->flags, \
- local_address, \
- &(ip_hdr->src_address), \
- vnet_buffer(b0)->sw_if_index[VLIB_RX], \
- VLIB_EDGE_IP##ipv); \
+ 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); \
\
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
(b0->flags & VLIB_BUFFER_IS_TRACED))) \
@@ -192,11 +245,11 @@ typedef enum
} \
\
vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
+ &counters[hicnb0->face_id \
+ * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_RX, \
+ 1, \
+ vlib_buffer_length_in_chain(vm, b0)); \
\
/* Verify speculative enqueue, maybe switch current next frame */ \
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
@@ -212,7 +265,6 @@ typedef enum
IP_HEADER_##ipv * ip_hdr0 = NULL; \
IP_HEADER_##ipv * ip_hdr1 = NULL; \
hicn_buffer_t *hicnb0, *hicnb1; \
- u32 swif0, swif1; \
\
/* Prefetch for next iteration. */ \
vlib_buffer_t *b2, *b3; \
@@ -251,26 +303,20 @@ typedef enum
next1 = is_icmp1*NEXT_MAPME_IP##ipv + \
(1-is_icmp1)*NEXT_INTEREST_IP##ipv; \
\
- swif0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- swif1 = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- \
- ADDRESSX2_IP##ipv; \
\
- DPO_ADD_LOCK_IP##ipv \
- (&(hicnb0->face_dpo_id), \
+ DPO_ADD_LOCK_IFACE_IP##ipv \
+ (&(hicnb0->face_id), \
&hicnb0->flags, \
- local_address0, \
&(ip_hdr0->src_address), \
vnet_buffer(b0)->sw_if_index[VLIB_RX], \
- VLIB_EDGE_IP##ipv); \
+ NEXT_DATA_LOOKUP_IP##ipv); \
\
- DPO_ADD_LOCK_IP##ipv \
- (&(hicnb1->face_dpo_id), \
+ DPO_ADD_LOCK_IFACE_IP##ipv \
+ (&(hicnb1->face_id), \
&hicnb1->flags, \
- local_address1, \
&(ip_hdr1->src_address), \
vnet_buffer(b1)->sw_if_index[VLIB_RX], \
- VLIB_EDGE_IP##ipv); \
+ NEXT_DATA_LOOKUP_IP##ipv); \
\
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
(b0->flags & VLIB_BUFFER_IS_TRACED))) \
@@ -299,14 +345,14 @@ typedef enum
} \
\
vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
+ &counters[hicnb0->face_id \
* HICN_N_COUNTER], thread_index, \
HICN_FACE_COUNTERS_INTEREST_RX, \
1, \
vlib_buffer_length_in_chain(vm, b0)); \
\
vlib_increment_combined_counter ( \
- &counters[hicnb1->face_dpo_id.dpoi_index \
+ &counters[hicnb1->face_id \
* HICN_N_COUNTER], thread_index, \
HICN_FACE_COUNTERS_INTEREST_RX, \
1, \
@@ -319,7 +365,7 @@ typedef enum
}while(0)
static uword
-hicn_iface_ip4_input_node_fn (vlib_main_t * vm,
+hicn4_iface_input_node_fn (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
@@ -359,12 +405,12 @@ hicn_iface_ip4_input_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn_iface_ip4_input_format_trace (u8 * s, va_list * args)
+hicn4_iface_input_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_ip4_input_trace_t *t =
- va_arg (*args, hicn_iface_ip4_input_trace_t *);
+ hicn4_iface_input_trace_t *t =
+ va_arg (*args, hicn4_iface_input_trace_t *);
s =
format (s, "IFACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -377,28 +423,28 @@ hicn_iface_ip4_input_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_ip4_input_node) =
+VLIB_REGISTER_NODE (hicn4_iface_input_node) =
{
- .function = hicn_iface_ip4_input_node_fn,
- .name = "hicn-iface-ip4-input",
+ .function = hicn4_iface_input_node_fn,
+ .name = "hicn4-iface-input",
.vector_size = sizeof (u32),
- .format_trace = hicn_iface_ip4_input_format_trace,
+ .format_trace = hicn4_iface_input_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_ip4_input_error_strings),
- .error_strings = hicn_iface_ip4_input_error_strings,
- .n_next_nodes = HICN_IFACE_IP4_INPUT_N_NEXT,
+ .n_errors = ARRAY_LEN (hicn4_iface_input_error_strings),
+ .error_strings = hicn4_iface_input_error_strings,
+ .n_next_nodes = HICN4_IFACE_INPUT_N_NEXT,
/* edit / add dispositions*/
.next_nodes =
{
- [HICN_IFACE_IP4_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
- [HICN_IFACE_IP4_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
- [HICN_IFACE_IP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ [HICN4_IFACE_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
+ //[HICN4_IFACE_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
+ [HICN4_IFACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
/* *INDENT-ON* */
static uword
-hicn_iface_ip6_input_node_fn (vlib_main_t * vm,
+hicn6_iface_input_node_fn (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
@@ -439,12 +485,12 @@ hicn_iface_ip6_input_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn_iface_ip6_input_format_trace (u8 * s, va_list * args)
+hicn6_iface_input_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_ip6_input_trace_t *t =
- va_arg (*args, hicn_iface_ip6_input_trace_t *);
+ hicn6_iface_input_trace_t *t =
+ va_arg (*args, hicn6_iface_input_trace_t *);
s =
format (s, "IFACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -457,22 +503,22 @@ hicn_iface_ip6_input_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_ip6_input_node) =
+VLIB_REGISTER_NODE (hicn6_iface_input_node) =
{
- .function = hicn_iface_ip6_input_node_fn,
- .name = "hicn-iface-ip6-input",
+ .function = hicn6_iface_input_node_fn,
+ .name = "hicn6-iface-input",
.vector_size = sizeof (u32),
- .format_trace = hicn_iface_ip6_input_format_trace,
+ .format_trace = hicn6_iface_input_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_ip6_input_error_strings),
- .error_strings = hicn_iface_ip6_input_error_strings,
- .n_next_nodes = HICN_IFACE_IP6_INPUT_N_NEXT,
+ .n_errors = ARRAY_LEN (hicn6_iface_input_error_strings),
+ .error_strings = hicn6_iface_input_error_strings,
+ .n_next_nodes = HICN6_IFACE_INPUT_N_NEXT,
/* edit / add dispositions*/
.next_nodes =
{
- [HICN_IFACE_IP6_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
- [HICN_IFACE_IP6_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
- [HICN_IFACE_IP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ [HICN6_IFACE_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
+ //[HICN6_IFACE_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
+ [HICN6_IFACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
/* *INDENT-ON* */
@@ -482,7 +528,7 @@ VLIB_REGISTER_NODE (hicn_iface_ip6_input_node) =
static inline void
hicn_rewrite_iface_data4 (vlib_main_t * vm, vlib_buffer_t * b0,
- const hicn_face_t * iface)
+ const hicn_face_t * iface, u32 * next)
{
ip4_header_t *ip0;
@@ -495,21 +541,21 @@ hicn_rewrite_iface_data4 (vlib_main_t * vm, vlib_buffer_t * b0,
ip0->length = clib_host_to_net_u16 (sval);
ip0->ttl = 254; // FIXME TTL
- vnet_buffer (b0)->ip.adj_index[VLIB_TX] = ~0;
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index;
+ *next = iface->dpo.dpoi_next_node;
hicn_header_t *hicn = vlib_buffer_get_current (b0);
ip46_address_t temp_addr;
ip46_address_reset (&temp_addr);
- hicn_face_ip_t *iface_ip = (hicn_face_ip_t *) iface->data;
hicn_type_t type = hicn_get_buffer (b0)->type;
hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
- &(iface_ip->remote_addr), &(temp_addr),
- iface->shared.pl_id);
+ &(iface->nat_addr), &(temp_addr),
+ iface->pl_id);
}
static inline void
hicn_rewrite_iface_data6 (vlib_main_t * vm, vlib_buffer_t * b0,
- const hicn_face_t * iface)
+ const hicn_face_t * iface, u32 * next)
{
ip6_header_t *ip0;
@@ -523,80 +569,24 @@ hicn_rewrite_iface_data6 (vlib_main_t * vm, vlib_buffer_t * b0,
ip0->payload_length = clib_host_to_net_u16 (sval);
ip0->hop_limit = HICN_IP6_HOP_LIMIT;
- vnet_buffer (b0)->ip.adj_index[VLIB_TX] = ~0;
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index;
+ *next = iface->dpo.dpoi_next_node;
+
hicn_header_t *hicn = vlib_buffer_get_current (b0);
ip46_address_t temp_addr;
ip46_address_reset (&temp_addr);
- hicn_face_ip_t *iface_ip = (hicn_face_ip_t *) iface->data;
hicn_type_t type = hicn_get_buffer (b0)->type;
hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
- &(iface_ip->remote_addr), &(temp_addr),
- iface->shared.pl_id);
+ &(iface->nat_addr), &(temp_addr),
+ iface->pl_id);
}
-static char *hicn_iface_ip4_output_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-static char *hicn_iface_ip6_output_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-} hicn_iface_ip4_output_trace_t;
-
-typedef enum
-{
- HICN_IFACE_IP4_OUTPUT_NEXT_LOOKUP,
- HICN_IFACE_IP4_OUTPUT_NEXT_ERROR_DROP,
- HICN_IFACE_IP4_OUTPUT_N_NEXT,
-} hicn_iface_ip4_output_next_t;
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-} hicn_iface_ip6_output_trace_t;
-
-typedef enum
-{
- HICN_IFACE_IP6_OUTPUT_NEXT_LOOKUP,
- HICN_IFACE_IP6_OUTPUT_NEXT_ERROR_DROP,
- HICN_IFACE_IP6_OUTPUT_N_NEXT,
-} hicn_iface_ip6_output_next_t;
-
-#define ERROR_OUTPUT_IP4 HICN_IFACE_IP4_OUTPUT_NEXT_ERROR_DROP
-#define ERROR_OUTPUT_IP6 HICN_IFACE_IP6_OUTPUT_NEXT_ERROR_DROP
-
-#define NEXT_DATA_LOOKUP_IP4 HICN_IFACE_IP4_OUTPUT_NEXT_LOOKUP
-#define NEXT_DATA_LOOKUP_IP6 HICN_IFACE_IP6_OUTPUT_NEXT_LOOKUP
-
-#define HICN_REWRITE_DATA_IP4 hicn_rewrite_iface_data4
-#define HICN_REWRITE_DATA_IP6 hicn_rewrite_iface_data6
-
-#define TRACE_OUTPUT_PKT_IP4 hicn_iface_ip4_output_trace_t
-#define TRACE_OUTPUT_PKT_IP6 hicn_iface_ip6_output_trace_t
-
#define iface_output_x1(ipv) \
do { \
vlib_buffer_t *b0; \
u32 bi0; \
- u32 next0 = ERROR_OUTPUT_IP##ipv; \
+ u32 next0 = next_index; \
hicn_face_t * face; \
\
/* Prefetch for next iteration. */ \
@@ -624,8 +614,7 @@ typedef enum
if (PREDICT_TRUE(face != NULL)) \
{ \
HICN_REWRITE_DATA_IP##ipv \
- (vm, b0, face); \
- next0 = NEXT_DATA_LOOKUP_IP##ipv; \
+ (vm, b0, face, &next0); \
stats.pkts_data_count += 1; \
vlib_increment_combined_counter ( \
&counters[face_id * HICN_N_COUNTER], \
@@ -660,8 +649,8 @@ typedef enum
do { \
vlib_buffer_t *b0, *b1; \
u32 bi0, bi1; \
- u32 next0 = ERROR_OUTPUT_IP##ipv; \
- u32 next1 = ERROR_OUTPUT_IP##ipv; \
+ u32 next0 = next_index; \
+ u32 next1 = next_index; \
hicn_face_t *face0, *face1; \
\
/* Prefetch for next iteration. */ \
@@ -698,8 +687,7 @@ typedef enum
if (PREDICT_TRUE(face0 != NULL)) \
{ \
HICN_REWRITE_DATA_IP##ipv \
- (vm, b0, face0); \
- next0 = NEXT_DATA_LOOKUP_IP##ipv; \
+ (vm, b0, face0, &next0); \
stats.pkts_data_count += 1; \
vlib_increment_combined_counter ( \
&counters[face_id0 * HICN_N_COUNTER], \
@@ -712,8 +700,7 @@ typedef enum
if (PREDICT_TRUE(face1 != NULL)) \
{ \
HICN_REWRITE_DATA_IP##ipv \
- (vm, b1, face1); \
- next1 = NEXT_DATA_LOOKUP_IP##ipv; \
+ (vm, b1, face1, &next1); \
stats.pkts_data_count += 1; \
vlib_increment_combined_counter ( \
&counters[face_id1 * HICN_N_COUNTER], \
@@ -759,7 +746,7 @@ typedef enum
static uword
-hicn_iface_ip4_output_node_fn (vlib_main_t * vm,
+hicn4_iface_output_node_fn (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
@@ -797,12 +784,12 @@ hicn_iface_ip4_output_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn_iface_ip4_output_format_trace (u8 * s, va_list * args)
+hicn4_iface_output_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_ip4_output_trace_t *t =
- va_arg (*args, hicn_iface_ip4_output_trace_t *);
+ hicn4_iface_output_trace_t *t =
+ va_arg (*args, hicn4_iface_output_trace_t *);
s =
format (s, "IFACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -815,28 +802,27 @@ hicn_iface_ip4_output_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_ip4_output_node) =
+VLIB_REGISTER_NODE (hicn4_iface_output_node) =
{
- .function = hicn_iface_ip4_output_node_fn,
- .name = "hicn-iface-ip4-output",
+ .function = hicn4_iface_output_node_fn,
+ .name = "hicn4-iface-output",
.vector_size = sizeof (u32),
- .format_trace = hicn_iface_ip4_output_format_trace,
+ .format_trace = hicn4_iface_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_ip4_output_error_strings),
- .error_strings = hicn_iface_ip4_output_error_strings,
- .n_next_nodes = HICN_IFACE_IP4_OUTPUT_N_NEXT,
+ .n_errors = ARRAY_LEN (hicn4_iface_output_error_strings),
+ .error_strings = hicn4_iface_output_error_strings,
+ .n_next_nodes = HICN4_IFACE_OUTPUT_N_NEXT,
/* edit / add dispositions here */
.next_nodes =
{
- [HICN_IFACE_IP4_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
- [HICN_IFACE_IP4_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
+ [HICN4_IFACE_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
},
};
/* *INDENT-ON* */
static uword
-hicn_iface_ip6_output_node_fn (vlib_main_t * vm,
+hicn6_iface_output_node_fn (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
@@ -873,12 +859,12 @@ hicn_iface_ip6_output_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn_iface_ip6_output_format_trace (u8 * s, va_list * args)
+hicn6_iface_output_format_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_ip6_output_trace_t *t =
- va_arg (*args, hicn_iface_ip6_output_trace_t *);
+ hicn6_iface_output_trace_t *t =
+ va_arg (*args, hicn6_iface_output_trace_t *);
s =
format (s, "IFACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -891,21 +877,20 @@ hicn_iface_ip6_output_format_trace (u8 * s, va_list * args)
* Node registration for the interest forwarder node
*/
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_ip6_output_node) =
+VLIB_REGISTER_NODE (hicn6_iface_output_node) =
{
- .function = hicn_iface_ip6_output_node_fn,
- .name = "hicn-iface-ip6-output",
+ .function = hicn6_iface_output_node_fn,
+ .name = "hicn6-iface-output",
.vector_size = sizeof (u32),
- .format_trace = hicn_iface_ip6_output_format_trace,
+ .format_trace = hicn6_iface_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_ip6_output_error_strings),
- .error_strings = hicn_iface_ip6_output_error_strings,
- .n_next_nodes = HICN_IFACE_IP6_OUTPUT_N_NEXT,
+ .n_errors = ARRAY_LEN (hicn6_iface_output_error_strings),
+ .error_strings = hicn6_iface_output_error_strings,
+ .n_next_nodes = HICN6_IFACE_OUTPUT_N_NEXT,
/* edit / add dispositions here */
.next_nodes =
{
- [HICN_IFACE_IP6_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
- [HICN_IFACE_IP6_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
+ [HICN6_IFACE_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
},
};
/* *INDENT-ON* */
diff --git a/hicn-plugin/src/faces/ip/iface_ip_node.h b/hicn-plugin/src/faces/iface_node.h
index 36923f069..761721b2f 100644
--- a/hicn-plugin/src/faces/ip/iface_ip_node.h
+++ b/hicn-plugin/src/faces/iface_node.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
diff --git a/hicn-plugin/src/faces/ip/dpo_ip.c b/hicn-plugin/src/faces/ip/dpo_ip.c
deleted file mode 100644
index d05fec1a0..000000000
--- a/hicn-plugin/src/faces/ip/dpo_ip.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "dpo_ip.h"
-
-mhash_t hicn_face_ip_local_hashtb;
-mhash_t hicn_face_ip_remote_hashtb;
-dpo_type_t hicn_face_ip_type;
-
-hicn_face_ip_vec_t * hicn_vec_pool;
-
-const static char *const hicn_face_ip4dpoi_nodes[] = {
- "hicn-face-ip4-input",
- "hicn-face-ip4-output",
- "hicn-iface-ip4-input",
- "hicn-iface-ip4-output",
- NULL,
-};
-
-const static char *const hicn_face_ip6dpoi_nodes[] = {
- "hicn-face-ip6-input",
- "hicn-face-ip6-output",
- "hicn-iface-ip6-input",
- "hicn-iface-ip6-output",
- NULL,
-};
-
-const static char *const *const hicn_ip_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = hicn_face_ip4dpoi_nodes,
- [DPO_PROTO_IP6] = hicn_face_ip6dpoi_nodes
-};
-
-const static dpo_vft_t hicn_face_ip_vft = {
- .dv_lock = hicn_face_lock,
- .dv_unlock = hicn_face_unlock,
- .dv_format = format_hicn_face_ip,
-};
-
-/* Must be executed after all the strategy nodes are created */
-void
-hicn_dpo_ip_module_init (void)
-{
- mhash_init (&hicn_face_ip_local_hashtb,
- sizeof (hicn_face_ip_input_faces_t) /* value */ ,
- sizeof (hicn_face_ip_key_t) /* key */ );
- mhash_init (&hicn_face_ip_remote_hashtb,
- sizeof (hicn_face_id_t) /* value */ ,
- sizeof (hicn_face_ip_key_t) /* key */ );
-
- pool_alloc(hicn_vec_pool, 100);
-
- /*
- * How much useful is the following registration?
- * So far it seems that we need it only for setting the dpo_type.
- */
- hicn_face_ip_type =
- dpo_register_new_type (&hicn_face_ip_vft, hicn_ip_nodes);
-}
-
-void
-hicn_dpo_ip_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
- u16 dpoi_next_node)
-{
- hicn_face_id_t face_dpoi_id = hicn_dpoi_get_index (face);
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
- dpo_set (dpo, face->shared.face_type,
- ip46_address_is_ip4 (&ip_face->local_addr) ? DPO_PROTO_IP4 :
- DPO_PROTO_IP6, face_dpoi_id);
- dpo->dpoi_next_node = dpoi_next_node;
-}
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/ip/face_ip.c b/hicn-plugin/src/faces/ip/face_ip.c
deleted file mode 100644
index a2fe069ed..000000000
--- a/hicn-plugin/src/faces/ip/face_ip.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates. Licensed under the
- * Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the
- * License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-#include <vnet/adj/adj_midchain.h>
-#include <vnet/adj/adj.h>
-
-#include "face_ip.h"
-#include "face_ip_node.h"
-#include "dpo_ip.h"
-#include "../../strategy_dpo_manager.h"
-#include "../face.h"
-#include "../../cache_policies/cs_lru.h"
-#include "../../infra.h"
-#include "../../hicn.h"
-#include "../app/face_prod.h"
-#include "../app/face_cons.h"
-
-#include "../../mapme.h" // HICN_MAPME_EVENT_*
-#include "../../mapme_eventmgr.h" // hicn_mapme_eventmgr_process_node
-
-extern vlib_node_registration_t hicn_mapme_eventmgr_process_node;
-
-u32 strategy_face_ip4_vlib_edge;
-u32 strategy_face_ip6_vlib_edge;
-
-void
-hicn_face_ip_init (vlib_main_t * vm)
-{
- int strategy_nodes_n = hicn_strategy_get_all_available ();
-
- /* Default Strategy has index 0 and it always exists */
- strategy_face_ip4_vlib_edge = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_ip4_output_node.index);
-
- strategy_face_ip6_vlib_edge = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_ip6_output_node.index);
- /*
- * Create and edge between al the other strategy nodes and the
- * ip_encap nodes.
- */
- for (int i = 1; i < strategy_nodes_n; i++)
- {
- u32 temp_index4 = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_ip4_output_node.index);
- u32 temp_index6 = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_ip6_output_node.index);
- ASSERT (temp_index4 == strategy_face_ip4_vlib_edge);
- ASSERT (temp_index6 == strategy_face_ip6_vlib_edge);
- }
-
- u32 temp_index4 = vlib_node_add_next (vm,
- hicn_interest_hitpit_node.index,
- hicn_face_ip4_output_node.index);
- u32 temp_index6 = vlib_node_add_next (vm,
- hicn_interest_hitpit_node.index,
- hicn_face_ip6_output_node.index);
-
- ASSERT (temp_index4 == strategy_face_ip4_vlib_edge);
- ASSERT (temp_index6 == strategy_face_ip6_vlib_edge);
-
-
- hicn_dpo_ip_module_init ();
-
- register_face_type (hicn_face_ip_type, &ip_vft, "ip");
-}
-
-int
-hicn_face_ip_del (hicn_face_id_t face_id)
-{
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- hicn_face_ip_t *face_ip = (hicn_face_ip_t *) face->data;
- hicn_face_ip_key_t key;
- hicn_face_ip_key_t old_key;
- hicn_face_ip_key_t old_key2;
-
- if (ip46_address_is_ip4 (&face_ip->local_addr))
- {
- hicn_face_ip4_get_key (&(face_ip->local_addr.ip4), face->shared.sw_if,
- &key);
- hicn_face_ip_input_faces_t *in_faces_vec =
- hicn_face_ip4_get_vec (&(face_ip->local_addr.ip4), face->shared.sw_if,
- &hicn_face_ip_local_hashtb);
- if (in_faces_vec != NULL)
- {
- hicn_face_ip_vec_t *vec =
- pool_elt_at_index (hicn_vec_pool, in_faces_vec->vec_id);
- u32 index_face = vec_search (*vec, face_id);
- vec_del1 (*vec, index_face);
-
- if (vec_len (*vec) == 0)
- {
- pool_put_index (hicn_vec_pool, in_faces_vec->vec_id);
- mhash_unset (&hicn_face_ip_local_hashtb, &key,
- (uword *) & old_key);
- vec_free (*vec);
- }
- else
- {
- /* Check if the face we are deleting is the preferred one. */
- /* If so, repleace with another. */
- if (in_faces_vec->face_id == face_id)
- {
- in_faces_vec->face_id = (*vec)[0];
- }
- }
- hicn_face_ip4_get_key (&(face_ip->remote_addr.ip4),
- face->shared.sw_if, &key);
- mhash_unset (&hicn_face_ip_remote_hashtb, &key,
- (uword *) & old_key2);
- }
- }
- else
- {
- hicn_face_ip6_get_key (&(face_ip->local_addr.ip6), face->shared.sw_if,
- &key);
-
- hicn_face_ip_input_faces_t *in_faces_vec =
- hicn_face_ip6_get_vec (&(face_ip->local_addr.ip6), face->shared.sw_if,
- &hicn_face_ip_local_hashtb);
- if (in_faces_vec != NULL)
- {
- hicn_face_ip_vec_t *vec =
- pool_elt_at_index (hicn_vec_pool, in_faces_vec->vec_id);
- u32 index_face = vec_search (*vec, face_id);
- vec_del1 (*vec, index_face);
-
- if (vec_len (*vec) == 0)
- {
- pool_put (hicn_vec_pool, vec);
- mhash_unset (&hicn_face_ip_local_hashtb, &key,
- (uword *) & old_key);
- vec_free (*vec);
- }
- else
- {
- /* Check if the face we are deleting is the preferred one. */
- /* If so, repleace with another. */
- if (in_faces_vec->face_id == face_id)
- {
- in_faces_vec->face_id = (*vec)[0];
- }
- }
- hicn_face_ip6_get_key (&(face_ip->remote_addr.ip6),
- face->shared.sw_if, &key);
- mhash_unset (&hicn_face_ip_remote_hashtb, &key,
- (uword *) & old_key);
- }
- }
- return hicn_face_del (face_id);
-}
-
-/**
- * @brief Helper for handling midchain adjacencies
- */
-void
-face_midchain_fixup_t (vlib_main_t * vm,
- const struct ip_adjacency_t_ *adj,
- vlib_buffer_t * b0, const void *data)
-{
- vnet_buffer (b0)->sw_if_index[VLIB_TX] = 0;
-};
-
-/**
- * @brief Build a rewrite string for the face.
- */
-static u8 *
-face_build_rewrite_i (void)
-{
- /*
- * passing the adj code a NULL rewrite means 'i don't have one cos
- * t'other end is unresolved'. That's not the case here. For the mpls
- * tunnel there are just no bytes of encap to apply in the adj. We'll impose
- * the label stack once we choose a path. So return a zero length rewrite.
- */
- u8 *rewrite = NULL;
-
- vec_validate (rewrite, 0);
- vec_reset_length (rewrite);
-
- return (rewrite);
-}
-
-always_inline int
-hicn_face_ip_find_adj (const ip46_address_t * remote_addr,
- int sw_if, adj_index_t * adj)
-{
- fib_prefix_t fib_pfx;
- fib_node_index_t fib_entry_index;
- fib_prefix_from_ip46_addr (remote_addr, &fib_pfx);
- fib_pfx.fp_len = ip46_address_is_ip4 (remote_addr) ? 32 : 128;
- vnet_link_t link_type =
- ip46_address_is_ip4 (&fib_pfx.fp_addr) ? VNET_LINK_IP4 : VNET_LINK_IP6;
- *adj = adj_nbr_find (fib_pfx.fp_proto, link_type, &fib_pfx.fp_addr, sw_if);
-
- if (*adj == ADJ_INDEX_INVALID)
- {
- u32 fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
- HICN_FIB_TABLE,
- FIB_SOURCE_PRIORITY_HI);
-
- fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
-
- if (fib_entry_index == (FIB_NODE_INDEX_INVALID))
- return HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;
-
- *adj = fib_entry_get_adj (fib_entry_index);
- ip_adjacency_t *temp = NULL;
- if (*adj != ~0)
- temp = adj_get (*adj);
-
- if (temp == NULL || temp->lookup_next_index <= IP_LOOKUP_NEXT_MIDCHAIN)
- {
- if (sw_if != ~0)
- *adj =
- adj_nbr_add_or_lock (fib_pfx.fp_proto, link_type, remote_addr,
- sw_if);
- else
- return HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;
- }
- else
- {
- adj_nbr_midchain_update_rewrite (*adj, &face_midchain_fixup_t, NULL,
- ADJ_FLAG_NONE,
- face_build_rewrite_i ());
- adj_midchain_delegate_stack (*adj, fib_index, &fib_pfx);
- }
- }
-
- return HICN_ERROR_NONE;
-}
-
-/*
- * Utility that adds a new face cache entry. For the moment we assume that
- * the ip_adjacency has already been set up.
- */
-int
-hicn_face_ip_add (const ip46_address_t * local_addr,
- const ip46_address_t * remote_addr,
- int sw_if, hicn_face_id_t * pfaceid, u8 is_app_prod)
-{
- dpo_proto_t dpo_proto;
-
- /* Check if we found at least one ip address */
- if (ip46_address_is_zero (remote_addr))
- return HICN_ERROR_FACE_NO_GLOBAL_IP;
-
- hicn_face_flags_t flags = (hicn_face_flags_t) 0;
- flags |= HICN_FACE_FLAGS_FACE;
-
- hicn_face_t *face;
- if (ip46_address_is_ip4 (local_addr))
- {
- face =
- hicn_face_ip4_get (&(remote_addr->ip4), sw_if,
- &hicn_face_ip_remote_hashtb);
-
- /* If remote matches the face we need to check if it is an incomplete face */
- if (face == NULL)
- {
- hicn_iface_ip_add (local_addr, remote_addr, sw_if, pfaceid);
- face = hicn_dpoi_get_from_idx (*pfaceid);
- }
- else
- {
- *pfaceid = hicn_dpoi_get_index (face);
- }
-
- if (!(face->shared.flags & HICN_FACE_FLAGS_IFACE))
- return HICN_ERROR_FACE_ALREADY_CREATED;
-
- hicn_face_ip_key_t key;
- hicn_face_ip4_get_key (&(local_addr->ip4), sw_if, &key);
-
- hicn_face_ip_input_faces_t *in_faces =
- hicn_face_ip4_get_vec (&(local_addr->ip4), sw_if,
- &hicn_face_ip_local_hashtb);
-
- if (in_faces == NULL)
- {
- adj_index_t adj;
- int ret = hicn_face_ip_find_adj (remote_addr, sw_if, &adj);
- if (ret != HICN_ERROR_NONE)
- return ret;
-
- hicn_face_ip_input_faces_t in_faces_temp;
- hicn_face_ip_vec_t *vec;
- pool_get (hicn_vec_pool, vec);
- *vec = vec_new (hicn_face_ip_vec_t, 0);
- u32 index = vec - hicn_vec_pool;
- in_faces_temp.vec_id = index;
- vec_add1 (*vec, *pfaceid);
-
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
- clib_memcpy (&ip_face->local_addr, local_addr,
- sizeof (ip4_address_t));
- clib_memcpy (&ip_face->remote_addr, remote_addr,
- sizeof (ip4_address_t));
- face->shared.sw_if = sw_if;
- face->shared.flags = flags;
- face->shared.adj = adj;
-
- dpo_proto = DPO_PROTO_IP4;
-
- in_faces_temp.face_id = *pfaceid;
-
- mhash_set_mem (&hicn_face_ip_local_hashtb, &key,
- (uword *) & in_faces_temp, 0);
- }
- else
- {
- hicn_face_ip_vec_t *vec =
- pool_elt_at_index (hicn_vec_pool, in_faces->vec_id);
-
- /* */
- if (vec_search (*vec, *pfaceid) != ~0)
- return HICN_ERROR_FACE_ALREADY_CREATED;
-
- adj_index_t adj;
- int ret = hicn_face_ip_find_adj (remote_addr, sw_if, &adj);
- if (ret != HICN_ERROR_NONE)
- return ret;
-
- vec_add1 (*vec, *pfaceid);
-
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
- clib_memcpy (&ip_face->local_addr, local_addr,
- sizeof (ip4_address_t));
- clib_memcpy (&ip_face->remote_addr, remote_addr,
- sizeof (ip4_address_t));
- face->shared.sw_if = sw_if;
- face->shared.flags = flags;
- face->shared.adj = adj;
-
- dpo_proto = DPO_PROTO_IP4;
-
- mhash_set_mem (&hicn_face_ip_local_hashtb, &key, (uword *) in_faces,
- 0);
-
- /* If the face is an application producer face, we set it as the preferred incoming face. */
- /* This is required to handle the CS separation, and the push api in a lightway */
- if (is_app_prod)
- {
- in_faces->face_id = *pfaceid;
- }
- }
- }
- else
- {
- face =
- hicn_face_ip6_get (&(remote_addr->ip6), sw_if,
- &hicn_face_ip_remote_hashtb);
-
- /* If remote matches the face is a iface */
- if (face == NULL)
- {
- hicn_iface_ip_add (local_addr, remote_addr, sw_if, pfaceid);
- face = hicn_dpoi_get_from_idx (*pfaceid);
- }
- else
- {
- *pfaceid = hicn_dpoi_get_index (face);
- }
-
- if (!(face->shared.flags & HICN_FACE_FLAGS_IFACE))
- return HICN_ERROR_FACE_ALREADY_CREATED;
-
- hicn_face_ip_key_t key;
- hicn_face_ip6_get_key (&(local_addr->ip6), sw_if, &key);
-
- hicn_face_ip_input_faces_t *in_faces =
- hicn_face_ip6_get_vec (&(local_addr->ip6), sw_if,
- &hicn_face_ip_local_hashtb);
-
- if (in_faces == NULL)
- {
- adj_index_t adj;
- int ret = hicn_face_ip_find_adj (remote_addr, sw_if, &adj);
- if (ret != HICN_ERROR_NONE)
- return ret;
-
- hicn_face_ip_input_faces_t in_faces_temp;
- hicn_face_ip_vec_t *vec;
- pool_get (hicn_vec_pool, vec);
- vec_alloc (*vec, 1);
- u32 index = vec - hicn_vec_pool;
- in_faces_temp.vec_id = index;
- vec_add1 (*vec, *pfaceid);
-
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
- clib_memcpy (&ip_face->local_addr, local_addr,
- sizeof (ip6_address_t));
- clib_memcpy (&ip_face->remote_addr, remote_addr,
- sizeof (ip6_address_t));
- face->shared.sw_if = sw_if;
- face->shared.flags = flags;
- face->shared.adj = adj;
-
- dpo_proto = DPO_PROTO_IP6;
-
- in_faces_temp.face_id = *pfaceid;
-
- mhash_set_mem (&hicn_face_ip_local_hashtb, &key,
- (uword *) & in_faces_temp, 0);
- }
- else
- {
- hicn_face_ip_vec_t *vec =
- pool_elt_at_index (hicn_vec_pool, in_faces->vec_id);
-
- /* */
- if (vec_search (*vec, *pfaceid) != ~0)
- return HICN_ERROR_FACE_ALREADY_CREATED;
-
- adj_index_t adj;
- int ret = hicn_face_ip_find_adj (remote_addr, sw_if, &adj);
- if (ret != HICN_ERROR_NONE)
- return ret;
-
- vec_add1 (*vec, *pfaceid);
-
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
- clib_memcpy (&ip_face->local_addr, local_addr,
- sizeof (ip6_address_t));
- clib_memcpy (&ip_face->remote_addr, remote_addr,
- sizeof (ip6_address_t));
- face->shared.sw_if = sw_if;
- face->shared.flags = flags;
- face->shared.adj = adj;
-
- dpo_proto = DPO_PROTO_IP6;
-
- mhash_set_mem (&hicn_face_ip_local_hashtb, &key, (uword *) in_faces,
- 0);
-
- /* If the face is an application producer face, we set it as the preferred incoming face. */
- /* This is required to handle the CS separation, and the push api in a lightway */
- if (is_app_prod)
- {
- in_faces->face_id = *pfaceid;
- }
- }
- }
-
- retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
- hicn_mapme_eventmgr_process_node.index,
- HICN_MAPME_EVENT_FACE_ADD, 1,
- sizeof (retx_t));
-
- /* *INDENT-OFF* */
- *retx = (retx_t)
- {
- .prefix = 0,
- .dpo = (dpo_id_t)
- {
- .dpoi_type = hicn_face_ip_type,
- .dpoi_proto = dpo_proto,
- .dpoi_next_node = 0,
- .dpoi_index = *pfaceid,
- }
- };
- /* *INDENT-ON* */
-
- return HICN_ERROR_NONE;
-}
-
-u8 *
-format_hicn_face_ip (u8 * s, va_list * args)
-{
- index_t index = va_arg (*args, index_t);
- CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
- hicn_face_t *face;
- hicn_face_ip_t *ip_face;
- ip_adjacency_t *adj;
- vnet_main_t *vnm = vnet_get_main ();
-
- face = hicn_dpoi_get_from_idx (index);
- ip_face = (hicn_face_ip_t *) face->data;
-
- if (face->shared.flags & HICN_FACE_FLAGS_FACE)
- {
- ASSERT (face->shared.adj != (adj_index_t) ~ 0);
- adj = adj_get (face->shared.adj);
-
- hicn_face_id_t face_id = hicn_dpoi_get_index (face);
- s = format (s, "%U Face %d: ", format_white_space, indent, face_id);
- s = format (s, "type IP local %U ",
- format_ip46_address, &ip_face->local_addr, IP46_TYPE_ANY);
- s =
- format (s, "remote %U ", format_ip46_address, &ip_face->remote_addr,
- IP46_TYPE_ANY);
- s = format (s, "%U", format_vnet_link, adj->ia_link);
-
- vnet_sw_interface_t *sw_int =
- vnet_get_sw_interface_or_null (vnm, face->shared.sw_if);
- if (sw_int != NULL)
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm, sw_int);
-
-
- if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD))
- s = format (s, " %U", format_hicn_face_prod, face_id, 0);
- else if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS))
- s = format (s, " %U", format_hicn_face_cons, face_id, 0);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
- s = format (s, " (deleted)");
- }
- else
- {
- hicn_face_id_t face_id = hicn_dpoi_get_index (face);
- s = format (s, "%U iFace %d: ", format_white_space, indent, face_id);
- s = format (s, "type IP local %U remote %U",
- format_ip46_address, &ip_face->local_addr, IP46_TYPE_ANY,
- format_ip46_address, &ip_face->remote_addr, IP46_TYPE_ANY);
-
- vnet_sw_interface_t *sw_int =
- vnet_get_sw_interface_or_null (vnm, face->shared.sw_if);
- if (sw_int != NULL)
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm, sw_int);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD))
- s = format (s, " %U", format_hicn_face_prod, face_id, 0);
- else if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS))
- s = format (s, " %U", format_hicn_face_cons, face_id, 0);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
- s = format (s, " (deleted)");
- }
-
- return s;
-}
-
-void
-hicn_face_ip_get_dpo (hicn_face_t * face, dpo_id_t * dpo)
-{
-
- hicn_face_ip_t *face_ip = (hicn_face_ip_t *) face->data;
- return hicn_dpo_ip_create_from_face (face, dpo,
- ip46_address_is_ip4
- (&face_ip->remote_addr) ?
- strategy_face_ip4_vlib_edge :
- strategy_face_ip6_vlib_edge);
-}
-
-hicn_face_vft_t ip_vft = {
- .format_face = format_hicn_face_ip,
- .hicn_face_del = hicn_face_ip_del,
- .hicn_face_get_dpo = hicn_face_ip_get_dpo,
-};
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/ip/face_ip.h b/hicn-plugin/src/faces/ip/face_ip.h
deleted file mode 100644
index 74f3a83dc..000000000
--- a/hicn-plugin/src/faces/ip/face_ip.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HICN_FACE_IP_H__
-#define __HICN_FACE_IP_H__
-
-#include <vlib/vlib.h>
-#include <vnet/vnet.h>
-#include "../face.h"
-#include "../../cache_policies/cs_policy.h"
-
-/**
- * @file
- *
- * @brief IP face
- *
- * A face is carried through nodes as a dpo. The face state is the object
- * pointed by the dpoi_index in the dpo_id_t (see
- * https://docs.fd.io/vpp/18.07/d0/d37/dpo_8h_source.html)
- */
-typedef struct hicn_ip_face_t_
-{
- /**
- * The headers to paint, in packet painting order
- */
- /* Local address of the interface sw_if */
- ip46_address_t local_addr;
-
- /* Remote address of neighbor */
- ip46_address_t remote_addr;
-
-} hicn_face_ip_t;
-
-/**
- * @bried vector of faces used to collect faces having the same local address
- *
- */
-typedef hicn_face_id_t *hicn_face_ip_vec_t;
-
-typedef struct hicn_ip_input_faces_s_
-{
- /* Vector of all possible input faces */
- u32 vec_id;
-
- /* Preferred face. If an prod_app face is in the vector it will be the preferred one. */
- /* It's not possible to have multiple prod_app face in the same vector, they would have */
- /* the same local address. Every prod_app face is a point-to-point face between the forwarder */
- /* and the application. */
- hicn_face_id_t face_id;
-
-} hicn_face_ip_input_faces_t;
-
-/**
- * Hash tables that indexes a face by local address. For fast lookup when an
- * data arrives.
- */
-extern mhash_t hicn_face_ip_local_hashtb;
-
-/**
- * Hash tables that indexes a face by remote address. For fast lookup when an
- * interest arrives.
- */
-extern mhash_t hicn_face_ip_remote_hashtb;
-
-/**
- * Pool containing the vector of possible incoming faces.
- */
-extern hicn_face_ip_vec_t *hicn_vec_pool;
-
-/**
- * Key definition for the mhash table. An ip face is uniquely identified by ip
- * address and the interface id. The ip address can correspond to the remote ip
- * address of the next hicn hop, or to the local address of the receiving
- * interface. The former is used to retrieve the incoming face when an interest
- * is received, the latter when the arring packet is a data.
- */
-typedef struct hicn_face_ip_key_s
-{
- ip46_address_t addr;
- u32 sw_if;
-} hicn_face_ip_key_t;
-
-
-extern hicn_face_type_t hicn_face_ip_type;
-extern hicn_face_vft_t ip_vft;
-
-/**
- * @brief Create the key object for the mhash. Fill in the key object with the
- * expected values.
- *
- * @param addr Local or remote ip v6 address of the face
- * @param sw_if interface associated to the face
- * @param key Pointer to an allocated hicn_face_ip_key_t object
- */
-always_inline void
-hicn_face_ip6_get_key (const ip6_address_t * addr,
- u32 sw_if, hicn_face_ip_key_t * key)
-{
- key->addr.ip6 = *addr;
- key->sw_if = sw_if;
-}
-
-
-/**
- * @brief Create the key object for the mhash. Fill in the key object with the
- * expected values.
- *
- * @param addr Local or remote ip v4 address of the face
- * @param sw_if interface associated to the face
- * @param key Pointer to an allocated hicn_face_ip_key_t object
- */
-always_inline void
-hicn_face_ip4_get_key (const ip4_address_t * addr,
- u32 sw_if, hicn_face_ip_key_t * key)
-{
- ip46_address_set_ip4 (&(key->addr), addr);
- key->sw_if = sw_if;
-}
-
-/**
- * @brief Get the dpoi from the ip v4 address. Does not add any lock.
- *
- * @param addr Ip v4 address used to create the key for the hash table.
- * @param sw_if Software interface id used to create the key for the hash table.
- * @param hashtb Hash table (remote or local) where to perform the lookup.
- *
- * @result Pointer to the face.
- */
-always_inline hicn_face_t *
-hicn_face_ip4_get (const ip4_address_t * addr, u32 sw_if, mhash_t * hashtb)
-{
- hicn_face_ip_key_t key;
-
- hicn_face_ip4_get_key (addr, sw_if, &key);
-
- hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb,
- &key);
-
- return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
-}
-
-/**
- * @brief Get the vector of faces from the ip v4 address. Does not add any lock.
- *
- * @param addr Ip v4 address used to create the key for the hash table.
- * @param sw_if Software interface id used to create the key for the hash table.
- * @param hashtb Hash table (remote or local) where to perform the lookup.
- *
- * @result Pointer to the face.
- */
-always_inline hicn_face_ip_input_faces_t *
-hicn_face_ip4_get_vec (const ip4_address_t * addr, u32 sw_if,
- mhash_t * hashtb)
-{
- hicn_face_ip_key_t key;
-
- hicn_face_ip4_get_key (addr, sw_if, &key);
- return (hicn_face_ip_input_faces_t *) mhash_get (hashtb, &key);
-}
-
-/**
- * @brief Get the vector of faces from the ip v6 address. Does not add any lock.
- *
- * @param addr Ip v6 address used to create the key for the hash table.
- * @param sw_if Software interface id used to create the key for the hash table.
- * @param hashtb Hash table (remote or local) where to perform the lookup.
- *
- * @result Pointer to the face.
- */
-always_inline hicn_face_ip_input_faces_t *
-hicn_face_ip6_get_vec (const ip6_address_t * addr, u32 sw_if,
- mhash_t * hashtb)
-{
- hicn_face_ip_key_t key;
-
- hicn_face_ip6_get_key (addr, sw_if, &key);
- return (hicn_face_ip_input_faces_t *) mhash_get (hashtb, &key);
-}
-
-/**
- * @brief Get the dpoi from the ip v6 address. Does not add any lock.
- *
- * @param addr Ip v6 address used to create the key for the hash table.
- * @param sw_if Software interface id used to create the key for the hash table.
- * @param hashtb Hash table (remote or local) where to perform the lookup.
- *
- * @result Pointer to the face.
- */
-always_inline hicn_face_t *
-hicn_face_ip6_get (const ip6_address_t * addr, u32 sw_if, mhash_t * hashtb)
-{
- hicn_face_ip_key_t key;
-
- hicn_face_ip6_get_key (addr, sw_if, &key);
-
- hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb,
- &key);
-
- return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
-}
-
-/**
- * @brief Create a new face ip. API for other modules (e.g., routing)
- *
- * @param local_addr Local ip v4 or v6 address of the face
- * @param remote_addr Remote ip v4 or v6 address of the face
- * @param sw_if interface associated to the face
- * @param is_app_face Boolean to set the face as an application face
- * @param pfaceid Pointer to return the face id
- * @param is_app_prod if HICN_FACE_FLAGS_APPFACE_PROD the face is a local application face, all other values are ignored
- * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally
- * reachable ip address, otherwise HICN_ERROR_NONE
- */
-int hicn_face_ip_add (const ip46_address_t * local_addr,
- const ip46_address_t * remote_addr,
- int swif, hicn_face_id_t * pfaceid, u8 is_app_prod);
-
-/**
- * @brief Create a new incomplete face ip. (Meant to be used by the data plane)
- *
- * @param local_addr Local ip v4 or v6 address of the face
- * @param remote_addr Remote ip v4 or 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_ip_add (const ip46_address_t * local_addr,
- const ip46_address_t * remote_addr,
- int sw_if, hicn_face_id_t * pfaceid)
-{
- hicn_face_t *face;
- pool_get (hicn_dpoi_face_pool, face);
-
- hicn_face_ip_t *ip_face = (hicn_face_ip_t *) (face->data);
-
- clib_memcpy (&(ip_face->local_addr.ip6), local_addr,
- sizeof (ip6_address_t));
- clib_memcpy (&(ip_face->remote_addr.ip6), remote_addr,
- sizeof (ip6_address_t));
- face->shared.sw_if = sw_if;
-
- face->shared.adj = ADJ_INDEX_INVALID;
- face->shared.pl_id = (u16) 0;
- face->shared.face_type = hicn_face_ip_type;
- face->shared.flags = HICN_FACE_FLAGS_IFACE;
- face->shared.locks = 1;
-
- hicn_face_ip_key_t key;
- hicn_face_ip6_get_key (&(remote_addr->ip6), sw_if, &key);
- *pfaceid = hicn_dpoi_get_index (face);
-
- mhash_set_mem (&hicn_face_ip_remote_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
- * @return HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise
- * HICN_ERROR_NONE
- */
-int hicn_face_ip_del (hicn_face_id_t face_id);
-
-/**
- * @brief Format a IP face
- *
- * @param s Pointer to a previous string. If null it will be initialize
- * @param args Array storing input values. Expected u32 face_id and u32 indent
- * @return String with the formatted face
- */
-u8 *format_hicn_face_ip (u8 * s, va_list * args);
-
-/**
- * @brief Create a dpo from an ip face
- *
- * @param face Face from which to create the dpo
- * @return the dpo
- */
-void hicn_face_ip_get_dpo (hicn_face_t * face, dpo_id_t * dpo);
-
-#endif // __HICN_FACE_IP_H__
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/ip/face_ip_cli.c b/hicn-plugin/src/faces/ip/face_ip_cli.c
deleted file mode 100644
index 4c4986f97..000000000
--- a/hicn-plugin/src/faces/ip/face_ip_cli.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vnet/vnet.h>
-#include <vnet/dpo/dpo.h>
-#include <vlib/vlib.h>
-
-#include "face_ip.h"
-#include "dpo_ip.h"
-#include "../face.h"
-
-#define HICN_FACE_NONE 0
-#define HICN_FACE_DELETE 1
-#define HICN_FACE_ADD 2
-
-static clib_error_t *
-hicn_face_ip_cli_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
-{
- vnet_main_t *vnm = vnet_get_main ();
- ip46_address_t local_addr;
- ip46_address_t remote_addr;
- hicn_face_id_t face_id = HICN_FACE_NULL;
- int ret = HICN_ERROR_NONE;
- int sw_if;
- int face_op = HICN_FACE_NONE;
-
- ip46_address_reset (&local_addr);
- /* Get a line of input. */
- unformat_input_t _line_input, *line_input = &_line_input;
- if (!unformat_user (main_input, unformat_line_input, line_input))
- {
- return (0);
- }
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "del"))
- {
- if (unformat (line_input, "id %d", &face_id))
- face_op = HICN_FACE_DELETE;
- else
- {
- return clib_error_return (0, "missing face id");
- }
- }
- else if (unformat (line_input, "add"))
- {
- face_op = HICN_FACE_ADD;
- if (unformat (line_input, "local %U",
- unformat_ip46_address, &local_addr, IP46_TYPE_ANY));
-
- if (unformat (line_input, "remote %U intfc %U",
- unformat_ip46_address, &remote_addr,
- IP46_TYPE_ANY, unformat_vnet_sw_interface, vnm,
- &sw_if));
- else
- {
- return clib_error_return (0, "%s '%U'",
- get_error_string
- (HICN_ERROR_CLI_INVAL),
- format_unformat_error, line_input);
- }
- }
- else
- {
- return clib_error_return (0, "%s '%U'",
- get_error_string (HICN_ERROR_CLI_INVAL),
- format_unformat_error, line_input);
- }
- }
-
- if (face_id != HICN_FACE_NULL)
- {
-
- if (!hicn_dpoi_idx_is_valid (face_id))
- {
- return clib_error_return (0, "%s, face_id %d not valid",
- get_error_string (ret), face_id);
- }
- }
-
- int rv;
- switch (face_op)
- {
- case HICN_FACE_ADD:
-
- /* Check for presence of next hop address */
- if ((remote_addr.as_u64[0] == (u64) 0)
- && (remote_addr.as_u64[1] == (u64) 0))
- {
- return clib_error_return (0, "next hop address not specified");
- }
-
- if (ip46_address_is_zero (&local_addr))
- {
- if (!vnet_sw_interface_is_valid (vnm, sw_if))
- return clib_error_return (0, "interface not valid");
-
- if (ip46_address_is_ip4 (&remote_addr))
- {
- ip_interface_address_t *interface_address;
- ip4_address_t *addr =
- ip4_interface_address_matching_destination (&ip4_main,
- &remote_addr.ip4,
- sw_if,
- &interface_address);
-
- if (addr == NULL)
- addr = ip4_interface_first_address (&ip4_main,
- sw_if,
- &interface_address);
-
- if (addr == NULL)
- return clib_error_return (0,
- "no valid ip address on interface %d",
- sw_if);
-
- ip46_address_set_ip4 (&local_addr, addr);
- }
- else
- {
- ip_interface_address_t *interface_address;
- ip6_interface_address_matching_destination (&ip6_main,
- &remote_addr.ip6,
- sw_if,
- &interface_address);
-
- ip6_address_t *addr = NULL;
- if (interface_address != NULL)
- addr =
- (ip6_address_t *)
- ip_interface_address_get_address (&ip6_main.lookup_main,
- interface_address);
-
- if (addr == NULL)
- addr = ip6_interface_first_address (&ip6_main, sw_if);
-
- if (addr == NULL)
- return clib_error_return (0,
- "no valid ip address on interface %d",
- sw_if);
-
- ip46_address_set_ip6 (&local_addr, addr);
- }
- }
-
- rv = hicn_face_ip_add (&local_addr, &remote_addr, sw_if, &face_id, 0);
-
- if (rv == HICN_ERROR_NONE)
- {
- vlib_cli_output (vm, "Face id: %d", face_id);
- }
- else
- {
- return clib_error_return (0, get_error_string (rv));
- }
- break;
- case HICN_FACE_DELETE:
- rv = hicn_face_ip_del (face_id);
- if (rv == HICN_ERROR_NONE)
- {
- vlib_cli_output (vm, "Face %d deleted", face_id);
- }
- else
- {
- return clib_error_return (0, get_error_string (rv));
- }
- break;
- default:
- return clib_error_return (0, "Operation (%d) not implemented", face_op);
- break;
- }
- return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
- get_error_string
- (rv));
-}
-
-/* cli declaration for 'cfg face' */
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (hicn_face_ip_cli_set_command, static) =
-{
- .path = "hicn face ip",
- .short_help = "hicn face ip {add [local <src_address>] remote <dst_address> intfc <sw_if>} | {del id <face_id>}",
- .function = hicn_face_ip_cli_set_command_fn,
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/ip/face_ip_node.h b/hicn-plugin/src/faces/ip/face_ip_node.h
deleted file mode 100644
index 000395a04..000000000
--- a/hicn-plugin/src/faces/ip/face_ip_node.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HICN_FACE_IP_NODE_H__
-#define __HICN_FACE_IP_NODE_H__
-
-#include <vlib/vlib.h>
-#include <vnet/vnet.h>
-
-extern vlib_node_registration_t hicn_face_ip4_input_node;
-extern vlib_node_registration_t hicn_face_ip4_output_node;
-extern vlib_node_registration_t hicn_face_ip6_input_node;
-extern vlib_node_registration_t hicn_face_ip6_output_node;
-
-/**
- * @brief Initialize the ip face module
- */
-void hicn_face_ip_init (vlib_main_t * vm);
-
-#endif // __HICN_FACE_IP_NODE_H__
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.c b/hicn-plugin/src/faces/udp/dpo_udp.c
deleted file mode 100644
index 987d52bb7..000000000
--- a/hicn-plugin/src/faces/udp/dpo_udp.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "dpo_udp.h"
-
-#include <vnet/ip/format.h>
-#include <vnet/adj/adj.h>
-#include <vnet/vnet.h>
-#include <vlib/vlib.h>
-
-const static char *const hicn_face_ip4udp_nodes[] = {
- "hicn-face-encap-udp4",
- "hicn-face-decap-udp4",
- "hicn-iface-decap-udp4",
- "hicn-iface-encap-udp4",
- NULL,
-};
-
-const static char *const hicn_face_ip6udp_nodes[] = {
- "hicn-face-encap-udp6",
- "hicn-face-decap-udp6",
- "hicn-iface-decap-udp6",
- "hicn-iface-encap-udp6",
- NULL,
-};
-
-const static char *const *const hicn_ipudp_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = hicn_face_ip4udp_nodes,
- [DPO_PROTO_IP6] = hicn_face_ip6udp_nodes
-};
-
-
-const static dpo_vft_t hicn_dpoi_udp_vft = {
- .dv_lock = hicn_face_lock,
- .dv_unlock = hicn_face_unlock,
- .dv_format = format_hicn_face_udp,
-};
-
-/* Must be executed after all the strategy nodes are created */
-void
-hicn_dpo_udp_module_init (void)
-{
- mhash_init (&hicn_face_udp_hashtb, sizeof (hicn_face_id_t) /* value */ ,
- sizeof (hicn_face_udp_key_t) /* key */ );
-
- /*
- * How much useful is the following registration?
- * So far it seems that we need it only for setting the dpo_type.
- */
- hicn_face_udp_type =
- dpo_register_new_type (&hicn_dpoi_udp_vft, hicn_ipudp_nodes);
-}
-
-
-/* Here udp ports are in host order, move them to network order to do the lookup */
-int
-hicn_dpo_udp4_create (dpo_id_t * dpo,
- const ip4_address_t * src_ip,
- const ip4_address_t * dst_ip,
- u16 src_port, u16 dst_port,
- u32 sw_if,
- adj_index_t ip_adj,
- u32 node_index,
- hicn_face_flags_t flags, hicn_face_id_t * face_id)
-{
- u16 net_src_port = clib_host_to_net_u16 (src_port);
- u16 net_dst_port = clib_host_to_net_u16 (dst_port);
- hicn_face_t *face =
- hicn_face_udp4_get (src_ip, dst_ip, net_src_port, net_dst_port);
-
- u8 hicnb_flags;
- /* ip_csum_t sum0; */
-
- if (face != NULL)
- return HICN_ERROR_FACE_ALREADY_CREATED;
-
- hicn_dpo_udp4_add_and_lock (dpo, src_ip, dst_ip, net_src_port, net_dst_port,
- node_index, &hicnb_flags, sw_if);
-
- face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
-
- hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data;
-
- udp_face->hdrs.ip4.ip.checksum =
- ip4_header_checksum (&(udp_face->hdrs.ip4.ip));
-
- face->shared.flags = flags;
- face->shared.adj = ip_adj;
- *face_id = hicn_dpoi_get_index (face);
-
- return HICN_ERROR_NONE;
-}
-
-
-int
-hicn_dpo_udp6_create (dpo_id_t * dpo,
- const ip6_address_t * src_ip,
- const ip6_address_t * dst_ip,
- u16 src_port, u16 dst_port,
- u32 sw_if,
- adj_index_t ip_adj,
- u32 node_index,
- hicn_face_flags_t flags, hicn_face_id_t * face_id)
-{
- u16 net_src_port = clib_host_to_net_u16 (src_port);
- u16 net_dst_port = clib_host_to_net_u16 (dst_port);
- hicn_face_t *face =
- hicn_face_udp6_get (src_ip, dst_ip, net_src_port, net_dst_port);
- u8 hicnb_flags;
-
- if (face != NULL)
- return HICN_ERROR_FACE_ALREADY_CREATED;
-
- hicn_dpo_udp6_add_and_lock (dpo, src_ip, dst_ip, net_src_port, net_dst_port,
- node_index, &hicnb_flags, sw_if);
-
- face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
-
- face->shared.flags = flags;
- face->shared.adj = ip_adj;
- *face_id = hicn_dpoi_get_index (face);
-
- return HICN_ERROR_NONE;
-}
-
-void
-hicn_dpo_udp_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
- u16 dpoi_next_node)
-{
- hicn_face_id_t face_dpoi_id = hicn_dpoi_get_index (face);
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
- u8 version =
- (face_udp->hdrs.ip4.ip.ip_version_and_header_length & 0xf0) >> 4;
- dpo_set (dpo, face->shared.face_type,
- version == 4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6, face_dpoi_id);
- dpo->dpoi_next_node = dpoi_next_node;
-}
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.h b/hicn-plugin/src/faces/udp/dpo_udp.h
deleted file mode 100644
index 98abf3d29..000000000
--- a/hicn-plugin/src/faces/udp/dpo_udp.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HICN_DPO_UDP_H__
-#define __HICN_DPO_UDP_H__
-
-#include <vnet/adj/adj_types.h>
-#include <vnet/ip/ip4_packet.h>
-#include <vnet/ip/ip6_packet.h>
-
-#include "face_udp.h"
-#include "../face.h"
-#include "../../error.h"
-
-extern u32 strategy_face_udp4_vlib_edge;
-extern u32 strategy_face_udp6_vlib_edge;
-
-
-/**
- * @brief Initialize the internal structures of the dpo udp face module.
- */
-void hicn_dpo_udp_module_init (void);
-
-/**
- * @brief Create a udp face and its corresponding dpo. Meant to be used for the
- * control plane.
- *
- * @param dpo: Data plane object that point to the face created.
- * @param local_addr: Local address of the UDP tunnel
- * @param remote_addr: Remote address of the UDP tunnel
- * @param local_port: Local port of the UDP tunnel
- * @param remote_port: Remote port of the UDP tunnel
- * @param adj: Ip adjacency corresponding to the remote address in the face
- * @param node_index: vlib edge index to use in the packet processing
- * @param flags: Flags of the face
- * @param face_id: Identifier for the face (dpoi_index)
- * @return HICN_ERROR_FACE_ALREADY_CREATED if the face exists, otherwise HICN_ERROR_NONE
- */
-int
-hicn_dpo_udp4_create (dpo_id_t * dpo,
- const ip4_address_t * local_addr,
- const ip4_address_t * remote_addr,
- u16 local_port, u16 remote_port,
- u32 sw_if,
- adj_index_t adj,
- u32 node_index,
- hicn_face_flags_t flags, hicn_face_id_t * face_id);
-
-/**
- * @brief Retrieve a face using the face identifier, i.e., the quadruplet (local_addr, remote_addr,
- * local_port, remote_port). This method adds a lock on the face state.
- *
- * @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
- * @param local_addr: Local address of the UDP tunnel
- * @param remote_addr: Remote address of the UDP tunnel
- * @param local_port: Local port of the UDP tunnel
- * @param remote_port: Remote port of the UDP tunnel
- * @param hicnb_flags: Flags that indicate whether the face is an application
- * face or not in the hicn_buffer. (Currently only IP faces can be appface)
- *
- * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
- */
-always_inline int
-hicn_dpo_udp4_lock (dpo_id_t * dpo,
- const ip4_address_t * local_addr,
- const ip4_address_t * remote_addr,
- u16 local_port, u16 remote_port, u8 * hicnb_flags)
-{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
-
- hicn_face_t *face =
- hicn_face_udp4_get (local_addr, remote_addr, local_port, remote_port);
-
- if (PREDICT_FALSE (face == NULL))
- return HICN_ERROR_FACE_NOT_FOUND;
-
- index_t dpoi_index = hicn_dpoi_get_index (face);
- dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
- dpo->dpoi_next_node = strategy_face_udp4_vlib_edge;
- dpo_unlock (dpo);
-
- *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
-
- return HICN_ERROR_NONE;
-}
-
-/**
- * @brief Retrieve, or create if it doesn't exist, a face from the face
- * identifier (local_addr, remote_addr, local_port, remote_port) and returns its
- * dpo. This method adds a lock on the face state.
- *
- * @param dpo: Result of the lookup
- * @param local_addr: Local address of the UDP tunnel
- * @param remote_addr: Remote address of the UDP tunnel
- * @param local_port: Local port of the UDP tunnel
- * @param remote_port: Remote port of the UDP tunnel
- * @param hicnb_flags: Flags that indicate whether the face is an application
- * face or not. (Currently only IP faces can be appface)
- * @param node_index: vlib edge index to use in the packet processing
- */
-always_inline void
-hicn_dpo_udp4_add_and_lock (dpo_id_t * dpo,
- const ip4_address_t * local_addr,
- const ip4_address_t * remote_addr,
- u16 local_port, u16 remote_port,
- u32 node_index, u8 * hicnb_flags, u32 sw_if)
-{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
-
- hicn_face_t *face =
- hicn_face_udp4_get (local_addr, remote_addr, local_port, remote_port);
-
- if (face == NULL)
- {
-
- 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);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
-
- return;
- }
-
- *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
-
- hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
- dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
-}
-
-/**
- * @brief Create a udp face and its corresponding dpo. Meant to be used for the
- * control plane.
- *
- * @param dpo: Data plane object that point to the face created.
- * @param local_addr: Local address of the UDP tunnel
- * @param remote_addr: Remote address of the UDP tunnel
- * @param local_port: Local port of the UDP tunnel
- * @param remote_port: Remote port of the UDP tunnel
- * @param adj: Ip adjacency corresponding to the remote address in the face
- * @param node_index: vlib edge index to use in the packet processing
- * @param flags: Flags of the face
- * @param face_id: Identifier for the face (dpoi_index)
- * @return HICN_ERROR_FACE_ALREADY_CREATED if the face exists, otherwise HICN_ERROR_NONE
- */
-int
-hicn_dpo_udp6_create (dpo_id_t * dpo,
- const ip6_address_t * local_addr,
- const ip6_address_t * remote_addr,
- u16 local_port, u16 remote_port,
- u32 sw_if,
- adj_index_t adj,
- u32 node_index,
- hicn_face_flags_t flags, hicn_face_id_t * face_id);
-
-
-/**
- * @brief Retrieve a face using the face identifier, i.e., the quadruplet (local_addr, remote_addr,
- * local_port, remote_port). This method adds a lock on the face state.
- *
- * @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
- * @param local_addr: Local address of the UDP tunnel
- * @param remote_addr: Remote address of the UDP tunnel
- * @param local_port: Local port of the UDP tunnel
- * @param remote_port: Remote port of the UDP tunnel
- * @param hicnb_flags: Flags that indicate whether the face is an application
- * face or not. (Currently only IP faces can be appface)
- *
- * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
- */
-always_inline int
-hicn_dpo_udp6_lock (dpo_id_t * dpo,
- const ip6_address_t * local_addr,
- const ip6_address_t * remote_addr,
- u16 local_port, u16 remote_port, u8 * hicnb_flags)
-{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
-
- hicn_face_t *face =
- hicn_face_udp6_get (local_addr, remote_addr, local_port, remote_port);
-
-
- if (PREDICT_FALSE (face == NULL))
- 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_IP6, dpoi_index);
- dpo->dpoi_next_node = strategy_face_udp6_vlib_edge;
- dpo_unlock (dpo);
- *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
-
- return HICN_ERROR_NONE;
-}
-
-/**
- * @brief Retrieve, or create if it doesn't exist, a face from the face
- * identifier (local_addr, remote_addr, local_port, remote_port) and returns its
- * dpo. This method adds a lock on the face state.
- *
- * @param dpo: Result of the lookup
- * @param local_addr: Local address of the UDP tunnel
- * @param remote_addr: Remote address of the UDP tunnel
- * @param local_port: Local port of the UDP tunnel
- * @param remote_port: Remote port of the UDP tunnel
- * @param hicnb_flags: Flags that indicate whether the face is an application
- * face or not. (Currently only IP faces can be appface)
- * @param node_index: vlib edge index to use in the packet processing
- */
-always_inline void
-hicn_dpo_udp6_add_and_lock (dpo_id_t * dpo,
- const ip6_address_t * local_addr,
- const ip6_address_t * remote_addr,
- u16 local_port, u16 remote_port,
- u32 node_index, u8 * hicnb_flags, u32 sw_if)
-{
- dpo->dpoi_type = DPO_FIRST;
- dpo->dpoi_proto = DPO_PROTO_NONE;
- dpo->dpoi_index = INDEX_INVALID;
- dpo->dpoi_next_node = 0;
-
- hicn_face_t *face =
- hicn_face_udp6_get (local_addr, remote_addr, local_port, remote_port);
-
- if (face == NULL)
- {
- 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);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
-
- return;
- }
-
- *hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
-
- hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
- dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP6, dpoi_index);
- dpo->dpoi_next_node = node_index;
- dpo_unlock (dpo);
-}
-
-/**
- * @brief Create a dpo from a udp face
- *
- * @param face Face from which to create the dpo
- * @return the dpo
- */
-void hicn_dpo_udp_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
- u16 dpoi_next_node);
-
-#endif // __HICN_DPO_UDP_H__
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/face_udp.c b/hicn-plugin/src/faces/udp/face_udp.c
deleted file mode 100644
index f427505dd..000000000
--- a/hicn-plugin/src/faces/udp/face_udp.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates. Licensed under the
- * Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the
- * License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-#include <vlib/vlib.h>
-#include <vnet/vnet.h>
-#include <vnet/udp/udp.h>
-
-#include "face_udp.h"
-#include "face_udp_node.h"
-#include "iface_udp_node.h"
-#include "dpo_udp.h"
-#include "../face.h"
-#include "../../infra.h"
-#include "../../strategy.h"
-#include "../../strategy_dpo_manager.h"
-#include "../../hicn.h"
-
-#include "../../mapme.h" // HICN_MAPME_EVENT_*
-#include "../../mapme_eventmgr.h" // hicn_mapme_eventmgr_process_node
-extern vlib_node_registration_t hicn_mapme_eventmgr_process_node;
-
-mhash_t hicn_face_udp_hashtb;
-
-dpo_type_t hicn_face_udp_type;
-
-ip4_header_t ip4_header_skl = {
- .ip_version_and_header_length = IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS,
- .tos = 0x00,
- .length = (u16) 0,
- .fragment_id = (u16) 0,
- .flags_and_fragment_offset = (u16) 0,
- .ttl = 254,
- .protocol = IP_PROTOCOL_UDP,
- .checksum = 0,
- .src_address = {{0}},
- .dst_address = {{0}},
-};
-
-ip6_header_t ip6_header_skl = {
-#if CLIB_ARCH_IS_BIG_ENDIAN
- .ip_version_traffic_class_and_flow_label = 0x60000000,
-#else
- .ip_version_traffic_class_and_flow_label = 0x00000060,
-#endif
- .payload_length = (u16) 0,
- .protocol = IP_PROTOCOL_UDP,
- .hop_limit = 254,
- .src_address = {{0}},
- .dst_address = {{0}}
-};
-
-u32 strategy_face_udp4_vlib_edge;
-u32 strategy_face_udp6_vlib_edge;
-
-/*
- * Separated from the hicn_face_udp_init because it cannot be called by the
- * init macro due to dependencies with other modules not yet initialied
- */
-void
-hicn_face_udp_init_internal ()
-{
- ip4_header_t *ip4_hdr = &ip4_header_skl;
- ip4_header_skl.checksum = ip4_header_checksum (ip4_hdr);
-}
-
-void
-hicn_face_udp_init (vlib_main_t * vm)
-{
- int strategy_nodes_n = hicn_strategy_get_all_available ();
-
- /* Default Strategy has index 0 and it always exists */
- strategy_face_udp4_vlib_edge = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_udp4_output_node.
- index);
- strategy_face_udp6_vlib_edge =
- vlib_node_add_next (vm, hicn_strategy_node.index,
- hicn_face_udp6_output_node.index);
-
- /*
- * Create and edge between al the other strategy nodes and the
- * udp_output nodes.
- */
- for (int i = 1; i < strategy_nodes_n; i++)
- {
- u32 temp_index4 = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_udp4_output_node.index);
- u32 temp_index6 = vlib_node_add_next (vm,
- hicn_strategy_node.index,
- hicn_face_udp6_output_node.index);
- ASSERT (temp_index4 == strategy_face_udp4_vlib_edge);
- ASSERT (temp_index6 == strategy_face_udp6_vlib_edge);
- }
-
- u32 temp_index4 = vlib_node_add_next (vm,
- hicn_interest_hitpit_node.index,
- hicn_face_udp4_output_node.index);
- u32 temp_index6 = vlib_node_add_next (vm,
- hicn_interest_hitpit_node.index,
- hicn_face_udp6_output_node.index);
-
- ASSERT (temp_index4 == strategy_face_udp4_vlib_edge);
- ASSERT (temp_index6 == strategy_face_udp6_vlib_edge);
-
- hicn_dpo_udp_module_init ();
-
- register_face_type (hicn_face_udp_type, &udp_vft, "udp");;
-}
-
-int
-hicn_face_udp_add (const ip46_address_t * local_addr,
- const ip46_address_t * remote_addr, u16 local_port,
- u16 remote_port, u32 swif, hicn_face_id_t * pfaceid)
-{
- adj_index_t ip_adj;
- int ret = HICN_ERROR_NONE;
- dpo_proto_t dpo_proto;
-
- hicn_face_flags_t flags = (hicn_face_flags_t) 0;
- flags |= HICN_FACE_FLAGS_FACE;
- vlib_main_t * vm = vlib_get_main();
-
- if (ip46_address_is_ip4 (local_addr) && ip46_address_is_ip4 (remote_addr))
- {
- fib_prefix_t fib_pfx;
- fib_node_index_t fib_entry_index;
- fib_prefix_from_ip46_addr (remote_addr, &fib_pfx);
- fib_pfx.fp_len = ip46_address_is_ip4 (remote_addr) ? 32 : 128;
-
- u32 fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
- HICN_FIB_TABLE,
- FIB_SOURCE_PRIORITY_HI);
- fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
-
- ip_adj = fib_entry_get_adj (fib_entry_index);
-
- if (ip_adj == ~0)
- return HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;
-
- hicn_face_t *face =
- hicn_face_udp4_get (&local_addr->ip4, &remote_addr->ip4, local_port,
- remote_port);
-
- 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->ip4),
- sizeof (ip4_address_t));
- clib_memcpy (&(udp_face->hdrs.ip4.ip.dst_address), &(remote_addr->ip4),
- sizeof (ip4_address_t));
-
- udp_face->hdrs.ip4.udp.src_port = local_port;
- udp_face->hdrs.ip4.udp.dst_port = remote_port;
-
- ip_csum_t csum = udp_face->hdrs.ip4.ip.checksum;
- csum = ip_csum_sub_even (csum, ip4_header_skl.src_address.as_u32);
- csum = ip_csum_sub_even (csum, ip4_header_skl.dst_address.as_u32);
- csum =
- ip_csum_add_even (csum, udp_face->hdrs.ip4.ip.src_address.as_u32);
- csum =
- ip_csum_add_even (csum, udp_face->hdrs.ip4.ip.dst_address.as_u32);
- udp_face->hdrs.ip4.ip.checksum = ip_csum_fold (csum);
-
- face->shared.adj = ip_adj;
- face->shared.sw_if = swif;
- face->shared.pl_id = (u16) 0;
- face->shared.face_type = hicn_face_udp_type;
- face->shared.flags = flags;
- face->shared.locks = 0;
-
- hicn_face_udp_key_t key;
- hicn_face_udp4_get_key (&local_addr->ip4, &remote_addr->ip4, 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);
-
- *pfaceid = hicn_dpoi_get_index (face);
- dpo_proto = DPO_PROTO_IP4;
- fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI);
-
- udp_register_dst_port(vm, clib_net_to_host_u16(local_port), hicn_iface_udp4_input_node.index, 1);
- }
- else if (!ip46_address_is_ip4 (local_addr)
- && !ip46_address_is_ip4 (remote_addr))
- {
- fib_prefix_t fib_pfx;
- fib_node_index_t fib_entry_index;
- fib_prefix_from_ip46_addr (remote_addr, &fib_pfx);
- fib_pfx.fp_len = ip46_address_is_ip4 (remote_addr) ? 32 : 128;
-
- u32 fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
- HICN_FIB_TABLE,
- FIB_SOURCE_PRIORITY_HI);
- fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
-
- ip_adj = fib_entry_get_adj (fib_entry_index);
-
- if (ip_adj == ~0)
- return HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;
-
- hicn_face_t *face =
- hicn_face_udp6_get (&local_addr->ip6, &remote_addr->ip6, local_port,
- remote_port);
-
- 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 = ip_adj;
- face->shared.sw_if = swif;
- face->shared.pl_id = (u16) 0;
- face->shared.face_type = hicn_face_udp_type;
- face->shared.flags = flags;
- face->shared.locks = 0;
-
- hicn_face_udp_key_t key;
- hicn_face_udp6_get_key (&local_addr->ip6, &remote_addr->ip6, 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);
-
- *pfaceid = hicn_dpoi_get_index (face);
- dpo_proto = DPO_PROTO_IP6;
- fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI);
-
- udp_register_dst_port(vm, clib_net_to_host_u16(local_port), hicn_iface_udp6_input_node.index, 0);
- }
- else
- {
- return HICN_ERROR_IPS_ADDR_TYPE_NONUNIFORM;
- }
-
- 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);
- }
-
- retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
- hicn_mapme_eventmgr_process_node.
- index,
- HICN_MAPME_EVENT_FACE_ADD, 1,
- sizeof (retx_t));
- /* *INDENT-OFF* */
- *retx = (retx_t)
- {
- .prefix = 0,
- .dpo = (dpo_id_t)
- {
- .dpoi_type = hicn_face_udp_type,
- .dpoi_proto = dpo_proto,
- .dpoi_next_node = 0,
- .dpoi_index = *pfaceid,
- }
- };
- /* *INDENT-ON* */
-
- //Take a lock on the face which will be removed when the face is deleted
- hicn_face_lock (&(retx->dpo));
-
-
- return ret;
-}
-
-int
-hicn_face_udp_del (u32 faceid)
-{
- hicn_face_t *face = hicn_dpoi_get_from_idx (faceid);
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
- hicn_face_udp_key_t key;
- hicn_face_udp_key_t old_key;
-
- if (face_udp->hdrs.ip4.ip.ip_version_and_header_length ==
- IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS)
- {
- hicn_face_udp4_get_key (&face_udp->hdrs.ip4.ip.src_address,
- &face_udp->hdrs.ip4.ip.dst_address,
- face_udp->hdrs.ip4.udp.src_port,
- face_udp->hdrs.ip4.udp.dst_port, &key);
- mhash_unset (&hicn_face_udp_hashtb, &key, (uword *) & old_key);
- }
- else
- {
- hicn_face_udp6_get_key (&face_udp->hdrs.ip6.ip.src_address,
- &face_udp->hdrs.ip6.ip.dst_address,
- face_udp->hdrs.ip6.udp.src_port,
- face_udp->hdrs.ip6.udp.dst_port, &key);
- mhash_unset (&hicn_face_udp_hashtb, &key, (uword *) & old_key);
- }
- return hicn_face_del (faceid);
-}
-
-u8 *
-format_hicn_face_udp (u8 * s, va_list * args)
-{
- hicn_face_id_t face_id = va_arg (*args, index_t);
- CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
- hicn_face_t *face;
- hicn_face_udp_t *udp_face;
- ip_adjacency_t *adj;
- u8 ipv = IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS;
- vnet_main_t *vnm = vnet_get_main ();
-
-
- face = hicn_dpoi_get_from_idx (face_id);
- udp_face = (hicn_face_udp_t *) (face->data);
-
- if (face->shared.flags & HICN_FACE_FLAGS_FACE)
- {
- ASSERT (face->shared.adj != (adj_index_t) ~ 0);
- adj = adj_get (face->shared.adj);
-
- s = format (s, "%U Face %d: ", format_white_space, indent, face_id);
- if (udp_face->hdrs.ip4.ip.ip_version_and_header_length == ipv)
- {
- s = format (s, "type UDP local %U|%u ",
- format_ip4_address, &udp_face->hdrs.ip4.ip.src_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.src_port));
- s =
- format (s, "remote %U|%u ", format_ip4_address,
- &udp_face->hdrs.ip4.ip.dst_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.dst_port));
- s = format (s, "%U", format_vnet_link, adj->ia_link);
-
- vnet_sw_interface_t *sw_int =
- vnet_get_sw_interface_or_null (vnm, face->shared.sw_if);
- if (sw_int != NULL)
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- sw_int);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
- s = format (s, " (deleted)");
- }
- else
- {
- s = format (s, "type UDP local %U|%u ",
- format_ip6_address, &udp_face->hdrs.ip6.ip.src_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.src_port));
- s =
- format (s, "remote %U|%u ", format_ip6_address,
- &udp_face->hdrs.ip6.ip.dst_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.dst_port));
- s = format (s, "%U", format_vnet_link, adj->ia_link);
-
- vnet_sw_interface_t *sw_int =
- vnet_get_sw_interface_or_null (vnm, face->shared.sw_if);
- if (sw_int != NULL)
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- sw_int);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
- s = format (s, " (deleted)");
- }
- }
- else
- {
- s = format (s, "%U iFace %d: ", format_white_space, indent, face_id);
- if (udp_face->hdrs.ip4.ip.ip_version_and_header_length == ipv)
- {
- s = format (s, "type UDP local %U|%u",
- format_ip4_address, &udp_face->hdrs.ip4.ip.src_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.src_port));
- s =
- format (s, " local %U|%u", format_ip4_address,
- &udp_face->hdrs.ip4.ip.dst_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.dst_port));
-
- vnet_sw_interface_t *sw_int =
- vnet_get_sw_interface_or_null (vnm, face->shared.sw_if);
- if (sw_int != NULL)
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- sw_int);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
- s = format (s, " (deleted)");
- }
- else
- {
- s = format (s, "type UDP local %U|%u",
- format_ip6_address, &udp_face->hdrs.ip6.ip.src_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.src_port));
- s =
- format (s, " remote %U|%u", format_ip6_address,
- &udp_face->hdrs.ip6.ip.dst_address,
- clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.dst_port));
-
- vnet_sw_interface_t *sw_int =
- vnet_get_sw_interface_or_null (vnm, face->shared.sw_if);
- if (sw_int != NULL)
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- sw_int);
-
- if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
- s = format (s, " (deleted)");
- }
- }
-
- return s;
-}
-
-void
-hicn_face_udp_get_dpo (hicn_face_t * face, dpo_id_t * dpo)
-{
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
- u8 version =
- (face_udp->hdrs.ip4.ip.ip_version_and_header_length & 0xf0) >> 4;
- return hicn_dpo_udp_create_from_face (face, dpo,
- version ==
- (u8) 4 ? strategy_face_udp4_vlib_edge
- : strategy_face_udp6_vlib_edge);
-}
-
-hicn_face_vft_t udp_vft = {
- .format_face = format_hicn_face_udp,
- .hicn_face_del = hicn_face_udp_del,
- .hicn_face_get_dpo = hicn_face_udp_get_dpo,
-};
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/face_udp.h b/hicn-plugin/src/faces/udp/face_udp.h
deleted file mode 100644
index 5dfc76e22..000000000
--- a/hicn-plugin/src/faces/udp/face_udp.h
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HICN_FACE_UDP_H__
-#define __HICN_FACE_UDP_H__
-
-#include <vlib/vlib.h>
-#include <vnet/vnet.h>
-#include <vnet/ip/ip6_packet.h>
-#include <vnet/udp/udp_packet.h>
-
-#include "../face.h"
-
-/**
- * @file
- * @brief UDP face
- *
- * This file containes the definition of UDP faces.
- * UDP faces encap and decap an hicn packet into a UDP tunnel.
- * Src and dst address in interest and data packets are not considered and
- * should be set to 0 (not checked in the forwarder).
- */
-
-/* Pre-instantiated ip header to fast fill an newly encapsulated packet */
-extern ip4_header_t ip4_header_skl;
-extern ip6_header_t ip6_header_skl;
-
-#define INVALID_UDP_DPO_INDEX ~0
-
-/**
- * @brief UDP face representation. The following is stored in the data field of
- * an hicn_face_t object (see hicn_face.h). A UDP face is identifies by the
- * quadruplet (src addr, dst addr, src port, dst port).
- */
-typedef struct hicn_face_udp_t_
-{
- /**
- * The headers to paint, in packet painting order
- */
- union
- {
- struct
- {
- ip4_header_t ip;
- udp_header_t udp;
- } __attribute__ ((packed)) ip4;
- struct
- {
- ip6_header_t ip;
- udp_header_t udp;
- } __attribute__ ((packed)) ip6;
- } __attribute__ ((packed)) hdrs;
-} hicn_face_udp_t;
-
-/* Hast table mapping the udp key with the face id (dpoi_index pointing to and
- element in the face pool defined in hicn_face.h)*/
-extern mhash_t hicn_face_udp_hashtb;
-
-/**
- * @brief Hash table key.
- */
-typedef struct hicn_face_udp_key_s
-{
- ip46_address_t local_addr;
- ip46_address_t remote_addr;
- u16 local_port;
- u16 remote_port;
-} hicn_face_udp_key_t;
-
-/* DPO type for the udp face */
-extern dpo_type_t hicn_face_udp_type;
-
-/* VFT table for the udp face. Mainly used to format the face in the right way */
-extern hicn_face_vft_t udp_vft;
-
-/**
- * @brief Create the key object for the mhash. Fill in the key object with the
- * expected values.
- *
- * @param local_addr Local address of the UDP tunnel
- * @param remote_addr Remote address of the UDP tunnel
- * @param local_port Local port of the UDP tunnel
- * @param remote_port Remote port of the UDP tunnel
- * @param key Pointer to an allocated hicn_face_udp_key_t object
- */
-always_inline void
-hicn_face_udp4_get_key (const ip4_address_t * local_addr,
- const ip4_address_t * remote_addr,
- u16 local_port, u16 remote_port,
- hicn_face_udp_key_t * key)
-{
-
- ip46_address_set_ip4 (&(key->local_addr), local_addr);
- ip46_address_set_ip4 (&(key->remote_addr), remote_addr);
- key->local_port = local_port;
- key->remote_port = remote_port;
-}
-
-/**
- * @brief Create the key object for the mhash. Fill in the key object with the
- * expected values.
- *
- * @param local_addr Local address of the UDP tunnel
- * @param remote_addr Remote address of the UDP tunnel
- * @param local_port Local port of the UDP tunnel
- * @param remote_port Remote port of the UDP tunnel
- * @param key Pointer to an allocated hicn_face_udp_key_t object
- */
-always_inline void
-hicn_face_udp6_get_key (const ip6_address_t * local_addr,
- const ip6_address_t * remote_addr,
- u16 local_port, u16 remote_port,
- hicn_face_udp_key_t * key)
-{
- key->local_addr.ip6 = *local_addr;
- key->remote_addr.ip6 = *remote_addr;
- key->local_port = local_port;
- key->remote_port = remote_port;
-}
-
-/**
- * @brief Get the dpoi from the quadruplet that identifies the face. Does not add any lock.
- *
- * @param local_addr Local address of the UDP tunnel
- * @param remote_addr Remote address of the UDP tunnel
- * @param local_port Local port of the UDP tunnel
- * @param remote_port Remote port of the UDP tunnel
- *
- * @result Pointer to the face.
- */
-always_inline hicn_face_t *
-hicn_face_udp4_get (const ip4_address_t * local_addr,
- const ip4_address_t * remote_addr,
- u16 local_port, u16 remote_port)
-{
- 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_face_id_t *) mhash_get (&hicn_face_udp_hashtb,
- &key);
-
- return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
-}
-
-/**
- * @brief Get the dpoi from the quadruplet that identifies the face. Does not add any lock.
- *
- * @param local_addr Local address of the UDP tunnel (network order)
- * @param remote_addr Remote address of the UDP tunnel (network order)
- * @param local_port Local port of the UDP tunnel (network order)
- * @param remote_port Remote port of the UDP tunnel (network order)
- *
- * @result Pointer to the face.
- */
-always_inline hicn_face_t *
-hicn_face_udp6_get (const ip6_address_t * local_addr,
- const ip6_address_t * remote_addr,
- u16 local_port, u16 remote_port)
-{
- 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_face_id_t *) mhash_get (&hicn_face_udp_hashtb,
- &key);
-
- return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
-}
-
-
-/**
- * @brief Initialize the udp face module
- */
-void hicn_face_udp_init (vlib_main_t * vm);
-
-/**
- * @brief Create a new face ip. API for other modules (e.g., routing)
- *
- * @param local_addr Local ip v4 or v6 address of the face (network order)
- * @param remote_addr Remote ip v4 or v6 address of the face (network order)
- * @param local_port Local udp port of the face (network order)
- * @param remote_port Remote udp port of the face (network order)
- * @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
- */
-int hicn_face_udp_add (const ip46_address_t * local_addr,
- const ip46_address_t * remote_addr, u16 local_port,
- 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);
-
- hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
-
- mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 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 = 1;
- 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);
-
- hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
-
- mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 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
- * @return HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise
- * HICN_ERROR_NONE
- */
-int hicn_face_udp_del (hicn_face_id_t faceid);
-
-/**
- * @brief Format a UDP face
- *
- * @param s Pointer to a previous string. If null it will be initialize
- * @param args Array storing input values. Expected u32 indent and u32 face_id
- * @return String with the formatted face
- */
-u8 *format_hicn_face_udp (u8 * s, va_list * args);
-
-/**
- * @brief Create a dpo from a udp face
- *
- * @param face Face from which to create the dpo
- * @return the dpo
- */
-void hicn_face_udp_get_dpo (hicn_face_t * face, dpo_id_t * dpo);
-
-/**
- * @brief Init some internal structures
- */
-void hicn_face_udp_init_internal (void);
-
-#endif // __HICN_FACE_UDP_H__
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/face_udp_cli.c b/hicn-plugin/src/faces/udp/face_udp_cli.c
deleted file mode 100644
index 7bb172ce8..000000000
--- a/hicn-plugin/src/faces/udp/face_udp_cli.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "face_udp.h"
-#include "dpo_udp.h"
-
-#include <vnet/vnet.h>
-#include <vnet/dpo/dpo.h>
-#include <vlib/vlib.h>
-#include <vnet/ip/format.h>
-
-#define HICN_FACE_NONE 0
-#define HICN_FACE_DELETE 1
-#define HICN_FACE_ADD 2
-
-
-static clib_error_t *
-hicn_face_udp_cli_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
-{
- vnet_main_t *vnm = vnet_get_main ();
- ip46_address_t src_addr;
- u32 src_port = 0;
- ip46_address_t dst_addr;
- u32 dst_port = 0;
- hicn_face_id_t face_id = HICN_FACE_NULL;
- int ret = HICN_ERROR_NONE;
- int sw_if;
- int face_op = HICN_FACE_NONE;
-
- ip46_address_reset (&src_addr);
- ip46_address_reset (&dst_addr);
- /* Get a line of input. */
- unformat_input_t _line_input, *line_input = &_line_input;
- if (!unformat_user (main_input, unformat_line_input, line_input))
- {
- return (0);
- }
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "del"))
- {
- if (unformat (line_input, "id %d", &face_id))
- face_op = HICN_FACE_DELETE;
- else
- {
- return clib_error_return (0, "missing face id");
- }
- }
- else if (unformat (line_input, "add"))
- {
- face_op = HICN_FACE_ADD;
- if (unformat
- (line_input, "src_addr %U port %u dst_addr %U port %u intfc %U",
- unformat_ip46_address, &src_addr, IP46_TYPE_ANY, &src_port,
- unformat_ip46_address, &dst_addr, IP46_TYPE_ANY, &dst_port,
- unformat_vnet_sw_interface, vnm, &sw_if));
- else
- {
- return clib_error_return (0, "%s '%U'",
- get_error_string
- (HICN_ERROR_CLI_INVAL),
- format_unformat_error, line_input);
- }
- }
- else
- {
- return clib_error_return (0, "%s '%U'",
- get_error_string (HICN_ERROR_CLI_INVAL),
- format_unformat_error, line_input);
- }
- }
-
- if (face_id != HICN_FACE_NULL)
- {
- if (!hicn_dpoi_idx_is_valid (face_id))
- {
- return clib_error_return (0, "%s, face_id %d not valid",
- get_error_string (ret), face_id);
- }
- }
-
- int rv;
- switch (face_op)
- {
- case HICN_FACE_ADD:
-
- /* Check for presence of next hop address */
- if (((dst_addr.as_u64[0] == (u64) 0) && (dst_addr.as_u64[1] == (u64) 0))
- || dst_port == 0)
- {
- return clib_error_return (0, "dst address and port not specified");
- }
-
- if (((src_addr.as_u64[0] == (u64) 0) && (src_addr.as_u64[1] == (u64) 0))
- || src_port == 0)
- {
- return clib_error_return (0, "src address not specified");
- }
-
- rv =
- hicn_face_udp_add (&src_addr, &dst_addr,
- clib_host_to_net_u16 (src_port),
- clib_host_to_net_u16 (dst_port), sw_if, &face_id);
- if (rv == HICN_ERROR_NONE)
- {
- vlib_cli_output (vm, "Face id: %d", face_id);
- }
- else
- {
- return clib_error_return (0, get_error_string (rv));
- }
- break;
- case HICN_FACE_DELETE:
- rv = hicn_face_udp_del (face_id);
- if (rv == HICN_ERROR_NONE)
- {
- vlib_cli_output (vm, "Face %d deleted", face_id);
- }
- else
- {
- return clib_error_return (0, get_error_string (rv));
- }
- break;
- default:
- return clib_error_return (0, "Operation (%d) not implemented", face_op);
- break;
- }
- return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
- get_error_string
- (rv));
-}
-
-/* cli declaration for 'cfg face' */
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (hicn_face_udp_cli_set_command, static) =
-{
- .path = "hicn face udp",
- .short_help = "hicn face udp {add src_addr <src_address> port <src_port > dst_addr <dst_address> port <dst_port>} intfc <interface> | {del id <face_id>}",
- .function = hicn_face_udp_cli_set_command_fn,
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/face_udp_node.c b/hicn-plugin/src/faces/udp/face_udp_node.c
deleted file mode 100644
index c82336659..000000000
--- a/hicn-plugin/src/faces/udp/face_udp_node.c
+++ /dev/null
@@ -1,1030 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <vlib/vlib.h>
-#include <vnet/vnet.h>
-#include <vnet/ip/ip_packet.h>
-
-#include "face_udp.h"
-#include "face_udp_node.h"
-#include "dpo_udp.h"
-#include "../face.h"
-#include "../../strategy.h"
-#include "../../strategy_dpo_manager.h"
-#include "../../hicn.h"
-
-/**
- * @File
- *
- * Definition of the nodes for udp faces.
- */
-
-vlib_node_registration_t hicn_face_udp4_input_node;
-vlib_node_registration_t hicn_face_udp6_input_node;
-vlib_node_registration_t hicn_face_udp4_output_node;
-vlib_node_registration_t hicn_face_udp6_output_node;
-
-static char *hicn_face_udp4_input_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-static char *hicn_face_udp6_input_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_face_udp4_input_trace_t;
-
-typedef enum
-{
- HICN_FACE_UDP4_INPUT_NEXT_DATA,
- HICN_FACE_UDP4_INPUT_NEXT_MAPME,
- HICN_FACE_UDP4_INPUT_NEXT_ERROR_DROP,
- HICN_FACE_UDP4_INPUT_N_NEXT,
-} hicn_face_udp4_input_next_t;
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_face_udp6_input_trace_t;
-
-typedef enum
-{
- HICN_FACE_UDP6_INPUT_NEXT_DATA,
- HICN_FACE_UDP6_INPUT_NEXT_MAPME,
- HICN_FACE_UDP6_INPUT_NEXT_ERROR_DROP,
- HICN_FACE_UDP6_INPUT_N_NEXT,
-} hicn_face_udp6_input_next_t;
-
-#define ERROR_INPUT_UDP4 HICN_FACE_UDP4_INPUT_NEXT_ERROR_DROP
-#define ERROR_INPUT_UDP6 HICN_FACE_UDP6_INPUT_NEXT_ERROR_DROP
-
-#define NEXT_MAPME_UDP4 HICN_FACE_UDP4_INPUT_NEXT_MAPME
-#define NEXT_MAPME_UDP6 HICN_FACE_UDP6_INPUT_NEXT_MAPME
-#define NEXT_DATA_UDP4 HICN_FACE_UDP4_INPUT_NEXT_DATA
-#define NEXT_DATA_UDP6 HICN_FACE_UDP6_INPUT_NEXT_DATA
-
-#define IP_HEADER_4 ip4_header_t
-#define IP_HEADER_6 ip6_header_t
-
-#define HICN_DPO_UDP_LOCK_IP4 hicn_dpo_udp4_lock
-#define HICN_DPO_UDP_LOCK_IP6 hicn_dpo_udp6_lock
-
-#define TRACE_INPUT_PKT_UDP4 hicn_face_udp4_input_trace_t
-#define TRACE_INPUT_PKT_UDP6 hicn_face_udp6_input_trace_t
-
-#define SIZE_HICN_HEADER4 sizeof(ip4_header_t) + sizeof(udp_header_t)
-#define SIZE_HICN_HEADER6 sizeof(ip6_header_t) + sizeof(udp_header_t)
-
-
-#define face_input_x1(ipv) \
- do { \
- int ret; \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = ERROR_INPUT_UDP##ipv; \
- IP_HEADER_##ipv * ip_hdr = NULL; \
- u8 * inner_ip_hdr = NULL; \
- udp_header_t * udp_hdr = NULL; \
- hicn_buffer_t * hicnb0; \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- udp_hdr = (udp_header_t *) (ip_hdr + 1); \
- hicnb0 = hicn_get_buffer(b0); \
- \
- inner_ip_hdr = (u8 *)(udp_hdr + 1); \
- u8 is_v6 = hicn_is_v6((hicn_header_t *)inner_ip_hdr); \
- u8 is_icmp = is_v6*(inner_ip_hdr[6] == IPPROTO_ICMPV6) + \
- (1 - is_v6)*(inner_ip_hdr[9] == IPPROTO_ICMPV4); \
- \
- ret = HICN_DPO_UDP_LOCK_IP##ipv \
- (&(hicnb0->face_dpo_id), \
- &(ip_hdr->dst_address), \
- &(ip_hdr->src_address), \
- (udp_hdr->dst_port), \
- (udp_hdr->src_port), \
- &hicnb0->flags); \
- \
- if ( PREDICT_FALSE(ret != HICN_ERROR_NONE) ) \
- { \
- next0 = ERROR_INPUT_UDP##ipv; \
- } \
- else \
- { \
- next0 = is_icmp*NEXT_MAPME_UDP##ipv + \
- (1-is_icmp)*NEXT_DATA_UDP##ipv; \
- stats.pkts_data_count += 1; \
- \
- vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
- sizeof(udp_header_t)); \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_DATA_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_CONTENT; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- }while(0) \
-
-#define face_input_x2(ipv) \
- do { \
- int ret0, ret1; \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0 = ERROR_INPUT_UDP##ipv; \
- u32 next1 = ERROR_INPUT_UDP##ipv; \
- IP_HEADER_##ipv * ip_hdr0 = NULL; \
- IP_HEADER_##ipv * ip_hdr1 = NULL; \
- u8 * inner_ip_hdr0 = NULL; \
- u8 * inner_ip_hdr1 = NULL; \
- udp_header_t * udp_hdr0 = NULL; \
- udp_header_t * udp_hdr1 = NULL; \
- hicn_buffer_t *hicnb0, *hicnb1; \
- \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
- udp_hdr0 = (udp_header_t *) (ip_hdr0 + 1); \
- udp_hdr1 = (udp_header_t *) (ip_hdr1 + 1); \
- hicnb0 = hicn_get_buffer(b0); \
- hicnb1 = hicn_get_buffer(b1); \
- \
- inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
- u8 is_v6_0 = hicn_is_v6((hicn_header_t *)inner_ip_hdr0); \
- u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[6] == IPPROTO_ICMPV6) + \
- (1 - is_v6_0)*(inner_ip_hdr0[9] == IPPROTO_ICMPV4); \
- \
- inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
- u8 is_v6_1 = hicn_is_v6((hicn_header_t *)inner_ip_hdr1); \
- u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[6] == IPPROTO_ICMPV6) + \
- (1 - is_v6_1)*(inner_ip_hdr1[9] == IPPROTO_ICMPV4); \
- \
- ret0 = HICN_DPO_UDP_LOCK_IP##ipv \
- (&(hicnb0->face_dpo_id), \
- &(ip_hdr0->dst_address), \
- &(ip_hdr0->src_address), \
- (udp_hdr0->dst_port), \
- (udp_hdr0->src_port), \
- &hicnb0->flags); \
- \
- ret1 = HICN_DPO_UDP_LOCK_IP##ipv \
- (&(hicnb1->face_dpo_id), \
- &(ip_hdr1->dst_address), \
- &(ip_hdr1->src_address), \
- (udp_hdr1->dst_port), \
- (udp_hdr1->src_port), \
- &hicnb1->flags); \
- \
- if ( PREDICT_FALSE(ret0 != HICN_ERROR_NONE) ) \
- { \
- next0 = ERROR_INPUT_UDP##ipv; \
- } \
- else \
- { \
- stats.pkts_data_count += 1; \
- next0 = is_icmp0*NEXT_MAPME_UDP##ipv + \
- (1-is_icmp0)*NEXT_DATA_UDP##ipv; \
- \
- vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
- sizeof(udp_header_t)); \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_DATA_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if ( PREDICT_FALSE(ret1 != HICN_ERROR_NONE) ) \
- { \
- next1 = ERROR_INPUT_UDP##ipv; \
- } \
- else \
- { \
- stats.pkts_data_count += 1; \
- next1 = is_icmp1*NEXT_MAPME_UDP##ipv + \
- (1-is_icmp1)*NEXT_DATA_UDP##ipv; \
- \
- vlib_buffer_advance(b1, sizeof(IP_HEADER_##ipv) + \
- sizeof(udp_header_t)); \
- vlib_increment_combined_counter ( \
- &counters[hicnb1->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index,\
- HICN_FACE_COUNTERS_DATA_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_CONTENT; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_CONTENT; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- }while(0) \
-
-static uword
-hicn_face_udp4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- /* Dual loop, X2 */
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- face_input_x2 (4);
- }
-
- /* Dual loop, X1 */
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- face_input_x1 (4);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_face_udp4_input_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_udp4_input_trace_t *t =
- va_arg (*args, hicn_face_udp4_input_trace_t *);
-
- s =
- format (s, "FACE_UDP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_face_udp4_input_node) =
-{
- .function = hicn_face_udp4_input_node_fn,
- .name = "hicn-face-udp4-input",
- .vector_size = sizeof (u32),
- .format_trace = hicn_face_udp4_input_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_face_udp4_input_error_strings),
- .error_strings = hicn_face_udp4_input_error_strings,
- .n_next_nodes = HICN_FACE_UDP4_INPUT_N_NEXT,
- /* edit / add dispositions here */
- .next_nodes =
- {
- [HICN_FACE_UDP4_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
- [HICN_FACE_UDP4_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
- [HICN_FACE_UDP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-
-static uword
-hicn_face_udp6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- /* Dual loop, X2 */
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- face_input_x2 (6);
- }
-
- /* Dual loop, X1 */
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- face_input_x1 (6);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_PROCESSED, stats.pkts_processed);
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_face_udp6_input_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_udp6_input_trace_t *t =
- va_arg (*args, hicn_face_udp6_input_trace_t *);
-
- s =
- format (s, "FACE_UDP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_face_udp6_input_node) =
-{
- .function = hicn_face_udp6_input_node_fn,
- .name = "hicn-face-udp6-input",
- .vector_size = sizeof (u32),
- .format_trace = hicn_face_udp6_input_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_face_udp6_input_error_strings),
- .error_strings = hicn_face_udp6_input_error_strings,
- .n_next_nodes = HICN_FACE_UDP6_INPUT_N_NEXT,
- /* edit / add dispositions here */
- .next_nodes =
- {
- [HICN_FACE_UDP6_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
- [HICN_FACE_UDP6_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
- [HICN_FACE_UDP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-/******* Face Output *******/
-
-always_inline void
-hicn_face_udp4_encap (vlib_main_t * vm,
- vlib_buffer_t * outer_b0,
- hicn_face_t * face, u32 * next)
-{
- u16 old_l0 = 0, new_l0;
- ip_csum_t sum0;
- ip4_header_t *ip0;
- udp_header_t *udp0;
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
-
- /* ip */
- ip0 = vlib_buffer_get_current (outer_b0);
- clib_memcpy (ip0, &(face_udp->hdrs.ip4.ip), sizeof (ip4_header_t) +
- sizeof (udp_header_t));
-
- /* Fix UDP length */
- udp0 = (udp_header_t *) (ip0 + 1);
-
- new_l0 =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, outer_b0) -
- sizeof (*ip0));
- udp0->length = new_l0;
-
- old_l0 = ip0->length;
- ip0->length =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, outer_b0));
-
- sum0 = ip0->checksum;
-
- //old_l0 always 0, see the rewrite setup
- new_l0 = ip0->length;
-
- sum0 = ip_csum_update (sum0, old_l0, new_l0, ip4_header_t,
- length /* changed member */ );
- ip0->checksum = sum0;
-
- int is_iface = 0;
- ip_adjacency_t *adj;
- if (PREDICT_FALSE (face->shared.adj == ~0))
- is_iface = 1;
- else
- adj = adj_get (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
- (is_iface || 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_PRIORITY_HI);
-
- fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
-
- face->shared.adj = fib_entry_get_adj (fib_entry_index);
- face->shared.flags &= ~HICN_FACE_FLAGS_IFACE;
- face->shared.flags |= HICN_FACE_FLAGS_FACE;
-
- adj = adj_get (face->shared.adj);
- }
-
- vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj;
- *next = adj->lookup_next_index;
-}
-
-always_inline void
-hicn_face_udp6_encap (vlib_main_t * vm,
- vlib_buffer_t * outer_b0,
- hicn_face_t * face, u32 * next)
-{
- int bogus0;
- u16 new_l0;
- ip6_header_t *ip0;
- udp_header_t *udp0;
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
-
- /* ip */
- ip0 = vlib_buffer_get_current (outer_b0);
- clib_memcpy (ip0, &(face_udp->hdrs.ip6.ip), sizeof (ip6_header_t) +
- sizeof (udp_header_t));
- new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, outer_b0)
- - sizeof (*ip0));
- ip0->payload_length = new_l0;
-
- /* Fix UDP length */
- udp0 = (udp_header_t *) (ip0 + 1);
- udp0->length = new_l0;
-
- udp0->checksum =
- ip6_tcp_udp_icmp_compute_checksum (vm, outer_b0, ip0, &bogus0);
-
- ASSERT (bogus0 == 0);
-
- if (udp0->checksum == 0)
- udp0->checksum = 0xffff;
-
- int is_iface = 0;
- ip_adjacency_t *adj;
- if (PREDICT_FALSE (face->shared.adj == ~0))
- is_iface = 1;
- else
- adj = adj_get (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 (is_iface || 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_PRIORITY_HI);
-
- fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
-
- face->shared.adj = fib_entry_get_adj (fib_entry_index);
- face->shared.flags &= ~HICN_FACE_FLAGS_IFACE;
- face->shared.flags |= HICN_FACE_FLAGS_FACE;
-
- adj = adj_get (face->shared.adj);
- }
-
- vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj;
-
- *next = adj->lookup_next_index;
-}
-
-static char *hicn_face_udp4_output_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-static char *hicn_face_udp6_output_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_face_udp4_output_trace_t;
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_face_udp6_output_trace_t;
-
-#define HICN_FACE_UDP_ENCAP_IP4 hicn_face_udp4_encap
-#define HICN_FACE_UDP_ENCAP_IP6 hicn_face_udp6_encap
-
-#define TRACE_OUTPUT_PKT_UDP4 hicn_face_udp4_output_trace_t
-#define TRACE_OUTPUT_PKT_UDP6 hicn_face_udp6_output_trace_t
-
-#define IP_HEADER_4 ip4_header_t
-#define IP_HEADER_6 ip6_header_t
-
-#define face_output_x1(ipv) \
- do { \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = IP_LOOKUP_NEXT_DROP; \
- hicn_face_t * face; \
- \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- face = \
- hicn_dpoi_get_from_idx(face_id); \
- \
- if (PREDICT_TRUE(face != NULL)) \
- { \
- /* Adjust vlib buffer. Create space for the udp tunnel. */ \
- vlib_buffer_advance(b0, -(sizeof (IP_HEADER_##ipv) + \
- sizeof (udp_header_t))); \
- \
- \
- HICN_FACE_UDP_ENCAP_IP##ipv \
- (vm, b0, face, &next0); \
- stats.pkts_interest_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_INTEREST_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0));\
- } \
- \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0) + \
- SIZE_HICN_HEADER##ipv, \
- sizeof (t->packet_data)); \
- } \
- \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- } while(0) \
-
-
-#define face_output_x2(ipv) \
- do { \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0 = IP_LOOKUP_NEXT_DROP; \
- u32 next1 = IP_LOOKUP_NEXT_DROP; \
- hicn_face_t *face0, *face1; \
- \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- \
- hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \
- face0 = \
- hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
- face1 = \
- hicn_dpoi_get_from_idx(vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \
- \
- if (PREDICT_TRUE(face0 != NULL)) \
- { \
- /* Adjust vlib buffer. Create space for the udp tunnel. */ \
- vlib_buffer_advance(b0, -(sizeof (IP_HEADER_##ipv) + \
- sizeof (udp_header_t))); \
- \
- \
- HICN_FACE_UDP_ENCAP_IP##ipv \
- (vm, b0, face0, &next0); \
- stats.pkts_interest_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id0 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_INTEREST_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if (PREDICT_TRUE(face1 != NULL)) \
- { \
- /* Adjust vlib buffer. Create space for the udp tunnel. */ \
- vlib_buffer_advance(b1, -(sizeof (IP_HEADER_##ipv) + \
- sizeof (udp_header_t))); \
- \
- \
- HICN_FACE_UDP_ENCAP_IP##ipv \
- (vm, b1, face1, &next1); \
- stats.pkts_interest_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id1 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_INTEREST_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- } \
- \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0) + \
- SIZE_HICN_HEADER##ipv, \
- sizeof (t->packet_data)); \
- } \
- \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1) + \
- SIZE_HICN_HEADER##ipv, \
- sizeof (t->packet_data)); \
- } \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- } while(0) \
-
-
-static uword
-hicn_face_udp4_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- /* Dual loop, X2 */
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- face_output_x2 (4);
- }
-
- /* Dual loop, X1 */
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- face_output_x1 (4);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
- stats.pkts_interest_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_face_udp4_output_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_udp4_output_trace_t *t =
- va_arg (*args, hicn_face_udp4_output_trace_t *);
-
- s =
- format (s, "FACE_UDP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/* *INDENT-OFF* */
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_face_udp4_output_node) =
-{
- .function = hicn_face_udp4_output_node_fn,
- .name = "hicn-face-udp4-output",
- .vector_size = sizeof (u32),
- .format_trace = hicn_face_udp4_output_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_face_udp4_output_error_strings),
- .error_strings = hicn_face_udp4_output_error_strings,
- .n_next_nodes = IP4_LOOKUP_N_NEXT,
- /* Reusing the list of nodes from lookup to be compatible with arp */
- .next_nodes = IP4_LOOKUP_NEXT_NODES,
-};
-/* *INDENT-ON* */
-
-/* *INDENT-ON* */
-
-static uword
-hicn_face_udp6_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- /* Dual loop, X2 */
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- face_output_x2 (6);
- }
-
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- face_output_x1 (6);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
- stats.pkts_interest_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_face_udp6_output_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_face_udp6_output_trace_t *t =
- va_arg (*args, hicn_face_udp6_output_trace_t *);
-
- s =
- format (s, "FACE_UDP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%u",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/* *INDENT-OFF* */
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_face_udp6_output_node) =
-{
- .function = hicn_face_udp6_output_node_fn,
- .name = "hicn-face-udp6-output",
- .vector_size = sizeof (u32),
- .format_trace = hicn_face_udp6_output_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_face_udp6_output_error_strings),
- .error_strings = hicn_face_udp6_output_error_strings,
- .n_next_nodes = IP6_LOOKUP_N_NEXT,
- /* Reusing the list of nodes from lookup to be compatible with neighbour discovery */
- .next_nodes = IP6_LOOKUP_NEXT_NODES,
-};
-/* *INDENT-ON* */
-
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.c b/hicn-plugin/src/faces/udp/iface_udp_node.c
deleted file mode 100644
index 1fdd68f0b..000000000
--- a/hicn-plugin/src/faces/udp/iface_udp_node.c
+++ /dev/null
@@ -1,987 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "iface_udp_node.h"
-#include "dpo_udp.h"
-#include "../face.h"
-
-#include "../../infra.h"
-#include "../../hicn.h"
-
-/**
- * @File
- *
- * Definition of the nodes for udp incomplete faces.
- */
-
-vlib_node_registration_t hicn_iface_udp4_input_node;
-vlib_node_registration_t hicn_iface_udp6_input_node;
-vlib_node_registration_t hicn_iface_udp4_output_node;
-vlib_node_registration_t hicn_iface_udp6_output_node;
-
-u32 data_fwd_face_udp4_vlib_edge;
-u32 data_fwd_face_udp6_vlib_edge;
-
-void
-hicn_iface_udp_init (vlib_main_t * vm)
-{
- data_fwd_face_udp4_vlib_edge = vlib_node_add_next (vm,
- hicn_data_fwd_node.index,
- hicn_iface_udp4_output_node.index);
-
- data_fwd_face_udp6_vlib_edge = vlib_node_add_next (vm,
- hicn_data_fwd_node.index,
- hicn_iface_udp6_output_node.index);
-
- u32 temp_index4 = vlib_node_add_next (vm,
- hicn_interest_hitcs_node.index,
- hicn_iface_udp4_output_node.index);
- u32 temp_index6 = vlib_node_add_next (vm,
- hicn_interest_hitcs_node.index,
- hicn_iface_udp6_output_node.index);
-
- ASSERT (temp_index4 == data_fwd_face_udp4_vlib_edge);
- ASSERT (temp_index6 == data_fwd_face_udp6_vlib_edge);
-}
-
-static char *hicn_iface_udp4_input_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-static char *hicn_iface_udp6_input_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-u32
-get_face_udp4_output_node (void)
-{
- return data_fwd_face_udp4_vlib_edge;
-}
-
-u32
-get_face_udp6_output_node (void)
-{
- return data_fwd_face_udp6_vlib_edge;
-}
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_iface_udp4_input_trace_t;
-
-typedef enum
-{
- HICN_IFACE_UDP4_INPUT_NEXT_INTEREST,
- HICN_IFACE_UDP4_INPUT_NEXT_MAPME,
- HICN_IFACE_UDP4_INPUT_NEXT_ERROR_DROP,
- HICN_IFACE_UDP4_INPUT_N_NEXT,
-} hicn_iface_udp4_input_next_t;
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_iface_udp6_input_trace_t;
-
-typedef enum
-{
- HICN_IFACE_UDP6_INPUT_NEXT_INTEREST,
- HICN_IFACE_UDP6_INPUT_NEXT_MAPME,
- HICN_IFACE_UDP6_INPUT_NEXT_ERROR_DROP,
- HICN_IFACE_UDP6_INPUT_N_NEXT,
-} hicn_iface_udp6_input_next_t;
-
-#define ERROR_INPUT_UDP4 HICN_IFACE_UDP4_INPUT_NEXT_ERROR_DROP
-#define ERROR_INPUT_UDP6 HICN_IFACE_UDP6_INPUT_NEXT_ERROR_DROP
-
-#define IP_HEADER_4 ip4_header_t
-#define IP_HEADER_6 ip6_header_t
-
-#define NEXT_MAPME_UDP4 HICN_IFACE_UDP4_INPUT_NEXT_MAPME
-#define NEXT_MAPME_UDP6 HICN_IFACE_UDP6_INPUT_NEXT_MAPME
-
-#define NEXT_INTEREST_UDP4 HICN_IFACE_UDP4_INPUT_NEXT_INTEREST
-#define NEXT_INTEREST_UDP6 HICN_IFACE_UDP6_INPUT_NEXT_INTEREST
-
-#define HICN_IFACE_UDP_ADD_LOCK_IP4 hicn_dpo_udp4_add_and_lock
-#define HICN_IFACE_UDP_ADD_LOCK_IP6 hicn_dpo_udp6_add_and_lock
-
-#define GET_FACE_UDP4 get_face_udp4_output_node
-#define GET_FACE_UDP6 get_face_udp6_output_node
-
-#define TRACE_INPUT_PKT_UDP4 hicn_iface_udp4_input_trace_t
-#define TRACE_INPUT_PKT_UDP6 hicn_iface_udp6_input_trace_t
-
-#define iface_input_x1(ipv) \
- do { \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = ERROR_INPUT_UDP##ipv; \
- IP_HEADER_##ipv * ip_hdr = NULL; \
- u8 * inner_ip_hdr = NULL; \
- udp_header_t * udp_hdr = NULL; \
- hicn_buffer_t * hicnb0; \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- udp_hdr = (udp_header_t *) (ip_hdr + 1); \
- hicnb0 = hicn_get_buffer(b0); \
- \
- stats.pkts_interest_count += 1; \
- \
- inner_ip_hdr = (u8 *)(udp_hdr + 1); \
- u8 is_v6 = hicn_is_v6((hicn_header_t *)inner_ip_hdr); \
- u8 is_icmp = is_v6*(inner_ip_hdr[6] == IPPROTO_ICMPV6) + \
- (1 - is_v6)*(inner_ip_hdr[9] == IPPROTO_ICMPV4); \
- \
- next0 = is_icmp*NEXT_MAPME_UDP##ipv + \
- (1-is_icmp)*NEXT_INTEREST_UDP##ipv; \
- \
- HICN_IFACE_UDP_ADD_LOCK_IP##ipv \
- (&(hicnb0->face_dpo_id), \
- &(ip_hdr->dst_address), \
- &(ip_hdr->src_address), \
- udp_hdr->dst_port, \
- udp_hdr->src_port, \
- GET_FACE_UDP##ipv \
- (), \
- &hicnb0->flags, \
- vnet_buffer(b0)->sw_if_index[VLIB_RX]); \
- \
- vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
- sizeof(udp_header_t)); \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index,\
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- }while(0)
-
-
-#define iface_input_x2(ipv) \
- do { \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0, next1 = ERROR_INPUT_UDP##ipv; \
- IP_HEADER_##ipv * ip_hdr0 = NULL, *ip_hdr1 = NULL; \
- u8 * inner_ip_hdr0 = NULL, *inner_ip_hdr1 = NULL; \
- udp_header_t * udp_hdr0 = NULL, *udp_hdr1 = NULL; \
- hicn_buffer_t * hicnb0, *hicnb1; \
- \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
- udp_hdr0 = (udp_header_t *) (ip_hdr0 + 1); \
- udp_hdr1 = (udp_header_t *) (ip_hdr1 + 1); \
- hicnb0 = hicn_get_buffer(b0); \
- hicnb1 = hicn_get_buffer(b1); \
- \
- stats.pkts_interest_count += 2; \
- \
- inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
- inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
- u8 is_v6_0 = hicn_is_v6((hicn_header_t *)inner_ip_hdr0); \
- u8 is_v6_1 = hicn_is_v6((hicn_header_t *)inner_ip_hdr1); \
- u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[6] == IPPROTO_ICMPV6) + \
- (1 - is_v6_0)*(inner_ip_hdr0[9] == IPPROTO_ICMPV4); \
- u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[6] == IPPROTO_ICMPV6) + \
- (1 - is_v6_1)*(inner_ip_hdr1[9] == IPPROTO_ICMPV4); \
- \
- next0 = is_icmp0*NEXT_MAPME_UDP##ipv + \
- (1-is_icmp0)*NEXT_INTEREST_UDP##ipv; \
- next1 = is_icmp1*NEXT_MAPME_UDP##ipv + \
- (1-is_icmp1)*NEXT_INTEREST_UDP##ipv; \
- \
- HICN_IFACE_UDP_ADD_LOCK_IP##ipv \
- (&(hicnb0->face_dpo_id), \
- &(ip_hdr0->dst_address), \
- &(ip_hdr0->src_address), \
- udp_hdr0->dst_port, \
- udp_hdr0->src_port, \
- GET_FACE_UDP##ipv \
- (), \
- &hicnb0->flags, \
- vnet_buffer(b0)->sw_if_index[VLIB_RX]); \
- \
- \
- HICN_IFACE_UDP_ADD_LOCK_IP##ipv \
- (&(hicnb1->face_dpo_id), \
- &(ip_hdr1->dst_address), \
- &(ip_hdr1->src_address), \
- udp_hdr1->dst_port, \
- udp_hdr1->src_port, \
- GET_FACE_UDP##ipv \
- (), \
- &hicnb1->flags, \
- vnet_buffer(b1)->sw_if_index[VLIB_RX]); \
- \
- vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
- sizeof(udp_header_t)); \
- \
- vlib_buffer_advance(b1, sizeof(IP_HEADER_##ipv) + \
- sizeof(udp_header_t)); \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1), \
- sizeof (t->packet_data)); \
- } \
- \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index,\
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- \
- vlib_increment_combined_counter ( \
- &counters[hicnb1->face_dpo_id.dpoi_index \
- * HICN_N_COUNTER], thread_index,\
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- }while(0)
-
-
-static uword
-hicn_iface_udp4_input_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- /* Dual loop, X2 */
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- iface_input_x2 (4);
- }
-
- /* Dual loop, X1 */
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- iface_input_x1 (4);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
- stats.pkts_interest_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_iface_udp4_input_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_udp4_input_trace_t *t =
- va_arg (*args, hicn_iface_udp4_input_trace_t *);
-
- s =
- format (s, "IFACE_UDP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_udp4_input_node) =
-
-{
- .function = hicn_iface_udp4_input_node_fn,
- .name = "hicn-iface-udp4-input",
- .vector_size = sizeof (u32),
- .format_trace = hicn_iface_udp4_input_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_udp4_input_error_strings),
- .error_strings = hicn_iface_udp4_input_error_strings,
- .n_next_nodes = HICN_IFACE_UDP4_INPUT_N_NEXT,
- .next_nodes =
- {
- [HICN_IFACE_UDP4_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
- [HICN_IFACE_UDP4_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
- [HICN_IFACE_UDP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-
-static uword
-hicn_iface_udp6_input_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- /* Dual loop, X2 */
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- iface_input_x2 (6);
- }
-
- /* Dual loop, X1 */
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- iface_input_x1 (6);
- }
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
- stats.pkts_interest_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_iface_udp6_input_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_udp6_input_trace_t *t =
- va_arg (*args, hicn_iface_udp6_input_trace_t *);
-
- s =
- format (s, "IFACE_UDP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_udp6_input_node) =
-{
- .function = hicn_iface_udp6_input_node_fn,
- .name = "hicn-iface-udp6-input",
- .vector_size = sizeof (u32),
- .format_trace = hicn_iface_udp6_input_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_udp6_input_error_strings),
- .error_strings = hicn_iface_udp6_input_error_strings,
- .n_next_nodes = HICN_IFACE_UDP6_INPUT_N_NEXT,
- .next_nodes =
- {
- [HICN_IFACE_UDP6_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
- [HICN_IFACE_UDP6_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
- [HICN_IFACE_UDP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-/******* Iface Output *******/
-
-always_inline void
-hicn_iface_udp4_encap (vlib_main_t * vm,
- vlib_buffer_t * b0, hicn_face_t * face)
-{
- u16 new_l0 = 0;
- ip4_header_t *ip0;
- udp_header_t *udp0;
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
-
- /* Adjust vlib buffers */
- /* Set the right length on the header buffer */
- /* Move the next buffer current data pointer back to the ip+tcp header (hicn header) */
- word offset = sizeof (ip4_header_t) + sizeof (udp_header_t);
- vlib_buffer_advance (b0, -offset);
-
- /* ip */
- ip0 = vlib_buffer_get_current (b0);
- clib_memcpy (ip0, &(face_udp->hdrs.ip4.ip), sizeof (ip4_header_t) +
- sizeof (udp_header_t));
-
- /* Fix UDP length */
- udp0 = (udp_header_t *) (ip0 + 1);
-
- new_l0 =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
- sizeof (*ip0));
- udp0->length = new_l0;
-
- ip0->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
- ip0->checksum = ip4_header_checksum (ip0);
-}
-
-always_inline void
-hicn_iface_udp6_encap (vlib_main_t * vm,
- vlib_buffer_t * b0, hicn_face_t * face)
-{
- int bogus0;
- u16 new_l0;
- ip6_header_t *ip0;
- udp_header_t *udp0;
- hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
-
- /* Adjust vlib buffer */
- word offset = sizeof (ip6_header_t) + sizeof (udp_header_t);
- vlib_buffer_advance (b0, -offset);
-
- /* ip */
- ip0 = vlib_buffer_get_current (b0);
- clib_memcpy (ip0, &(face_udp->hdrs.ip6.ip), sizeof (ip6_header_t) +
- sizeof (udp_header_t));
-
- new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
- - sizeof (*ip0));
-
- ip0->payload_length = new_l0;
-
- /* Fix UDP length */
- udp0 = (udp_header_t *) (ip0 + 1);
- udp0->length = new_l0;
-
- udp0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip0, &bogus0);
-
- ASSERT (bogus0 == 0);
-
- if (udp0->checksum == 0)
- udp0->checksum = 0xffff;
-}
-
-static char *hicn_iface_udp4_output_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-static char *hicn_iface_udp6_output_error_strings[] = {
-#define _(sym, string) string,
- foreach_hicnfwd_error
-#undef _
-};
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_iface_udp4_output_trace_t;
-
-typedef enum
-{
- HICN_IFACE_UDP4_OUTPUT_NEXT_LOOKUP,
- HICN_IFACE_UDP4_OUTPUT_NEXT_ERROR_DROP,
- HICN_IFACE_UDP4_OUTPUT_N_NEXT,
-} hicn_iface_udp4_output_next_t;
-
-/* Trace context struct */
-typedef struct
-{
- u32 next_index;
- u32 sw_if_index;
- u8 pkt_type;
- u8 packet_data[60];
-}
-hicn_iface_udp6_output_trace_t;
-
-typedef enum
-{
- HICN_IFACE_UDP6_OUTPUT_NEXT_LOOKUP,
- HICN_IFACE_UDP6_OUTPUT_NEXT_ERROR_DROP,
- HICN_IFACE_UDP6_OUTPUT_N_NEXT,
-} hicn_iface_udp6_output_next_t;
-
-#define ERROR_OUTPUT_UDP4 HICN_IFACE_UDP4_OUTPUT_NEXT_ERROR_DROP
-#define ERROR_OUTPUT_UDP6 HICN_IFACE_UDP6_OUTPUT_NEXT_ERROR_DROP
-
-#define IP_HEADER_4 ip4_header_t
-#define IP_HEADER_6 ip6_header_t
-
-#define NEXT_LOOKUP_UDP4 HICN_IFACE_UDP4_OUTPUT_NEXT_LOOKUP
-#define NEXT_LOOKUP_UDP6 HICN_IFACE_UDP6_OUTPUT_NEXT_LOOKUP
-
-#define HICN_IFACE_UDP_ADD_LOCK_IP4 hicn_dpo_udp4_add_and_lock
-#define HICN_IFACE_UDP_ADD_LOCK_IP6 hicn_dpo_udp6_add_and_lock
-
-#define HICN_FACE_UDP_ENCAP_IP4 hicn_iface_udp4_encap
-#define HICN_FACE_UDP_ENCAP_IP6 hicn_iface_udp6_encap
-
-#define TRACE_OUTPUT_PKT_UDP4 hicn_iface_udp4_output_trace_t
-#define TRACE_OUTPUT_PKT_UDP6 hicn_iface_udp6_output_trace_t
-
-#define SIZE_HICN_HEADER4 sizeof(ip4_header_t) + sizeof(udp_header_t)
-#define SIZE_HICN_HEADER6 sizeof(ip6_header_t) + sizeof(udp_header_t)
-
-#define iface_output_x1(ipv) \
- do { \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = ERROR_OUTPUT_UDP##ipv; \
- hicn_face_t * face; \
- \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- \
- hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- face = \
- hicn_dpoi_get_from_idx(face_id); \
- \
- if (PREDICT_TRUE(face != NULL)) \
- { \
- HICN_FACE_UDP_ENCAP_IP##ipv \
- (vm, b0, face); \
- next0 = NEXT_LOOKUP_UDP##ipv; \
- stats.pkts_data_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_DATA_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0) + \
- SIZE_HICN_HEADER##ipv, \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- } while(0)
-
-#define iface_output_x2(ipv) \
- do { \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0 = ERROR_OUTPUT_UDP##ipv, next1 = ERROR_OUTPUT_UDP##ipv; \
- hicn_face_t *face0, *face1; \
- \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- \
- /* Dequeue packets buffers */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- \
- hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \
- face0 = \
- hicn_dpoi_get_from_idx(face_id0); \
- face1 = \
- hicn_dpoi_get_from_idx(face_id1); \
- \
- if (PREDICT_TRUE(face0 != NULL)) \
- { \
- HICN_FACE_UDP_ENCAP_IP##ipv \
- (vm, b0, face0); \
- next0 = NEXT_LOOKUP_UDP##ipv; \
- stats.pkts_data_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id0 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_DATA_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if (PREDICT_TRUE(face1 != NULL)) \
- { \
- HICN_FACE_UDP_ENCAP_IP##ipv \
- (vm, b1, face1); \
- next1 = NEXT_LOOKUP_UDP##ipv; \
- stats.pkts_data_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id1 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_DATA_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0) + \
- SIZE_HICN_HEADER##ipv, \
- sizeof (t->packet_data)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_UDP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1) + \
- SIZE_HICN_HEADER##ipv, \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- } while(0)
-
-
-static uword
-hicn_iface_udp4_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- iface_output_x2 (4);
- }
-
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- iface_output_x1 (4);
- }
-
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
-
- return (frame->n_vectors);
-}
-
-/* packet trace format function */
-static u8 *
-hicn_iface_udp4_output_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_udp4_output_trace_t *t =
- va_arg (*args, hicn_iface_udp4_output_trace_t *);
-
- s =
- format (s,
- "IFACE_UDP4_OUTPUT: pkt: %d, out face %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_udp4_output_node) =
-{
- .function = hicn_iface_udp4_output_node_fn,
- .name = "hicn-iface-udp4-output",
- .vector_size = sizeof (u32),
- .format_trace = hicn_iface_udp4_output_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_udp4_output_error_strings),
- .error_strings = hicn_iface_udp4_output_error_strings,
- .n_next_nodes = HICN_IFACE_UDP4_OUTPUT_N_NEXT,
- /* edit / add dispositions here */
- .next_nodes =
- {
- [HICN_IFACE_UDP4_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
- [HICN_IFACE_UDP4_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-
-static uword
-hicn_iface_udp6_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next, next_index;
- vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
- u32 thread_index = vm->thread_index;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- iface_output_x2 (6);
- }
-
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- iface_output_x1 (6);
- }
-
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
-
- return (frame->n_vectors);
-
-}
-
-/* packet trace format function */
-static u8 *
-hicn_iface_udp6_output_format_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn_iface_udp6_output_trace_t *t =
- va_arg (*args, hicn_iface_udp6_output_trace_t *);
-
- s =
- format (s,
- "IFACE_UDP6_OUTPUT: pkt: %d, out face %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- (t->packet_data[0] & 0xf0) ==
- 0x40 ? format_ip4_header : format_ip6_header, t->packet_data,
- sizeof (t->packet_data));
- return (s);
-}
-
-/*
- * Node registration for the interest forwarder node
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn_iface_udp6_output_node) =
-{
- .function = hicn_iface_udp6_output_node_fn,
- .name = "hicn-iface-udp6-output",
- .vector_size = sizeof (u32),
- .format_trace = hicn_iface_udp6_output_format_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN (hicn_iface_udp6_output_error_strings),
- .error_strings = hicn_iface_udp6_output_error_strings,
- .n_next_nodes = HICN_IFACE_UDP6_OUTPUT_N_NEXT,
- /* edit / add dispositions here */
- .next_nodes =
- {
- [HICN_IFACE_UDP6_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
- [HICN_IFACE_UDP6_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.h b/hicn-plugin/src/faces/udp/iface_udp_node.h
deleted file mode 100644
index 957d19217..000000000
--- a/hicn-plugin/src/faces/udp/iface_udp_node.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HICN_IFACE_UDP_H__
-#define __HICN_IFACE_UDP_H__
-
-#include <vlib/vlib.h>
-
-extern vlib_node_registration_t hicn_iface_udp4_input_node;
-extern vlib_node_registration_t hicn_iface_udp6_input_node;
-extern vlib_node_registration_t hicn_iface_udp4_output_node;
-extern vlib_node_registration_t hicn_iface_udp6_output_node;
-
-void hicn_iface_udp_init (vlib_main_t * vm);
-
-#endif // __HICN_FACE_UDP_H__
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */