summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_rib.c
diff options
context:
space:
mode:
authorDinesh G Dutt <ddutt@cumulusnetworks.com>2015-03-26 12:49:09 -0700
committerTimo Teräs <timo.teras@iki.fi>2015-06-04 11:30:34 +0300
commit6ba8861ce832ca9789c8ee1d77db87b6927467c9 (patch)
treebacf61c35ea12f2e2d8575666d3d6649d6784efb /zebra/zebra_rib.c
parente101cddf66298ee6a7c5b6dd31907fb19fb468cb (diff)
downloadquagga-6ba8861ce832ca9789c8ee1d77db87b6927467c9.tar.bz2
quagga-6ba8861ce832ca9789c8ee1d77db87b6927467c9.tar.xz
zebra-nexthop-tracking.patch
Added support for nexthop tracking of a prefix. Support for protocols to register zebra to notify them when a nexthop becomes valid. With this support, protocols such as BGP no longer have to periodically scan the RIB checking if a prefix is valid or invalid. Complete documentation in doc/next-hop-tracking.txt. [TT: Rebased on top of master.] Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_rib.c')
-rw-r--r--zebra/zebra_rib.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index f247f1d2..2ad4d2ea 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -34,6 +34,7 @@
#include "workqueue.h"
#include "prefix.h"
#include "routemap.h"
+#include "nexthop.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
@@ -41,6 +42,7 @@
#include "zebra/redistribute.h"
#include "zebra/debug.h"
#include "zebra/zebra_fpm.h"
+#include "zebra/zebra_rnh.h"
/* Default rtm_table for all clients */
extern struct zebra_t zebrad;
@@ -154,6 +156,8 @@ vrf_alloc (const char *name)
vrf->stable[AFI_IP][SAFI_MULTICAST] = route_table_init ();
vrf->stable[AFI_IP6][SAFI_MULTICAST] = route_table_init ();
+ vrf->rnh_table[AFI_IP] = route_table_init();
+ vrf->rnh_table[AFI_IP6] = route_table_init();
return vrf;
}
@@ -213,31 +217,6 @@ vrf_static_table (afi_t afi, safi_t safi, u_int32_t id)
return vrf->stable[afi][safi];
}
-/*
- * nexthop_type_to_str
- */
-const char *
-nexthop_type_to_str (enum nexthop_types_t nh_type)
-{
- static const char *desc[] = {
- "none",
- "Directly connected",
- "Interface route",
- "IPv4 nexthop",
- "IPv4 nexthop with ifindex",
- "IPv4 nexthop with ifname",
- "IPv6 nexthop",
- "IPv6 nexthop with ifindex",
- "IPv6 nexthop with ifname",
- "Null0 nexthop",
- };
-
- if (nh_type >= ZEBRA_NUM_OF (desc))
- return "<Invalid nh type>";
-
- return desc[nh_type];
-}
-
/* Add nexthop to the end of a nexthop list. */
static void
_nexthop_add (struct nexthop **target, struct nexthop *nexthop)
@@ -254,7 +233,7 @@ _nexthop_add (struct nexthop **target, struct nexthop *nexthop)
}
/* Add nexthop to the end of a rib node's nexthop list */
-static void
+void
nexthop_add (struct rib *rib, struct nexthop *nexthop)
{
_nexthop_add(&rib->nexthop, nexthop);
@@ -274,10 +253,8 @@ nexthop_delete (struct rib *rib, struct nexthop *nexthop)
rib->nexthop_num--;
}
-static void nexthops_free(struct nexthop *nexthop);
-
/* Free nexthop. */
-static void
+void
nexthop_free (struct nexthop *nexthop)
{
if (nexthop->ifname)
@@ -288,7 +265,7 @@ nexthop_free (struct nexthop *nexthop)
}
/* Frees a list of nexthops */
-static void
+void
nexthops_free (struct nexthop *nexthop)
{
struct nexthop *nh, *next;
@@ -1596,6 +1573,18 @@ process_subq (struct list * subq, u_char qindex)
return 1;
}
+/*
+ * All meta queues have been processed. Trigger next-hop evaluation.
+ */
+static void
+meta_queue_process_complete (struct work_queue *dummy)
+{
+ zebra_evaluate_rnh_table(0, AF_INET);
+#ifdef HAVE_IPV6
+ zebra_evaluate_rnh_table(0, AF_INET6);
+#endif /* HAVE_IPV6 */
+}
+
/* Dispatch the meta queue by picking, processing and unlocking the next RN from
* a non-empty sub-queue with lowest priority. wq is equal to zebra->ribq and data
* is pointed to the meta queue structure.
@@ -1748,6 +1737,7 @@ rib_queue_init (struct zebra_t *zebra)
/* fill in the work queue spec */
zebra->ribq->spec.workfunc = &meta_queue_process;
zebra->ribq->spec.errorfunc = NULL;
+ zebra->ribq->spec.completion_func = &meta_queue_process_complete;
/* XXX: TODO: These should be runtime configurable via vty */
zebra->ribq->spec.max_retries = 3;
zebra->ribq->spec.hold = rib_process_hold_time;