summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-11-04 13:26:37 -0500
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-12-08 14:12:10 -0500
commit9bcdd1a252ba84424eb06e84adf7fb48ae66ce1f (patch)
treee604d71dcc41c9449d91c6d85c732320d6a112ec
parent0d955affd51df42dd5ae24b0d41edd992fb59a78 (diff)
downloadquagga-9bcdd1a252ba84424eb06e84adf7fb48ae66ce1f.tar.bz2
quagga-9bcdd1a252ba84424eb06e84adf7fb48ae66ce1f.tar.xz
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>
-rw-r--r--zebra/zebra_rib.c141
1 files changed, 41 insertions, 100 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 516d9d99..4d122c42 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1669,7 +1669,7 @@ rib_queue_init (struct zebra_t *zebra)
* 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 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
/* 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 @@ static_install_ipv4 (safi_t safi, struct prefix *p, struct static_route *si)
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 @@ static_install_ipv4 (safi_t safi, struct prefix *p, struct static_route *si)
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 @@ static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate,
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 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
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 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
si->next = cp;
/* Install into rib. */
- static_install_ipv6 (p, si);
+ static_install_route (AFI_IP6, SAFI_UNICAST, p, si);
return 1;
}