From 1b6c7932a8feb419aae73a00a6784d7c110decdc Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Fri, 24 Sep 2021 15:27:36 -0500 Subject: [PATCH] ip: set error number on failed intf addr Type: fix A subinterface that does not have exact match enabled cannot have an IP address configured on it. When this is validated in the functions which add an interface IP address for IPv4 and IPv6, a clib_error_t * is returned but api_errno is not set. The API handler uses the value of vnet_main.api_errno to set the return value in it's reply. Since it was not set, the API reports the operation succeeded. Set vnet_main.api_errno if vnet_sw_interface_supports_addressing() returns a non-null value when adding/deleting an interface IP address. Change-Id: I257a30d21788986102a2a719235e714ff16a24e8 Signed-off-by: Matthew Smith --- src/vnet/ip/ip4_forward.c | 5 ++++- src/vnet/ip/ip6_forward.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 5cd5e418fd6..055df637c7f 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -655,7 +655,10 @@ ip4_add_del_interface_address_internal (vlib_main_t * vm, error = vnet_sw_interface_supports_addressing (vnm, sw_if_index); if (error) - return error; + { + vnm->api_errno = VNET_API_ERROR_UNSUPPORTED; + return error; + } ip4_addr_fib_init (&ip4_af, address, vec_elt (im->fib_index_by_sw_if_index, sw_if_index)); diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index 8daf2614c15..d9c015f6fb4 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -310,7 +310,10 @@ ip6_add_del_interface_address (vlib_main_t * vm, error = vnet_sw_interface_supports_addressing (vnm, sw_if_index); if (error) - return error; + { + vnm->api_errno = VNET_API_ERROR_UNSUPPORTED; + return error; + } if (ip6_address_is_link_local_unicast (address)) { -- 2.16.6