urpf: add mode for specific fib index lookup

this patch adds a mode to urpf in order to perform the lookup in a specified vrf instead of the interface vrf
Type: feature
Change-Id: Ieb91de6ccdfbf32b6939364f3bebeecd2d57af19
Signed-off-by: hedi bouattour <hedibouattour2010@gmail.com>
This commit is contained in:
hedi bouattour
2022-09-14 12:39:23 +00:00
committed by Neale Ranns
parent 9260b8861e
commit b3605eab5a
5 changed files with 176 additions and 39 deletions
+8 -14
View File
@@ -128,6 +128,11 @@ urpf_inline (vlib_main_t * vm,
h1 += vnet_buffer (b[1])->ip.save_rewrite_length;
}
fib_index0 =
urpf_cfgs[af][dir][vnet_buffer (b[0])->sw_if_index[dir]].fib_index;
fib_index1 =
urpf_cfgs[af][dir][vnet_buffer (b[1])->sw_if_index[dir]].fib_index;
if (AF_IP4 == af)
{
const ip4_header_t *ip0, *ip1;
@@ -135,11 +140,6 @@ urpf_inline (vlib_main_t * vm,
ip0 = (ip4_header_t *) h0;
ip1 = (ip4_header_t *) h1;
fib_index0 = ip4_main.fib_index_by_sw_if_index
[vnet_buffer (b[0])->sw_if_index[dir]];
fib_index1 = ip4_main.fib_index_by_sw_if_index
[vnet_buffer (b[1])->sw_if_index[dir]];
ip4_fib_forwarding_lookup_x2 (fib_index0,
fib_index1,
&ip0->src_address,
@@ -155,11 +155,6 @@ urpf_inline (vlib_main_t * vm,
{
const ip6_header_t *ip0, *ip1;
fib_index0 = ip6_main.fib_index_by_sw_if_index
[vnet_buffer (b[0])->sw_if_index[dir]];
fib_index1 = ip6_main.fib_index_by_sw_if_index
[vnet_buffer (b[1])->sw_if_index[dir]];
ip0 = (ip6_header_t *) h0;
ip1 = (ip6_header_t *) h1;
@@ -255,12 +250,13 @@ urpf_inline (vlib_main_t * vm,
if (VLIB_TX == dir)
h0 += vnet_buffer (b[0])->ip.save_rewrite_length;
fib_index0 =
urpf_cfgs[af][dir][vnet_buffer (b[0])->sw_if_index[dir]].fib_index;
if (AF_IP4 == af)
{
const ip4_header_t *ip0;
fib_index0 = ip4_main.fib_index_by_sw_if_index
[vnet_buffer (b[0])->sw_if_index[dir]];
ip0 = (ip4_header_t *) h0;
lb_index0 = ip4_fib_forwarding_lookup (fib_index0,
@@ -275,8 +271,6 @@ urpf_inline (vlib_main_t * vm,
const ip6_header_t *ip0;
ip0 = (ip6_header_t *) h0;
fib_index0 = ip6_main.fib_index_by_sw_if_index
[vnet_buffer (b[0])->sw_if_index[dir]];
lb_index0 = ip6_fib_table_fwding_lookup (fib_index0,
&ip0->src_address);