diff options
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 bca73898c5..45e4435ee5 100644 --- a/zebra/zebra_mpls_openbsd.c +++ b/zebra/zebra_mpls_openbsd.c @@ -238,7 +238,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) { @@ -288,28 +288,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 |
