zebra: Combine static_install_ipv[4|6]

Combine the static_install_ipv[4|6] function calls into
static_install_route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 516d9d9..4d122c4 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1669,7 +1669,7 @@
  * as a route_node will not be requeued, if already queued.
  *
  * RIBs are submitted via rib_addnode or rib_delnode which set minimal
- * state, or static_install_ipv{4,6} (when an existing RIB is updated)
+ * state, or static_install_route (when an existing RIB is updated)
  * and then submit route_node to queue for best-path selection later.
  * Order of add/delete state changes are preserved for any given RIB.
  *
@@ -2279,14 +2279,14 @@
 
 /* Install static route into rib. */
 static void
-static_install_ipv4 (safi_t safi, struct prefix *p, struct static_route *si)
+static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_route *si)
 {
   struct rib *rib;
   struct route_node *rn;
   struct route_table *table;
 
   /* Lookup table.  */
-  table = zebra_vrf_table (AFI_IP, safi, si->vrf_id);
+  table = zebra_vrf_table (afi, safi, si->vrf_id);
   if (! table)
     return;
 
@@ -2308,15 +2308,24 @@
       route_unlock_node (rn);
       switch (si->type)
         {
-          case STATIC_IPV4_GATEWAY:
-            nexthop_ipv4_add (rib, &si->addr.ipv4, NULL);
-            break;
-          case STATIC_IPV4_IFNAME:
-            nexthop_ifname_add (rib, si->ifname);
-            break;
-          case STATIC_IPV4_BLACKHOLE:
-            nexthop_blackhole_add (rib);
-            break;
+	case STATIC_IPV4_GATEWAY:
+	  nexthop_ipv4_add (rib, &si->addr.ipv4, NULL);
+	  break;
+	case STATIC_IPV4_IFNAME:
+	  nexthop_ifname_add (rib, si->ifname);
+	  break;
+	case STATIC_IPV4_BLACKHOLE:
+	  nexthop_blackhole_add (rib);
+	  break;
+	case STATIC_IPV6_GATEWAY:
+	  nexthop_ipv6_add (rib, &si->addr.ipv6);
+	  break;
+	case STATIC_IPV6_IFNAME:
+	  nexthop_ifname_add (rib, si->ifname);
+	  break;
+	case STATIC_IPV6_GATEWAY_IFNAME:
+	  nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
+	  break;
         }
       rib_queue_add (&zebrad, rn);
     }
@@ -2334,15 +2343,24 @@
 
       switch (si->type)
         {
-          case STATIC_IPV4_GATEWAY:
-            nexthop_ipv4_add (rib, &si->addr.ipv4, NULL);
-            break;
-          case STATIC_IPV4_IFNAME:
-            nexthop_ifname_add (rib, si->ifname);
-            break;
-          case STATIC_IPV4_BLACKHOLE:
-            nexthop_blackhole_add (rib);
-            break;
+	case STATIC_IPV4_GATEWAY:
+	  nexthop_ipv4_add (rib, &si->addr.ipv4, NULL);
+	  break;
+	case STATIC_IPV4_IFNAME:
+	  nexthop_ifname_add (rib, si->ifname);
+	  break;
+	case STATIC_IPV4_BLACKHOLE:
+	  nexthop_blackhole_add (rib);
+	  break;
+	case STATIC_IPV6_GATEWAY:
+	  nexthop_ipv6_add (rib, &si->addr.ipv6);
+	  break;
+	case STATIC_IPV6_IFNAME:
+	  nexthop_ifname_add (rib, si->ifname);
+	  break;
+	case STATIC_IPV6_GATEWAY_IFNAME:
+	  nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
+	  break;
         }
 
       /* Save the flags of this static routes (reject, blackhole) */
@@ -2521,7 +2539,7 @@
   si->next = cp;
 
   /* Install into rib. */
-  static_install_ipv4 (safi, p, si);
+  static_install_route (AFI_IP, safi, p, si);
 
   return 1;
 }
@@ -2824,83 +2842,6 @@
   return 0;
 }
 
-/* Install static route into rib. */
-static void
-static_install_ipv6 (struct prefix *p, struct static_route *si)
-{
-  struct rib *rib;
-  struct route_table *table;
-  struct route_node *rn;
-
-  /* Lookup table.  */
-  table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, si->vrf_id);
-  if (! table)
-    return;
-
-  /* Lookup existing route */
-  rn = route_node_get (table, p);
-  RNODE_FOREACH_RIB (rn, rib)
-    {
-      if (CHECK_FLAG(rib->status, RIB_ENTRY_REMOVED))
-        continue;
-
-      if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance)
-        break;
-    }
-
-  if (rib)
-    {
-      /* Same distance static route is there.  Update it with new
-         nexthop. */
-      route_unlock_node (rn);
-
-      switch (si->type)
-	{
-	case STATIC_IPV6_GATEWAY:
-	  nexthop_ipv6_add (rib, &si->addr.ipv6);
-	  break;
-	case STATIC_IPV6_IFNAME:
-	  nexthop_ifname_add (rib, si->ifname);
-	  break;
-	case STATIC_IPV6_GATEWAY_IFNAME:
-	  nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
-	  break;
-	}
-      rib_queue_add (&zebrad, rn);
-    }
-  else
-    {
-      /* This is new static route. */
-      rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
-      
-      rib->type = ZEBRA_ROUTE_STATIC;
-      rib->distance = si->distance;
-      rib->metric = 0;
-      rib->vrf_id = si->vrf_id;
-      rib->table = zebrad.rtm_table_default;
-      rib->nexthop_num = 0;
-
-      switch (si->type)
-	{
-	case STATIC_IPV6_GATEWAY:
-	  nexthop_ipv6_add (rib, &si->addr.ipv6);
-	  break;
-	case STATIC_IPV6_IFNAME:
-	  nexthop_ifname_add (rib, si->ifname);
-	  break;
-	case STATIC_IPV6_GATEWAY_IFNAME:
-	  nexthop_ipv6_ifname_add (rib, &si->addr.ipv6, si->ifname);
-	  break;
-	}
-
-      /* Save the flags of this static routes (reject, blackhole) */
-      rib->flags = si->flags;
-
-      /* Link this rib to the tree. */
-      rib_addnode (rn, rib);
-    }
-}
-
 static int
 static_ipv6_nexthop_same (struct nexthop *nexthop, struct static_route *si)
 {
@@ -3065,7 +3006,7 @@
   si->next = cp;
 
   /* Install into rib. */
-  static_install_ipv6 (p, si);
+  static_install_route (AFI_IP6, SAFI_UNICAST, p, si);
 
   return 1;
 }