zebra: fix administrative distance issues

* Reuse route_distance() on rib_add_multipath() and on rib_add();
* Set the admin distance of LDP and BGP MPLS LSPs.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2017-09-11 22:51:40 -03:00
parent c710b277cf
commit 0492eea08e
2 changed files with 11 additions and 8 deletions

View File

@ -408,11 +408,17 @@ void zebra_mpls_vty_init(void);
*/ */
static inline u_char lsp_distance(enum lsp_types_t type) static inline u_char lsp_distance(enum lsp_types_t type)
{ {
if (type == ZEBRA_LSP_STATIC) switch (type) {
case ZEBRA_LSP_STATIC:
return (route_distance(ZEBRA_ROUTE_STATIC)); return (route_distance(ZEBRA_ROUTE_STATIC));
case ZEBRA_LSP_LDP:
return (route_distance(ZEBRA_ROUTE_LDP));
case ZEBRA_LSP_BGP:
return (route_distance(ZEBRA_ROUTE_BGP));
default:
return 150; return 150;
} }
}
/* /*
* Map RIB type to LSP type. Used when labeled-routes from BGP * Map RIB type to LSP type. Used when labeled-routes from BGP

View File

@ -2233,7 +2233,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
/* Set default distance by route type. */ /* Set default distance by route type. */
if (re->distance == 0) { if (re->distance == 0) {
re->distance = route_info[re->type].distance; re->distance = route_distance(re->type);
/* iBGP distance is 200. */ /* iBGP distance is 200. */
if (re->type == ZEBRA_ROUTE_BGP if (re->type == ZEBRA_ROUTE_BGP
@ -2450,10 +2450,7 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance,
/* Set default distance by route type. */ /* Set default distance by route type. */
if (distance == 0) { if (distance == 0) {
if ((unsigned)type >= array_size(route_info)) distance = route_distance(type);
distance = 150;
else
distance = route_info[type].distance;
/* iBGP distance is 200. */ /* iBGP distance is 200. */
if (type == ZEBRA_ROUTE_BGP if (type == ZEBRA_ROUTE_BGP