summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface.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.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.c')
-rw-r--r--src/vnet/interface.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 982abbd0199..05a1c7c34a9 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -768,18 +768,25 @@ sw_interface_walk_callback (vnet_main_t * vnm, u32 sw_if_index, void *ctx)
return WALK_CONTINUE;
}
-void
-vnet_hw_interface_set_mtu (vnet_main_t * vnm, u32 hw_if_index, u32 mtu)
+clib_error_t *
+vnet_hw_interface_set_mtu (vnet_main_t *vnm, u32 hw_if_index, u32 mtu)
{
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
if (hi->max_packet_bytes != mtu)
{
+ if (mtu > hi->max_supported_packet_bytes ||
+ mtu < hi->min_supported_packet_bytes)
+ return vnet_error (VNET_ERR_INVALID_VALUE,
+ "requested mtu must be in the %u to %u range",
+ hi->min_supported_packet_bytes,
+ hi->max_supported_packet_bytes);
hi->max_packet_bytes = mtu;
ethernet_set_flags (vnm, hw_if_index, ETHERNET_INTERFACE_FLAG_MTU);
vnet_hw_interface_walk_sw (vnm, hw_if_index, sw_interface_walk_callback,
&mtu);
}
+ return 0;
}
static void