diff options
author | Steven Luong <sluong@cisco.com> | 2021-03-03 19:03:38 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-03-04 10:58:35 +0000 |
commit | 8d462190587f78658c8a9e33ed4f35c2d873965f (patch) | |
tree | f420d3488930fe32d27e59cb8cc1323516170a8c | |
parent | b4704f2570fb2484b3085c8d25d0c850cc3fc77f (diff) |
bonding: coverity woe in bond_dev_class fuction
Coverity complans the line
h = hashes;
uses uninitialized variable if the prior ASSERT statement is hit.
ASSERT is compiled out coverity as well as in release image. So the
complain is legitimate. Change the ASSERT to drop the frame and log
an error instead.
Type: fix
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: Ibf0c204fe3626afca69ea84484e606566cf3244c
-rw-r--r-- | src/vnet/bonding/device.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/vnet/bonding/device.c b/src/vnet/bonding/device.c index e14d08a2f9e..c69d5a40145 100644 --- a/src/vnet/bonding/device.c +++ b/src/vnet/bonding/device.c @@ -28,10 +28,11 @@ #include <vnet/ip-neighbor/ip4_neighbor.h> #include <vnet/ip-neighbor/ip6_neighbor.h> -#define foreach_bond_tx_error \ - _(NONE, "no error") \ - _(IF_DOWN, "interface down") \ - _(NO_MEMBER, "no member") +#define foreach_bond_tx_error \ + _ (NONE, "no error") \ + _ (IF_DOWN, "interface down") \ + _ (BAD_LB_MODE, "bad load balance mode") \ + _ (NO_MEMBER, "no member") typedef enum { @@ -762,7 +763,15 @@ VNET_DEVICE_CLASS_TX_FN (bond_dev_class) (vlib_main_t * vm, else if (bif->lb == BOND_LB_RR) bond_tx_inline (vm, bif, bufs, hashes, n_left, n_members, BOND_LB_RR); else - ASSERT (0); + { + vlib_buffer_free (vm, vlib_frame_vector_args (frame), frame->n_vectors); + vlib_increment_simple_counter ( + vnet_main.interface_main.sw_if_counters + VNET_INTERFACE_COUNTER_DROP, + thread_index, bif->sw_if_index, frame->n_vectors); + vlib_error_count (vm, node->node_index, BOND_TX_ERROR_BAD_LB_MODE, + frame->n_vectors); + return frame->n_vectors; + } /* calculate port out of hash */ h = hashes; |