diff options
author | Neale Ranns <nranns@cisco.com> | 2018-12-09 12:54:51 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-12-10 13:43:38 +0000 |
commit | be2286b0a4ff0cd31791b86d38a5e72b06bc17c2 (patch) | |
tree | 50fde349dfbb9fc8bb32563e1f171899246849f8 /src/vnet/ip | |
parent | 6919b0de476e50307520a1f2389ffe7988f2c5a6 (diff) |
IP-local: any IP can appear as the source (VPP-1522)
Change-Id: Ib0d9b533d72c899b77c9a7bd1daa9b4a55b7221c
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r-- | src/vnet/ip/ip4_forward.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 1911f088008..1ca4f9309e6 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -1334,6 +1334,7 @@ typedef struct ip4_address_t src; u32 lbi; u8 error; + u8 first; } ip4_local_last_check_t; static inline void @@ -1350,7 +1351,8 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0, vnet_buffer (b)->sw_if_index[VLIB_TX] != ~0 ? vnet_buffer (b)->sw_if_index[VLIB_TX] : vnet_buffer (b)->ip.fib_index; - if (PREDICT_FALSE (last_check->src.as_u32 != ip0->src_address.as_u32)) + if (PREDICT_FALSE (last_check->first || + (last_check->src.as_u32 != ip0->src_address.as_u32))) { mtrie0 = &ip4_fib_get (vnet_buffer (b)->ip.fib_index)->mtrie; leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, &ip0->src_address); @@ -1392,6 +1394,7 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0, vnet_buffer (b)->ip.adj_index[VLIB_TX] = last_check->lbi; vnet_buffer (b)->ip.adj_index[VLIB_RX] = last_check->lbi; *error0 = last_check->error; + last_check->first = 0; } } @@ -1403,9 +1406,10 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip, ip4_fib_mtrie_t *mtrie[2]; const dpo_id_t *dpo[2]; load_balance_t *lb[2]; - u32 not_last_hit = 0; + u32 not_last_hit; u32 lbi[2]; + not_last_hit = last_check->first; not_last_hit |= ip[0]->src_address.as_u32 ^ last_check->src.as_u32; not_last_hit |= ip[1]->src_address.as_u32 ^ last_check->src.as_u32; @@ -1482,6 +1486,7 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip, error[0] = last_check->error; error[1] = last_check->error; + last_check->first = 0; } } @@ -1532,9 +1537,16 @@ ip4_local_inline (vlib_main_t * vm, u8 error[2], pt[2]; ip4_local_last_check_t last_check = { + /* + * 0.0.0.0 can appear as the source address of an IP packet, + * as can any other address, hence the need to use the 'first' + * member to make sure the .lbi is initialised for the first + * packet. + */ .src = {.as_u32 = 0}, .lbi = ~0, - .error = IP4_ERROR_UNKNOWN_PROTOCOL + .error = IP4_ERROR_UNKNOWN_PROTOCOL, + .first = 1, }; from = vlib_frame_vector_args (frame); |