diff options
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index ddf2766737..ee9d5d76e0 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -472,6 +472,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re, SET_FLAG(old->status, ROUTE_ENTRY_QUEUED); /* Free old FIB nexthop group */ + UNSET_FLAG(old->status, ROUTE_ENTRY_USE_FIB_NHG); if (old->fib_ng.nexthop) { nexthops_free(old->fib_ng.nexthop); old->fib_ng.nexthop = NULL; @@ -574,6 +575,7 @@ static void rib_uninstall(struct route_node *rn, struct route_entry *re) nexthops_free(re->fib_ng.nexthop); re->fib_ng.nexthop = NULL; } + UNSET_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG); for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); @@ -1375,7 +1377,7 @@ static bool rib_update_nhg_from_ctx(struct nexthop_group *re_nhg, continue; /* Check for a FIB nexthop corresponding to the RIB nexthop */ - if (nexthop_same(ctx_nexthop, nexthop) == false) { + if (!nexthop_same(ctx_nexthop, nexthop)) { /* If the FIB doesn't know about the nexthop, * it's not installed */ @@ -1490,7 +1492,7 @@ static bool rib_update_re_from_ctx(struct route_entry *re, VRF_LOGNAME(vrf), re->vrf_id, dest_str); goto check_backups; - } else if (re->fib_ng.nexthop) { + } else if (CHECK_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG)) { /* * Free stale fib list and move on to check the rib nhg. */ @@ -1501,6 +1503,8 @@ static bool rib_update_re_from_ctx(struct route_entry *re, nexthops_free(re->fib_ng.nexthop); re->fib_ng.nexthop = NULL; + UNSET_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG); + /* Note that the installed nexthops have changed */ changed_p = true; } else { @@ -1546,20 +1550,15 @@ no_nexthops: */ if (IS_ZEBRA_DEBUG_RIB) zlog_debug( - "%s(%u):%s update_from_ctx(): changed %s, adding new fib nhg", + "%s(%u):%s update_from_ctx(): changed %s, adding new fib nhg%s", VRF_LOGNAME(vrf), re->vrf_id, dest_str, - (changed_p ? "true" : "false")); + (changed_p ? "true" : "false"), + ctxnhg->nexthop != NULL ? "" : " (empty)"); + /* Set the flag about the dedicated fib list */ + SET_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG); if (ctxnhg->nexthop) copy_nexthops(&(re->fib_ng.nexthop), ctxnhg->nexthop, NULL); - else { - /* Bit of a special case when the fib has _no_ installed - * nexthops. - */ - nexthop = nexthop_new(); - nexthop->type = NEXTHOP_TYPE_IPV4; - _nexthop_add(&(re->fib_ng.nexthop), nexthop); - } check_backups: @@ -1611,7 +1610,7 @@ check_backups: } /* - * If a FIB backup nexthop set exists: attach a copy + * If a FIB backup nexthop set exists, attach a copy * to the route if any backup is installed */ if (ctxnhg && ctxnhg->nexthop) { @@ -1936,7 +1935,7 @@ static int rib_count_installed_nh(struct route_entry *re) /* The meaningful flag depends on where the installed * nexthops reside. */ - if (nhg == &(re->fib_backup_ng)) { + if (nhg == &(re->fib_ng)) { if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) count++; } else { @@ -1945,9 +1944,12 @@ static int rib_count_installed_nh(struct route_entry *re) } } - for (ALL_NEXTHOPS_PTR(rib_get_fib_backup_nhg(re), nexthop)) { - if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) - count++; + nhg = rib_get_fib_backup_nhg(re); + if (nhg) { + for (ALL_NEXTHOPS_PTR(nhg, nexthop)) { + if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) + count++; + } } return count; @@ -2629,6 +2631,8 @@ static void _route_entry_dump_nh(const struct route_entry *re, char nhname[PREFIX_STRLEN]; char backup_str[50]; char wgt_str[50]; + char temp_str[10]; + int i; struct interface *ifp; struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id); @@ -2654,8 +2658,12 @@ static void _route_entry_dump_nh(const struct route_entry *re, backup_str[0] = '\0'; if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_HAS_BACKUP)) { - snprintf(backup_str, sizeof(backup_str), "backup %d,", - (int)nexthop->backup_idx); + snprintf(backup_str, sizeof(backup_str), "backup "); + for (i = 0; i < nexthop->backup_num; i++) { + snprintf(temp_str, sizeof(temp_str), "%d, ", + nexthop->backup_idx[i]); + strlcat(backup_str, temp_str, sizeof(backup_str)); + } } wgt_str[0] = '\0'; |
