diff options
author | Anton Nikolaev <anikolaev@netgate.com> | 2022-05-16 10:33:17 +0000 |
---|---|---|
committer | Matthew Smith <mgsmith@netgate.com> | 2022-05-17 19:42:17 +0000 |
commit | 61f6a4c4f026a83390f41595cb77771a668cc55c (patch) | |
tree | eb7ffe4d7d65fe5c9d00c25720ea31b53aa65070 /src/plugins/avf/device.c | |
parent | 59a08e65094db28884fc40e9562e303fde3b21d8 (diff) |
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 <anikolaev@netgate.com>
Change-Id: Ib462ed6ed685654af4687041e115bfb74e640f13
Diffstat (limited to 'src/plugins/avf/device.c')
-rw-r--r-- | src/plugins/avf/device.c | 5 |
1 files changed, 3 insertions, 2 deletions
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) |