From 61f6a4c4f026a83390f41595cb77771a668cc55c Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 16 May 2022 10:33:17 +0000 Subject: interface: fix overflow of link speed. Type: fix There were several places where mbps were converted to kbps for link_speed, but often drivers of devices set link speed to unknown (0xFFFFFFFF) on initialization, so there was multiplication of link_speed equal 0xFFFFFFFF(UINT32_MAX) by 1000, this provides overflow of unsigned int, and as result link_speed was equal 4295 Gbps, but actually link_speed is unknown. Signed-off-by: Anton Nikolaev Change-Id: Ib462ed6ed685654af4687041e115bfb74e640f13 --- src/plugins/avf/device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins/avf') diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index df6d12881a5..d12785cc552 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -1169,8 +1169,9 @@ avf_process_one_device (vlib_main_t * vm, avf_device_t * ad, int is_irq) flags |= (VNET_HW_INTERFACE_FLAG_FULL_DUPLEX | VNET_HW_INTERFACE_FLAG_LINK_UP); vnet_hw_interface_set_flags (vnm, ad->hw_if_index, flags); - vnet_hw_interface_set_link_speed (vnm, ad->hw_if_index, - mbps * 1000); + vnet_hw_interface_set_link_speed ( + vnm, ad->hw_if_index, + (mbps == UINT32_MAX) ? UINT32_MAX : mbps * 1000); ad->link_speed = mbps; } else if (!link_up && (ad->flags & AVF_DEVICE_F_LINK_UP) != 0) -- cgit 1.2.3-korg