summaryrefslogtreecommitdiffstats
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/face.c2
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_cli.c104
2 files changed, 54 insertions, 52 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)