bgpd: wide option

Signed-off-by: Madhuri Kuruganti <k.madhuri@samsung.com>
This commit is contained in:
Madhuri Kuruganti 2020-07-23 14:50:52 +05:30
parent 9d9adc84c7
commit ae2488324e
5 changed files with 114 additions and 87 deletions

View File

@ -679,7 +679,8 @@ static void show_esi_routes(struct bgp *bgp,
if (json) if (json)
json_path = json_object_new_array(); json_path = json_object_new_array();
route_vty_out(vty, p, pi, 0, SAFI_EVPN, json_path); route_vty_out(vty, p, pi, 0, SAFI_EVPN, json_path,
false);
if (json) if (json)
json_object_array_add(json_paths, json_path); json_object_array_add(json_paths, json_path);
@ -788,7 +789,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
json_path); json_path);
else else
route_vty_out(vty, p, pi, 0, SAFI_EVPN, route_vty_out(vty, p, pi, 0, SAFI_EVPN,
json_path); json_path, false);
if (json) if (json)
json_object_array_add(json_paths, json_path); json_object_array_add(json_paths, json_path);
@ -1314,7 +1315,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
route_vty_out(vty, route_vty_out(vty,
bgp_dest_get_prefix(rm), bgp_dest_get_prefix(rm),
pi, no_display, SAFI_EVPN, pi, no_display, SAFI_EVPN,
json_array); json_array, false);
no_display = 1; no_display = 1;
} }
@ -2813,7 +2814,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
SAFI_EVPN, json_path); SAFI_EVPN, json_path);
} else } else
route_vty_out(vty, p, pi, 0, SAFI_EVPN, route_vty_out(vty, p, pi, 0, SAFI_EVPN,
json_path); json_path, false);
if (json) if (json)
json_object_array_add(json_paths, json_object_array_add(json_paths,

View File

@ -7411,7 +7411,7 @@ void bgp_redistribute_withdraw(struct bgp *bgp, afi_t afi, int type,
/* Static function to display route. */ /* Static function to display route. */
static void route_vty_out_route(const struct prefix *p, struct vty *vty, static void route_vty_out_route(const struct prefix *p, struct vty *vty,
json_object *json) json_object *json, bool wide)
{ {
int len = 0; int len = 0;
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -7466,7 +7466,7 @@ static void route_vty_out_route(const struct prefix *p, struct vty *vty,
} }
if (!json) { if (!json) {
len = 17 - len; len = wide ? (45 - len) : (17 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 20, " "); vty_out(vty, "\n%*s", 20, " ");
else else
@ -7569,7 +7569,7 @@ static char *bgp_nexthop_hostname(struct peer *peer,
/* called from terminal list command */ /* called from terminal list command */
void route_vty_out(struct vty *vty, const struct prefix *p, void route_vty_out(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi, struct bgp_path_info *path, int display, safi_t safi,
json_object *json_paths) json_object *json_paths, bool wide)
{ {
int len; int len;
struct attr *attr = path->attr; struct attr *attr = path->attr;
@ -7596,11 +7596,11 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
if (!json_paths) { if (!json_paths) {
/* print prefix and mask */ /* print prefix and mask */
if (!display) if (!display)
route_vty_out_route(p, vty, json_path); route_vty_out_route(p, vty, json_path, wide);
else else
vty_out(vty, "%*s", 17, " "); vty_out(vty, "%*s", (wide ? 45 : 17), " ");
} else { } else {
route_vty_out_route(p, vty, json_path); route_vty_out_route(p, vty, json_path, wide);
} }
/* /*
@ -7690,7 +7690,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
else else
len = vty_out(vty, "%s%s", nexthop, vrf_id_str); len = vty_out(vty, "%s%s", nexthop, vrf_id_str);
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
else else
@ -7720,7 +7720,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
len = vty_out(vty, "%pI4%s", &attr->nexthop, len = vty_out(vty, "%pI4%s", &attr->nexthop,
vrf_id_str); vrf_id_str);
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
else else
@ -7756,7 +7756,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
&attr->nexthop, &attr->nexthop,
vrf_id_str); vrf_id_str);
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
else else
@ -7787,7 +7787,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
len = vty_out(vty, "%pI4%s", &attr->nexthop, len = vty_out(vty, "%pI4%s", &attr->nexthop,
vrf_id_str); vrf_id_str);
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
else else
@ -7860,10 +7860,9 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
if (path->peer->conf_if) { if (path->peer->conf_if) {
len = vty_out(vty, "%s", len = vty_out(vty, "%s",
path->peer->conf_if); path->peer->conf_if);
len = 16 - len; /* len of IPv6 /* len of IPv6 addr + max len of def
addr + max * ifname */
len of def len = wide ? (41 - len) : (16 - len);
ifname */
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
@ -7882,7 +7881,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
&attr->mp_nexthop_local, &attr->mp_nexthop_local,
vrf_id_str); vrf_id_str);
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
@ -7900,7 +7899,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
&attr->mp_nexthop_global, &attr->mp_nexthop_global,
vrf_id_str); vrf_id_str);
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
@ -7914,10 +7913,16 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
if (json_paths) if (json_paths)
json_object_int_add(json_path, "metric", attr->med); json_object_int_add(json_path, "metric", attr->med);
else if (wide)
vty_out(vty, "%7u", attr->med);
else else
vty_out(vty, "%10u", attr->med); vty_out(vty, "%10u", attr->med);
else if (!json_paths) else if (!json_paths) {
vty_out(vty, " "); if (wide)
vty_out(vty, "%*s", 7, " ");
else
vty_out(vty, "%*s", 10, " ");
}
/* Local Pref */ /* Local Pref */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
@ -8021,7 +8026,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
/* called from terminal list command */ /* called from terminal list command */
void route_vty_out_tmp(struct vty *vty, const struct prefix *p, void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
struct attr *attr, safi_t safi, bool use_json, struct attr *attr, safi_t safi, bool use_json,
json_object *json_ar) json_object *json_ar, bool wide)
{ {
json_object *json_status = NULL; json_object *json_status = NULL;
json_object *json_net = NULL; json_object *json_net = NULL;
@ -8053,7 +8058,7 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
json_object_string_add(json_net, "network", buff); json_object_string_add(json_net, "network", buff);
} }
} else } else
route_vty_out_route(p, vty, NULL); route_vty_out_route(p, vty, NULL, wide);
/* Print attribute */ /* Print attribute */
if (attr) { if (attr) {
@ -8114,6 +8119,9 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
vty_out(vty, "%-16s", vty_out(vty, "%-16s",
inet_ntoa( inet_ntoa(
attr->mp_nexthop_global_in)); attr->mp_nexthop_global_in));
else if (wide)
vty_out(vty, "%-41s",
inet_ntoa(attr->nexthop));
else else
vty_out(vty, "%-16s", vty_out(vty, "%-16s",
inet_ntoa(attr->nexthop)); inet_ntoa(attr->nexthop));
@ -8126,7 +8134,7 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
inet_ntop(AF_INET6, inet_ntop(AF_INET6,
&attr->mp_nexthop_global, buf, &attr->mp_nexthop_global, buf,
BUFSIZ)); BUFSIZ));
len = 16 - len; len = wide ? (41 - len) : (16 - len);
if (len < 1) if (len < 1)
vty_out(vty, "\n%*s", 36, " "); vty_out(vty, "\n%*s", 36, " ");
else else
@ -8134,7 +8142,12 @@ void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
} }
if (attr->flag if (attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
vty_out(vty, "%10u", attr->med); if (wide)
vty_out(vty, "%7u", attr->med);
else
vty_out(vty, "%10u", attr->med);
else if (wide)
vty_out(vty, " ");
else else
vty_out(vty, " "); vty_out(vty, " ");
@ -8185,7 +8198,7 @@ void route_vty_out_tag(struct vty *vty, const struct prefix *p,
/* print prefix and mask */ /* print prefix and mask */
if (json == NULL) { if (json == NULL) {
if (!display) if (!display)
route_vty_out_route(p, vty, NULL); route_vty_out_route(p, vty, NULL, false);
else else
vty_out(vty, "%*s", 17, " "); vty_out(vty, "%*s", 17, " ");
} }
@ -8282,7 +8295,7 @@ void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
/* print prefix and mask */ /* print prefix and mask */
if (!display) if (!display)
route_vty_out_route(p, vty, json_path); route_vty_out_route(p, vty, json_path, false);
else else
vty_out(vty, "%*s", 17, " "); vty_out(vty, "%*s", 17, " ");
@ -8397,7 +8410,7 @@ static void damp_route_vty_out(struct vty *vty, const struct prefix *p,
/* print prefix and mask */ /* print prefix and mask */
if (!use_json) { if (!use_json) {
if (!display) if (!display)
route_vty_out_route(p, vty, NULL); route_vty_out_route(p, vty, NULL, false);
else else
vty_out(vty, "%*s", 17, " "); vty_out(vty, "%*s", 17, " ");
} }
@ -8468,7 +8481,7 @@ static void flap_route_vty_out(struct vty *vty, const struct prefix *p,
/* print prefix and mask */ /* print prefix and mask */
if (!use_json) { if (!use_json) {
if (!display) if (!display)
route_vty_out_route(p, vty, NULL); route_vty_out_route(p, vty, NULL, false);
else else
vty_out(vty, "%*s", 17, " "); vty_out(vty, "%*s", 17, " ");
} }
@ -9583,7 +9596,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
void *output_arg, bool use_json, char *rd, void *output_arg, bool use_json, char *rd,
int is_last, unsigned long *output_cum, int is_last, unsigned long *output_cum,
unsigned long *total_cum, unsigned long *total_cum,
unsigned long *json_header_depth) unsigned long *json_header_depth, bool wide)
{ {
struct bgp_path_info *pi; struct bgp_path_info *pi;
struct bgp_dest *dest; struct bgp_dest *dest;
@ -9807,7 +9820,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|| type == bgp_show_type_flap_neighbor) || type == bgp_show_type_flap_neighbor)
vty_out(vty, BGP_SHOW_FLAP_HEADER); vty_out(vty, BGP_SHOW_FLAP_HEADER);
else else
vty_out(vty, BGP_SHOW_HEADER); vty_out(vty, (wide ? BGP_SHOW_HEADER_WIDE
: BGP_SHOW_HEADER));
header = 0; header = 0;
} }
if (rd != NULL && !display && !output_count) { if (rd != NULL && !display && !output_count) {
@ -9828,7 +9842,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
json_paths); json_paths);
else else
route_vty_out(vty, dest_p, pi, display, safi, route_vty_out(vty, dest_p, pi, display, safi,
json_paths); json_paths, wide);
display++; display++;
} }
@ -9936,7 +9950,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
prefix_rd2str(&prd, rd, sizeof(rd)); prefix_rd2str(&prd, rd, sizeof(rd));
bgp_show_table(vty, bgp, safi, itable, type, output_arg, bgp_show_table(vty, bgp, safi, itable, type, output_arg,
use_json, rd, next == NULL, &output_cum, use_json, rd, next == NULL, &output_cum,
&total_cum, &json_header_depth); &total_cum, &json_header_depth, false);
if (next == NULL) if (next == NULL)
show_msg = false; show_msg = false;
} }
@ -9953,7 +9967,8 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
enum bgp_show_type type, void *output_arg, bool use_json) enum bgp_show_type type, void *output_arg, bool use_json,
bool wide)
{ {
struct bgp_table *table; struct bgp_table *table;
unsigned long json_header_depth = 0; unsigned long json_header_depth = 0;
@ -9987,11 +10002,12 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
safi = SAFI_UNICAST; safi = SAFI_UNICAST;
return bgp_show_table(vty, bgp, safi, table, type, output_arg, use_json, return bgp_show_table(vty, bgp, safi, table, type, output_arg, use_json,
NULL, 1, NULL, NULL, &json_header_depth); NULL, 1, NULL, NULL, &json_header_depth, wide);
} }
static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi,
safi_t safi, bool use_json) safi_t safi, bool use_json,
bool wide)
{ {
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct bgp *bgp; struct bgp *bgp;
@ -10020,7 +10036,7 @@ static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi,
: bgp->name); : bgp->name);
} }
bgp_show(vty, bgp, afi, safi, bgp_show_type_normal, NULL, bgp_show(vty, bgp, afi, safi, bgp_show_type_normal, NULL,
use_json); use_json, wide);
} }
if (use_json) if (use_json)
@ -10507,8 +10523,8 @@ static int bgp_show_lcommunity(struct vty *vty, struct bgp *bgp, int argc,
return bgp_show(vty, bgp, afi, safi, return bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_lcommunity_exact (exact ? bgp_show_type_lcommunity_exact
: bgp_show_type_lcommunity), : bgp_show_type_lcommunity),
lcom, uj); lcom, uj, false);
} }
static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp, static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp,
@ -10527,8 +10543,8 @@ static int bgp_show_lcommunity_list(struct vty *vty, struct bgp *bgp,
return bgp_show(vty, bgp, afi, safi, return bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_lcommunity_list_exact (exact ? bgp_show_type_lcommunity_list_exact
: bgp_show_type_lcommunity_list), : bgp_show_type_lcommunity_list),
list, uj); list, uj, false);
} }
DEFUN (show_ip_bgp_large_community_list, DEFUN (show_ip_bgp_large_community_list,
@ -10607,7 +10623,7 @@ DEFUN (show_ip_bgp_large_community,
exact_match, afi, safi, uj); exact_match, afi, safi, uj);
} else } else
return bgp_show(vty, bgp, afi, safi, return bgp_show(vty, bgp, afi, safi,
bgp_show_type_lcommunity_all, NULL, uj); bgp_show_type_lcommunity_all, NULL, uj, false);
} }
static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi, static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi,
@ -10831,7 +10847,7 @@ DEFUN(show_ip_bgp, show_ip_bgp_cmd,
} }
/* BGP route print out function with JSON */ /* BGP route print out function with JSON */
DEFUN (show_ip_bgp_json, DEFPY (show_ip_bgp_json,
show_ip_bgp_json_cmd, show_ip_bgp_json_cmd,
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\ "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
[cidr-only\ [cidr-only\
@ -10841,7 +10857,7 @@ DEFUN (show_ip_bgp_json,
|accept-own|accept-own-nexthop|route-filter-v6\ |accept-own|accept-own-nexthop|route-filter-v6\
|route-filter-v4|route-filter-translated-v6\ |route-filter-v4|route-filter-translated-v6\
|route-filter-translated-v4] [exact-match]\ |route-filter-translated-v4] [exact-match]\
] [json]", ] [json$uj | wide$wide]",
SHOW_STR SHOW_STR
IP_STR IP_STR
BGP_STR BGP_STR
@ -10869,7 +10885,8 @@ DEFUN (show_ip_bgp_json,
"RT translated VPNv6 route filtering (well-known community)\n" "RT translated VPNv6 route filtering (well-known community)\n"
"RT translated VPNv4 route filtering (well-known community)\n" "RT translated VPNv4 route filtering (well-known community)\n"
"Exact match of the communities\n" "Exact match of the communities\n"
JSON_STR) JSON_STR
"Increase table width for longer prefixes\n")
{ {
afi_t afi = AFI_IP6; afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
@ -10877,7 +10894,6 @@ DEFUN (show_ip_bgp_json,
struct bgp *bgp = NULL; struct bgp *bgp = NULL;
int idx = 0; int idx = 0;
int exact_match = 0; int exact_match = 0;
bool uj = use_json(argc, argv);
if (uj) if (uj)
argc--; argc--;
@ -10889,16 +10905,17 @@ DEFUN (show_ip_bgp_json,
if (argv_find(argv, argc, "cidr-only", &idx)) if (argv_find(argv, argc, "cidr-only", &idx))
return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only, return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
NULL, uj); NULL, uj, wide);
if (argv_find(argv, argc, "dampening", &idx)) { if (argv_find(argv, argc, "dampening", &idx)) {
if (argv_find(argv, argc, "dampened-paths", &idx)) if (argv_find(argv, argc, "dampened-paths", &idx))
return bgp_show(vty, bgp, afi, safi, return bgp_show(vty, bgp, afi, safi,
bgp_show_type_dampend_paths, NULL, uj); bgp_show_type_dampend_paths, NULL, uj,
wide);
else if (argv_find(argv, argc, "flap-statistics", &idx)) else if (argv_find(argv, argc, "flap-statistics", &idx))
return bgp_show(vty, bgp, afi, safi, return bgp_show(vty, bgp, afi, safi,
bgp_show_type_flap_statistics, NULL, bgp_show_type_flap_statistics, NULL, uj,
uj); wide);
} }
if (argv_find(argv, argc, "community", &idx)) { if (argv_find(argv, argc, "community", &idx)) {
@ -10924,11 +10941,11 @@ DEFUN (show_ip_bgp_json,
exact_match, afi, safi, uj); exact_match, afi, safi, uj);
else else
return (bgp_show(vty, bgp, afi, safi, return (bgp_show(vty, bgp, afi, safi,
bgp_show_type_community_all, NULL, bgp_show_type_community_all, NULL, uj,
uj)); wide));
} }
return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj); return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj, wide);
} }
DEFUN (show_ip_bgp_route, DEFUN (show_ip_bgp_route,
@ -11039,22 +11056,22 @@ DEFUN (show_ip_bgp_regexp,
bgp_show_type_regexp, uj); bgp_show_type_regexp, uj);
} }
DEFUN (show_ip_bgp_instance_all, DEFPY (show_ip_bgp_instance_all,
show_ip_bgp_instance_all_cmd, show_ip_bgp_instance_all_cmd,
"show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [json]", "show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [json$uj | wide$wide]",
SHOW_STR SHOW_STR
IP_STR IP_STR
BGP_STR BGP_STR
BGP_INSTANCE_ALL_HELP_STR BGP_INSTANCE_ALL_HELP_STR
BGP_AFI_HELP_STR BGP_AFI_HELP_STR
BGP_SAFI_WITH_LABEL_HELP_STR BGP_SAFI_WITH_LABEL_HELP_STR
JSON_STR) JSON_STR
"Increase table width for longer prefixes\n")
{ {
afi_t afi = AFI_IP; afi_t afi = AFI_IP;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
struct bgp *bgp = NULL; struct bgp *bgp = NULL;
int idx = 0; int idx = 0;
bool uj = use_json(argc, argv);
if (uj) if (uj)
argc--; argc--;
@ -11064,7 +11081,7 @@ DEFUN (show_ip_bgp_instance_all,
if (!idx) if (!idx)
return CMD_WARNING; return CMD_WARNING;
bgp_show_all_instances_routes_vty(vty, afi, safi, uj); bgp_show_all_instances_routes_vty(vty, afi, safi, uj, wide);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -11087,7 +11104,7 @@ static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr,
return CMD_WARNING; return CMD_WARNING;
} }
rc = bgp_show(vty, bgp, afi, safi, type, regex, use_json); rc = bgp_show(vty, bgp, afi, safi, type, regex, use_json, false);
bgp_regex_free(regex); bgp_regex_free(regex);
return rc; return rc;
} }
@ -11105,7 +11122,7 @@ static int bgp_show_prefix_list(struct vty *vty, struct bgp *bgp,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_show(vty, bgp, afi, safi, type, plist, 0); return bgp_show(vty, bgp, afi, safi, type, plist, 0, false);
} }
static int bgp_show_filter_list(struct vty *vty, struct bgp *bgp, static int bgp_show_filter_list(struct vty *vty, struct bgp *bgp,
@ -11121,7 +11138,7 @@ static int bgp_show_filter_list(struct vty *vty, struct bgp *bgp,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_show(vty, bgp, afi, safi, type, as_list, 0); return bgp_show(vty, bgp, afi, safi, type, as_list, 0, false);
} }
static int bgp_show_route_map(struct vty *vty, struct bgp *bgp, static int bgp_show_route_map(struct vty *vty, struct bgp *bgp,
@ -11136,7 +11153,7 @@ static int bgp_show_route_map(struct vty *vty, struct bgp *bgp,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_show(vty, bgp, afi, safi, type, rmap, 0); return bgp_show(vty, bgp, afi, safi, type, rmap, 0, false);
} }
static int bgp_show_community(struct vty *vty, struct bgp *bgp, static int bgp_show_community(struct vty *vty, struct bgp *bgp,
@ -11155,7 +11172,7 @@ static int bgp_show_community(struct vty *vty, struct bgp *bgp,
ret = bgp_show(vty, bgp, afi, safi, ret = bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_community_exact (exact ? bgp_show_type_community_exact
: bgp_show_type_community), : bgp_show_type_community),
com, use_json); com, use_json, false);
community_free(&com); community_free(&com);
return ret; return ret;
@ -11176,7 +11193,7 @@ static int bgp_show_community_list(struct vty *vty, struct bgp *bgp,
return bgp_show(vty, bgp, afi, safi, return bgp_show(vty, bgp, afi, safi,
(exact ? bgp_show_type_community_list_exact (exact ? bgp_show_type_community_list_exact
: bgp_show_type_community_list), : bgp_show_type_community_list),
list, 0); list, 0, false);
} }
static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp, static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp,
@ -11194,7 +11211,7 @@ static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp,
return CMD_WARNING; return CMD_WARNING;
} }
ret = bgp_show(vty, bgp, afi, safi, type, p, 0); ret = bgp_show(vty, bgp, afi, safi, type, p, 0, false);
prefix_free(&p); prefix_free(&p);
return ret; return ret;
} }
@ -11959,7 +11976,7 @@ DEFUN (show_bgp_l2vpn_evpn_route_prefix,
static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
safi_t safi, enum bgp_show_adj_route_type type, safi_t safi, enum bgp_show_adj_route_type type,
const char *rmap_name, bool use_json, const char *rmap_name, bool use_json,
json_object *json) json_object *json, bool wide)
{ {
struct bgp_table *table; struct bgp_table *table;
struct bgp_adj_in *ain; struct bgp_adj_in *ain;
@ -12115,7 +12132,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
} }
if (header2) { if (header2) {
if (!use_json) if (!use_json)
vty_out(vty, BGP_SHOW_HEADER); vty_out(vty,
(wide ? BGP_SHOW_HEADER_WIDE
: BGP_SHOW_HEADER));
header2 = 0; header2 = 0;
} }
@ -12148,7 +12167,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
filtered_count++; filtered_count++;
route_vty_out_tmp(vty, rn_p, &attr, safi, route_vty_out_tmp(vty, rn_p, &attr, safi,
use_json, json_ar); use_json, json_ar, wide);
bgp_attr_undup(&attr, ain->attr); bgp_attr_undup(&attr, ain->attr);
output_count++; output_count++;
} }
@ -12219,7 +12238,8 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
if (header2) { if (header2) {
if (!use_json) if (!use_json)
vty_out(vty, vty_out(vty,
BGP_SHOW_HEADER); (wide ? BGP_SHOW_HEADER_WIDE
: BGP_SHOW_HEADER));
header2 = 0; header2 = 0;
} }
@ -12234,7 +12254,8 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
if (ret != RMAP_DENY) { if (ret != RMAP_DENY) {
route_vty_out_tmp( route_vty_out_tmp(
vty, rn_p, &attr, safi, vty, rn_p, &attr, safi,
use_json, json_ar); use_json, json_ar,
wide);
output_count++; output_count++;
} else { } else {
filtered_count++; filtered_count++;
@ -12273,7 +12294,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi, static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi,
safi_t safi, enum bgp_show_adj_route_type type, safi_t safi, enum bgp_show_adj_route_type type,
const char *rmap_name, bool use_json) const char *rmap_name, bool use_json, bool wide)
{ {
json_object *json = NULL; json_object *json = NULL;
@ -12310,14 +12331,15 @@ static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi,
return CMD_WARNING; return CMD_WARNING;
} }
show_adj_route(vty, peer, afi, safi, type, rmap_name, use_json, json); show_adj_route(vty, peer, afi, safi, type, rmap_name, use_json, json,
wide);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (show_ip_bgp_instance_neighbor_advertised_route, DEFPY (show_ip_bgp_instance_neighbor_advertised_route,
show_ip_bgp_instance_neighbor_advertised_route_cmd, show_ip_bgp_instance_neighbor_advertised_route_cmd,
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json]", "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json$uj | wide$wide]",
SHOW_STR SHOW_STR
IP_STR IP_STR
BGP_STR BGP_STR
@ -12333,7 +12355,8 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
"Display the filtered routes received from neighbor\n" "Display the filtered routes received from neighbor\n"
"Route-map to modify the attributes\n" "Route-map to modify the attributes\n"
"Name of the route map\n" "Name of the route map\n"
JSON_STR) JSON_STR
"Increase table width for longer prefixes\n")
{ {
afi_t afi = AFI_IP6; afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
@ -12343,7 +12366,6 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
struct peer *peer; struct peer *peer;
enum bgp_show_adj_route_type type = bgp_show_adj_route_advertised; enum bgp_show_adj_route_type type = bgp_show_adj_route_advertised;
int idx = 0; int idx = 0;
bool uj = use_json(argc, argv);
if (uj) if (uj)
argc--; argc--;
@ -12371,7 +12393,7 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
if (argv_find(argv, argc, "route-map", &idx)) if (argv_find(argv, argc, "route-map", &idx))
rmap_name = argv[++idx]->arg; rmap_name = argv[++idx]->arg;
return peer_adj_routes(vty, peer, afi, safi, type, rmap_name, uj); return peer_adj_routes(vty, peer, afi, safi, type, rmap_name, uj, wide);
} }
DEFUN (show_ip_bgp_neighbor_received_prefix_filter, DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
@ -12479,7 +12501,8 @@ static int bgp_show_neighbor_route(struct vty *vty, struct peer *peer,
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json); return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json,
false);
} }
DEFUN (show_ip_bgp_flowspec_routes_detailed, DEFUN (show_ip_bgp_flowspec_routes_detailed,
@ -12508,7 +12531,8 @@ DEFUN (show_ip_bgp_flowspec_routes_detailed,
if (!idx) if (!idx)
return CMD_WARNING; return CMD_WARNING;
return bgp_show(vty, bgp, afi, safi, bgp_show_type_detail, NULL, uj); return bgp_show(vty, bgp, afi, safi, bgp_show_type_detail, NULL, uj,
false);
} }
DEFUN (show_ip_bgp_neighbor_routes, DEFUN (show_ip_bgp_neighbor_routes,

View File

@ -72,6 +72,7 @@ enum bgp_show_adj_route_type {
#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n" #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete\n\n"
#define BGP_SHOW_NCODE_HEADER "Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self\n" #define BGP_SHOW_NCODE_HEADER "Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self\n"
#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path\n" #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path\n"
#define BGP_SHOW_HEADER_WIDE " Network Next Hop Metric LocPrf Weight Path\n"
/* Maximum number of labels we can process or send with a prefix. We /* Maximum number of labels we can process or send with a prefix. We
* really do only 1 for MPLS (BGP-LU) but we can do 2 for EVPN-VxLAN. * really do only 1 for MPLS (BGP-LU) but we can do 2 for EVPN-VxLAN.
@ -618,13 +619,13 @@ extern struct bgp_path_info *info_make(int type, int sub_type,
extern void route_vty_out(struct vty *vty, const struct prefix *p, extern void route_vty_out(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi, struct bgp_path_info *path, int display, safi_t safi,
json_object *json_paths); json_object *json_paths, bool wide);
extern void route_vty_out_tag(struct vty *vty, const struct prefix *p, extern void route_vty_out_tag(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, struct bgp_path_info *path, int display,
safi_t safi, json_object *json); safi_t safi, json_object *json);
extern void route_vty_out_tmp(struct vty *vty, const struct prefix *p, extern void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
struct attr *attr, safi_t safi, bool use_json, struct attr *attr, safi_t safi, bool use_json,
json_object *json_ar); json_object *json_ar, bool wide);
extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p, extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, struct bgp_path_info *path, int display,
json_object *json); json_object *json);

View File

@ -262,14 +262,15 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
route_vty_out_tmp(vty, dest_p, route_vty_out_tmp(vty, dest_p,
adj->adv->baa->attr, adj->adv->baa->attr,
SUBGRP_SAFI(subgrp), SUBGRP_SAFI(subgrp),
0, NULL); 0, NULL, false);
output_count++; output_count++;
} }
if ((flags & UPDWALK_FLAGS_ADVERTISED) if ((flags & UPDWALK_FLAGS_ADVERTISED)
&& adj->attr) { && adj->attr) {
route_vty_out_tmp( route_vty_out_tmp(vty, dest_p,
vty, dest_p, adj->attr, adj->attr,
SUBGRP_SAFI(subgrp), 0, NULL); SUBGRP_SAFI(subgrp),
0, NULL, false);
output_count++; output_count++;
} }
} }

View File

@ -226,7 +226,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
rd_header = 0; rd_header = 0;
} }
route_vty_out_tmp(vty, bgp_dest_get_prefix(rm), attr, route_vty_out_tmp(vty, bgp_dest_get_prefix(rm), attr,
safi, use_json, json_routes); safi, use_json, json_routes, false);
output_count++; output_count++;
} }