]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Remove route only if NHE is installed check
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 14 May 2019 22:58:02 +0000 (15:58 -0700)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:40 +0000 (11:13 -0400)
Only remove a route if the nexthop it is using is still installed.
If a nexthop object is removed from the kernel, all routes referencing
it will be removed from the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zebra_dplane.c
zebra/zebra_rib.c

index 429d4c59a1a2e84c7e25dcfcb2af64557e3ff211..239988b3abd936a16f52159101ab627b60b4e183 100644 (file)
@@ -1525,9 +1525,24 @@ static int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx,
        zns = zvrf->zns;
        dplane_ctx_ns_init(ctx, zns, (op == DPLANE_OP_ROUTE_UPDATE));
 
+#ifdef HAVE_NETLINK
        if (re->nhe_id && zns->supports_nh) {
                ctx->u.rinfo.nhe.id = zebra_nhg_get_resolved_id(re->nhe_id);
+
+               /*
+                * It checks if the nhe is even installed
+                * before trying to uninstall it. If the
+                * nexthop is uninstalled and the kernel
+                * is using nexthop objects, this route
+                * has already been uninstalled.
+                */
+               if (!CHECK_FLAG(zebra_nhg_lookup_id(ctx->u.rinfo.nhe.id)->flags,
+                               NEXTHOP_GROUP_INSTALLED)) {
+                       ret = ENOENT;
+                       goto done;
+               }
        }
+#endif /* HAVE_NETLINK */
 
        /* Trying out the sequence number idea, so we can try to detect
         * when a result is stale.
@@ -1836,8 +1851,11 @@ dplane_route_update_internal(struct route_node *rn,
        if (ret == AOK)
                result = ZEBRA_DPLANE_REQUEST_QUEUED;
        else {
-               atomic_fetch_add_explicit(&zdplane_info.dg_route_errors, 1,
-                                         memory_order_relaxed);
+               if (ret == ENOENT)
+                       result = ZEBRA_DPLANE_REQUEST_SUCCESS;
+               else
+                       atomic_fetch_add_explicit(&zdplane_info.dg_route_errors,
+                                                 1, memory_order_relaxed);
                if (ctx)
                        dplane_ctx_free(&ctx);
        }
index 8fe673cb31865bb9e88cfd2d4b4f0f9ea5b34187..0258c240906e4828214aa4471ff4743b5d9be9c2 100644 (file)
@@ -618,16 +618,6 @@ void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re)
        rib_table_info_t *info = srcdest_rnode_table_info(rn);
        struct zebra_vrf *zvrf = vrf_info_lookup(re->vrf_id);
 
-       // TODO: Might need to move this?
-       // It checks if the nhe is even valid
-       // before trying to uninstall it. If the
-       // nexthop is invalid/uninstalled, then
-       // this route is not in the kernel anymore
-       // most likely.
-       if (!zebra_nhg_id_is_valid(re->nhe_id))
-               return;
-
-
        if (info->safi != SAFI_UNICAST) {
                UNSET_FLAG(re->status, ROUTE_ENTRY_INSTALLED);
                for (ALL_NEXTHOPS_PTR(re->ng, nexthop))