diff options
author | Alex Popovsky <apopovsk@cisco.com> | 2016-09-01 20:57:45 -0700 |
---|---|---|
committer | John Lo <loj@cisco.com> | 2016-09-02 10:46:15 +0000 |
commit | 52901246e02c3d648c25a089c3dce5b6b4fb3112 (patch) | |
tree | a9a121a0a5a62f0bac73991c884ee4741c62a346 /vnet | |
parent | ee4743adf5019ccc800257991492aec75d2f3e44 (diff) |
Fix for invalid check of SPARSE_VEC_INVALID_INDEX
When looking up a UDP port / GRE protocol in the sparse vectors
next_by_dst_port / next_by_protocol a data from the vector was
tested for SPARSE_VEC_INVALID_INDEX instead of sparse index itself.
This doesn’t matter for most cases since V[0] = 0 is true for all
sparse vectors. This however could cause an issue when a valid
sparse entry e.g. V[1234] = 0, with data (0) mistakenly passing
the test for SPARSE_VEC_INVALID_INDEX, while the index itself (1234)
is a valid index.
Change-Id: I04818cc43efeae047a4dae79078157d48b8c359c
Signed-off-by: Alex Popovsky <apopovsk@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r-- | vnet/vnet/gre/node.c | 6 | ||||
-rw-r--r-- | vnet/vnet/ip/udp_local.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/vnet/vnet/gre/node.c b/vnet/vnet/gre/node.c index d226c2f507c..97f9dac2e2b 100644 --- a/vnet/vnet/gre/node.c +++ b/vnet/vnet/gre/node.c @@ -145,8 +145,8 @@ gre_input (vlib_main_t * vm, next0 = vec_elt(rt->next_by_protocol, i0); next1 = vec_elt(rt->next_by_protocol, i1); - b0->error = node->errors[next0 == SPARSE_VEC_INVALID_INDEX ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE]; - b1->error = node->errors[next1 == SPARSE_VEC_INVALID_INDEX ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE]; + b0->error = node->errors[i0 == SPARSE_VEC_INVALID_INDEX ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE]; + b1->error = node->errors[i1 == SPARSE_VEC_INVALID_INDEX ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE]; version0 = clib_net_to_host_u16 (h0->flags_and_version); verr0 = version0 & GRE_VERSION_MASK; @@ -317,7 +317,7 @@ drop1: next0 = vec_elt(rt->next_by_protocol, i0); b0->error = - node->errors[next0 == SPARSE_VEC_INVALID_INDEX + node->errors[i0 == SPARSE_VEC_INVALID_INDEX ? GRE_ERROR_UNKNOWN_PROTOCOL : GRE_ERROR_NONE]; version0 = clib_net_to_host_u16 (h0->flags_and_version); diff --git a/vnet/vnet/ip/udp_local.c b/vnet/vnet/ip/udp_local.c index 9940323286a..76766308df9 100644 --- a/vnet/vnet/ip/udp_local.c +++ b/vnet/vnet/ip/udp_local.c @@ -179,7 +179,7 @@ udp46_input_inline (vlib_main_t * vm, next0 = (error0 == 0) ? vec_elt(rt->next_by_dst_port, i0) : next0; next1 = (error1 == 0) ? vec_elt(rt->next_by_dst_port, i1) : next1; - if (PREDICT_FALSE(next0 == SPARSE_VEC_INVALID_INDEX)) + if (PREDICT_FALSE(i0 == SPARSE_VEC_INVALID_INDEX)) { // move the pointer back so icmp-error can find the // ip packet header @@ -206,7 +206,7 @@ udp46_input_inline (vlib_main_t * vm, vlib_buffer_advance (b0, sizeof (*h0)); } - if (PREDICT_FALSE(next1 == SPARSE_VEC_INVALID_INDEX)) + if (PREDICT_FALSE(i1 == SPARSE_VEC_INVALID_INDEX)) { // move the pointer back so icmp-error can find the // ip packet header @@ -303,7 +303,7 @@ udp46_input_inline (vlib_main_t * vm, i0 = sparse_vec_index (rt->next_by_dst_port, h0->dst_port); next0 = vec_elt(rt->next_by_dst_port, i0); - if (PREDICT_FALSE(next0 == SPARSE_VEC_INVALID_INDEX)) + if (PREDICT_FALSE(i0 == SPARSE_VEC_INVALID_INDEX)) { // move the pointer back so icmp-error can find the // ip packet header |