diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-06-07 10:19:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-07 10:19:53 -0400 |
| commit | 5356483183040219320f255b6c8b62e5fc0a0665 (patch) | |
| tree | 4e8f8788af55862c645ebf17f4baefb29e3b6357 /zebra/zebra_mpls_openbsd.c | |
| parent | 02deafa69780f4fe759dd351da2f5abe09fdfb78 (diff) | |
| parent | cc4dd86703a5489dda0fd94609a41d62c1e79dd6 (diff) | |
Merge pull request #688 from opensourcerouting/openbsd-mpls-fixes
Small fixes for OpenBSD
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 eaa80ac558..5dfe16caf5 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 |
