diff options
author | Neale Ranns <nranns@cisco.com> | 2017-07-15 07:37:25 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-07-18 20:46:29 +0000 |
commit | 57b5860f013953ce161d05302e05370db9cd6ee2 (patch) | |
tree | 2d4cdbbc631848be4c43c599698019b2121e000b /src/vnet/ip | |
parent | 51822bf07a3f0fe72834ea94659faf6e262475ba (diff) |
FIB path preference
Paths are given a preference, lowest value is 'best'. Only paths that are up are up contribute to fprwarding - that's unchanged. What's new is that of the path's that re up only those that have the best preference contribute. A poor man's primary and backup. It's not true primary/backup function because the FIB must converge before the lower preference paths are used.
Change-Id: Ie4453c4a7b1094c6c2b51fe1594b8302103bb68e
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r-- | src/vnet/ip/ip.api | 5 | ||||
-rw-r--r-- | src/vnet/ip/ip_api.c | 6 | ||||
-rwxr-xr-x | src/vnet/ip/lookup.c | 31 |
3 files changed, 20 insertions, 22 deletions
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index 7097a13014d..fa363370c56 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -31,6 +31,7 @@ define ip_fib_dump /** \brief FIB path @param sw_if_index - index of the interface @param weight - The weight, for UCMP + @param preference - The preference of the path. lowest preference is prefered @param is_local - local if non-zero, else remote @param is_drop - Drop the packet @param is_unreach - Drop the packet and rate limit send ICMP unreachable @@ -43,7 +44,8 @@ define ip_fib_dump typeonly manual_print manual_endian define fib_path { u32 sw_if_index; - u32 weight; + u8 weight; + u8 preference; u8 is_local; u8 is_drop; u8 is_unreach; @@ -374,6 +376,7 @@ autoreply define ip_add_del_route /* Is last/not-last message in group of multiple add/del messages. */ u8 not_last; u8 next_hop_weight; + u8 next_hop_preference; u8 dst_address_length; u8 dst_address[16]; u8 next_hop_address[16]; diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c index 2680d6010dc..d00ae76cfe8 100644 --- a/src/vnet/ip/ip_api.c +++ b/src/vnet/ip/ip_api.c @@ -716,7 +716,8 @@ add_del_route_t_handler (u8 is_multipath, const ip46_address_t * next_hop, u32 next_hop_sw_if_index, u8 next_hop_fib_index, - u32 next_hop_weight, + u16 next_hop_weight, + u16 next_hop_preference, mpls_label_t next_hop_via_label, mpls_label_t * next_hop_out_label_stack) { @@ -729,6 +730,7 @@ add_del_route_t_handler (u8 is_multipath, .frp_sw_if_index = next_hop_sw_if_index, .frp_fib_index = next_hop_fib_index, .frp_weight = next_hop_weight, + .frp_preference = next_hop_preference, .frp_label_stack = next_hop_out_label_stack, }; fib_route_path_t *paths = NULL; @@ -971,6 +973,7 @@ ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp) ntohl (mp->next_hop_sw_if_index), next_hop_fib_index, mp->next_hop_weight, + mp->next_hop_preference, ntohl (mp->next_hop_via_label), label_stack)); } @@ -1029,6 +1032,7 @@ ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp) &nh, ntohl (mp->next_hop_sw_if_index), next_hop_fib_index, mp->next_hop_weight, + mp->next_hop_preference, ntohl (mp->next_hop_via_label), label_stack)); } diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index 6547cad51b1..533d010a738 100755 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -360,6 +360,7 @@ vnet_ip_route_cmd (vlib_main_t * vm, fib_prefix_t *prefixs = NULL, pfx; mpls_label_t out_label, via_label; clib_error_t *error = NULL; + u32 weight, preference; u32 table_id, is_del; vnet_main_t *vnm; u32 fib_index; @@ -441,26 +442,6 @@ vnet_ip_route_cmd (vlib_main_t * vm, pfx.fp_proto = FIB_PROTOCOL_IP6; vec_add1 (prefixs, pfx); } - else if (unformat (line_input, "via %U %U weight %u", - unformat_ip4_address, - &rpath.frp_addr.ip4, - unformat_vnet_sw_interface, vnm, - &rpath.frp_sw_if_index, &rpath.frp_weight)) - { - rpath.frp_proto = FIB_PROTOCOL_IP4; - vec_add1 (rpaths, rpath); - } - - else if (unformat (line_input, "via %U %U weight %u", - unformat_ip6_address, - &rpath.frp_addr.ip6, - unformat_vnet_sw_interface, vnm, - &rpath.frp_sw_if_index, &rpath.frp_weight)) - { - rpath.frp_proto = FIB_PROTOCOL_IP6; - vec_add1 (rpaths, rpath); - } - else if (unformat (line_input, "via %U %U", unformat_ip4_address, &rpath.frp_addr.ip4, @@ -482,6 +463,16 @@ vnet_ip_route_cmd (vlib_main_t * vm, rpath.frp_proto = FIB_PROTOCOL_IP6; vec_add1 (rpaths, rpath); } + else if (unformat (line_input, "weight %u", &weight)) + { + ASSERT (vec_len (rpaths)); + rpaths[vec_len (rpaths) - 1].frp_weight = weight; + } + else if (unformat (line_input, "preference %u", &preference)) + { + ASSERT (vec_len (rpaths)); + rpaths[vec_len (rpaths) - 1].frp_preference = preference; + } else if (unformat (line_input, "via %U next-hop-table %d", unformat_ip4_address, &rpath.frp_addr.ip4, &rpath.frp_fib_index)) |