]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Move clear_nhlfe_installed to calling functions
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 23 Oct 2017 14:10:06 +0000 (10:10 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 27 Oct 2017 14:41:07 +0000 (10:41 -0400)
The function clear_nhlfe_installed is to be called
when we get a install failure of some sort for
a lsp change.  Since an install failure can happen
in both linux and openBSD moving the function call
northbound is a good idea.

I've also added it to the kernel_del_lsp for completeness
on failure as well, even though neither linux or openBSD
currently can fail a uninstall.

This still leaves the hole where if we have multiple
nhlfes and have an install failure we are not quite
doing the right thing by just blanketly calling
clear_nhlfe_installed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/rt_netlink.c
zebra/rt_netlink.h
zebra/zebra_mpls.c
zebra/zebra_mpls_netlink.c

index 67abe53c39a39133a296f5c1868fbdff44d85f0f..e8333ef0cf645fbb32bc43aeae0872e099ba1911 100644 (file)
@@ -2474,23 +2474,4 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp)
        return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,
                            0);
 }
-
-/*
- * Handle failure in LSP install, clear flags for NHLFE.
- */
-void clear_nhlfe_installed(zebra_lsp_t *lsp)
-{
-       zebra_nhlfe_t *nhlfe;
-       struct nexthop *nexthop;
-
-       for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) {
-               nexthop = nhlfe->nexthop;
-               if (!nexthop)
-                       continue;
-
-               UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED);
-               UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
-       }
-}
-
 #endif /* HAVE_NETLINK */
index 980ff915cc6e892cf354258f82b7151324cb4edf..afb03f878d95c92a651cd0d365f603205eefb4fa 100644 (file)
@@ -54,7 +54,6 @@
 
 void rt_netlink_init(void);
 
-extern void clear_nhlfe_installed(zebra_lsp_t *lsp);
 extern int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp);
 
 extern int netlink_route_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
index 7b87355ed4824bb9bdae5042f897718d586377a4..3765849adf22f6a0933ff1fee8f78de62aa252dc 100644 (file)
@@ -129,6 +129,24 @@ static int mpls_processq_init(struct zebra_t *zebra);
 
 /* Static functions */
 
+/*
+ * Handle failure in LSP install, clear flags for NHLFE.
+ */
+static void clear_nhlfe_installed(zebra_lsp_t *lsp)
+{
+       zebra_nhlfe_t *nhlfe;
+       struct nexthop *nexthop;
+
+       for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) {
+               nexthop = nhlfe->nexthop;
+               if (!nexthop)
+                       continue;
+
+               UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED);
+               UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
+       }
+}
+
 /*
  * Install label forwarding entry based on labeled-route entry.
  */
@@ -821,11 +839,16 @@ static void lsp_select_best_nhlfe(zebra_lsp_t *lsp)
  */
 static void lsp_uninstall_from_kernel(struct hash_backet *backet, void *ctxt)
 {
+       int ret;
        zebra_lsp_t *lsp;
 
        lsp = (zebra_lsp_t *)backet->data;
-       if (CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED))
-               kernel_del_lsp(lsp);
+       if (CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) {
+               ret = kernel_del_lsp(lsp);
+
+               if (!ret)
+                       clear_nhlfe_installed(lsp);
+       }
 }
 
 /*
@@ -846,6 +869,7 @@ static void lsp_schedule(struct hash_backet *backet, void *ctxt)
  */
 static wq_item_status lsp_process(struct work_queue *wq, void *data)
 {
+       int ret = 1;
        zebra_lsp_t *lsp;
        zebra_nhlfe_t *oldbest, *newbest;
        char buf[BUFSIZ], buf2[BUFSIZ];
@@ -877,20 +901,23 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data)
        if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) {
                /* Not already installed */
                if (newbest) {
-                       kernel_add_lsp(lsp);
+                       ret = kernel_add_lsp(lsp);
                        zvrf->lsp_installs++;
                }
        } else {
                /* Installed, may need an update and/or delete. */
                if (!newbest) {
-                       kernel_del_lsp(lsp);
+                       ret = kernel_del_lsp(lsp);
                        zvrf->lsp_removals++;
                } else if (CHECK_FLAG(lsp->flags, LSP_FLAG_CHANGED)) {
-                       kernel_upd_lsp(lsp);
+                       ret = kernel_upd_lsp(lsp);
                        zvrf->lsp_installs++;
                }
        }
 
+       if (!ret)
+               clear_nhlfe_installed(lsp);
+
        return WQ_SUCCESS;
 }
 
index 8b30783a9a591ba652a4b4fae905e879f9e6551b..8b8d018d03e54cb5db4823a1242a608204993b23 100644 (file)
@@ -40,8 +40,6 @@ int kernel_add_lsp(zebra_lsp_t *lsp)
        ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp);
        if (!ret)
                SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
-       else
-               clear_nhlfe_installed(lsp);
 
        return ret;
 }
@@ -74,8 +72,6 @@ int kernel_upd_lsp(zebra_lsp_t *lsp)
        ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp);
        if (!ret)
                SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
-       else
-               clear_nhlfe_installed(lsp);
 
        return ret;
 }