mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 00:13:40 +00:00
bgpd: combine special cases for vrf "all"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
This commit is contained in:
parent
8749a04cc2
commit
4fb25c53b8
@ -3612,28 +3612,17 @@ DEFUN (no_set_ip_nexthop,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CHECK ME - The following ALIASes need to be implemented in this DEFUN
|
||||
* "set metric (rtt|+rtt|-rtt)",
|
||||
* SET_STR
|
||||
* "Metric value for destination routing protocol\n"
|
||||
* "Assign round trip time\n"
|
||||
* "Add round trip time\n"
|
||||
* "Subtract round trip time\n"
|
||||
*
|
||||
* "set metric <+/-metric>",
|
||||
* SET_STR
|
||||
* "Metric value for destination routing protocol\n"
|
||||
* "Add or subtract metric\n"
|
||||
*
|
||||
*/
|
||||
DEFUN (set_metric,
|
||||
set_metric_cmd,
|
||||
"set metric (0-4294967295)",
|
||||
"set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>",
|
||||
SET_STR
|
||||
"Metric value for destination routing protocol\n"
|
||||
"Metric value\n")
|
||||
"Metric value\n"
|
||||
"Assign round trip time\n"
|
||||
"Add round trip time\n"
|
||||
"Subtract round trip time\n"
|
||||
"Add metric\n"
|
||||
"Subtract metric\n")
|
||||
{
|
||||
int idx_number = 2;
|
||||
return bgp_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
|
||||
|
288
bgpd/bgp_vty.c
288
bgpd/bgp_vty.c
@ -6747,34 +6747,6 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
bgp_show_summary_vty (struct vty *vty, const char *name,
|
||||
afi_t afi, safi_t safi, u_char use_json)
|
||||
{
|
||||
struct bgp *bgp;
|
||||
|
||||
if (name)
|
||||
{
|
||||
bgp = bgp_lookup_by_name (name);
|
||||
|
||||
if (! bgp)
|
||||
{
|
||||
vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
bgp = bgp_get_default ();
|
||||
|
||||
if (bgp)
|
||||
bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
|
||||
u_char use_json)
|
||||
@ -6791,14 +6763,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
|
||||
{
|
||||
if (use_json)
|
||||
{
|
||||
if (!(json = json_object_new_object()))
|
||||
{
|
||||
zlog_err("Unable to allocate memory for JSON object");
|
||||
vty_out (vty,
|
||||
"{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
|
||||
VTY_NEWLINE);
|
||||
return;
|
||||
}
|
||||
json = json_object_new_object();
|
||||
|
||||
if (! is_first)
|
||||
vty_out (vty, ",%s", VTY_NEWLINE);
|
||||
@ -6823,6 +6788,45 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
bgp_show_summary_vty (struct vty *vty, const char *name,
|
||||
afi_t afi, safi_t safi, u_char use_json)
|
||||
{
|
||||
struct bgp *bgp;
|
||||
|
||||
if (name)
|
||||
{
|
||||
if (strmatch(name, "all"))
|
||||
{
|
||||
bgp_show_all_instances_summary_vty (vty, afi, safi, use_json);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp = bgp_lookup_by_name (name);
|
||||
|
||||
if (! bgp)
|
||||
{
|
||||
if (use_json)
|
||||
vty_out (vty, "{}%s", VTY_NEWLINE);
|
||||
else
|
||||
vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
bgp = bgp_get_default ();
|
||||
|
||||
if (bgp)
|
||||
bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* `show ip bgp summary' commands. */
|
||||
DEFUN (show_ip_bgp_summary,
|
||||
show_ip_bgp_summary_cmd,
|
||||
@ -6857,22 +6861,6 @@ DEFUN (show_ip_bgp_summary,
|
||||
return bgp_show_summary_vty (vty, vrf, afi, safi, uj);
|
||||
}
|
||||
|
||||
DEFUN (show_ip_bgp_instance_all_summary,
|
||||
show_ip_bgp_instance_all_summary_cmd,
|
||||
"show ip bgp <view|vrf> all summary [json]",
|
||||
SHOW_STR
|
||||
IP_STR
|
||||
BGP_STR
|
||||
BGP_INSTANCE_ALL_HELP_STR
|
||||
"Summary of BGP neighbor status\n"
|
||||
"JavaScript Object Notation\n")
|
||||
{
|
||||
u_char uj = use_json(argc, argv);
|
||||
|
||||
bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
const char *
|
||||
afi_safi_print (afi_t afi, safi_t safi)
|
||||
{
|
||||
@ -8595,59 +8583,6 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
bgp_show_neighbor_vty (struct vty *vty, const char *name,
|
||||
enum show_type type, const char *ip_str, u_char use_json)
|
||||
{
|
||||
int ret;
|
||||
struct bgp *bgp;
|
||||
union sockunion su;
|
||||
json_object *json = NULL;
|
||||
|
||||
if (use_json)
|
||||
json = json_object_new_object();
|
||||
|
||||
if (name)
|
||||
{
|
||||
bgp = bgp_lookup_by_name (name);
|
||||
if (! bgp)
|
||||
{
|
||||
if (use_json)
|
||||
{
|
||||
json_object_boolean_true_add(json, "bgpNoSuchInstance");
|
||||
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
||||
json_object_free(json);
|
||||
}
|
||||
else
|
||||
vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
|
||||
|
||||
return CMD_WARNING;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp = bgp_get_default ();
|
||||
}
|
||||
|
||||
if (bgp)
|
||||
{
|
||||
if (ip_str)
|
||||
{
|
||||
ret = str2sockunion (ip_str, &su);
|
||||
if (ret < 0)
|
||||
bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
|
||||
else
|
||||
bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
|
||||
}
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
|
||||
{
|
||||
@ -8702,6 +8637,67 @@ bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
|
||||
vty_out (vty, "}%s", VTY_NEWLINE);
|
||||
}
|
||||
|
||||
static int
|
||||
bgp_show_neighbor_vty (struct vty *vty, const char *name,
|
||||
enum show_type type, const char *ip_str, u_char use_json)
|
||||
{
|
||||
int ret;
|
||||
struct bgp *bgp;
|
||||
union sockunion su;
|
||||
json_object *json = NULL;
|
||||
|
||||
if (use_json)
|
||||
json = json_object_new_object();
|
||||
|
||||
if (name)
|
||||
{
|
||||
if (strmatch(name, "all"))
|
||||
{
|
||||
bgp_show_all_instances_neighbors_vty (vty, use_json);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp = bgp_lookup_by_name (name);
|
||||
if (! bgp)
|
||||
{
|
||||
if (use_json)
|
||||
{
|
||||
json_object_boolean_true_add(json, "bgpNoSuchInstance");
|
||||
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
||||
json_object_free(json);
|
||||
}
|
||||
else
|
||||
vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
|
||||
|
||||
return CMD_WARNING;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp = bgp_get_default ();
|
||||
}
|
||||
|
||||
if (bgp)
|
||||
{
|
||||
if (ip_str)
|
||||
{
|
||||
ret = str2sockunion (ip_str, &su);
|
||||
if (ret < 0)
|
||||
bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
|
||||
else
|
||||
bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
|
||||
}
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* "show ip bgp neighbors" commands. */
|
||||
DEFUN (show_ip_bgp_neighbors,
|
||||
show_ip_bgp_neighbors_cmd,
|
||||
@ -8755,22 +8751,6 @@ DEFUN (show_ip_bgp_neighbors,
|
||||
return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj);
|
||||
}
|
||||
|
||||
DEFUN (show_ip_bgp_instance_all_neighbors,
|
||||
show_ip_bgp_instance_all_neighbors_cmd,
|
||||
"show [ip] bgp <view|vrf> all neighbors [json]",
|
||||
SHOW_STR
|
||||
IP_STR
|
||||
BGP_STR
|
||||
BGP_INSTANCE_ALL_HELP_STR
|
||||
"Detailed information on TCP and BGP neighbor connections\n"
|
||||
"JavaScript Object Notation\n")
|
||||
{
|
||||
u_char uj = use_json(argc, argv);
|
||||
|
||||
bgp_show_all_instances_neighbors_vty (vty, uj);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* Show BGP's AS paths internal data. There are both `show ip bgp
|
||||
paths' and `show ip mbgp paths'. Those functions results are the
|
||||
same.*/
|
||||
@ -8847,22 +8827,6 @@ DEFUN (show_ip_bgp_attr_info,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static int bgp_show_update_groups(struct vty *vty, const char *name,
|
||||
int afi, int safi,
|
||||
uint64_t subgrp_id)
|
||||
{
|
||||
struct bgp *bgp;
|
||||
|
||||
if (name)
|
||||
bgp = bgp_lookup_by_name (name);
|
||||
else
|
||||
bgp = bgp_get_default ();
|
||||
|
||||
if (bgp)
|
||||
update_group_show(bgp, afi, safi, vty, subgrp_id);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
|
||||
{
|
||||
@ -8879,6 +8843,35 @@ bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
bgp_show_update_groups(struct vty *vty, const char *name,
|
||||
int afi, int safi,
|
||||
uint64_t subgrp_id)
|
||||
{
|
||||
struct bgp *bgp;
|
||||
|
||||
if (name)
|
||||
{
|
||||
if (strmatch (name, "all"))
|
||||
{
|
||||
bgp_show_all_instances_updgrps_vty (vty, afi, safi);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp = bgp_lookup_by_name (name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bgp = bgp_get_default ();
|
||||
}
|
||||
|
||||
if (bgp)
|
||||
update_group_show(bgp, afi, safi, vty, subgrp_id);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (show_ip_bgp_updgrps,
|
||||
show_ip_bgp_updgrps_cmd,
|
||||
"show [ip] bgp [<view|vrf> WORD] [<<ipv4|ipv6|vpnv4|encap> [unicast]|ipv4 multicast>] update-groups [SUBGROUP-ID]",
|
||||
@ -8921,19 +8914,6 @@ DEFUN (show_ip_bgp_updgrps,
|
||||
return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id));
|
||||
}
|
||||
|
||||
DEFUN (show_ip_bgp_instance_all_updgrps,
|
||||
show_ip_bgp_instance_all_updgrps_cmd,
|
||||
"show ip bgp <view|vrf> all update-groups",
|
||||
SHOW_STR
|
||||
IP_STR
|
||||
BGP_STR
|
||||
BGP_INSTANCE_ALL_HELP_STR
|
||||
"Detailed info about dynamic update groups\n")
|
||||
{
|
||||
bgp_show_all_instances_updgrps_vty (vty, AFI_IP, SAFI_UNICAST);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (show_bgp_instance_all_ipv6_updgrps,
|
||||
show_bgp_instance_all_ipv6_updgrps_cmd,
|
||||
"show bgp <view|vrf> all update-groups",
|
||||
@ -10987,7 +10967,6 @@ bgp_vty_init (void)
|
||||
/* "show ip bgp summary" commands. */
|
||||
install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
|
||||
install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
|
||||
install_element (VIEW_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
|
||||
install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
|
||||
install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
|
||||
install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
|
||||
@ -10999,10 +10978,8 @@ bgp_vty_init (void)
|
||||
install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
|
||||
install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
|
||||
install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
|
||||
install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
|
||||
@ -11014,10 +10991,8 @@ bgp_vty_init (void)
|
||||
install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
|
||||
install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_summary_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
|
||||
install_element (ENABLE_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
|
||||
@ -11029,13 +11004,10 @@ bgp_vty_init (void)
|
||||
install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
|
||||
install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
|
||||
install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_instance_all_summary_cmd);
|
||||
|
||||
/* "show ip bgp neighbors" commands. */
|
||||
install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
|
||||
install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
|
||||
install_element (ENABLE_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
|
||||
|
||||
/* "show ip bgp peer-group" commands. */
|
||||
install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
|
||||
|
@ -2177,7 +2177,6 @@ DEFUN (vtysh_write_terminal,
|
||||
"Write running configuration to memory, network, or terminal\n"
|
||||
"Write to terminal\n")
|
||||
{
|
||||
/* CHECK ME argc referenced below */
|
||||
u_int i;
|
||||
char line[] = "write terminal\n";
|
||||
FILE *fp = NULL;
|
||||
@ -2199,10 +2198,6 @@ DEFUN (vtysh_write_terminal,
|
||||
VTY_NEWLINE);
|
||||
vty_out (vty, "!%s", VTY_NEWLINE);
|
||||
|
||||
for (i = 0; i < array_size(vtysh_client); i++)
|
||||
if ((argc < 1 ) || (begins_with(vtysh_client[i].name, argv[0])))
|
||||
vtysh_client_config (&vtysh_client[i], line);
|
||||
|
||||
/* Integrate vtysh specific configuration. */
|
||||
vtysh_config_write ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user