2003-10-27 Gilad Arnold <gilad.arnold@terayon.com>

        * zebra/zebra_rib.c: (nexthop_active_update) Check for multipath
          limit when setting changed flag to avoid spurious changes.
          (static_install_ipv{4,6}) dont uninstall by default, might not be
          required - avoid spurious uninstalls.
          (static_uninstall_ipv{4,6}) only uninstall the route if its
	  actually FIB route.
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index ccccd0a..05ff1e1 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -759,12 +759,18 @@
   for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
     {
       active = CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
-      rib->nexthop_active_num += nexthop_active_check (rn, rib, nexthop, set);
-      if (active != CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
-	SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
+
+      nexthop_active_check (rn, rib, nexthop, set);
+      if ((MULTIPATH_NUM == 0 || rib->nexthop_active_num < MULTIPATH_NUM)
+          && active != CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
+        SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
+
+      if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
+        rib->nexthop_active_num++;
     }
   return rib->nexthop_active_num;
 }
+
 
 #define RIB_SYSTEM_ROUTE(R) \
         ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)
@@ -1298,7 +1304,6 @@
     {
       /* Same distance static route is there.  Update it with new
          nexthop. */
-      rib_uninstall (rn, rib);
       route_unlock_node (rn);
       switch (si->type)
         {
@@ -1417,7 +1422,8 @@
     }
   else
     {
-      rib_uninstall (rn, rib);
+      if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
+        rib_uninstall (rn, rib);
       nexthop_delete (rib, nexthop);
       nexthop_free (nexthop);
       rib_process (rn, rib);
@@ -1860,7 +1866,6 @@
     {
       /* Same distance static route is there.  Update it with new
          nexthop. */
-      rib_uninstall (rn, rib);
       route_unlock_node (rn);
 
       switch (si->type)
@@ -1980,7 +1985,8 @@
     }
   else
     {
-      rib_uninstall (rn, rib);
+      if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
+        rib_uninstall (rn, rib);
       nexthop_delete (rib, nexthop);
       nexthop_free (nexthop);
       rib_process (rn, rib);