diff options
author | Neale Ranns <nranns@cisco.com> | 2018-08-29 02:09:47 -0700 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-08-29 12:06:41 +0000 |
commit | 270e1900856852163361a99db6b5c669e454b93b (patch) | |
tree | 1e890eb1dabe0ee7a27a6ee59f8ec97c31199b3a /src/vnet | |
parent | 6da5d8d237c52d999fe077dd278eaa9bc020f01b (diff) |
Consolidate table->index conversion in fib-path CLI processing
Change-Id: I221cebddc45efbfdec428b7df2af96e2aedff2dd
Signed-off-by: Neale Ranns <nranns@cisco.com>
(cherry picked from commit 77eb9073b178e8d4375bf0ef274246586f018ddc)
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/fib/fib_types.c | 15 | ||||
-rw-r--r-- | src/vnet/ip/lookup.c | 16 | ||||
-rw-r--r-- | src/vnet/mpls/mpls.c | 19 |
3 files changed, 14 insertions, 36 deletions
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c index 1046e45b2f7..d54b5c4a19a 100644 --- a/src/vnet/fib/fib_types.c +++ b/src/vnet/fib/fib_types.c @@ -17,6 +17,7 @@ #include <vnet/fib/fib_types.h> #include <vnet/fib/fib_internal.h> +#include <vnet/fib/fib_table.h> #include <vnet/mpls/mpls.h> /* @@ -384,7 +385,7 @@ unformat_fib_route_path (unformat_input_t * input, va_list * args) { fib_route_path_t *rpath = va_arg (*args, fib_route_path_t *); u32 *payload_proto = va_arg (*args, u32*); - u32 weight, preference, udp_encap_id; + u32 weight, preference, udp_encap_id, fi; mpls_label_t out_label; vnet_main_t *vnm; @@ -426,6 +427,14 @@ unformat_fib_route_path (unformat_input_t * input, va_list * args) { rpath->frp_sw_if_index = ~0; rpath->frp_proto = DPO_PROTO_IP4; + + /* + * the user enter table-ids, convert to index + */ + fi = fib_table_find (FIB_PROTOCOL_IP4, rpath->frp_fib_index); + if (~0 == fi) + return 0; + rpath->frp_fib_index = fi; } else if (unformat (input, "%U next-hop-table %d", unformat_ip6_address, @@ -434,6 +443,10 @@ unformat_fib_route_path (unformat_input_t * input, va_list * args) { rpath->frp_sw_if_index = ~0; rpath->frp_proto = DPO_PROTO_IP6; + fi = fib_table_find (FIB_PROTOCOL_IP6, rpath->frp_fib_index); + if (~0 == fi) + return 0; + rpath->frp_fib_index = fi; } else if (unformat (input, "%U", unformat_ip4_address, diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index e0d1ac06dfb..e04c636a47c 100644 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -452,22 +452,6 @@ vnet_ip_route_cmd (vlib_main_t * vm, { for (j = 0; j < vec_len (rpaths); j++) { - u32 fi; - /* - * the CLI parsing stored table Ids, swap to FIB indicies - */ - fi = fib_table_find (prefixs[i].fp_proto, - rpaths[i].frp_fib_index); - - if (~0 == fi) - { - error = - clib_error_return (0, "Via table %d does not exist", - rpaths[i].frp_fib_index); - goto done; - } - rpaths[i].frp_fib_index = fi; - fib_prefix_t rpfx = { .fp_len = prefixs[i].fp_len, .fp_proto = prefixs[i].fp_proto, diff --git a/src/vnet/mpls/mpls.c b/src/vnet/mpls/mpls.c index aaaba39869e..c35aef943cd 100644 --- a/src/vnet/mpls/mpls.c +++ b/src/vnet/mpls/mpls.c @@ -312,7 +312,6 @@ vnet_mpls_local_label (vlib_main_t * vm, else { fib_node_index_t fib_index; - u32 fi; if (NULL == rpaths) { @@ -325,24 +324,6 @@ vnet_mpls_local_label (vlib_main_t * vm, pfx.fp_label = local_label; pfx.fp_payload_proto = rpaths[0].frp_proto; - /* - * the CLI parsing stored table Ids, swap to FIB indicies - */ - if (FIB_NODE_INDEX_INVALID == rpath.frp_sw_if_index) - { - fi = fib_table_find(dpo_proto_to_fib(pfx.fp_payload_proto), - rpaths[0].frp_fib_index); - - if (~0 == fi) - { - error = clib_error_return(0 , "%U Via table %d does not exist", - format_dpo_proto, pfx.fp_payload_proto, - rpaths[0].frp_fib_index); - goto done; - } - rpaths[0].frp_fib_index = fi; - } - fib_index = mpls_fib_index_from_table_id(table_id); if (FIB_NODE_INDEX_INVALID == fib_index) |