aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-04-02 11:13:43 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-04-02 11:13:43 +0200
commit84b72f153e9d125aa276e1cb5a05b9380a557171 (patch)
tree040299843af972b98793d5a53b1145acb0896b1f /hicn-plugin/src
parent508bbc426747750cfa7171a0ae1d1c777c98a800 (diff)
[HICN-158] Fixed ip face deletion from binary api
Change-Id: I7a793e3664e30f765861fd5153c99fecb47ce863 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src')
-rw-r--r--hicn-plugin/src/faces/face.c2
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_cli.c104
-rw-r--r--hicn-plugin/src/hicn.api8
-rw-r--r--hicn-plugin/src/hicn_api.c6
-rw-r--r--hicn-plugin/src/hicn_api_test.c10
5 files changed, 66 insertions, 64 deletions
diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c
index baf90a185..3be42a77f 100644
--- a/hicn-plugin/src/faces/face.c
+++ b/hicn-plugin/src/faces/face.c
@@ -127,7 +127,7 @@ hicn_face_del (hicn_face_id_t face_id)
{
int ret = HICN_ERROR_NONE;
- if (pool_len (hicn_dpoi_face_pool) > face_id)
+ if (hicn_dpoi_idx_is_valid (face_id))
{
hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
if (face->shared.locks == 0)
diff --git a/hicn-plugin/src/faces/ip/face_ip_cli.c b/hicn-plugin/src/faces/ip/face_ip_cli.c
index ba7765541..58cf8d562 100644
--- a/hicn-plugin/src/faces/ip/face_ip_cli.c
+++ b/hicn-plugin/src/faces/ip/face_ip_cli.c
@@ -92,57 +92,6 @@ hicn_face_ip_cli_set_command_fn (vlib_main_t * vm,
}
}
- 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);
- }
- }
-
int rv;
switch (face_op)
{
@@ -155,6 +104,59 @@ hicn_face_ip_cli_set_command_fn (vlib_main_t * vm,
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);
if (rv == HICN_ERROR_NONE)
diff --git a/hicn-plugin/src/hicn.api b/hicn-plugin/src/hicn.api
index 48e2eace5..0debf25c5 100644
--- a/hicn-plugin/src/hicn.api
+++ b/hicn-plugin/src/hicn.api
@@ -199,7 +199,7 @@ define hicn_api_face_ip_del
u32 context;
/* A Face ID to be deleted */
- u16 faceid;
+ u32 faceid;
};
define hicn_api_face_ip_del_reply
@@ -220,7 +220,7 @@ define hicn_api_face_ip_params_get
u32 context;
/* A Face to be retrieved */
- u16 faceid;
+ u32 faceid;
};
define hicn_api_face_stats_details
@@ -354,7 +354,7 @@ define hicn_api_route_nhop_del
u8 len;
/* Specific next-hop to be removed */
- u16 faceid;
+ u32 faceid;
};
define hicn_api_route_nhop_del_reply
@@ -390,7 +390,7 @@ define hicn_api_route_get_reply
u32 context;
/* List of faces pointing to the next hops */
- u16 faceids[1000];
+ u32 faceids[1000];
/* Strategy */
u32 strategy_id;
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index c8b3dc269..a97796252 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -282,8 +282,8 @@ vl_api_hicn_api_face_ip_del_t_handler (vl_api_hicn_api_face_ip_del_t * mp)
hicn_main_t *sm = &hicn_main;
- hicn_face_id_t faceid = clib_net_to_host_u16 (mp->faceid);
- rv = hicn_face_del (faceid);
+ hicn_face_id_t faceid = clib_net_to_host_u32 (mp->faceid);
+ rv = hicn_face_ip_del (faceid);
REPLY_MACRO (VL_API_HICN_API_FACE_IP_DEL_REPLY /* , rmp, mp, rv */ );
@@ -298,7 +298,7 @@ static void
hicn_main_t *sm = &hicn_main;
- hicn_face_id_t faceid = clib_net_to_host_u16 (mp->faceid);
+ hicn_face_id_t faceid = clib_net_to_host_u32 (mp->faceid);
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_HICN_API_FACE_IP_PARAMS_GET_REPLY, (
diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c
index 4225f0078..d69c20770 100644
--- a/hicn-plugin/src/hicn_api_test.c
+++ b/hicn-plugin/src/hicn_api_test.c
@@ -413,7 +413,7 @@ api_hicn_api_face_ip_del (vat_main_t * vam)
{
unformat_input_t *input = vam->input;
vl_api_hicn_api_face_ip_del_t *mp;
- int faceid = 0, ret;
+ u32 faceid = 0, ret;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -427,14 +427,14 @@ api_hicn_api_face_ip_del (vat_main_t * vam)
}
//Check for presence of face ID
- if (faceid == 0)
+ if (faceid == ~0)
{
clib_warning ("Please specify face ID");
return 1;
}
//Construct the API message
M (HICN_API_FACE_IP_DEL, mp);
- mp->faceid = clib_host_to_net_i32 (faceid);
+ mp->faceid = clib_host_to_net_u32 (faceid);
//send it...
S (mp);
@@ -450,7 +450,7 @@ api_hicn_api_face_ip_params_get (vat_main_t * vam)
{
unformat_input_t *input = vam->input;
vl_api_hicn_api_face_ip_params_get_t *mp;
- int faceid = 0, ret;
+ u32 faceid = 0, ret;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -471,7 +471,7 @@ api_hicn_api_face_ip_params_get (vat_main_t * vam)
}
//Construct the API message
M (HICN_API_FACE_IP_PARAMS_GET, mp);
- mp->faceid = clib_host_to_net_i32 (faceid);
+ mp->faceid = clib_host_to_net_u32 (faceid);
//send it...
S (mp);