zebra: fix some issues in recursive backup nexthop code

Fix a couple of small things in the code that captures backup
nexthops during recursive resolution.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
Mark Stapp 2021-03-24 15:01:50 -04:00
parent 7408af70f5
commit c56c16eb2c

View File

@ -1814,9 +1814,6 @@ static int resolve_backup_nexthops(const struct nexthop *nexthop,
assert(nexthop->backup_num <= NEXTHOP_MAX_BACKUPS);
if (resolve_nhe->backup_info->nhe == NULL)
resolve_nhe->backup_info->nhe = zebra_nhg_alloc();
/* Locate backups from the original nexthop's backup index and nhe */
for (i = 0; i < nexthop->backup_num; i++) {
idx = nexthop->backup_idx[i];
@ -1832,6 +1829,8 @@ static int resolve_backup_nexthops(const struct nexthop *nexthop,
map->map[j].new_idx;
resolved->backup_num++;
SET_FLAG(resolved->flags, NEXTHOP_FLAG_HAS_BACKUP);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%s: found map idx orig %d, new %d",
__func__, map->map[j].orig_idx,
@ -1856,6 +1855,9 @@ static int resolve_backup_nexthops(const struct nexthop *nexthop,
if (bnh == NULL)
continue;
if (resolve_nhe->backup_info == NULL)
resolve_nhe->backup_info = zebra_nhg_backup_alloc();
/* Update backup info in the resolving nexthop and its nhe */
newnh = nexthop_dup_no_recurse(bnh, NULL);
@ -1871,6 +1873,7 @@ static int resolve_backup_nexthops(const struct nexthop *nexthop,
}
nh->next = newnh;
j++;
} else /* First one */
resolve_nhe->backup_info->nhe->nhg.nexthop = newnh;
@ -1879,6 +1882,8 @@ static int resolve_backup_nexthops(const struct nexthop *nexthop,
resolved->backup_idx[resolved->backup_num] = j;
resolved->backup_num++;
SET_FLAG(resolved->flags, NEXTHOP_FLAG_HAS_BACKUP);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%s: added idx orig %d, new %d",
__func__, idx, j);