*/
DEFUN(show_bgp_l2vpn_evpn_summary,
show_bgp_l2vpn_evpn_summary_cmd,
- "show bgp [vrf VRFNAME] l2vpn evpn summary [established|failed] [json]",
+ "show bgp [vrf VRFNAME] l2vpn evpn summary [established|failed] [wide] [json]",
SHOW_STR
BGP_STR
"bgp vrf\n"
"Summary of BGP neighbor status\n"
"Show only sessions in Established state\n"
"Show only sessions not in Established state\n"
+ "Increase table width for longer output\n"
JSON_STR)
{
int idx_vrf = 0;
- bool uj = use_json(argc, argv);
+ int idx = 0;
char *vrf = NULL;
- bool show_failed = false;
- bool show_established = false;
+ uint8_t show_flags = 0;
if (argv_find(argv, argc, "vrf", &idx_vrf))
vrf = argv[++idx_vrf]->arg;
- if (argv_find(argv, argc, "failed", &idx_vrf))
- show_failed = true;
- if (argv_find(argv, argc, "established", &idx_vrf))
- show_established = true;
- return bgp_show_summary_vty(vty, vrf, AFI_L2VPN, SAFI_EVPN, show_failed,
- show_established, uj);
+ if (argv_find(argv, argc, "failed", &idx))
+ SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED);
+
+ if (argv_find(argv, argc, "established", &idx))
+ SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED);
+
+ if (argv_find(argv, argc, "wide", &idx))
+ SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE);
+
+ if (use_json(argc, argv))
+ SET_FLAG(show_flags, BGP_SHOW_OPT_JSON);
+
+ return bgp_show_summary_vty(vty, vrf, AFI_L2VPN, SAFI_EVPN, show_flags);
}
int bgp_evpn_cli_parse_type(int *type, struct cmd_token **argv, int argc)
/* Show BGP peer's summary information. */
static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
- bool show_failed, bool show_established,
- bool use_json)
+ uint8_t show_flags)
{
struct peer *peer;
struct listnode *node, *nnode;
json_object *json_peers = NULL;
struct peer_af *paf;
struct bgp_filter *filter;
+ bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
+ bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED);
+ bool show_established =
+ CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED);
+ bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE);
/* labeled-unicast routes are installed in the unicast table so in order
* to
vty_out(vty, "%*s", max_neighbor_width - 8,
" ");
if (show_failed)
- vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n");
+ vty_out(vty,
+ BGP_SHOW_SUMMARY_HEADER_FAILED);
else
vty_out(vty,
- "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n");
+ show_wide
+ ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
+ : BGP_SHOW_SUMMARY_HEADER_ALL);
}
}
&peer->ibuf->count,
memory_order_relaxed);
- vty_out(vty,
- "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s",
- peer->as, PEER_TOTAL_RX(peer),
- PEER_TOTAL_TX(peer),
- peer->version[afi][safi], inq_count,
- outq_count,
- peer_uptime(peer->uptime, timebuf,
- BGP_UPTIME_LEN, 0, NULL));
+ if (show_wide)
+ vty_out(vty,
+ "4 %10u %10u %9u %9u %8" PRIu64
+ " %4zu %4zu %8s",
+ peer->as,
+ peer->change_local_as
+ ? peer->change_local_as
+ : peer->local_as,
+ PEER_TOTAL_RX(peer),
+ PEER_TOTAL_TX(peer),
+ peer->version[afi][safi],
+ inq_count, outq_count,
+ peer_uptime(peer->uptime,
+ timebuf,
+ BGP_UPTIME_LEN, 0,
+ NULL));
+ else
+ vty_out(vty, "4 %10u %9u %9u %8" PRIu64
+ " %4zu %4zu %8s",
+ peer->as, PEER_TOTAL_RX(peer),
+ PEER_TOTAL_TX(peer),
+ peer->version[afi][safi],
+ inq_count, outq_count,
+ peer_uptime(peer->uptime,
+ timebuf,
+ BGP_UPTIME_LEN, 0,
+ NULL));
if (peer->status == Established) {
if (peer->afc_recv[afi][safi]) {
if (peer->desc)
vty_out(vty, " %s",
bgp_peer_description_stripped(
- peer->desc, 20));
+ peer->desc,
+ show_wide ? 64 : 20));
else
vty_out(vty, " N/A");
vty_out(vty, "\n");
}
static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi,
- int safi, bool show_failed,
- bool show_established, bool use_json)
+ int safi, uint8_t show_flags)
{
int is_first = 1;
int afi_wildcard = (afi == AFI_MAX);
int safi_wildcard = (safi == SAFI_MAX);
int is_wildcard = (afi_wildcard || safi_wildcard);
bool nbr_output = false;
+ bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
if (use_json && is_wildcard)
vty_out(vty, "{\n");
}
}
bgp_show_summary(vty, bgp, afi, safi,
- show_failed, show_established,
- use_json);
+ show_flags);
}
safi++;
if (!safi_wildcard)
}
static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi,
- safi_t safi, bool show_failed,
- bool show_established,
- bool use_json)
+ safi_t safi, uint8_t show_flags)
{
struct listnode *node, *nnode;
struct bgp *bgp;
int is_first = 1;
bool nbr_output = false;
+ bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
if (use_json)
vty_out(vty, "{\n");
? VRF_DEFAULT_NAME
: bgp->name);
}
- bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed,
- show_established, use_json);
+ bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_flags);
}
if (use_json)
}
int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi,
- safi_t safi, bool show_failed, bool show_established,
- bool use_json)
+ safi_t safi, uint8_t show_flags)
{
struct bgp *bgp;
+ bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
if (name) {
if (strmatch(name, "all")) {
- bgp_show_all_instances_summary_vty(
- vty, afi, safi, show_failed, show_established,
- use_json);
+ bgp_show_all_instances_summary_vty(vty, afi, safi,
+ show_flags);
return CMD_SUCCESS;
} else {
bgp = bgp_lookup_by_name(name);
}
bgp_show_summary_afi_safi(vty, bgp, afi, safi,
- show_failed, show_established,
- use_json);
+ show_flags);
return CMD_SUCCESS;
}
}
bgp = bgp_get_default();
if (bgp)
- bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed,
- show_established, use_json);
+ bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_flags);
else {
if (use_json)
vty_out(vty, "{}\n");
/* `show [ip] bgp summary' commands. */
DEFPY (show_ip_bgp_summary,
show_ip_bgp_summary_cmd,
- "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [json$uj]",
+ "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [wide] [json$uj]",
SHOW_STR
IP_STR
BGP_STR
"Summary of BGP neighbor status\n"
"Show only sessions in Established state\n"
"Show only sessions not in Established state\n"
+ "Increase table width for longer output\n"
JSON_STR)
{
char *vrf = NULL;
afi_t afi = AFI_MAX;
safi_t safi = SAFI_MAX;
- bool show_failed = false;
- bool show_established = false;
+ uint8_t show_flags = 0;
int idx = 0;
}
if (argv_find(argv, argc, "failed", &idx))
- show_failed = true;
+ SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED);
+
if (argv_find(argv, argc, "established", &idx))
- show_established = true;
+ SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED);
+
+ if (argv_find(argv, argc, "wide", &idx))
+ SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE);
+
+ if (argv_find(argv, argc, "json", &idx))
+ SET_FLAG(show_flags, BGP_SHOW_OPT_JSON);
- return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed,
- show_established, uj);
+ return bgp_show_summary_vty(vty, vrf, afi, safi, show_flags);
}
const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json)