2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

netdev-offload: Fix Clang's static analyzer 'Division by zero' warnings.

When enabling DPDK with the configure the below, ovs-vswitchd will crash.

  ovs-vsctl set Open_vSwitch . other_config:n-offload-threads=0
  ovs-vsctl set Open_vSwitch . other_config:hw-offload=true

This issue arises because setting the 'n-offload-threads' value to zero
is not a supported configuration. This fix addresses this by implementing
a check to ensure a valid 'n-offload-threads' value, both during
configuration and statistics gathering.

Fixes: 62c2d8a675 ("netdev-offload: Add multi-thread API.")
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Simon Horman <horms@ovn.org>
This commit is contained in:
Eelco Chaudron
2023-10-23 16:22:47 +02:00
committed by Simon Horman
parent 979bc94b1b
commit 08212d755e
4 changed files with 8 additions and 3 deletions

View File

@@ -4748,6 +4748,10 @@ dpif_netdev_offload_stats_get(struct dpif *dpif,
}
nb_thread = netdev_offload_thread_nb();
if (!nb_thread) {
return EINVAL;
}
/* nb_thread counters for the overall total as well. */
stats->size = ARRAY_SIZE(hwol_stats) * (nb_thread + 1);
stats->counters = xcalloc(stats->size, sizeof *stats->counters);