From 4a83e7a04a6eef80452633a517a2e9ce7839391b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 29 Nov 2017 08:53:33 -0500 Subject: zebra: Fix lsp add/del from kernel using SETFLAG Setup a interface such that the add/del of lsp's from the kernel can have a callback for success/failure. Signed-off-by: Donald Sharp --- zebra/zebra_mpls_netlink.c | 47 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'zebra/zebra_mpls_netlink.c') diff --git a/zebra/zebra_mpls_netlink.c b/zebra/zebra_mpls_netlink.c index 0abc4959fa..64b1a7c0ac 100644 --- a/zebra/zebra_mpls_netlink.c +++ b/zebra/zebra_mpls_netlink.c @@ -29,16 +29,21 @@ /* * Install Label Forwarding entry into the kernel. */ -int kernel_add_lsp(zebra_lsp_t *lsp) +void kernel_add_lsp(zebra_lsp_t *lsp) { int ret; - if (!lsp || !lsp->best_nhlfe) // unexpected - return -1; + if (!lsp || !lsp->best_nhlfe) { // unexpected + kernel_lsp_pass_fail(lsp, SOUTHBOUND_INSTALL_FAILURE); + return; + } ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp); - return ret; + kernel_lsp_pass_fail(lsp, + (!ret) ? + SOUTHBOUND_INSTALL_SUCCESS : + SOUTHBOUND_INSTALL_FAILURE); } /* @@ -52,14 +57,16 @@ int kernel_add_lsp(zebra_lsp_t *lsp) * through the metric field (before kernel-MPLS). This shouldn't be an issue * any longer, so REPLACE can be reintroduced. */ -int kernel_upd_lsp(zebra_lsp_t *lsp) +void kernel_upd_lsp(zebra_lsp_t *lsp) { int ret; zebra_nhlfe_t *nhlfe; struct nexthop *nexthop; - if (!lsp || !lsp->best_nhlfe) // unexpected - return -1; + if (!lsp || !lsp->best_nhlfe) { // unexpected + kernel_lsp_pass_fail(lsp, SOUTHBOUND_INSTALL_FAILURE); + return; + } /* Any NHLFE that was installed but is not selected now needs to * have its flags updated. @@ -78,25 +85,37 @@ int kernel_upd_lsp(zebra_lsp_t *lsp) ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp); - return ret; + kernel_lsp_pass_fail(lsp, + (!ret) ? + SOUTHBOUND_INSTALL_SUCCESS : + SOUTHBOUND_INSTALL_FAILURE); } /* * Delete Label Forwarding entry from the kernel. */ -int kernel_del_lsp(zebra_lsp_t *lsp) +void kernel_del_lsp(zebra_lsp_t *lsp) { int ret; - if (!lsp) // unexpected - return -1; + if (!lsp) { // unexpected + kernel_lsp_pass_fail(lsp, + SOUTHBOUND_DELETE_FAILURE); + return; + } - if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) - return -1; + if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) { + kernel_lsp_pass_fail(lsp, + SOUTHBOUND_DELETE_FAILURE); + return; + } ret = netlink_mpls_multipath(RTM_DELROUTE, lsp); - return ret; + kernel_lsp_pass_fail(lsp, + (!ret) ? + SOUTHBOUND_DELETE_SUCCESS : + SOUTHBOUND_DELETE_FAILURE); } int mpls_kernel_init(void) -- cgit v1.2.3