aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip4_forward.c18
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);