diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2017-06-07 14:53:15 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2017-06-07 15:33:31 +0200 |
commit | c4c8dec041a6d7ea137bafa38078fe8fafc2166b (patch) | |
tree | ee54182daabd60c87c69bdb0c4abb811f7b69e20 /zebra/zebra_mpls_openbsd.c | |
parent | ldpd: remove pledge calls (diff) | |
download | frr-c4c8dec041a6d7ea137bafa38078fe8fafc2166b.tar.xz frr-c4c8dec041a6d7ea137bafa38078fe8fafc2166b.zip |
zebra: fix uninstallation of mpls lsps in openbsd
While here, fix a warning in kernel_lsp_cmd().
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_mpls_openbsd.c')
-rw-r--r-- | zebra/zebra_mpls_openbsd.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c index eaa80ac55..5dfe16caf 100644 --- a/zebra/zebra_mpls_openbsd.c +++ b/zebra/zebra_mpls_openbsd.c @@ -239,7 +239,7 @@ kernel_lsp_cmd (int action, zebra_lsp_t *lsp) { zebra_nhlfe_t *nhlfe; struct nexthop *nexthop = NULL; - int nexthop_num = 0; + unsigned int nexthop_num = 0; for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) { @@ -289,28 +289,52 @@ kernel_lsp_cmd (int action, zebra_lsp_t *lsp) int kernel_add_lsp (zebra_lsp_t *lsp) { + int ret; + if (!lsp || !lsp->best_nhlfe) // unexpected return -1; - return kernel_lsp_cmd (RTM_ADD, lsp); + UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED); + ret = kernel_lsp_cmd (RTM_ADD, lsp); + if (!ret) + SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); + + return ret; } int kernel_upd_lsp (zebra_lsp_t *lsp) { + int ret; + if (!lsp || !lsp->best_nhlfe) // unexpected return -1; - return kernel_lsp_cmd (RTM_CHANGE, lsp); + UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED); + UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); + ret = kernel_lsp_cmd (RTM_CHANGE, lsp); + if (!ret) + SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); + + return ret; } int kernel_del_lsp (zebra_lsp_t *lsp) { + int ret; + if (!lsp) // unexpected return -1; - return kernel_lsp_cmd (RTM_DELETE, lsp); + if (! CHECK_FLAG (lsp->flags, LSP_FLAG_INSTALLED)) + return -1; + + ret = kernel_lsp_cmd (RTM_DELETE, lsp); + if (!ret) + UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED); + + return ret; } #define MAX_RTSOCK_BUF 128 * 1024 |