]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_rib.c
Merge pull request #1163 from donaldsharp/deduplicate_nexthops
[mirror_frr.git] / zebra / zebra_rib.c
index f88e594a990de6ebcd21f94e3c35d5d0b1a9de86..d04b64b19ccac0dbbba649f0287cdebf30581255 100644 (file)
@@ -1134,7 +1134,6 @@ static int rib_can_delete_dest(rib_dest_t *dest)
 int rib_gc_dest(struct route_node *rn)
 {
        rib_dest_t *dest;
-       struct zebra_vrf *zvrf;
 
        dest = rib_dest_from_rnode(rn);
        if (!dest)
@@ -1143,9 +1142,12 @@ int rib_gc_dest(struct route_node *rn)
        if (!rib_can_delete_dest(dest))
                return 0;
 
-       zvrf = rib_dest_vrf(dest);
-       if (IS_ZEBRA_DEBUG_RIB)
+       if (IS_ZEBRA_DEBUG_RIB) {
+               struct zebra_vrf *zvrf;
+
+               zvrf = rib_dest_vrf(dest);
                rnode_debug(rn, zvrf_id(zvrf), "removing dest from table");
+       }
 
        dest->rnode = NULL;
        XFREE(MTYPE_RIB_DEST, dest);
@@ -2567,27 +2569,29 @@ static void rib_update_table(struct route_table *table,
                         */
                        RNODE_FOREACH_RE_SAFE(rn, re, next)
                        {
-                               if (re->type == ZEBRA_ROUTE_OSPF
-                                   || re->type == ZEBRA_ROUTE_OSPF6
-                                   || re->type == ZEBRA_ROUTE_BGP)
-                                       continue; /* protocol will handle. */
-                               else if (re->type == ZEBRA_ROUTE_STATIC) {
-                                       struct nexthop *nh;
-                                       for (nh = re->nexthop; nh;
-                                            nh = nh->next)
-                                               if (!(nh->type
-                                                             == NEXTHOP_TYPE_IPV4
-                                                     || nh->type
-                                                                == NEXTHOP_TYPE_IPV6))
-                                                       break;
-
-                                       /* If we only have nexthops to a
-                                        * gateway, NHT will
-                                        * take care.
-                                        */
-                                       if (nh)
-                                               rib_queue_add(rn);
-                               } else
+                               struct nexthop *nh;
+
+                               if (re->type != ZEBRA_ROUTE_SYSTEM &&
+                                   re->type != ZEBRA_ROUTE_KERNEL &&
+                                   re->type != ZEBRA_ROUTE_CONNECT &&
+                                   re->type != ZEBRA_ROUTE_STATIC)
+                                       continue;
+
+                               if (re->type != ZEBRA_ROUTE_STATIC) {
+                                       rib_queue_add(rn);
+                                       continue;
+                               }
+
+                               for (nh = re->nexthop; nh; nh = nh->next)
+                                       if (!(nh->type == NEXTHOP_TYPE_IPV4
+                                             || nh->type == NEXTHOP_TYPE_IPV6))
+                                               break;
+
+                               /* If we only have nexthops to a
+                                * gateway, NHT will
+                                * take care.
+                                */
+                               if (nh)
                                        rib_queue_add(rn);
                        }
                        break;