Merge pull request #6753 from mjstapp/fix_zebra_backup_sa

zebra: fix SA warnings in backup nexthop code
This commit is contained in:
Stephen Worley 2020-07-17 17:29:49 -04:00 committed by GitHub
commit 55528234ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View File

@ -3405,7 +3405,7 @@ int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
return 0; return 0;
if (IS_ZEBRA_DEBUG_MPLS) { if (IS_ZEBRA_DEBUG_MPLS) {
nhlfe2str(nhlfe, buf, BUFSIZ); nhlfe2str(nhlfe, buf, sizeof(buf));
zlog_debug("Del LSP in-label %u type %d nexthop %s flags 0x%x", zlog_debug("Del LSP in-label %u type %d nexthop %s flags 0x%x",
in_label, type, buf, nhlfe->flags); in_label, type, buf, nhlfe->flags);
} }
@ -3636,7 +3636,7 @@ int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label,
return 0; return 0;
if (IS_ZEBRA_DEBUG_MPLS) { if (IS_ZEBRA_DEBUG_MPLS) {
snhlfe2str(snhlfe, buf, BUFSIZ); snhlfe2str(snhlfe, buf, sizeof(buf));
zlog_debug( zlog_debug(
"Upd static LSP in-label %u nexthop %s out-label %u (old %u)", "Upd static LSP in-label %u nexthop %s out-label %u (old %u)",
in_label, buf, out_label, snhlfe->out_label); in_label, buf, out_label, snhlfe->out_label);
@ -3649,7 +3649,7 @@ int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label,
return -1; return -1;
if (IS_ZEBRA_DEBUG_MPLS) { if (IS_ZEBRA_DEBUG_MPLS) {
snhlfe2str(snhlfe, buf, BUFSIZ); snhlfe2str(snhlfe, buf, sizeof(buf));
zlog_debug( zlog_debug(
"Add static LSP in-label %u nexthop %s out-label %u", "Add static LSP in-label %u nexthop %s out-label %u",
in_label, buf, out_label); in_label, buf, out_label);
@ -3794,7 +3794,8 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
for (ALL_LIST_ELEMENTS_RO(lsp_list, node, lsp)) for (ALL_LIST_ELEMENTS_RO(lsp_list, node, lsp))
json_object_object_add( json_object_object_add(
json, label2str(lsp->ile.in_label, buf, BUFSIZ), json, label2str(lsp->ile.in_label, buf,
sizeof(buf)),
lsp_json(lsp)); lsp_json(lsp));
vty_out(vty, "%s\n", json_object_to_json_string_ext( vty_out(vty, "%s\n", json_object_to_json_string_ext(
@ -3849,7 +3850,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
out_label_str = mpls_label2str( out_label_str = mpls_label2str(
nexthop->nh_label->num_labels, nexthop->nh_label->num_labels,
&nexthop->nh_label->label[0], &nexthop->nh_label->label[0],
buf, BUFSIZ, 1); buf, sizeof(buf), 1);
else else
out_label_str = "-"; out_label_str = "-";

View File

@ -1936,7 +1936,7 @@ static int rib_count_installed_nh(struct route_entry *re)
/* The meaningful flag depends on where the installed /* The meaningful flag depends on where the installed
* nexthops reside. * nexthops reside.
*/ */
if (nhg == &(re->fib_backup_ng)) { if (nhg == &(re->fib_ng)) {
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
count++; count++;
} else { } else {
@ -1945,9 +1945,12 @@ static int rib_count_installed_nh(struct route_entry *re)
} }
} }
for (ALL_NEXTHOPS_PTR(rib_get_fib_backup_nhg(re), nexthop)) { nhg = rib_get_fib_backup_nhg(re);
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) if (nhg) {
count++; for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))
count++;
}
} }
return count; return count;

View File

@ -1187,8 +1187,11 @@ static int send_client(struct rnh *rnh, struct zserv *client,
for (ALL_NEXTHOPS_PTR(nhg, nh)) for (ALL_NEXTHOPS_PTR(nhg, nh))
if (rnh_nexthop_valid(re, nh)) { if (rnh_nexthop_valid(re, nh)) {
zapi_nexthop_from_nexthop(&znh, nh); zapi_nexthop_from_nexthop(&znh, nh);
zapi_nexthop_encode(s, &znh, ret = zapi_nexthop_encode(
0 /* flags */); s, &znh, 0 /* flags */);
if (ret < 0)
goto failure;
num++; num++;
} }
} }