From 00a9b150056699383635c6f9e0454e82162389b0 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Tue, 16 Jun 2020 08:28:27 -0400 Subject: [PATCH] zebra: include installed backup nexthops in kernel update Include any installed backups when updating the local kernel after processing an async notification. This includes routes' nexthops and LSPs' nhlfes. Add the 'b' character to the route show display and header to indicate backup nexthops. Signed-off-by: Mark Stapp --- lib/route_types.pl | 2 +- zebra/zebra_dplane.c | 25 +++++++++++++++++++++++++ zebra/zebra_mpls.c | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/route_types.pl b/lib/route_types.pl index f297096633..e007de4d69 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -121,7 +121,7 @@ sub codelist { } $str =~ s/ $//; push @lines, $str . "\\n\" \\\n"; - push @lines, " \" > - selected route, * - FIB route, q - queued route, r - rejected route\\n\\n\""; + push @lines, " \" > - selected route, * - FIB route, q - queued, r - rejected, b - backup\\n\\n\""; return join("", @lines); } diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index e34b6f23ff..65ce8392ce 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -2485,6 +2485,12 @@ dplane_route_notif_update(struct route_node *rn, copy_nexthops(&(new_ctx->u.rinfo.zd_ng.nexthop), (rib_get_fib_nhg(re))->nexthop, NULL); + /* Check for backup nexthops also */ + if (re->fib_backup_ng.nexthop) { + copy_nexthops(&(new_ctx->u.rinfo.zd_ng.nexthop), + re->fib_backup_ng.nexthop, NULL); + } + for (ALL_NEXTHOPS(new_ctx->u.rinfo.zd_ng, nexthop)) UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); @@ -2583,6 +2589,8 @@ dplane_lsp_notif_update(zebra_lsp_t *lsp, enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE; int ret = EINVAL; struct zebra_dplane_ctx *ctx = NULL; + struct nhlfe_list_head *head; + zebra_nhlfe_t *nhlfe, *new_nhlfe; /* Obtain context block */ ctx = dplane_ctx_alloc(); @@ -2591,10 +2599,27 @@ dplane_lsp_notif_update(zebra_lsp_t *lsp, goto done; } + /* Copy info from zebra LSP */ ret = dplane_ctx_lsp_init(ctx, op, lsp); if (ret != AOK) goto done; + /* Add any installed backup nhlfes */ + head = &(ctx->u.lsp.backup_nhlfe_list); + frr_each(nhlfe_list, head, nhlfe) { + + if (CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED) && + CHECK_FLAG(nhlfe->nexthop->flags, NEXTHOP_FLAG_FIB)) { + new_nhlfe = zebra_mpls_lsp_add_nh(&(ctx->u.lsp), + nhlfe->type, + nhlfe->nexthop); + + /* Need to copy flags too */ + new_nhlfe->flags = nhlfe->flags; + new_nhlfe->nexthop->flags = nhlfe->nexthop->flags; + } + } + /* Capture info about the source of the notification */ dplane_ctx_set_notif_provider( ctx, diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index e741268ebb..290273f664 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -2112,6 +2112,7 @@ static int update_nhlfes_from_ctx(struct nhlfe_list_head *nhlfe_head, __func__, buf); SET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED); + SET_FLAG(nhlfe->flags, NHLFE_FLAG_SELECTED); } else { if (is_debug) @@ -2119,6 +2120,7 @@ static int update_nhlfes_from_ctx(struct nhlfe_list_head *nhlfe_head, __func__, buf); UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED); + UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_SELECTED); } if (CHECK_FLAG(ctx_nhlfe->nexthop->flags, @@ -2140,6 +2142,7 @@ static int update_nhlfes_from_ctx(struct nhlfe_list_head *nhlfe_head, zlog_debug("%s: no match for lsp nhlfe %s", __func__, buf); UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED); + UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_SELECTED); UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); } -- 2.39.5