aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancois Clad <fclad@cisco.com>2018-01-31 14:46:45 +0100
committerNeale Ranns <nranns@cisco.com>2018-02-01 11:03:51 +0000
commitbe9b41ba3887452c864d1423ea03ed4ee2b9153c (patch)
treef2e1d7f6d610a0f2cdb862c8185ce8c8a8c35ac2 /src
parent49d8cddaba69a6f08cb990c9be9bebe87f33b808 (diff)
srv6-ad: fixing coverity issues
Change-Id: Ica6d8dd773bb3b478f1c7e40d59dfbdd4b588b85 Signed-off-by: Francois Clad <fclad@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/srv6-ad/node.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/plugins/srv6-ad/node.c b/src/plugins/srv6-ad/node.c
index 73957f55ab6..4bc110d8a1c 100644
--- a/src/plugins/srv6-ad/node.c
+++ b/src/plugins/srv6-ad/node.c
@@ -27,6 +27,7 @@ typedef struct
typedef struct
{
+ u8 error;
ip6_address_t src, dst;
} srv6_ad_rewrite_trace_t;
@@ -47,6 +48,11 @@ format_srv6_ad_rewrite_trace (u8 * s, va_list * args)
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
srv6_ad_rewrite_trace_t *t = va_arg (*args, srv6_ad_rewrite_trace_t *);
+ if (PREDICT_FALSE (t->error != 0))
+ {
+ return format (s, "SRv6-AD-rewrite: cache is empty");
+ }
+
return format (s, "SRv6-AD-rewrite: src %U dst %U",
format_ip6_address, &t->src, format_ip6_address, &t->dst);
}
@@ -352,10 +358,19 @@ srv6_ad4_rewrite_fn (vlib_main_t * vm,
{
srv6_ad_rewrite_trace_t *tr =
vlib_add_trace (vm, node, b0, sizeof *tr);
- clib_memcpy (tr->src.as_u8, ip0->src_address.as_u8,
- sizeof tr->src.as_u8);
- clib_memcpy (tr->dst.as_u8, ip0->dst_address.as_u8,
- sizeof tr->dst.as_u8);
+ tr->error = 0;
+
+ if (next0 == SRV6_AD_REWRITE_NEXT_ERROR)
+ {
+ tr->error = 1;
+ }
+ else
+ {
+ clib_memcpy (tr->src.as_u8, ip0->src_address.as_u8,
+ sizeof tr->src.as_u8);
+ clib_memcpy (tr->dst.as_u8, ip0->dst_address.as_u8,
+ sizeof tr->dst.as_u8);
+ }
}
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
@@ -472,10 +487,19 @@ srv6_ad6_rewrite_fn (vlib_main_t * vm,
{
srv6_ad_rewrite_trace_t *tr =
vlib_add_trace (vm, node, b0, sizeof *tr);
- clib_memcpy (tr->src.as_u8, ip0->src_address.as_u8,
- sizeof tr->src.as_u8);
- clib_memcpy (tr->dst.as_u8, ip0->dst_address.as_u8,
- sizeof tr->dst.as_u8);
+ tr->error = 0;
+
+ if (next0 == SRV6_AD_REWRITE_NEXT_ERROR)
+ {
+ tr->error = 1;
+ }
+ else
+ {
+ clib_memcpy (tr->src.as_u8, ip0->src_address.as_u8,
+ sizeof tr->src.as_u8);
+ clib_memcpy (tr->dst.as_u8, ip0->dst_address.as_u8,
+ sizeof tr->dst.as_u8);
+ }
}
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,