summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2020-10-23 17:03:14 +0200
committerDamjan Marion <dmarion@me.com>2020-10-24 09:12:51 +0000
commitac948ce17fb3207d7f45578ec016089cb6860340 (patch)
tree77b63d68bf012104388713f0f93421b66e977bb3 /src
parentfa4d4c635b82e31ecf7a52b8c794714f47b298cd (diff)
cnat: coverity fix
Type: fix Change-Id: Ie1153a0e0f1e9770bf3e0de9291131db91724b2e Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cnat/cnat_api.c27
-rw-r--r--src/plugins/cnat/cnat_src_policy.h5
-rw-r--r--src/plugins/cnat/cnat_translation.h2
3 files changed, 23 insertions, 11 deletions
diff --git a/src/plugins/cnat/cnat_api.c b/src/plugins/cnat/cnat_api.c
index 338cb5926a8..c215caae86f 100644
--- a/src/plugins/cnat/cnat_api.c
+++ b/src/plugins/cnat/cnat_api.c
@@ -43,25 +43,31 @@ static u32 cnat_base_msg_id;
#include <vlibapi/api_helper_macros.h>
-static void
+static int
cnat_endpoint_decode (const vl_api_cnat_endpoint_t * in,
cnat_endpoint_t * out)
{
+ int rv = 0;
out->ce_port = clib_net_to_host_u16 (in->port);
out->ce_sw_if_index = clib_net_to_host_u32 (in->sw_if_index);
out->ce_flags = 0;
if (out->ce_sw_if_index == INDEX_INVALID)
ip_address_decode2 (&in->addr, &out->ce_ip);
else
- ip_address_family_decode (in->if_af, &out->ce_ip.version);
+ rv = ip_address_family_decode (in->if_af, &out->ce_ip.version);
+ return rv;
}
-static void
+static int
cnat_endpoint_tuple_decode (const vl_api_cnat_endpoint_tuple_t * in,
cnat_endpoint_tuple_t * out)
{
- cnat_endpoint_decode (&in->src_ep, &out->src_ep);
- cnat_endpoint_decode (&in->dst_ep, &out->dst_ep);
+ int rv = 0;
+ rv = cnat_endpoint_decode (&in->src_ep, &out->src_ep);
+ if (rv)
+ return rv;
+ rv = cnat_endpoint_decode (&in->dst_ep, &out->dst_ep);
+ return rv;
}
static void
@@ -101,9 +107,14 @@ vl_api_cnat_translation_update_t_handler (vl_api_cnat_translation_update_t
for (pi = 0; pi < n_paths; pi++)
{
path = &paths[pi];
- cnat_endpoint_tuple_decode (&mp->translation.paths[pi], path);
+ rv = cnat_endpoint_tuple_decode (&mp->translation.paths[pi], path);
+ if (rv)
+ goto done;
}
- cnat_endpoint_decode (&mp->translation.vip, &vip);
+
+ rv = cnat_endpoint_decode (&mp->translation.vip, &vip);
+ if (rv)
+ goto done;
flags = mp->translation.flags;
if (!mp->translation.is_real_ip)
@@ -217,6 +228,8 @@ cnat_session_send_details (const cnat_session_t * session, void *args)
/* fill in the message */
mp->context = ctx->context;
+ ep.ce_sw_if_index = INDEX_INVALID;
+ ep.ce_flags = CNAT_EP_FLAG_RESOLVED;
ip_address2_from_46 (&session->value.cs_ip[VLIB_TX], session->key.cs_af,
&ep.ce_ip);
ep.ce_port = clib_host_to_net_u16 (session->value.cs_port[VLIB_TX]);
diff --git a/src/plugins/cnat/cnat_src_policy.h b/src/plugins/cnat/cnat_src_policy.h
index d76de8bd2cd..3057f641464 100644
--- a/src/plugins/cnat/cnat_src_policy.h
+++ b/src/plugins/cnat/cnat_src_policy.h
@@ -32,9 +32,8 @@ typedef enum
typedef enum cnat_source_policy_errors_
{
- CNAT_SOURCE_ERROR_EXHAUSTED_PORTS,
- CNAT_SOURCE_ERROR_USE_DEFAULT,
- CNAT_SOURCE_N_ERRORS,
+ CNAT_SOURCE_ERROR_EXHAUSTED_PORTS = 1,
+ CNAT_SOURCE_ERROR_USE_DEFAULT = 2,
} cnat_source_policy_errors_t;
typedef struct cnat_src_port_allocator_
diff --git a/src/plugins/cnat/cnat_translation.h b/src/plugins/cnat/cnat_translation.h
index a4ae1ece718..7a035814544 100644
--- a/src/plugins/cnat/cnat_translation.h
+++ b/src/plugins/cnat/cnat_translation.h
@@ -222,7 +222,7 @@ cnat_find_translation (index_t cti, u16 port, ip_protocol_t proto)
u64 key;
int rv;
- key = (proto << 24) | port;
+ key = ((u64) proto << 24) | port;
key = key << 32 | (u32) cti;
bkey.key = key;