aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/snat
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-01-18 10:23:22 -0500
committerDave Barach <dave@barachs.net>2017-01-18 10:32:15 -0500
commit8f544964a3df144a441b136c2a01427eca731eea (patch)
tree90f9eca233c2b12c8d1f96c0a27e617053c6e99e /src/plugins/snat
parentd8e478762919b5d40529d72edd3ff8a85fbe9800 (diff)
Fix coverity warnings, VPP-608
Change-Id: Ib0144ba3a9a09971d3946c932e8fed6d5c1ad278 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/plugins/snat')
-rw-r--r--src/plugins/snat/in2out.c8
-rw-r--r--src/plugins/snat/out2in.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/snat/in2out.c b/src/plugins/snat/in2out.c
index 76a6a12cec5..ba752cf0d41 100644
--- a/src/plugins/snat/in2out.c
+++ b/src/plugins/snat/in2out.c
@@ -1232,8 +1232,12 @@ snat_in2out_worker_handoff_fn (vlib_main_t * vm,
if (clib_bihash_search_8_8 (&sm->worker_by_in, &kv0, &value0))
{
/* No, assign next available worker (RR) */
- next_worker_index = sm->first_worker_index +
- sm->workers[sm->next_worker++ % vec_len (sm->workers)];
+ next_worker_index = sm->first_worker_index;
+ if (vec_len (sm->workers))
+ {
+ next_worker_index +=
+ sm->workers[sm->next_worker++ % _vec_len (sm->workers)];
+ }
/* add non-traslated packets worker lookup */
kv0.value = next_worker_index;
diff --git a/src/plugins/snat/out2in.c b/src/plugins/snat/out2in.c
index f1329733ecf..855e9efb806 100644
--- a/src/plugins/snat/out2in.c
+++ b/src/plugins/snat/out2in.c
@@ -901,8 +901,12 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm,
if (clib_bihash_search_8_8 (&sm->worker_by_out, &kv0, &value0))
{
/* No, assign next available worker (RR) */
- next_worker_index = sm->first_worker_index +
- sm->workers[sm->next_worker++ % vec_len (sm->workers)];
+ next_worker_index = sm->first_worker_index;
+ if (vec_len (sm->workers))
+ {
+ next_worker_index +=
+ sm->workers[sm->next_worker++ % _vec_len (sm->workers)];
+ }
}
else
{