]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: fix administrative distance issues 1160/head
authorRenato Westphal <renato@opensourcerouting.org>
Tue, 12 Sep 2017 01:51:40 +0000 (22:51 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 12 Sep 2017 14:02:25 +0000 (11:02 -0300)
* 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>
zebra/zebra_mpls.h
zebra/zebra_rib.c

index c8df8670f4a5d7f5231196124696afa3ce8c3426..51279798a42b9997c9b4a7704331a50ef805d9da 100644 (file)
@@ -408,10 +408,16 @@ void zebra_mpls_vty_init(void);
  */
 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 150;
+       case ZEBRA_LSP_LDP:
+               return (route_distance(ZEBRA_ROUTE_LDP));
+       case ZEBRA_LSP_BGP:
+               return (route_distance(ZEBRA_ROUTE_BGP));
+       default:
+               return 150;
+       }
 }
 
 /*
index e0c92801ce3f8a47978d44e5acc8717ff206b783..959ffdce8a411697c905e8386adc6d55ffb8cee5 100644 (file)
@@ -2233,7 +2233,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
 
        /* Set default distance by route type. */
        if (re->distance == 0) {
-               re->distance = route_info[re->type].distance;
+               re->distance = route_distance(re->type);
 
                /* iBGP distance is 200. */
                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. */
        if (distance == 0) {
-               if ((unsigned)type >= array_size(route_info))
-                       distance = 150;
-               else
-                       distance = route_info[type].distance;
+               distance = route_distance(type);
 
                /* iBGP distance is 200. */
                if (type == ZEBRA_ROUTE_BGP