zebra: Move clear_nhlfe_installed to calling functions

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>
This commit is contained in:
Donald Sharp 2017-10-23 10:10:06 -04:00
parent e4715aed63
commit 3d468f6604
4 changed files with 32 additions and 29 deletions

View 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 */

View 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,

View 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;
}

View 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;
}