summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces/ip/face_ip_cli.c
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/faces/ip/face_ip_cli.c
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/faces/ip/face_ip_cli.c')
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_cli.c104
1 files changed, 53 insertions, 51 deletions
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)