diff options
author | Matus Fabian <matfabia@cisco.com> | 2016-11-28 05:36:24 -0800 |
---|---|---|
committer | Matus Fabian <matfabia@cisco.com> | 2016-11-28 05:36:24 -0800 |
commit | 38fb44f51d73f631df82830b4a09681fb2e41a3c (patch) | |
tree | ce731a25d7bd9977bb6aae5a342cc835cfc1d196 /plugins/snat-plugin | |
parent | 985f3d11fae7f93eb9a9e96d59b8e7a066819672 (diff) |
snat: fix coverity issues
Change-Id: Icb8239c02af8758a9e4bf299726a89677f53451d
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'plugins/snat-plugin')
-rw-r--r-- | plugins/snat-plugin/snat/in2out.c | 2 | ||||
-rw-r--r-- | plugins/snat-plugin/snat/out2in.c | 4 | ||||
-rw-r--r-- | plugins/snat-plugin/snat/snat.c | 6 |
3 files changed, 10 insertions, 2 deletions
diff --git a/plugins/snat-plugin/snat/in2out.c b/plugins/snat-plugin/snat/in2out.c index e1edbb81..43ee2d0e 100644 --- a/plugins/snat-plugin/snat/in2out.c +++ b/plugins/snat-plugin/snat/in2out.c @@ -1047,6 +1047,8 @@ snat_in2out_worker_handoff_fn (vlib_main_t * vm, u32 current_worker_index = ~0; u32 cpu_index = os_get_cpu_number (); + ASSERT (vec_len (sm->workers)); + if (PREDICT_FALSE (handoff_queue_elt_by_worker_index == 0)) { vec_validate (handoff_queue_elt_by_worker_index, tm->n_vlib_mains - 1); diff --git a/plugins/snat-plugin/snat/out2in.c b/plugins/snat-plugin/snat/out2in.c index a4641d3a..13e596b9 100644 --- a/plugins/snat-plugin/snat/out2in.c +++ b/plugins/snat-plugin/snat/out2in.c @@ -830,6 +830,8 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm, u32 current_worker_index = ~0; u32 cpu_index = os_get_cpu_number (); + ASSERT (vec_len (sm->workers)); + if (PREDICT_FALSE (handoff_queue_elt_by_worker_index == 0)) { vec_validate (handoff_queue_elt_by_worker_index, tm->n_vlib_mains - 1); @@ -888,6 +890,8 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm, if (PREDICT_FALSE (next_worker_index != cpu_index)) { + do_handoff = 1; + if (next_worker_index != current_worker_index) { if (hf) diff --git a/plugins/snat-plugin/snat/snat.c b/plugins/snat-plugin/snat/snat.c index 70df44ea..02077c32 100644 --- a/plugins/snat-plugin/snat/snat.c +++ b/plugins/snat-plugin/snat/snat.c @@ -494,8 +494,10 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, if (!clib_bihash_search_8_8 (&sm->user_hash, &kv, &value)) { user_index = value.value; - clib_bihash_search_8_8 (&sm->worker_by_in, &kv, &value); - tsm = vec_elt_at_index (sm->per_thread_data, value.value); + if (!clib_bihash_search_8_8 (&sm->worker_by_in, &kv, &value)) + tsm = vec_elt_at_index (sm->per_thread_data, value.value); + else + tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers); u = pool_elt_at_index (tsm->users, user_index); if (u->nstaticsessions) { |