From 8fe8a7f6fbb9977b33addcd8d8ec88355bcaa583 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 18:04:09 -0700 Subject: BGP: Fix update-groups commands to match neighbors show update-groups summary was mislabeled. What it displays is not a summary at all, but the detailed info about all update-groups. Furthermore, there was no way to get detailed info about a specific subgroup. This patch renames "show * update-groups summary" to "show * update-groups" and adds an option to see the info specific to a subgroup only. It also validates the subgroup-id. show * update-groups summary will be added separately. --- bgpd/bgp_updgrp.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'bgpd/bgp_updgrp.c') diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 6d18e8346..667a30c6d 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -521,10 +521,42 @@ subgroup_total_packets_enqueued (struct update_subgroup *subgrp) static int update_group_show_walkcb (struct update_group *updgrp, void *arg) { - struct vty *vty = arg; + struct updwalk_context *ctx = arg; + struct vty *vty; struct update_subgroup *subgrp; struct peer_af *paf; struct bgp_filter *filter; + int match = 0; + + if (!ctx) + return; + + if (ctx->subgrp_id) + { + UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) + { + if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id)) + continue; + else + { + match = 1; + break; + } + } + } + else + { + match = 1; + } + + if (!match) + { + /* Since this routine is invoked from a walk, we cannot signal any */ + /* error here, can only return. */ + return CMD_SUCCESS; + } + + vty = ctx->vty; vty_out (vty, "Update-group %llu:%s", updgrp->id, VTY_NEWLINE); vty_out (vty, " Created: %s", timestamp_string (updgrp->uptime)); @@ -546,6 +578,8 @@ update_group_show_walkcb (struct update_group *updgrp, void *arg) UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) { + if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id)) + continue; vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, " Update-subgroup %llu:%s", subgrp->id, VTY_NEWLINE); vty_out (vty, " Created: %s", timestamp_string (subgrp->uptime)); @@ -1526,9 +1560,15 @@ update_group_init (struct bgp *bgp) } void -update_group_show (struct bgp *bgp, afi_t afi, safi_t safi, struct vty *vty) +update_group_show (struct bgp *bgp, afi_t afi, safi_t safi, struct vty *vty, + u_int64_t subgrp_id) { - update_group_af_walk (bgp, afi, safi, update_group_show_walkcb, vty); + struct updwalk_context ctx; + memset (&ctx, 0, sizeof (ctx)); + ctx.vty = vty; + ctx.subgrp_id = subgrp_id; + + update_group_af_walk (bgp, afi, safi, update_group_show_walkcb, &ctx); } /* -- cgit v1.2.3