aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-11-22 13:09:58 +0000
committerGerrit Code Review <gerrit@fd.io>2019-11-22 13:09:58 +0000
commit843fba473ff35d026a7c4d39aa269b06c55e1f91 (patch)
tree5748e42bc923d85cd15114409d2719a976d0106e /hicn-plugin
parent4d593c09d9cc1496788f7953de25832193064103 (diff)
parent62f7b46d4c49d6e5bfb5b3b537bfcaf6503e7bac (diff)
Merge "[HICN-405] Added application face delete"
Diffstat (limited to 'hicn-plugin')
-rw-r--r--hicn-plugin/src/cache_policies/cs_lru.c59
-rw-r--r--hicn-plugin/src/cache_policies/cs_lru.h2
-rw-r--r--hicn-plugin/src/cache_policies/cs_policy.h3
-rw-r--r--hicn-plugin/src/face_db.h3
-rw-r--r--hicn-plugin/src/faces/app/face_app_cli.c40
-rw-r--r--hicn-plugin/src/faces/app/face_cons.c14
-rw-r--r--hicn-plugin/src/faces/app/face_cons.h3
-rw-r--r--hicn-plugin/src/faces/app/face_prod.c33
-rw-r--r--hicn-plugin/src/faces/face.c1
-rw-r--r--hicn-plugin/src/faces/ip/dpo_ip.h28
-rw-r--r--hicn-plugin/src/faces/ip/face_ip.h16
-rw-r--r--hicn-plugin/src/faces/udp/dpo_udp.h12
-rw-r--r--hicn-plugin/src/faces/udp/face_udp.c43
-rw-r--r--hicn-plugin/src/faces/udp/face_udp.h2
-rw-r--r--hicn-plugin/src/hicn.api27
-rw-r--r--hicn-plugin/src/hicn_api.c78
-rw-r--r--hicn-plugin/src/hicn_api_test.c148
-rw-r--r--hicn-plugin/src/interest_hitpit_node.c5
-rw-r--r--hicn-plugin/src/pcs.c1
-rw-r--r--hicn-plugin/src/route.c116
-rw-r--r--hicn-plugin/src/strategy.c7
21 files changed, 442 insertions, 199 deletions
diff --git a/hicn-plugin/src/cache_policies/cs_lru.c b/hicn-plugin/src/cache_policies/cs_lru.c
index 1f1d14667..45c4b5b79 100644
--- a/hicn-plugin/src/cache_policies/cs_lru.c
+++ b/hicn-plugin/src/cache_policies/cs_lru.c
@@ -25,6 +25,7 @@ hicn_cs_policy_vft_t hicn_cs_lru = {
.hicn_cs_dequeue = &hicn_cs_lru_dequeue,
.hicn_cs_delete_get = &hicn_cs_lru_delete_get,
.hicn_cs_trim = &hicn_cs_lru_trim,
+ .hicn_cs_flush = &hicn_cs_lru_flush,
};
/*
@@ -151,10 +152,10 @@ hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
{
/* The element is already dequeue */
if (pcs->u.cs.cs_lru_next == 0)
- {
- /* Now detached from the list; attach at head */
- hicn_cs_lru_insert (pit, pnode, pcs, lru);
- }
+ {
+ /* Now detached from the list; attach at head */
+ hicn_cs_lru_insert (pit, pnode, pcs, lru);
+ }
ASSERT (lru->head ==
hicn_hashtb_node_idx_from_node (pit->pcs_table, pnode));
}
@@ -212,6 +213,56 @@ hicn_cs_lru_trim (hicn_pit_cs_t * pit, u32 * node_list, int sz,
return (i);
}
+int
+hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs,
+ hicn_cs_policy_t * state)
+{
+ if (state->head == 0 && state->tail == 0)
+ return 0;
+
+ hicn_hash_node_t *lrunode;
+ hicn_pcs_entry_t *lrupcs;
+ u32 idx;
+ int i = 0;
+
+ idx = state->tail;
+
+ while (idx != 0)
+ {
+ lrunode = hicn_hashtb_node_from_idx (pitcs->pcs_table, idx);
+ lrupcs = hicn_pit_get_data (lrunode);
+
+ u64 hashval = 0;
+ hicn_hashtb_fullhash ((u8 *) & (lrunode->hn_key.ks.key),
+ lrunode->hn_keysize, &hashval);
+ hicn_hash_bucket_t *bucket = NULL;
+ if ((hashval & (pitcs->pcs_table->ht_bucket_count - 1)) ==
+ lrunode->bucket_id)
+ {
+ //The bucket is in the non overflown
+ bucket =
+ pool_elt_at_index (pitcs->pcs_table->ht_buckets,
+ lrunode->bucket_id);
+ }
+ else
+ {
+ bucket =
+ pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets,
+ lrunode->bucket_id);
+ }
+ hicn_hash_entry_t *hash_entry =
+ &(bucket->hb_entries[lrunode->entry_idx]);
+ hash_entry->locks++;
+ hicn_pcs_cs_delete (vm, pitcs, &lrupcs, &lrunode, hash_entry, NULL,
+ NULL);
+ idx = state->tail;
+ i++;
+ }
+
+ return (i);
+
+}
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/hicn-plugin/src/cache_policies/cs_lru.h b/hicn-plugin/src/cache_policies/cs_lru.h
index 94320f7f9..0a58912d6 100644
--- a/hicn-plugin/src/cache_policies/cs_lru.h
+++ b/hicn-plugin/src/cache_policies/cs_lru.h
@@ -58,6 +58,8 @@ int hicn_cs_lru_trim (hicn_pit_cs_t * pcs, u32 * node_list, int sz,
hicn_cs_policy_t * lru);
+int hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs,
+ hicn_cs_policy_t * state);
#endif /* // __LRU_H__ */
/*
diff --git a/hicn-plugin/src/cache_policies/cs_policy.h b/hicn-plugin/src/cache_policies/cs_policy.h
index 08817de18..c1a9a44c9 100644
--- a/hicn-plugin/src/cache_policies/cs_policy.h
+++ b/hicn-plugin/src/cache_policies/cs_policy.h
@@ -68,6 +68,9 @@ typedef struct hicn_cs_policy_vft_s
int (*hicn_cs_trim) (struct hicn_pit_cs_s * p, u32 * node_list, int sz,
hicn_cs_policy_t * policy);
+
+ int (*hicn_cs_flush) (vlib_main_t * vm, struct hicn_pit_cs_s * p,
+ hicn_cs_policy_t * policy_state);
} hicn_cs_policy_vft_t;
diff --git a/hicn-plugin/src/face_db.h b/hicn-plugin/src/face_db.h
index c3308050a..17c28959a 100644
--- a/hicn-plugin/src/face_db.h
+++ b/hicn-plugin/src/face_db.h
@@ -110,9 +110,6 @@ hicn_face_db_add_face_dpo (dpo_id_t * dpo, hicn_face_db_t * face_db)
clib_memcpy (face, dpo, sizeof (dpo_id_t));
- /* This access the dpoi to increase the lock */
- dpo_lock (dpo);
-
u32 bitmap_index = dpo->dpoi_index % HICN_PIT_N_HOP_BITMAP_SIZE;
u32 position_array = bitmap_index / 8;
u8 bit_index = (u8) (bitmap_index - position_array * 8);
diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c
index 200f813cb..1e8eb6a5b 100644
--- a/hicn-plugin/src/faces/app/face_app_cli.c
+++ b/hicn-plugin/src/faces/app/face_app_cli.c
@@ -35,7 +35,8 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
{
vnet_main_t *vnm = vnet_get_main ();
fib_prefix_t prefix;
- hicn_face_id_t face_id = HICN_FACE_NULL;
+ hicn_face_id_t face_id1 = HICN_FACE_NULL;
+ hicn_face_id_t face_id2 = HICN_FACE_NULL;
u32 cs_reserved = HICN_PARAM_FACE_DFT_CS_RESERVED;
int ret = HICN_ERROR_NONE;
int sw_if;
@@ -57,7 +58,7 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
face_op = HICN_FACE_DELETE;
}
else if (face_op == HICN_FACE_DELETE
- && unformat (line_input, "id %d", &face_id))
+ && unformat (line_input, "id %d", &face_id1))
;
else if (unformat (line_input, "add"))
{
@@ -95,13 +96,13 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
}
}
- if (face_id != HICN_FACE_NULL)
+ if (face_id1 != HICN_FACE_NULL)
{
- if (!hicn_dpoi_idx_is_valid (face_id))
+ if (!hicn_dpoi_idx_is_valid (face_id1))
{
- return clib_error_return (0, "%s, face_id %d not valid",
- get_error_string (ret), face_id);
+ return clib_error_return (0, "%s, face_id1 %d not valid",
+ get_error_string (ret), face_id1);
}
}
@@ -116,15 +117,18 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
if (prod)
{
- prefix.fp_proto = ip46_address_is_ip4(&prefix.fp_addr) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
+ prefix.fp_proto =
+ ip46_address_is_ip4 (&prefix.
+ fp_addr) ? FIB_PROTOCOL_IP4 :
+ FIB_PROTOCOL_IP6;
rv =
- hicn_face_prod_add (&prefix, sw_if, &cs_reserved,
- &prod_addr, &face_id);
+ hicn_face_prod_add (&prefix, sw_if, &cs_reserved, &prod_addr,
+ &face_id1);
if (rv == HICN_ERROR_NONE)
{
u8 *sbuf = NULL;
sbuf =
- format (sbuf, "Face id: %d, producer address %U", face_id,
+ format (sbuf, "Face id: %d, producer address %U", face_id1,
format_ip46_address, &prod_addr,
0 /*IP46_ANY_TYPE */ );
vlib_cli_output (vm, "%s", sbuf);
@@ -137,13 +141,15 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
else
{
rv =
- hicn_face_cons_add (&cons_addr4, &cons_addr6, sw_if, &face_id);
+ hicn_face_cons_add (&cons_addr4, &cons_addr6, sw_if, &face_id1,
+ &face_id2);
if (rv == HICN_ERROR_NONE)
{
u8 *sbuf = NULL;
sbuf =
- format (sbuf, "Face id: %d, consumer addresses v4 %U v6 %U",
- face_id, format_ip4_address, &cons_addr4,
+ format (sbuf,
+ "Face id: %d, address v4 %U, face id: %d address v6 %U",
+ face_id1, format_ip4_address, &cons_addr4, face_id2,
format_ip6_address, &cons_addr6);
vlib_cli_output (vm, "%s", sbuf);
}
@@ -156,15 +162,15 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
}
case HICN_FACE_DELETE:
{
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id1);
if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
- rv = hicn_face_cons_del (face_id);
+ rv = hicn_face_cons_del (face_id1);
else
- rv = hicn_face_prod_del (face_id);
+ rv = hicn_face_prod_del (face_id1);
if (rv == HICN_ERROR_NONE)
{
- vlib_cli_output (vm, "Face %d deleted", face_id);
+ vlib_cli_output (vm, "Face %d deleted", face_id1);
}
else
{
diff --git a/hicn-plugin/src/faces/app/face_cons.c b/hicn-plugin/src/faces/app/face_cons.c
index 8278b6ab3..f258da787 100644
--- a/hicn-plugin/src/faces/app/face_cons.c
+++ b/hicn-plugin/src/faces/app/face_cons.c
@@ -23,7 +23,8 @@
int
hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
- u32 swif, hicn_face_id_t * faceid)
+ u32 swif, hicn_face_id_t * faceid1,
+ hicn_face_id_t * faceid2)
{
/* Create the corresponding appif if */
/* Retrieve a valid local ip address to assign to the appif */
@@ -56,9 +57,9 @@ hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
ip46_address_t nh_addr = to_ip46 (0, (u8 *) nh_addr4);
- hicn_iface_ip_add (&if_ip, &nh_addr, swif, faceid);
+ hicn_iface_ip_add (&if_ip, &nh_addr, swif, faceid1);
- hicn_face_t *face = hicn_dpoi_get_from_idx (*faceid);
+ hicn_face_t *face = hicn_dpoi_get_from_idx (*faceid1);
face->shared.flags |= HICN_FACE_FLAGS_APPFACE_CONS;
get_two_ip6_addresses (&(if_ip.ip6), nh_addr6);
@@ -67,9 +68,9 @@ hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
&(if_ip.ip6),
ADDR_MGR_IP6_CONS_LEN, 0 /* is_del */ );
- hicn_iface_ip_add (&if_ip, (ip46_address_t *) nh_addr6, swif, faceid);
+ hicn_iface_ip_add (&if_ip, (ip46_address_t *) nh_addr6, swif, faceid2);
- face = hicn_dpoi_get_from_idx (*faceid);
+ face = hicn_dpoi_get_from_idx (*faceid2);
face->shared.flags |= HICN_FACE_FLAGS_APPFACE_CONS;
return vnet_feature_enable_disable ("ip6-unicast",
@@ -81,6 +82,9 @@ hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
int
hicn_face_cons_del (hicn_face_id_t face_id)
{
+ if (!hicn_dpoi_idx_is_valid (face_id))
+ return HICN_ERROR_APPFACE_NOT_FOUND;
+
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
diff --git a/hicn-plugin/src/faces/app/face_cons.h b/hicn-plugin/src/faces/app/face_cons.h
index 067b45a1f..5f8f5dde8 100644
--- a/hicn-plugin/src/faces/app/face_cons.h
+++ b/hicn-plugin/src/faces/app/face_cons.h
@@ -47,7 +47,8 @@
*/
int
hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
- u32 swif, hicn_face_id_t * faceid);
+ u32 swif, hicn_face_id_t * faceid1,
+ hicn_face_id_t * faceid2);
/**
* @brief Delete an existing consumer application face
diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c
index 6c12e6d33..14e100adc 100644
--- a/hicn-plugin/src/faces/app/face_prod.c
+++ b/hicn-plugin/src/faces/app/face_prod.c
@@ -16,6 +16,7 @@
#include <vnet/ip/ip6_packet.h>
#include <vlib/vlib.h>
#include <vnet/vnet.h>
+#include <vnet/interface_funcs.h>
#include "face_prod.h"
#include "address_mgr.h"
@@ -53,8 +54,7 @@ hicn_app_state_create (u32 swif, fib_prefix_t * prefix)
/* Create the appif and store in the vector */
vec_validate (face_state_vec, swif);
- clib_memcpy (&(face_state_vec[swif].prefix), prefix,
- sizeof (fib_prefix_t));
+ clib_memcpy (&(face_state_vec[swif].prefix), prefix, sizeof (fib_prefix_t));
/* Set as busy the element in the vector */
pool_get (face_state_pool, swif_app);
@@ -139,6 +139,12 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
{
return HICN_ERROR_FWD_NOT_ENABLED;
}
+
+ if (vnet_get_sw_interface_or_null (vnm, sw_if) == NULL)
+ {
+ return HICN_ERROR_FACE_HW_INT_NOT_FOUND;
+ }
+
int ret = HICN_ERROR_NONE;
hicn_face_t *face = NULL;
@@ -146,8 +152,7 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
vnet_sw_interface_set_flags (vnm, sw_if, if_flags);
u8 *s0;
- s0 = format (0, "Prefix %U", format_fib_prefix,
- prefix);
+ s0 = format (0, "Prefix %U", format_fib_prefix, prefix);
vlib_cli_output (vm, "Received request for %s, swif %d\n", s0, sw_if);
@@ -218,7 +223,8 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
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);
+ hicn_face_ip_add (&local_app_ip, &remote_app_ip, sw_if, faceid,
+ HICN_FACE_FLAGS_APPFACE_PROD);
}
else
{
@@ -238,7 +244,8 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
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);
+ 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);
@@ -257,6 +264,7 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
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;
}
@@ -283,13 +291,15 @@ hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
int
hicn_face_prod_del (hicn_face_id_t face_id)
{
+ if (!hicn_dpoi_idx_is_valid (face_id))
+ return HICN_ERROR_APPFACE_NOT_FOUND;
+
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
if (face->shared.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_max += prod_face->policy.max;
hicn_main.pitcs.pcs_app_count -= prod_face->policy.max;
prod_face->policy.max = 0;
@@ -297,6 +307,15 @@ hicn_face_prod_del (hicn_face_id_t face_id)
hicn_route_del_nhop (&(face_state_vec[face->shared.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;
diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c
index 74939b77e..fa9d0d203 100644
--- a/hicn-plugin/src/faces/face.c
+++ b/hicn-plugin/src/faces/face.c
@@ -132,6 +132,7 @@ hicn_face_del (hicn_face_id_t face_id)
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)
pool_put_index (hicn_dpoi_face_pool, face_id);
else
diff --git a/hicn-plugin/src/faces/ip/dpo_ip.h b/hicn-plugin/src/faces/ip/dpo_ip.h
index d6b4f5f7e..c893c8be4 100644
--- a/hicn-plugin/src/faces/ip/dpo_ip.h
+++ b/hicn-plugin/src/faces/ip/dpo_ip.h
@@ -41,11 +41,15 @@ void hicn_dpo_ip_module_init (void);
*/
always_inline int
hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
- u32 * in_faces_vec_id,
+ u32 * in_faces_vec_id,
u8 * hicnb_flags,
const ip4_address_t * local_addr, u32 sw_if)
{
- hicn_face_ip_input_faces_t * in_faces_vec =
+ 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);
if (PREDICT_FALSE (in_faces_vec == NULL))
@@ -61,7 +65,7 @@ hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, in_faces_vec->face_id);
dpo->dpoi_next_node = ~0;
- dpo_lock (dpo);
+ dpo_unlock (dpo);
return HICN_ERROR_NONE;
}
@@ -80,11 +84,15 @@ hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
*/
always_inline int
hicn_dpo_ip6_lock_from_local (dpo_id_t * dpo,
- u32 * in_faces_vec_id,
+ u32 * in_faces_vec_id,
u8 * hicnb_flags,
const ip6_address_t * local_addr, u32 sw_if)
{
- hicn_face_ip_input_faces_t * in_faces_vec =
+ 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);
if (PREDICT_FALSE (in_faces_vec == NULL))
@@ -100,7 +108,7 @@ hicn_dpo_ip6_lock_from_local (dpo_id_t * dpo,
dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP6, in_faces_vec->face_id);
dpo->dpoi_next_node = ~0;
- dpo_lock (dpo);
+ dpo_unlock (dpo);
return HICN_ERROR_NONE;
}
@@ -144,7 +152,7 @@ hicn_dpo_ip4_add_and_lock_from_remote (dpo_id_t * dpo,
dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
dpo->dpoi_next_node = node_index;
- dpo_lock (dpo);
+ dpo_unlock (dpo);
return;
}
@@ -158,7 +166,7 @@ hicn_dpo_ip4_add_and_lock_from_remote (dpo_id_t * dpo,
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_lock (dpo);
+ dpo_unlock (dpo);
}
/**
@@ -198,7 +206,7 @@ hicn_dpo_ip6_add_and_lock_from_remote (dpo_id_t * dpo,
dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
dpo->dpoi_next_node = node_index;
- dpo_lock (dpo);
+ dpo_unlock (dpo);
return;
}
@@ -211,7 +219,7 @@ hicn_dpo_ip6_add_and_lock_from_remote (dpo_id_t * dpo,
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_lock (dpo);
+ dpo_unlock (dpo);
}
diff --git a/hicn-plugin/src/faces/ip/face_ip.h b/hicn-plugin/src/faces/ip/face_ip.h
index 0491af506..74f3a83dc 100644
--- a/hicn-plugin/src/faces/ip/face_ip.h
+++ b/hicn-plugin/src/faces/ip/face_ip.h
@@ -47,7 +47,7 @@ typedef struct hicn_ip_face_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 hicn_face_id_t *hicn_face_ip_vec_t;
typedef struct hicn_ip_input_faces_s_
{
@@ -77,7 +77,7 @@ 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;
+extern hicn_face_ip_vec_t *hicn_vec_pool;
/**
* Key definition for the mhash table. An ip face is uniquely identified by ip
@@ -161,12 +161,13 @@ hicn_face_ip4_get (const ip4_address_t * addr, u32 sw_if, mhash_t * hashtb)
* @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_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);
+ return (hicn_face_ip_input_faces_t *) mhash_get (hashtb, &key);
}
/**
@@ -179,12 +180,13 @@ hicn_face_ip4_get_vec (const ip4_address_t * addr, u32 sw_if, mhash_t * hashtb)
* @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_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);
+ return (hicn_face_ip_input_faces_t *) mhash_get (hashtb, &key);
}
/**
@@ -255,7 +257,7 @@ hicn_iface_ip_add (const ip46_address_t * local_addr,
face->shared.pl_id = (u16) 0;
face->shared.face_type = hicn_face_ip_type;
face->shared.flags = HICN_FACE_FLAGS_IFACE;
- face->shared.locks = 0;
+ face->shared.locks = 1;
hicn_face_ip_key_t key;
hicn_face_ip6_get_key (&(remote_addr->ip6), sw_if, &key);
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.h b/hicn-plugin/src/faces/udp/dpo_udp.h
index 06c65a9c2..98abf3d29 100644
--- a/hicn-plugin/src/faces/udp/dpo_udp.h
+++ b/hicn-plugin/src/faces/udp/dpo_udp.h
@@ -92,7 +92,7 @@ hicn_dpo_udp4_lock (dpo_id_t * dpo,
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_lock (dpo);
+ dpo_unlock (dpo);
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
@@ -138,7 +138,7 @@ hicn_dpo_udp4_add_and_lock (dpo_id_t * dpo,
*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_lock (dpo);
+ dpo_unlock (dpo);
return;
}
@@ -148,7 +148,7 @@ hicn_dpo_udp4_add_and_lock (dpo_id_t * dpo,
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_lock (dpo);
+ dpo_unlock (dpo);
}
/**
@@ -212,7 +212,7 @@ hicn_dpo_udp6_lock (dpo_id_t * dpo,
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_lock (dpo);
+ dpo_unlock (dpo);
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
return HICN_ERROR_NONE;
@@ -256,7 +256,7 @@ hicn_dpo_udp6_add_and_lock (dpo_id_t * dpo,
*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_lock (dpo);
+ dpo_unlock (dpo);
return;
}
@@ -266,7 +266,7 @@ hicn_dpo_udp6_add_and_lock (dpo_id_t * dpo,
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_lock (dpo);
+ dpo_unlock (dpo);
}
/**
diff --git a/hicn-plugin/src/faces/udp/face_udp.c b/hicn-plugin/src/faces/udp/face_udp.c
index ec43d9081..6a8e5c9e0 100644
--- a/hicn-plugin/src/faces/udp/face_udp.c
+++ b/hicn-plugin/src/faces/udp/face_udp.c
@@ -81,17 +81,15 @@ hicn_face_udp_init (vlib_main_t * vm)
/* Default Strategy has index 0 and it always exists */
strategy_face_udp4_vlib_edge = vlib_node_add_next (vm,
hicn_dpo_get_strategy_vft
- (default_dpo.
- hicn_dpo_get_type ())->
- get_strategy_node_index
+ (default_dpo.hicn_dpo_get_type
+ ())->get_strategy_node_index
(),
- hicn_face_udp4_output_node.
- index);
+ hicn_face_udp4_output_node.index);
strategy_face_udp6_vlib_edge =
vlib_node_add_next (vm,
- hicn_dpo_get_strategy_vft (default_dpo.
- hicn_dpo_get_type ())->
- get_strategy_node_index (),
+ hicn_dpo_get_strategy_vft
+ (default_dpo.hicn_dpo_get_type
+ ())->get_strategy_node_index (),
hicn_face_udp6_output_node.index);
/*
@@ -145,7 +143,7 @@ hicn_face_udp_add (const ip46_address_t * local_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;
+ 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,
@@ -155,14 +153,14 @@ hicn_face_udp_add (const ip46_address_t * local_addr,
ip_adj = fib_entry_get_adj (fib_entry_index);
if (ip_adj == ~0)
- return HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;
+ 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)
- return HICN_ERROR_FACE_ALREADY_CREATED;
+ return HICN_ERROR_FACE_ALREADY_CREATED;
pool_get (hicn_dpoi_face_pool, face);
@@ -211,7 +209,7 @@ hicn_face_udp_add (const ip46_address_t * local_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;
+ 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,
@@ -221,14 +219,14 @@ hicn_face_udp_add (const ip46_address_t * local_addr,
ip_adj = fib_entry_get_adj (fib_entry_index);
if (ip_adj == ~0)
- return HICN_ERROR_FACE_IP_ADJ_NOT_FOUND;
+ 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)
- return HICN_ERROR_FACE_ALREADY_CREATED;
+ return HICN_ERROR_FACE_ALREADY_CREATED;
pool_get (hicn_dpoi_face_pool, face);
@@ -275,8 +273,7 @@ hicn_face_udp_add (const ip46_address_t * local_addr,
}
retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
- hicn_mapme_eventmgr_process_node.
- index,
+ hicn_mapme_eventmgr_process_node.index,
HICN_MAPME_EVENT_FACE_ADD, 1,
sizeof (retx_t));
/* *INDENT-OFF* */
@@ -293,6 +290,9 @@ hicn_face_udp_add (const ip46_address_t * local_addr,
};
/* *INDENT-ON* */
+ //Take a lock on the face which will be removed when the face is deleted
+ hicn_face_lock (&(retx->dpo));
+
return ret;
}
@@ -304,15 +304,20 @@ hicn_face_udp_del (u32 faceid)
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)
+ 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,
+ 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,
+ 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);
}
diff --git a/hicn-plugin/src/faces/udp/face_udp.h b/hicn-plugin/src/faces/udp/face_udp.h
index cea3e7262..5dfc76e22 100644
--- a/hicn-plugin/src/faces/udp/face_udp.h
+++ b/hicn-plugin/src/faces/udp/face_udp.h
@@ -294,7 +294,7 @@ hicn_iface_udp4_add (const ip4_address_t * local_addr,
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.locks = 1;
face->shared.sw_if = sw_if;
hicn_face_udp_key_t key;
diff --git a/hicn-plugin/src/hicn.api b/hicn-plugin/src/hicn.api
index 2f33c901b..ba776c5f6 100644
--- a/hicn-plugin/src/hicn.api
+++ b/hicn-plugin/src/hicn.api
@@ -747,6 +747,18 @@ define hicn_api_register_prod_app_reply
u32 faceid;
};
+autoreply define hicn_api_face_prod_del
+{
+ /* Client identifier, set from api_main.my_client_index */
+ u32 client_index;
+
+ /* Arbitrary context, so client can match reply to request */
+ u32 context;
+
+ /* A Face ID to be deleted */
+ u32 faceid;
+};
+
define hicn_api_register_cons_app
{
/* Client identifier, set from api_main.my_client_index */
@@ -774,6 +786,21 @@ define hicn_api_register_cons_app_reply
vl_api_address_t src_addr6;
/* Return value: new Face ID, ~0 means no Face was created */
+ u32 faceid1;
+
+ /* Return value: new Face ID, ~0 means no Face was created */
+ u32 faceid2;
+};
+
+autoreply define hicn_api_face_cons_del
+{
+ /* Client identifier, set from api_main.my_client_index */
+ u32 client_index;
+
+ /* Arbitrary context, so client can match reply to request */
+ u32 context;
+
+ /* A Face ID to be deleted */
u32 faceid;
};
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index 6e5cef643..4c75d406d 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -86,8 +86,9 @@
_(HICN_API_PUNTING_ADD, hicn_api_punting_add) \
_(HICN_API_PUNTING_DEL, hicn_api_punting_del) \
_(HICN_API_REGISTER_PROD_APP, hicn_api_register_prod_app) \
- _(HICN_API_REGISTER_CONS_APP, hicn_api_register_cons_app)
-
+ _(HICN_API_FACE_PROD_DEL, hicn_api_face_prod_del) \
+ _(HICN_API_REGISTER_CONS_APP, hicn_api_register_cons_app) \
+ _(HICN_API_FACE_CONS_DEL, hicn_api_face_cons_del)
/****** SUPPORTING FUNCTION DECLARATIONS ******/
@@ -392,7 +393,6 @@ vl_api_hicn_api_face_del_t_handler (vl_api_hicn_api_face_del_t * mp)
}
REPLY_MACRO (VL_API_HICN_API_FACE_DEL_REPLY /* , rmp, mp, rv */ );
-
}
static void
@@ -488,7 +488,7 @@ send_faces_details (vl_api_registration_t * reg,
}
static void
- vl_api_hicn_api_faces_dump_t_handler (vl_api_hicn_api_faces_dump_t * mp)
+vl_api_hicn_api_faces_dump_t_handler (vl_api_hicn_api_faces_dump_t * mp)
{
hicn_face_t *face;
vl_api_registration_t *reg;
@@ -506,7 +506,7 @@ static void
}
static void
- vl_api_hicn_api_face_get_t_handler (vl_api_hicn_api_face_get_t * mp)
+vl_api_hicn_api_face_get_t_handler (vl_api_hicn_api_face_get_t * mp)
{
vl_api_hicn_api_face_get_reply_t *rmp;
int rv = 0;
@@ -745,8 +745,8 @@ send_route_details (vl_api_registration_t * reg,
{
mp->faceids[i] =
clib_host_to_net_u32 (((dpo_id_t *) &
- hicn_dpo_ctx->next_hops[i])->
- dpoi_index);
+ hicn_dpo_ctx->
+ next_hops[i])->dpoi_index);
mp->nfaces++;
}
}
@@ -817,8 +817,7 @@ static void
fib_table_walk (fib_table->ft_index,
FIB_PROTOCOL_IP4,
vl_api_hicn_api_route_dump_walk,
- &ctx);
- }
+ &ctx);}
));
pool_foreach (fib_table, im6->fibs, (
@@ -826,8 +825,7 @@ static void
fib_table_walk (fib_table->ft_index,
FIB_PROTOCOL_IP6,
vl_api_hicn_api_route_dump_walk,
- &ctx);
- }
+ &ctx);}
));
vec_foreach (lfeip, ctx.feis)
@@ -890,17 +888,20 @@ static void vl_api_hicn_api_strategy_get_t_handler
/****** PUNTING *******/
-static hicn_error_t add_ip_punting (vl_api_hicn_punting_ip_t * mp)
+static hicn_error_t
+add_ip_punting (vl_api_hicn_punting_ip_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
fib_prefix_t prefix;
ip_prefix_decode (&mp->prefix, &prefix);
u32 swif = clib_net_to_host_u32 (mp->swif);
- return hicn_punt_interest_data_for_ip (vm, &prefix, swif, HICN_PUNT_IP_TYPE, NO_L2);
+ return hicn_punt_interest_data_for_ip (vm, &prefix, swif, HICN_PUNT_IP_TYPE,
+ NO_L2);
}
-static hicn_error_t add_udp_punting (vl_api_hicn_punting_udp_t * mp)
+static hicn_error_t
+add_udp_punting (vl_api_hicn_punting_udp_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
fib_prefix_t prefix;
@@ -908,9 +909,11 @@ static hicn_error_t add_udp_punting (vl_api_hicn_punting_udp_t * mp)
u32 swif = clib_net_to_host_u32 (mp->swif);
u16 sport = clib_net_to_host_u16 (mp->sport);
u16 dport = clib_net_to_host_u16 (mp->sport);
- u8 type = mp->ip_version == ADDRESS_IP6 ? HICN_PUNT_UDP6_TYPE : HICN_PUNT_UDP4_TYPE;
+ u8 type =
+ mp->ip_version == ADDRESS_IP6 ? HICN_PUNT_UDP6_TYPE : HICN_PUNT_UDP4_TYPE;
- return hicn_punt_interest_data_for_udp (vm, &prefix, swif, type, sport, dport, NO_L2);
+ return hicn_punt_interest_data_for_udp (vm, &prefix, swif, type, sport,
+ dport, NO_L2);
}
static void vl_api_hicn_api_punting_add_t_handler
@@ -923,11 +926,11 @@ static void vl_api_hicn_api_punting_add_t_handler
if (mp->type == IP_PUNT)
{
- rv = add_ip_punting(&(mp->rule.ip));
+ rv = add_ip_punting (&(mp->rule.ip));
}
else if (mp->type == UDP_PUNT)
{
- rv = add_udp_punting(&(mp->rule.udp));
+ rv = add_udp_punting (&(mp->rule.udp));
}
else
{
@@ -981,6 +984,20 @@ static void vl_api_hicn_api_register_prod_app_t_handler
/* *INDENT-ON* */
}
+static void
+vl_api_hicn_api_face_prod_del_t_handler (vl_api_hicn_api_face_prod_del_t * mp)
+{
+ vl_api_hicn_api_face_prod_del_reply_t *rmp;
+ int rv = HICN_ERROR_FACE_NOT_FOUND;
+
+ hicn_main_t *sm = &hicn_main;
+
+ hicn_face_id_t faceid = clib_net_to_host_u32 (mp->faceid);
+ rv = hicn_face_prod_del (faceid);
+
+ REPLY_MACRO (VL_API_HICN_API_FACE_PROD_DEL_REPLY /* , rmp, mp, rv */ );
+}
+
static void vl_api_hicn_api_register_cons_app_t_handler
(vl_api_hicn_api_register_cons_app_t * mp)
{
@@ -992,20 +1009,39 @@ static void vl_api_hicn_api_register_cons_app_t_handler
ip46_address_t src_addr6 = ip46_address_initializer;
u32 swif = clib_net_to_host_u32 (mp->swif);
- u32 faceid;
+ u32 faceid1;
+ u32 faceid2;
- rv = hicn_face_cons_add (&src_addr4.ip4, &src_addr6.ip6, swif, &faceid);
+ rv =
+ hicn_face_cons_add (&src_addr4.ip4, &src_addr6.ip6, swif, &faceid1,
+ &faceid2);
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_HICN_API_REGISTER_CONS_APP_REPLY, (
{
ip_address_encode(&src_addr4, IP46_TYPE_ANY, &rmp->src_addr4);
ip_address_encode(&src_addr6, IP46_TYPE_ANY, &rmp->src_addr6);
- rmp->faceid = clib_net_to_host_u32(faceid);
+ rmp->faceid1 = clib_net_to_host_u32(faceid1);
+ rmp->faceid2 = clib_net_to_host_u32(faceid2);
}));
/* *INDENT-ON* */
}
+static void
+vl_api_hicn_api_face_cons_del_t_handler (vl_api_hicn_api_face_cons_del_t * mp)
+{
+ vl_api_hicn_api_face_cons_del_reply_t *rmp;
+ int rv = HICN_ERROR_FACE_NOT_FOUND;
+
+ hicn_main_t *sm = &hicn_main;
+
+ hicn_face_id_t faceid = clib_net_to_host_u32 (mp->faceid);
+ rv = hicn_face_cons_del (faceid);
+
+ REPLY_MACRO (VL_API_HICN_API_FACE_CONS_DEL_REPLY /* , rmp, mp, rv */ );
+}
+
+
/************************************************************************************/
#define vl_msg_name_crc_list
diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c
index 1dc8158d4..bf58cf245 100644
--- a/hicn-plugin/src/hicn_api_test.c
+++ b/hicn-plugin/src/hicn_api_test.c
@@ -183,11 +183,11 @@ fib_proto_from_ip46 (ip46_type_t iproto)
case IP46_TYPE_IP6:
return FIB_PROTOCOL_IP6;
case IP46_TYPE_ANY:
- ASSERT(0);
+ ASSERT (0);
return FIB_PROTOCOL_IP4;
}
- ASSERT(0);
+ ASSERT (0);
return FIB_PROTOCOL_IP4;
}
@@ -203,7 +203,7 @@ fib_proto_to_ip46 (fib_protocol_t fproto)
case FIB_PROTOCOL_MPLS:
return (IP46_TYPE_ANY);
}
- ASSERT(0);
+ ASSERT (0);
return (IP46_TYPE_ANY);
}
@@ -229,7 +229,7 @@ ip_prefix_encode (const fib_prefix_t * in, vl_api_prefix_t * out)
{
out->len = in->fp_len;
ip_address_encode (&in->fp_addr,
- fib_proto_to_ip46 (in->fp_proto), &out->address);
+ fib_proto_to_ip46 (in->fp_proto), &out->address);
}
/////////////////////////////////////////////////////
@@ -253,7 +253,9 @@ _(hicn_api_face_del_reply) \
_(hicn_api_route_nhops_add_reply) \
_(hicn_api_route_del_reply) \
_(hicn_api_route_nhop_del_reply) \
-_(hicn_api_punting_add_reply)
+_(hicn_api_punting_add_reply) \
+_(hicn_api_face_cons_del_reply) \
+_(hicn_api_face_prod_del_reply)
#define _(n) \
static void vl_api_##n##_t_handler \
@@ -297,7 +299,9 @@ _(HICN_API_STRATEGIES_GET_REPLY, hicn_api_strategies_get_reply) \
_(HICN_API_STRATEGY_GET_REPLY, hicn_api_strategy_get_reply) \
_(HICN_API_PUNTING_ADD_REPLY, hicn_api_punting_add_reply) \
_(HICN_API_REGISTER_PROD_APP_REPLY, hicn_api_register_prod_app_reply) \
-_(HICN_API_REGISTER_CONS_APP_REPLY, hicn_api_register_cons_app_reply)
+_(HICN_API_FACE_PROD_DEL_REPLY, hicn_api_face_prod_del_reply) \
+_(HICN_API_REGISTER_CONS_APP_REPLY, hicn_api_register_cons_app_reply) \
+_(HICN_API_FACE_CONS_DEL_REPLY, hicn_api_face_cons_del_reply)
static int
@@ -777,7 +781,8 @@ static void
clib_net_to_host_i32 (rmp->flags));
}
-static void format_ip_face (vl_api_hicn_face_ip_t * rmp)
+static void
+format_ip_face (vl_api_hicn_face_ip_t * rmp)
{
vat_main_t *vam = hicn_test_main.vat_main;
u8 *sbuf = 0;
@@ -798,7 +803,8 @@ static void format_ip_face (vl_api_hicn_face_ip_t * rmp)
clib_net_to_host_i32 (rmp->flags), rmp->if_name);
}
-static void format_udp_face (vl_api_hicn_face_udp_t * rmp)
+static void
+format_udp_face (vl_api_hicn_face_udp_t * rmp)
{
vat_main_t *vam = hicn_test_main.vat_main;
u8 *sbuf = 0;
@@ -813,8 +819,7 @@ static void format_udp_face (vl_api_hicn_face_udp_t * rmp)
sbuf =
format (0, "local_addr %U port %u remote_addr %U port %u",
format_ip46_address, &local_addr, 0 /*IP46_ANY_TYPE */ , lport,
- format_ip46_address,
- &remote_addr, 0 /*IP46_ANY_TYPE */ , rport);
+ format_ip46_address, &remote_addr, 0 /*IP46_ANY_TYPE */ , rport);
fformat (vam->ofp, "%s swif %d flags %d name %s\n",
sbuf,
@@ -1028,8 +1033,8 @@ api_hicn_api_route_get (vat_main_t * vam)
}
//Construct the API message
M (HICN_API_ROUTE_GET, mp);
- if (!ip46_address_is_ip4(&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46(IP46_TYPE_IP6);
+ if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
+ prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
ip_prefix_encode (&prefix, &mp->prefix);
//send it...
@@ -1185,8 +1190,8 @@ api_hicn_api_route_nhops_add (vat_main_t * vam)
M (HICN_API_ROUTE_NHOPS_ADD, mp);
ip_prefix_encode (&prefix, &mp->prefix);
- if (!ip46_address_is_ip4(&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46(IP46_TYPE_IP6);
+ if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
+ prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
mp->face_ids[0] = clib_host_to_net_u32 (faceid);
mp->n_faces = 1;
@@ -1232,8 +1237,8 @@ api_hicn_api_route_del (vat_main_t * vam)
M (HICN_API_ROUTE_DEL, mp);
ip_prefix_encode (&prefix, &mp->prefix);
- if (!ip46_address_is_ip4(&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46(IP46_TYPE_IP6);
+ if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
+ prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
/* send it... */
S (mp);
@@ -1280,8 +1285,8 @@ api_hicn_api_route_nhop_del (vat_main_t * vam)
M (HICN_API_ROUTE_NHOP_DEL, mp);
ip_prefix_encode (&prefix, &mp->prefix);
- if (!ip46_address_is_ip4(&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46(IP46_TYPE_IP6);
+ if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
+ prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
mp->faceid = clib_host_to_net_u32 (faceid);
@@ -1411,8 +1416,9 @@ static void
}
fformat (vam->ofp, "%s", mp->description);
}
+
static int
-api_hicn_api_ip_punting_add(vat_main_t * vam)
+api_hicn_api_ip_punting_add (vat_main_t * vam)
{
unformat_input_t *input = vam->input;
vl_api_hicn_api_punting_add_t *mp;
@@ -1451,9 +1457,9 @@ api_hicn_api_ip_punting_add(vat_main_t * vam)
/* Construct the API message */
M (HICN_API_PUNTING_ADD, mp);
mp->type = IP_PUNT;
- if (!ip46_address_is_ip4(&(prefix.fp_addr)))
+ if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
{
- prefix.fp_proto = fib_proto_from_ip46(IP46_TYPE_IP6);
+ prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
}
ip_prefix_encode (&prefix, &mp->rule.ip.prefix);
@@ -1469,7 +1475,7 @@ api_hicn_api_ip_punting_add(vat_main_t * vam)
}
static int
-api_hicn_api_udp_punting_add(vat_main_t * vam)
+api_hicn_api_udp_punting_add (vat_main_t * vam)
{
unformat_input_t *input = vam->input;
vl_api_hicn_api_punting_add_t *mp;
@@ -1489,13 +1495,13 @@ api_hicn_api_udp_punting_add(vat_main_t * vam)
else if (unformat (input, "sport %u", &sport));
else if (unformat (input, "dport %u", &dport));
else if (unformat (input, "ip4"))
- {
- ip_version = ADDRESS_IP4;
- }
+ {
+ ip_version = ADDRESS_IP4;
+ }
else if (unformat (input, "ip6"))
- {
- ip_version = ADDRESS_IP6;
- }
+ {
+ ip_version = ADDRESS_IP6;
+ }
else if (unformat (input, "intfc %d", &swif))
{;
}
@@ -1526,9 +1532,9 @@ api_hicn_api_udp_punting_add(vat_main_t * vam)
/* Construct the API message */
M (HICN_API_PUNTING_ADD, mp);
mp->type = UDP_PUNT;
- if (!ip46_address_is_ip4(&(prefix.fp_addr)))
+ if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
{
- prefix.fp_proto = fib_proto_from_ip46(IP46_TYPE_IP6);
+ prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
}
ip_prefix_encode (&prefix, &mp->rule.ip.prefix);
@@ -1579,6 +1585,10 @@ api_hicn_api_register_prod_app (vat_main_t * vam)
clib_warning ("Please specify prefix...");
return 1;
}
+
+ prefix.fp_proto =
+ ip46_address_is_ip4 (&(prefix.fp_addr)) ? FIB_PROTOCOL_IP4 :
+ FIB_PROTOCOL_IP6;
/* Construct the API message */
M (HICN_API_REGISTER_PROD_APP, mp);
ip_prefix_encode (&prefix, &mp->prefix);
@@ -1618,6 +1628,43 @@ static void
}
static int
+api_hicn_api_face_prod_del (vat_main_t * vam)
+{
+ unformat_input_t *input = vam->input;
+ vl_api_hicn_api_face_prod_del_t *mp;
+ u32 faceid = 0, ret;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "face %d", &faceid))
+ {;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ //Check for presence of face ID
+ if (faceid == ~0)
+ {
+ clib_warning ("Please specify face ID");
+ return 1;
+ }
+ //Construct the API message
+ M (HICN_API_FACE_PROD_DEL, mp);
+ mp->faceid = clib_host_to_net_u32 (faceid);
+
+ //send it...
+ S (mp);
+
+ //Wait for a reply...
+ W (ret);
+
+ return ret;
+}
+
+static int
api_hicn_api_register_cons_app (vat_main_t * vam)
{
vl_api_hicn_api_register_cons_app_t *mp;
@@ -1635,6 +1682,43 @@ api_hicn_api_register_cons_app (vat_main_t * vam)
return ret;
}
+static int
+api_hicn_api_face_cons_del (vat_main_t * vam)
+{
+ unformat_input_t *input = vam->input;
+ vl_api_hicn_api_face_cons_del_t *mp;
+ u32 faceid = 0, ret;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "face %d", &faceid))
+ {;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ //Check for presence of face ID
+ if (faceid == ~0)
+ {
+ clib_warning ("Please specify face ID");
+ return 1;
+ }
+ //Construct the API message
+ M (HICN_API_FACE_CONS_DEL, mp);
+ mp->faceid = clib_host_to_net_u32 (faceid);
+
+ //send it...
+ S (mp);
+
+ //Wait for a reply...
+ W (ret);
+
+ return ret;
+}
+
static void
vl_api_hicn_api_register_cons_app_reply_t_handler
(vl_api_hicn_api_register_cons_app_reply_t * mp)
@@ -1696,7 +1780,9 @@ _(hicn_api_strategy_get, "strategy <id>") \
_(hicn_api_ip_punting_add, "prefix <IP4/IP6>/<subnet> intfc <swif>") \
_(hicn_api_udp_punting_add, "prefix <IP4/IP6>/<subnet> intfc <swif> sport <port> dport <port> ip4/ip6") \
_(hicn_api_register_prod_app, "prefix <IP4/IP6>/<subnet> id <appif_id>") \
-_(hicn_api_register_cons_app, "")
+_(hicn_api_face_prod_del, "face <faceID>") \
+_(hicn_api_register_cons_app, "") \
+_(hicn_api_face_cons_del, "face <faceID>")
void
hicn_vat_api_hookup (vat_main_t * vam)
diff --git a/hicn-plugin/src/interest_hitpit_node.c b/hicn-plugin/src/interest_hitpit_node.c
index 21ba97db3..d5eeb20dd 100644
--- a/hicn-plugin/src/interest_hitpit_node.c
+++ b/hicn-plugin/src/interest_hitpit_node.c
@@ -173,11 +173,6 @@ hicn_interest_hitpit_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
if (found)
{
- /*
- * Remove lock on the dpo
- * stored in the vlib_buffer
- */
- dpo_unlock (&hicnb0->face_dpo_id);
strategy_vft0->hicn_select_next_hop (dpo_ctx_id0,
&nh_idx, &outface);
/* Retransmission */
diff --git a/hicn-plugin/src/pcs.c b/hicn-plugin/src/pcs.c
index 4226291a1..4355aaeb0 100644
--- a/hicn-plugin/src/pcs.c
+++ b/hicn-plugin/src/pcs.c
@@ -41,6 +41,7 @@ hicn_pit_create (hicn_pit_cs_t * p, u32 num_elems)
p->policy_vft.hicn_cs_dequeue = hicn_cs_lru.hicn_cs_dequeue;
p->policy_vft.hicn_cs_delete_get = hicn_cs_lru.hicn_cs_delete_get;
p->policy_vft.hicn_cs_trim = hicn_cs_lru.hicn_cs_trim;
+ p->policy_vft.hicn_cs_flush = hicn_cs_lru.hicn_cs_flush;
return (ret);
}
diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c
index 3581fe490..321f11940 100644
--- a/hicn-plugin/src/route.c
+++ b/hicn-plugin/src/route.c
@@ -86,6 +86,61 @@ hicn_route_get_dpo (const fib_prefix_t * prefix,
return ret;
}
+int
+hicn_route_add_nhops (hicn_face_id_t * face_id, u32 len,
+ const fib_prefix_t * prefix)
+{
+ const dpo_id_t *hicn_dpo_id;
+ int ret = HICN_ERROR_NONE;
+ dpo_id_t faces_dpo_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
+ int n_face_dpo = 0;
+ const hicn_dpo_vft_t *dpo_vft;
+ u32 fib_index;
+ vlib_main_t *vm = vlib_get_main ();
+ hicn_face_vft_t *face_vft = NULL;
+
+ if (face_id == NULL)
+ {
+ return HICN_ERROR_ROUTE_INVAL;
+ }
+ /*
+ * Check is the faces are available, otherwise skip the face
+ * id_adjacency existance is not checked. It should be checked before
+ * sending a packet out
+ */
+ for (int i = 0; i < clib_min (HICN_PARAM_FIB_ENTRY_NHOPS_MAX, len); i++)
+ {
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id[i]);
+ face_vft = hicn_face_get_vft (face->shared.face_type);
+ dpo_id_t face_dpo = DPO_INVALID;
+ face_vft->hicn_face_get_dpo (face, &face_dpo);
+
+ if (!dpo_id_is_valid (&face_dpo))
+ {
+ vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
+ return ret;
+ }
+ else
+ {
+ faces_dpo_tmp[n_face_dpo++] = face_dpo;
+ }
+ }
+
+ ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
+
+ if (ret == HICN_ERROR_NONE)
+ {
+ for (int i = 0; i < n_face_dpo && (ret == HICN_ERROR_NONE); i++)
+ {
+ u32 vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
+ dpo_vft = hicn_dpo_get_vft (vft_id);
+ ret = dpo_vft->hicn_dpo_add_update_nh (&faces_dpo_tmp[i],
+ hicn_dpo_id->dpoi_index);
+ }
+ }
+ return ret;
+}
+
/* Add a new route for a name prefix */
int
hicn_route_add (hicn_face_id_t * face_id, u32 len,
@@ -153,8 +208,8 @@ hicn_route_add (hicn_face_id_t * face_id, u32 len,
*/
dpo_set (&dpo,
default_dpo.hicn_dpo_get_type (),
- (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 : DPO_PROTO_IP6),
- dpo_idx);
+ (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 :
+ DPO_PROTO_IP6), dpo_idx);
/* Here is where we create the "via" like route */
/*
@@ -187,62 +242,7 @@ hicn_route_add (hicn_face_id_t * face_id, u32 len,
}
else if (ret == HICN_ERROR_NONE)
{
- ret = HICN_ERROR_ROUTE_ALREADY_EXISTS;
- }
- return ret;
-}
-
-int
-hicn_route_add_nhops (hicn_face_id_t * face_id, u32 len,
- const fib_prefix_t * prefix)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- dpo_id_t faces_dpo_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- int n_face_dpo = 0;
- const hicn_dpo_vft_t *dpo_vft;
- u32 fib_index;
- vlib_main_t *vm = vlib_get_main ();
- hicn_face_vft_t *face_vft = NULL;
-
- if (face_id == NULL)
- {
- return HICN_ERROR_ROUTE_INVAL;
- }
- /*
- * Check is the faces are available, otherwise skip the face
- * id_adjacency existance is not checked. It should be checked before
- * sending a packet out
- */
- for (int i = 0; i < clib_min (HICN_PARAM_FIB_ENTRY_NHOPS_MAX, len); i++)
- {
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id[i]);
- face_vft = hicn_face_get_vft (face->shared.face_type);
- dpo_id_t face_dpo = DPO_INVALID;
- face_vft->hicn_face_get_dpo (face, &face_dpo);
-
- if (!dpo_id_is_valid (&face_dpo))
- {
- vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
- return ret;
- }
- else
- {
- faces_dpo_tmp[n_face_dpo++] = face_dpo;
- }
- }
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_NONE)
- {
- for (int i = 0; i < n_face_dpo && (ret == HICN_ERROR_NONE); i++)
- {
- u32 vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
- dpo_vft = hicn_dpo_get_vft (vft_id);
- ret = dpo_vft->hicn_dpo_add_update_nh (&faces_dpo_tmp[i],
- hicn_dpo_id->dpoi_index);
- }
+ ret = hicn_route_add_nhops (face_id, len, prefix);
}
return ret;
}
diff --git a/hicn-plugin/src/strategy.c b/hicn-plugin/src/strategy.c
index d07045a72..62c2ddc8b 100644
--- a/hicn-plugin/src/strategy.c
+++ b/hicn-plugin/src/strategy.c
@@ -102,7 +102,7 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
hicn_face_db_add_face_dpo (&hicnb0->face_dpo_id, &(pitp->u.pit.faces));
/* Remove lock on the dpo stored in the vlib_buffer */
- dpo_unlock (&hicnb0->face_dpo_id);
+ //dpo_unlock (&hicnb0->face_dpo_id);
*next = outface->dpoi_next_node;
@@ -209,9 +209,8 @@ hicn_forward_interest_fn (vlib_main_t * vm,
*/
if (PREDICT_TRUE
(ret == HICN_ERROR_NONE && HICN_IS_NAMEHASH_CACHED (b0)
- && strategy->hicn_select_next_hop (vnet_buffer (b0)->
- ip.adj_index[VLIB_TX],
- &nh_idx,
+ && strategy->hicn_select_next_hop (vnet_buffer (b0)->ip.
+ adj_index[VLIB_TX], &nh_idx,
&outface) ==
HICN_ERROR_NONE))
{