diff options
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 67b3812ed3..d1d56f2cdb 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -106,7 +106,8 @@ static const struct { [ZEBRA_ROUTE_PBR] = {ZEBRA_ROUTE_PBR, 200, 5}, [ZEBRA_ROUTE_BFD] = {ZEBRA_ROUTE_BFD, 255, 5}, [ZEBRA_ROUTE_OPENFABRIC] = {ZEBRA_ROUTE_OPENFABRIC, 115, 3}, - [ZEBRA_ROUTE_VRRP] = {ZEBRA_ROUTE_VRRP, 255, 5} + [ZEBRA_ROUTE_VRRP] = {ZEBRA_ROUTE_VRRP, 255, 5}, + [ZEBRA_ROUTE_SRTE] = {ZEBRA_ROUTE_SRTE, 255, 5}, /* Any new route type added to zebra, should be mirrored here */ /* no entry/default: 150 */ @@ -472,6 +473,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; @@ -495,9 +497,6 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re, if (zvrf) zvrf->installs++; break; - /* Should never happen */ - case ZEBRA_DPLANE_REQUEST_PENDING: - break; } return; @@ -542,9 +541,6 @@ void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re) if (zvrf) zvrf->removals++; break; - /* Should never happen */ - case ZEBRA_DPLANE_REQUEST_PENDING: - break; } return; @@ -574,6 +570,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); @@ -1081,8 +1078,7 @@ static void rib_process(struct route_node *rn) if (re != old_selected) { if (IS_ZEBRA_DEBUG_RIB) zlog_debug( - "%s: %s(%u):%s: imported via import-table but denied " - "by the ip protocol table route-map", + "%s: %s(%u):%s: imported via import-table but denied by the ip protocol table route-map", __func__, VRF_LOGNAME(vrf), vrf_id, buf); @@ -1376,7 +1372,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 */ @@ -1491,7 +1487,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. */ @@ -1502,6 +1498,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 { @@ -1547,20 +1545,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: @@ -1612,7 +1605,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) { @@ -1937,7 +1930,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 { @@ -1946,9 +1939,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; @@ -2630,6 +2626,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); @@ -2655,8 +2653,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'; @@ -3149,8 +3151,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, if (nh) rnode_debug( rn, vrf_id, - "via %s ifindex %d type %d " - "doesn't exist in rib", + "via %s ifindex %d type %d doesn't exist in rib", inet_ntop(afi2family(afi), &nh->gate, buf2, sizeof(buf2)), @@ -3763,6 +3764,7 @@ static int rib_process_dplane_results(struct thread *thread) case DPLANE_OP_NEIGH_DELETE: case DPLANE_OP_VTEP_ADD: case DPLANE_OP_VTEP_DELETE: + case DPLANE_OP_NEIGH_DISCOVER: case DPLANE_OP_NONE: /* Don't expect this: just return the struct? */ dplane_ctx_fini(&ctx); |
