]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Zebra: Perform NHT evaluation for VRFs
authorvivek <vivek@cumulusnetworks.com>
Tue, 23 Feb 2016 03:42:19 +0000 (03:42 +0000)
committervivek <vivek@cumulusnetworks.com>
Tue, 23 Feb 2016 03:42:19 +0000 (03:42 +0000)
NHT evaluation was not being triggered for any VRF after RIB processing. Fix
this and attempt to schedule only those VRFs for which RIB processing was
scheduled.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Ticket: CM-9175
Reviewed By: CCR-4149
Testing Done: Manual verification

zebra/rib.h
zebra/zebra_rib.c

index 84941a6737485d5ed879af96b39d9c82f9123115..ae1f923cdea33d9d0c63ea4bdb2fc56bc3412467 100644 (file)
@@ -323,6 +323,10 @@ struct zebra_vrf
   /* FIB identifier.  */
   u_char fib_id;
 
+  /* Flags. */
+  u_int16_t flags;
+#define ZEBRA_VRF_RIB_SCHEDULED   (1 << 0)
+
   u_int32_t table_id;
 
   /* Routing table.  */
index 5b10739b4cd087f1829e21e5d3a82e52bda66c57..39b9d452ca3954146bbea6c7c05ef3bb3506f540 100644 (file)
@@ -1656,10 +1656,25 @@ process_subq (struct list * subq, u_char qindex)
 static void
 meta_queue_process_complete (struct work_queue *dummy)
 {
-  zebra_evaluate_rnh(0, AF_INET, 0, RNH_NEXTHOP_TYPE, NULL);
-  zebra_evaluate_rnh(0, AF_INET, 0, RNH_IMPORT_CHECK_TYPE, NULL);
-  zebra_evaluate_rnh(0, AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL);
-  zebra_evaluate_rnh(0, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL);
+  vrf_iter_t iter;
+  struct zebra_vrf *zvrf;
+
+  /* Evaluate nexthops for those VRFs which underwent route processing. This
+   * should limit the evaluation to the necessary VRFs in most common
+   * situations.
+   */
+  for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
+    {
+      if (((zvrf = vrf_iter2info (iter)) != NULL) &&
+          (zvrf->flags & ZEBRA_VRF_RIB_SCHEDULED))
+        {
+          zvrf->flags &= ~ZEBRA_VRF_RIB_SCHEDULED;
+          zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_NEXTHOP_TYPE, NULL);
+          zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_IMPORT_CHECK_TYPE, NULL);
+          zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL);
+          zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL);
+        }
+    }
 }
 
 /* Dispatch the meta queue by picking, processing and unlocking the next RN from
@@ -1714,6 +1729,7 @@ rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn)
   RNODE_FOREACH_RIB (rn, rib)
     {
       u_char qindex = meta_queue_map[rib->type];
+      struct zebra_vrf *zvrf;
 
       /* Invariant: at this point we always have rn->info set. */
       if (CHECK_FLAG (rib_dest_from_rnode (rn)->flags,
@@ -1728,6 +1744,10 @@ rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn)
       if (IS_ZEBRA_DEBUG_RIB_DETAILED)
        zlog_debug ("%u:%s/%d: rn %p queued into sub-queue %u",
                    rib->vrf_id, buf, rn->p.prefixlen, rn, qindex);
+
+      zvrf = zebra_vrf_lookup (rib->vrf_id);
+      if (zvrf)
+          zvrf->flags |= ZEBRA_VRF_RIB_SCHEDULED;
     }
 }