aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_api.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-01-16 22:47:55 +0100
committerDamjan Marion <damarion@cisco.com>2022-01-17 10:47:26 +0100
commit81bb6fc611d321a92ad2218e1b852db67980768a (patch)
tree66d88554a59d1e225347aca663f132475596f8bc /src/vnet/interface_api.c
parent7b90f669d83f432f3610ec0da522bd8ccc4dff01 (diff)
vnet: introduce vnet_error()
Decouples vnet return values from API return codes. New vnet_error() creates vnet_error_t whicgh contains both vnet function return value and return string. vnet_api_error() converts vlib_error_t constructed with vnet_error() to API return value. Type: improvement Change-Id: I17042954d48c010150fc1dfc5fce9330e8149e87 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/interface_api.c')
-rw-r--r--src/vnet/interface_api.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index 5218f74b0f4..d70cd1e42f8 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -146,6 +146,7 @@ vl_api_hw_interface_set_mtu_t_handler (vl_api_hw_interface_set_mtu_t * mp)
u32 sw_if_index = ntohl (mp->sw_if_index);
u16 mtu = ntohs (mp->mtu);
ethernet_main_t *em = &ethernet_main;
+ clib_error_t *err;
int rv = 0;
VALIDATE_SW_IF_INDEX (mp);
@@ -157,7 +158,6 @@ vl_api_hw_interface_set_mtu_t_handler (vl_api_hw_interface_set_mtu_t * mp)
goto bad_sw_if_index;
}
- vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, si->hw_if_index);
ethernet_interface_t *eif = ethernet_get_interface (em, si->hw_if_index);
if (!eif)
@@ -166,20 +166,13 @@ vl_api_hw_interface_set_mtu_t_handler (vl_api_hw_interface_set_mtu_t * mp)
goto bad_sw_if_index;
}
- if (mtu < hi->min_supported_packet_bytes)
+ if ((err = vnet_hw_interface_set_mtu (vnm, si->hw_if_index, mtu)))
{
- rv = VNET_API_ERROR_INVALID_VALUE;
+ rv = vnet_api_error (err);
+ clib_error_free (err);
goto bad_sw_if_index;
}
- if (mtu > hi->max_supported_packet_bytes)
- {
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto bad_sw_if_index;
- }
-
- vnet_hw_interface_set_mtu (vnm, si->hw_if_index, mtu);
-
BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_HW_INTERFACE_SET_MTU_REPLY);
}