mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 22:26:14 +00:00
bgpd: add "json" option to "show ip bgp ... dampening parameters"
Also: * rename show_ip_bgp_cmd to show_ip_bgp_dampening_params_cmd; * rename show_ip_bgp_json_cmd to show_ip_bgp_cmd. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
39c3c7364d
commit
fe0f234d13
@ -653,21 +653,42 @@ const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_path_info *path,
|
||||
}
|
||||
|
||||
static int bgp_print_dampening_parameters(struct bgp *bgp, struct vty *vty,
|
||||
afi_t afi, safi_t safi)
|
||||
afi_t afi, safi_t safi, bool use_json)
|
||||
{
|
||||
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) {
|
||||
vty_out(vty, "Half-life time: %lld min\n",
|
||||
(long long)damp[afi][safi].half_life / 60);
|
||||
vty_out(vty, "Reuse penalty: %d\n",
|
||||
damp[afi][safi].reuse_limit);
|
||||
vty_out(vty, "Suppress penalty: %d\n",
|
||||
damp[afi][safi].suppress_value);
|
||||
vty_out(vty, "Max suppress time: %lld min\n",
|
||||
(long long)damp[afi][safi].max_suppress_time / 60);
|
||||
vty_out(vty, "Max suppress penalty: %u\n",
|
||||
damp[afi][safi].ceiling);
|
||||
vty_out(vty, "\n");
|
||||
} else
|
||||
struct bgp_damp_config *bdc = &damp[afi][safi];
|
||||
|
||||
if (use_json) {
|
||||
json_object *json = json_object_new_object();
|
||||
|
||||
json_object_int_add(json, "halfLifeSecs",
|
||||
bdc->half_life);
|
||||
json_object_int_add(json, "reusePenalty",
|
||||
bdc->reuse_limit);
|
||||
json_object_int_add(json, "suppressPenalty",
|
||||
bdc->suppress_value);
|
||||
json_object_int_add(json, "maxSuppressTimeSecs",
|
||||
bdc->max_suppress_time);
|
||||
json_object_int_add(json, "maxSuppressPenalty",
|
||||
bdc->ceiling);
|
||||
|
||||
vty_out(vty, "%s\n",
|
||||
json_object_to_json_string_ext(
|
||||
json, JSON_C_TO_STRING_PRETTY));
|
||||
json_object_free(json);
|
||||
} else {
|
||||
vty_out(vty, "Half-life time: %lld min\n",
|
||||
(long long)bdc->half_life / 60);
|
||||
vty_out(vty, "Reuse penalty: %d\n", bdc->reuse_limit);
|
||||
vty_out(vty, "Suppress penalty: %d\n",
|
||||
bdc->suppress_value);
|
||||
vty_out(vty, "Max suppress time: %lld min\n",
|
||||
(long long)bdc->max_suppress_time / 60);
|
||||
vty_out(vty, "Max suppress penalty: %u\n",
|
||||
bdc->ceiling);
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
} else if (!use_json)
|
||||
vty_out(vty, "dampening not enabled for %s\n",
|
||||
get_afi_safi_str(afi, safi, false));
|
||||
|
||||
@ -678,6 +699,8 @@ int bgp_show_dampening_parameters(struct vty *vty, afi_t afi, safi_t safi,
|
||||
uint16_t show_flags)
|
||||
{
|
||||
struct bgp *bgp;
|
||||
bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON);
|
||||
|
||||
bgp = bgp_get_default();
|
||||
|
||||
if (bgp == NULL) {
|
||||
@ -686,7 +709,8 @@ int bgp_show_dampening_parameters(struct vty *vty, afi_t afi, safi_t safi,
|
||||
}
|
||||
|
||||
if (!CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL))
|
||||
return bgp_print_dampening_parameters(bgp, vty, afi, safi);
|
||||
return bgp_print_dampening_parameters(bgp, vty, afi, safi,
|
||||
use_json);
|
||||
|
||||
if (CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP)
|
||||
|| CHECK_FLAG(show_flags, BGP_SHOW_OPT_AFI_IP6)) {
|
||||
@ -697,11 +721,12 @@ int bgp_show_dampening_parameters(struct vty *vty, afi_t afi, safi_t safi,
|
||||
"Unknown"))
|
||||
continue;
|
||||
|
||||
if (!CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON))
|
||||
if (!use_json)
|
||||
vty_out(vty, "\nFor address family: %s\n\n",
|
||||
get_afi_safi_str(afi, safi, false));
|
||||
|
||||
bgp_print_dampening_parameters(bgp, vty, afi, safi);
|
||||
bgp_print_dampening_parameters(bgp, vty, afi, safi,
|
||||
use_json);
|
||||
}
|
||||
} else {
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
@ -709,11 +734,12 @@ int bgp_show_dampening_parameters(struct vty *vty, afi_t afi, safi_t safi,
|
||||
"Unknown"))
|
||||
continue;
|
||||
|
||||
if (!CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON))
|
||||
if (!use_json)
|
||||
vty_out(vty, "\nFor address family: %s\n",
|
||||
get_afi_safi_str(afi, safi, false));
|
||||
|
||||
bgp_print_dampening_parameters(bgp, vty, afi, safi);
|
||||
bgp_print_dampening_parameters(bgp, vty, afi, safi,
|
||||
use_json);
|
||||
}
|
||||
}
|
||||
return CMD_SUCCESS;
|
||||
|
@ -11997,22 +11997,28 @@ DEFUN(show_ip_bgp_afi_safi_statistics, show_ip_bgp_afi_safi_statistics_cmd,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* BGP route print out function without JSON */
|
||||
DEFPY(show_ip_bgp, show_ip_bgp_cmd,
|
||||
DEFPY(show_ip_bgp_dampening_params, show_ip_bgp_dampening_params_cmd,
|
||||
"show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
|
||||
" [" BGP_SAFI_WITH_LABEL_CMD_STR
|
||||
"]] [all$all] dampening parameters",
|
||||
"]] [all$all] dampening parameters [json]",
|
||||
SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
|
||||
BGP_SAFI_WITH_LABEL_HELP_STR
|
||||
"Display the entries for all address families\n"
|
||||
"Display detailed information about dampening\n"
|
||||
"Display detail of configured dampening parameters\n")
|
||||
"Display detail of configured dampening parameters\n"
|
||||
JSON_STR)
|
||||
{
|
||||
afi_t afi = AFI_IP6;
|
||||
safi_t safi = SAFI_UNICAST;
|
||||
struct bgp *bgp = NULL;
|
||||
int idx = 0;
|
||||
uint16_t show_flags = 0;
|
||||
bool uj = use_json(argc, argv);
|
||||
|
||||
if (uj) {
|
||||
argc--;
|
||||
SET_FLAG(show_flags, BGP_SHOW_OPT_JSON);
|
||||
}
|
||||
|
||||
/* [<ipv4|ipv6> [all]] */
|
||||
if (all) {
|
||||
@ -12029,17 +12035,11 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
|
||||
if (!idx)
|
||||
return CMD_WARNING;
|
||||
|
||||
if (argv_find(argv, argc, "dampening", &idx)) {
|
||||
if (argv_find(argv, argc, "parameters", &idx))
|
||||
return bgp_show_dampening_parameters(vty, afi, safi,
|
||||
show_flags);
|
||||
}
|
||||
|
||||
return CMD_WARNING;
|
||||
return bgp_show_dampening_parameters(vty, afi, safi, show_flags);
|
||||
}
|
||||
|
||||
/* BGP route print out function with JSON */
|
||||
DEFPY(show_ip_bgp_json, show_ip_bgp_json_cmd,
|
||||
/* BGP route print out function */
|
||||
DEFPY(show_ip_bgp, show_ip_bgp_cmd,
|
||||
"show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
|
||||
" [" BGP_SAFI_WITH_LABEL_CMD_STR
|
||||
"]]\
|
||||
@ -15026,10 +15026,10 @@ void bgp_route_init(void)
|
||||
install_element(BGP_IPV4L_NODE, &aggregate_addressv4_cmd);
|
||||
|
||||
install_element(VIEW_NODE, &show_ip_bgp_instance_all_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_afi_safi_statistics_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_statistics_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_json_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_route_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd);
|
||||
install_element(VIEW_NODE, &show_ip_bgp_statistics_all_cmd);
|
||||
|
@ -3553,6 +3553,13 @@ structure is extended with :clicmd:`show bgp [afi] [safi]`.
|
||||
|
||||
Display flap statistics of routes of the selected afi and safi selected.
|
||||
|
||||
.. clicmd:: show bgp [afi] [safi] [all] dampening parameters [json]
|
||||
|
||||
Display details of configured dampening parameters of the selected afi and
|
||||
safi.
|
||||
|
||||
If the ``json`` option is specified, output is displayed in JSON format.
|
||||
|
||||
.. clicmd:: show bgp [afi] [safi] [all] version (1-4294967295) [wide|json]
|
||||
|
||||
Display prefixes with matching version numbers. The version number and
|
||||
|
Loading…
Reference in New Issue
Block a user