aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/vmxnet3
diff options
context:
space:
mode:
authorAnton Nikolaev <anikolaev@netgate.com>2022-05-16 10:33:17 +0000
committerMatthew Smith <mgsmith@netgate.com>2022-05-17 19:42:17 +0000
commit61f6a4c4f026a83390f41595cb77771a668cc55c (patch)
treeeb7ffe4d7d65fe5c9d00c25720ea31b53aa65070 /src/plugins/vmxnet3
parent59a08e65094db28884fc40e9562e303fde3b21d8 (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/vmxnet3')
-rw-r--r--src/plugins/vmxnet3/vmxnet3.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3.c b/src/plugins/vmxnet3/vmxnet3.c
index a0c125a2c97..770cb2d418d 100644
--- a/src/plugins/vmxnet3/vmxnet3.c
+++ b/src/plugins/vmxnet3/vmxnet3.c
@@ -572,8 +572,9 @@ vmxnet3_event_irq_handler (vlib_main_t * vm, vlib_pci_dev_handle_t h,
{
vd->flags |= VMXNET3_DEVICE_F_LINK_UP;
vd->link_speed = ret >> 16;
- vnet_hw_interface_set_link_speed (vnm, vd->hw_if_index,
- vd->link_speed * 1000);
+ vnet_hw_interface_set_link_speed (
+ vnm, vd->hw_if_index,
+ (vd->link_speed == UINT32_MAX) ? UINT32_MAX : vd->link_speed * 1000);
vnet_hw_interface_set_flags (vnm, vd->hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
}
@@ -867,8 +868,9 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
vd->flags |= VMXNET3_DEVICE_F_INITIALIZED;
vmxnet3_enable_interrupt (vd);
- vnet_hw_interface_set_link_speed (vnm, vd->hw_if_index,
- vd->link_speed * 1000);
+ vnet_hw_interface_set_link_speed (
+ vnm, vd->hw_if_index,
+ (vd->link_speed == UINT32_MAX) ? UINT32_MAX : vd->link_speed * 1000);
if (vd->flags & VMXNET3_DEVICE_F_LINK_UP)
vnet_hw_interface_set_flags (vnm, vd->hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);