aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-11-21 11:59:54 +0000
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-11-22 12:47:14 +0000
commit62f7b46d4c49d6e5bfb5b3b537bfcaf6503e7bac (patch)
tree35e206900cf6a1535df2b3439a55e0fdd9091a7f /hicn-plugin/src/faces
parentae6f3b8e1f55fc4bb7807c293850d3cb46cab1fd (diff)
[HICN-405] Added application face delete
Added two new messages in the binary api: - hicn_api_face_cons_del to delete a consumer face - hicn_api_face_prod_del to delete a producer face Added the corresponding commands in the vpp_api_test for debugging and testing Reworked the cache policy structure to add a new function that flash the content store from the content coming from the destroyed producer face. This is required since the CS while each producer face has its own lru list. Removing only the producer face without flushing the CS from the content coming from the producer face will lead to a segfault in case there is a hit in the CS as the lru no longer exists and it won't be possible to update the head of the lru. Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com> Change-Id: I8776c86952d50900aa504dd22aec521ed25c1dae
Diffstat (limited to 'hicn-plugin/src/faces')
-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
10 files changed, 119 insertions, 73 deletions
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;