2006-01-18 Gunnar Stigen <gunnar.stigen@axxessit.no>
* zebra_rib.c: Take interface metric into account.
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index fb983bd..5d9cb2f 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -919,10 +919,23 @@
if (rib->distance == DISTANCE_INFINITY)
continue;
- /* Newly selected rib. */
- if (! select || rib->distance < select->distance
- || rib->type == ZEBRA_ROUTE_CONNECT)
- select = rib;
+ /* Newly selected rib, the common case. */
+ if (!select)
+ {
+ select = rib;
+ continue;
+ }
+
+ /* filter route selection in following order:
+ * - lower distance beats higher
+ * - connected beats other types
+ * - lower metric beats higher for equal distance
+ * - last, hence oldest, route wins tie break.
+ */
+ if ((rib->type == ZEBRA_ROUTE_CONNECT)
+ || (rib->distance <= select->distance))
+ if (rib->metric <= select->metric)
+ select = rib;
}
/* Deleted route check. */