Merge svn revisions 997 and 1000 from Zebra cvs repository.
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index b054c7b..7a5a394 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -288,6 +288,7 @@
           ospf6_route_delete (route);
           SET_FLAG (old->flag, OSPF6_ROUTE_ADD);
           ospf6_route_count_assert (table);
+
           return old;
         }
 
@@ -315,10 +316,11 @@
       ospf6_route_lock (route);
 
       SET_FLAG (route->flag, OSPF6_ROUTE_CHANGE);
+      ospf6_route_count_assert (table);
+
       if (table->hook_add)
         (*table->hook_add) (route);
 
-      ospf6_route_count_assert (table);
       return route;
     }
 
@@ -353,12 +355,12 @@
 
       ospf6_route_lock (route);
       table->count++;
+      ospf6_route_count_assert (table);
 
       SET_FLAG (route->flag, OSPF6_ROUTE_ADD);
       if (table->hook_add)
         (*table->hook_add) (route);
 
-      ospf6_route_count_assert (table);
       return route;
     }
 
@@ -414,12 +416,12 @@
     }
 
   table->count++;
+  ospf6_route_count_assert (table);
 
   SET_FLAG (route->flag, OSPF6_ROUTE_ADD);
   if (table->hook_add)
     (*table->hook_add) (route);
 
-  ospf6_route_count_assert (table);
   return route;
 }
 
@@ -470,13 +472,15 @@
         node->info = NULL; /* should unlock route_node here ? */
     }
 
+  table->count--;
+  ospf6_route_count_assert (table);
+
+  SET_FLAG (route->flag, OSPF6_ROUTE_WAS_REMOVED);
+
   if (table->hook_remove)
     (*table->hook_remove) (route);
 
   ospf6_route_unlock (route);
-  table->count--;
-
-  ospf6_route_count_assert (table);
 }
 
 struct ospf6_route *