aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNitin Saxena <nsaxena@marvell.com>2020-01-04 12:28:42 +0530
committerFlorin Coras <florin.coras@gmail.com>2020-01-11 16:53:41 +0000
commit2d18d2ea9f0e3d6c47d365ec135af651b14e8165 (patch)
tree251f0dcd684503f1419379e4db3fb64afcb24859 /src
parentdfb3e4106f8013d40522570362a776d096f51413 (diff)
ip: avoid fib lookup for consecutive pkts having same source IP
Type: fix Fixes: be2286b0 This patch does following: - If terminating frame has consecutive packets with same source IP, this patch avoids fib lookup for those packets in ip4-local node. This drops cycle count for ip4-local node on both ARM and x86. It being done by enabling dead code in else {} case of ip4_local_check_src_x2() and ip4_local_check_src() functions. - In case all packets in terminating frame have unique source IP (e.g: incrementing), ip4-local is costlier by 2 cycles (broadwell) Change-Id: I472ddc324716cec8bfe601568b8aeb7565f97ab3 Signed-off-by: Nitin Saxena <nsaxena@marvell.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/ip/ip4_forward.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index aa554eab5fb..b8defc56afd 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -1504,8 +1504,8 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0,
* vnet_buffer()->ip.adj_index[VLIB_TX] will be set to the index of the
* adjacency for the source address (the remote sender's address)
*/
- if (PREDICT_FALSE (last_check->first ||
- (last_check->src.as_u32 != ip0->src_address.as_u32)))
+ if (PREDICT_TRUE (last_check->src.as_u32 != ip0->src_address.as_u32) ||
+ last_check->first)
{
mtrie0 = &ip4_fib_get (vnet_buffer (b)->ip.fib_index)->mtrie;
leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, &ip0->src_address);
@@ -1542,6 +1542,7 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0,
last_check->src.as_u32 = ip0->src_address.as_u32;
last_check->lbi = lbi0;
last_check->error = *error0;
+ last_check->first = 0;
}
else
{
@@ -1549,7 +1550,6 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0,
vnet_buffer (b)->ip.adj_index[VLIB_TX];
vnet_buffer (b)->ip.adj_index[VLIB_TX] = last_check->lbi;
*error0 = last_check->error;
- last_check->first = 0;
}
}
@@ -1584,7 +1584,7 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip,
* vnet_buffer()->ip.adj_index[VLIB_TX] will be set to the index of the
* adjacency for the source address (the remote sender's address)
*/
- if (PREDICT_FALSE (not_last_hit))
+ if (PREDICT_TRUE (not_last_hit))
{
mtrie[0] = &ip4_fib_get (vnet_buffer (b[0])->ip.fib_index)->mtrie;
mtrie[1] = &ip4_fib_get (vnet_buffer (b[1])->ip.fib_index)->mtrie;
@@ -1638,6 +1638,7 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip,
last_check->src.as_u32 = ip[1]->src_address.as_u32;
last_check->lbi = lbi[1];
last_check->error = error[1];
+ last_check->first = 0;
}
else
{
@@ -1651,7 +1652,6 @@ 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;
}
}