aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/hicn_api_test.c
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/hicn_api_test.c
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/hicn_api_test.c')
-rw-r--r--hicn-plugin/src/hicn_api_test.c148
1 files changed, 117 insertions, 31 deletions
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)