Merge pull request #10878 from ton31337/fix/bgp_crash_vrf_all_all

bgpd: Fix crash for `show ip bgp vrf all all`
This commit is contained in:
Donald Sharp 2022-03-28 08:27:19 -04:00 committed by GitHub
commit a80d833f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12463,6 +12463,8 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
output_arg, show_flags, output_arg, show_flags,
rpki_target_state); rpki_target_state);
} else { } else {
struct listnode *node;
struct bgp *abgp;
/* show <ip> bgp ipv4 all: AFI_IP, show <ip> bgp ipv6 all: /* show <ip> bgp ipv4 all: AFI_IP, show <ip> bgp ipv6 all:
* AFI_IP6 */ * AFI_IP6 */
@ -12474,8 +12476,10 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
afi = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP) afi = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP)
? AFI_IP ? AFI_IP
: AFI_IP6; : AFI_IP6;
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, abgp)) {
FOREACH_SAFI (safi) { FOREACH_SAFI (safi) {
if (!bgp_afi_safi_peer_exists(bgp, afi, safi)) if (!bgp_afi_safi_peer_exists(abgp, afi,
safi))
continue; continue;
if (uj) { if (uj) {
@ -12484,29 +12488,36 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
else else
vty_out(vty, ",\n"); vty_out(vty, ",\n");
vty_out(vty, "\"%s\":{\n", vty_out(vty, "\"%s\":{\n",
get_afi_safi_str(afi, safi, get_afi_safi_str(afi,
safi,
true)); true));
} else } else
vty_out(vty, vty_out(vty,
"\nFor address family: %s\n", "\nFor address family: %s\n",
get_afi_safi_str(afi, safi, get_afi_safi_str(
afi, safi,
false)); false));
if (community) if (community)
bgp_show_community(vty, bgp, community, bgp_show_community(
exact_match, afi, vty, abgp, community,
safi, show_flags); exact_match, afi, safi,
show_flags);
else else
bgp_show(vty, bgp, afi, safi, sh_type, bgp_show(vty, abgp, afi, safi,
output_arg, show_flags, sh_type, output_arg,
show_flags,
rpki_target_state); rpki_target_state);
if (uj) if (uj)
vty_out(vty, "}\n"); vty_out(vty, "}\n");
} }
}
} else { } else {
/* show <ip> bgp all: for each AFI and SAFI*/ /* show <ip> bgp all: for each AFI and SAFI*/
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, abgp)) {
FOREACH_AFI_SAFI (afi, safi) { FOREACH_AFI_SAFI (afi, safi) {
if (!bgp_afi_safi_peer_exists(bgp, afi, safi)) if (!bgp_afi_safi_peer_exists(abgp, afi,
safi))
continue; continue;
if (uj) { if (uj) {
@ -12516,26 +12527,31 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
vty_out(vty, ",\n"); vty_out(vty, ",\n");
vty_out(vty, "\"%s\":{\n", vty_out(vty, "\"%s\":{\n",
get_afi_safi_str(afi, safi, get_afi_safi_str(afi,
safi,
true)); true));
} else } else
vty_out(vty, vty_out(vty,
"\nFor address family: %s\n", "\nFor address family: %s\n",
get_afi_safi_str(afi, safi, get_afi_safi_str(
afi, safi,
false)); false));
if (community) if (community)
bgp_show_community(vty, bgp, community, bgp_show_community(
exact_match, afi, vty, abgp, community,
safi, show_flags); exact_match, afi, safi,
show_flags);
else else
bgp_show(vty, bgp, afi, safi, sh_type, bgp_show(vty, abgp, afi, safi,
output_arg, show_flags, sh_type, output_arg,
show_flags,
rpki_target_state); rpki_target_state);
if (uj) if (uj)
vty_out(vty, "}\n"); vty_out(vty, "}\n");
} }
} }
}
if (uj) if (uj)
vty_out(vty, "}\n"); vty_out(vty, "}\n");
} }