span: crash in span_mirror [VPP-1254] 90/12090/1
authorSteven <sluong@cisco.com>
Wed, 25 Apr 2018 05:43:07 +0000 (22:43 -0700)
committerSteven <sluong@cisco.com>
Wed, 25 Apr 2018 05:47:44 +0000 (22:47 -0700)
commit516d63ff2c6671f3b0dc641511a50017a9804179
treeeb4d0e8b12d107ec1a35cdacd9201ef63b9ba63f
parent6e4f40b6a9635df83cbafae348ab72017861fa8b
span: crash in span_mirror [VPP-1254]

It is possible for span-input to get call with sw_if_index which is greater than
sm->interfaces and crashes in span_mirror () in the following line

  span_interface_t *si0 = vec_elt_at_index (sm->interfaces, sw_if_index0);

For example, span-input mirrors a main interface as source, it may actually get
call for traffic coming in from the subinterface and crashes.

The fix is simply to check if sw_if_index >= vec_len (sm->interfaces) and
punt if it is.

Change-Id: I8312eb321d638518e14ba2326fffd1a7919646ca
Signed-off-by: Steven <sluong@cisco.com>
src/vnet/span/node.c