]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: accept async notification for un-install
authorMark Stapp <mjs@voltanet.io>
Wed, 11 Dec 2019 16:22:53 +0000 (11:22 -0500)
committerMark Stapp <mjs@voltanet.io>
Wed, 11 Dec 2019 16:22:53 +0000 (11:22 -0500)
Handle an async notification when a route-update operation
uninstalls one route in favor of another.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
zebra/zebra_rib.c

index dbd6daae9f376958773252ba3aa33e46af6baeaa..fb5dadd2d6228e4e2439b49703434c295bc1490b 100644 (file)
@@ -1788,18 +1788,40 @@ static void rib_process_dplane_notify(struct zebra_dplane_ctx *ctx)
        /* Ensure we clear the QUEUED flag */
        UNSET_FLAG(re->status, ROUTE_ENTRY_QUEUED);
 
-       /* Is this a notification that ... matters? We only really care about
-        * the route that is currently selected for installation.
+       /* Is this a notification that ... matters? We mostly care about
+        * the route that is currently selected for installation; we may also
+        * get an un-install notification, and handle that too.
         */
        if (re != dest->selected_fib) {
-               /* TODO -- don't skip processing entirely? We might like to
-                * at least report on the event.
+               /*
+                * If we need to, clean up after a delete that was part of
+                * an update operation.
                 */
-               if (debug_p)
-                       zlog_debug("%u:%s dplane notif, but type %s not selected_fib",
-                                  dplane_ctx_get_vrf(ctx), dest_str,
-                                  zebra_route_string(
-                                          dplane_ctx_get_type(ctx)));
+               end_count = 0;
+               for (ALL_NEXTHOPS_PTR(dplane_ctx_get_ng(ctx), nexthop)) {
+                       if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
+                               end_count++;
+               }
+
+               /* If no nexthops or none installed, ensure that this re
+                * gets its 'installed' flag cleared.
+                */
+               if (end_count == 0) {
+                       if (CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED))
+                               UNSET_FLAG(re->status, ROUTE_ENTRY_INSTALLED);
+                       if (debug_p)
+                               zlog_debug("%u:%s dplane notif, uninstalled type %s route",
+                                          dplane_ctx_get_vrf(ctx), dest_str,
+                                          zebra_route_string(
+                                                  dplane_ctx_get_type(ctx)));
+               } else {
+                       /* At least report on the event. */
+                       if (debug_p)
+                               zlog_debug("%u:%s dplane notif, but type %s not selected_fib",
+                                          dplane_ctx_get_vrf(ctx), dest_str,
+                                          zebra_route_string(
+                                                  dplane_ctx_get_type(ctx)));
+               }
                goto done;
        }