summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2022-03-28 08:27:19 -0400
committerGitHub <noreply@github.com>2022-03-28 08:27:19 -0400
commita80d833f6b477851e752e6e27ba7d1dae70739b7 (patch)
tree93b0818998df5186e05e5cf8f9dc52fcdf001425
parent80e39114b502f683638c58de94e4125fc85a3478 (diff)
parentfa5ac3786591b1ea855e8789dead74aa3c36d366 (diff)
Merge pull request #10878 from ton31337/fix/bgp_crash_vrf_all_all
bgpd: Fix crash for `show ip bgp vrf all all`
-rw-r--r--bgpd/bgp_route.c122
1 files changed, 69 insertions, 53 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 3abfa7ebcf..5255eb5800 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -12463,6 +12463,8 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
output_arg, show_flags,
rpki_target_state);
} else {
+ struct listnode *node;
+ struct bgp *abgp;
/* show <ip> bgp ipv4 all: AFI_IP, show <ip> bgp ipv6 all:
* AFI_IP6 */
@@ -12474,66 +12476,80 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
afi = CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP)
? AFI_IP
: AFI_IP6;
- FOREACH_SAFI (safi) {
- if (!bgp_afi_safi_peer_exists(bgp, afi, safi))
- continue;
+ for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, abgp)) {
+ FOREACH_SAFI (safi) {
+ if (!bgp_afi_safi_peer_exists(abgp, afi,
+ safi))
+ continue;
- if (uj) {
- if (first)
- first = false;
+ if (uj) {
+ if (first)
+ first = false;
+ else
+ vty_out(vty, ",\n");
+ vty_out(vty, "\"%s\":{\n",
+ get_afi_safi_str(afi,
+ safi,
+ true));
+ } else
+ vty_out(vty,
+ "\nFor address family: %s\n",
+ get_afi_safi_str(
+ afi, safi,
+ false));
+
+ if (community)
+ bgp_show_community(
+ vty, abgp, community,
+ exact_match, afi, safi,
+ show_flags);
else
- vty_out(vty, ",\n");
- vty_out(vty, "\"%s\":{\n",
- get_afi_safi_str(afi, safi,
- true));
- } else
- vty_out(vty,
- "\nFor address family: %s\n",
- get_afi_safi_str(afi, safi,
- false));
-
- if (community)
- bgp_show_community(vty, bgp, community,
- exact_match, afi,
- safi, show_flags);
- else
- bgp_show(vty, bgp, afi, safi, sh_type,
- output_arg, show_flags,
- rpki_target_state);
- if (uj)
- vty_out(vty, "}\n");
+ bgp_show(vty, abgp, afi, safi,
+ sh_type, output_arg,
+ show_flags,
+ rpki_target_state);
+ if (uj)
+ vty_out(vty, "}\n");
+ }
}
} else {
/* show <ip> bgp all: for each AFI and SAFI*/
- FOREACH_AFI_SAFI (afi, safi) {
- if (!bgp_afi_safi_peer_exists(bgp, afi, safi))
- continue;
-
- if (uj) {
- if (first)
- first = false;
- else
- vty_out(vty, ",\n");
+ for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, abgp)) {
+ FOREACH_AFI_SAFI (afi, safi) {
+ if (!bgp_afi_safi_peer_exists(abgp, afi,
+ safi))
+ continue;
- vty_out(vty, "\"%s\":{\n",
- get_afi_safi_str(afi, safi,
- true));
- } else
- vty_out(vty,
- "\nFor address family: %s\n",
- get_afi_safi_str(afi, safi,
- false));
+ if (uj) {
+ if (first)
+ first = false;
+ else
+ vty_out(vty, ",\n");
- if (community)
- bgp_show_community(vty, bgp, community,
- exact_match, afi,
- safi, show_flags);
- else
- bgp_show(vty, bgp, afi, safi, sh_type,
- output_arg, show_flags,
- rpki_target_state);
- if (uj)
- vty_out(vty, "}\n");
+ vty_out(vty, "\"%s\":{\n",
+ get_afi_safi_str(afi,
+ safi,
+ true));
+ } else
+ vty_out(vty,
+ "\nFor address family: %s\n",
+ get_afi_safi_str(
+ afi, safi,
+ false));
+
+ if (community)
+ bgp_show_community(
+ vty, abgp, community,
+ exact_match, afi, safi,
+ show_flags);
+ else
+ bgp_show(vty, abgp, afi, safi,
+ sh_type, output_arg,
+ show_flags,
+ rpki_target_state);
+ if (uj)
+ vty_out(vty, "}\n");
+ }
}
}
if (uj)