aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2017-08-22 13:10:01 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2017-08-25 07:33:51 +0000
commit81d1e27eed522e0fa4c4f670042bdc8159f0fc9b (patch)
treed2302b4cc1e95b3c448b09a6080f8a77201e4a09 /src
parent57d963f88b2c99e698e2b29f72e190f47f41b1ad (diff)
vl_api_sw_interface_set_mtu_t_handler: fix assert in vnet_get_hw_interface
The handler was calling the routines with sw_if_index instead of hw_if_index, fix that by an extra call to vnet_get_sw_interface, and check that the interface type is VNET_SW_INTERFACE_TYPE_HARDWARE before proceeding. Change-Id: I4a6f65f44e250ecdb2b72d2693c9d7db5a52b966 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com> (cherry picked from commit 778df28c2a1520f58c293700c578bdd73e61cecf)
Diffstat (limited to 'src')
-rw-r--r--src/vnet/interface_api.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index 9949f83660b..113728cd3c3 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -98,8 +98,15 @@ vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp)
VALIDATE_SW_IF_INDEX (mp);
- vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, sw_if_index);
- ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index);
+ vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
+ if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ 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)
{
@@ -122,7 +129,7 @@ vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp)
if (hi->max_packet_bytes != mtu)
{
hi->max_packet_bytes = mtu;
- ethernet_set_flags (vnm, sw_if_index, flags);
+ ethernet_set_flags (vnm, si->hw_if_index, flags);
}
BAD_SW_IF_INDEX_LABEL;