summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Winter <mwinter@opensourcerouting.org>2018-03-11 23:32:16 +0100
committerGitHub <noreply@github.com>2018-03-11 23:32:16 +0100
commit5f9f8b3bdc71b956bee27bec2e7cedf3c2324aed (patch)
tree67cb8282fc5df03d229e847664e031d59266cdf4
parent0885dda78e504950ed5cff736c0e4dffbad6643b (diff)
parent33bb24176ed110ca717846e198775ff0715b7f03 (diff)
Merge pull request #1838 from qlyoung/bgpd-fix-update-group-commands-4.0
bgpd: fix update-group show commands [4.0]
-rw-r--r--bgpd/bgp_vty.c255
1 files changed, 31 insertions, 224 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index d30b057cbc..63f3ccfc91 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -10288,227 +10288,43 @@ static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name,
}
}
-DEFUN (show_ip_bgp_updgrps_adj,
- show_ip_bgp_updgrps_adj_cmd,
- "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- "Detailed info about dynamic update groups\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_type = 4;
- show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST,
- argv[idx_type]->arg, 0);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_bgp_instance_updgrps_adj,
- show_ip_bgp_instance_updgrps_adj_cmd,
- "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- BGP_INSTANCE_HELP_STR
- "Detailed info about dynamic update groups\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_word = 4;
- int idx_type = 6;
- show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP,
- SAFI_UNICAST, argv[idx_type]->arg, 0);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_bgp_updgrps_afi_adj,
- show_bgp_updgrps_afi_adj_cmd,
- "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- BGP_AFI_SAFI_HELP_STR
- "Detailed info about dynamic update groups\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_afi = 2;
- int idx_safi = 3;
- int idx_type = 5;
- show_bgp_updgrps_adj_info_aux(
- vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text),
- bgp_vty_safi_from_str(argv[idx_safi]->text),
- argv[idx_type]->arg, 0);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_bgp_updgrps_adj,
- show_bgp_updgrps_adj_cmd,
- "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- "Detailed info about dynamic update groups\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_type = 3;
- show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST,
- argv[idx_type]->arg, 0);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_bgp_instance_updgrps_adj,
- show_bgp_instance_updgrps_adj_cmd,
- "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- BGP_INSTANCE_HELP_STR
- "Detailed info about dynamic update groups\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_word = 3;
- int idx_type = 5;
- show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6,
- SAFI_UNICAST, argv[idx_type]->arg, 0);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_bgp_updgrps_adj_s,
- show_ip_bgp_updgrps_adj_s_cmd,
- "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- "Detailed info about dynamic update groups\n"
- "Specific subgroup to display info for\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
+DEFPY(show_ip_bgp_instance_updgrps_adj_s,
+ show_ip_bgp_instance_updgrps_adj_s_cmd,
+ "show [ip]$ip bgp [<view|vrf> VIEWVRFNAME$vrf] [<ipv4|ipv6>$afi <unicast|multicast|vpn>$safi] update-groups [SUBGROUP-ID]$sgid <advertise-queue|advertised-routes|packet-queue>$rtq",
+ SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
+ "Detailed info about dynamic update groups\n"
+ "Specific subgroup to display info for\n"
+ "Advertisement queue\n"
+ "Announced routes\n"
+ "Packet queue\n")
{
- int idx_subgroup_id = 4;
- int idx_type = 5;
- uint64_t subgrp_id;
-
- subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10);
-
- show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST,
- argv[idx_type]->arg, subgrp_id);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_bgp_instance_updgrps_adj_s,
- show_ip_bgp_instance_updgrps_adj_s_cmd,
- "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- BGP_INSTANCE_HELP_STR
- "Detailed info about dynamic update groups\n"
- "Specific subgroup to display info for\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_vrf = 4;
- int idx_subgroup_id = 6;
- int idx_type = 7;
- uint64_t subgrp_id;
-
- subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10);
-
- show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP,
- SAFI_UNICAST, argv[idx_type]->arg,
- subgrp_id);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_bgp_updgrps_afi_adj_s,
- show_bgp_updgrps_afi_adj_s_cmd,
- "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- BGP_AFI_SAFI_HELP_STR
- "Detailed info about dynamic update groups\n"
- "Specific subgroup to display info for\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_afi = 2;
- int idx_safi = 3;
- int idx_subgroup_id = 5;
- int idx_type = 6;
- uint64_t subgrp_id;
-
- subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10);
-
- show_bgp_updgrps_adj_info_aux(
- vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text),
- bgp_vty_safi_from_str(argv[idx_safi]->text),
- argv[idx_type]->arg, subgrp_id);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_bgp_updgrps_adj_s,
- show_bgp_updgrps_adj_s_cmd,
- "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- "Detailed info about dynamic update groups\n"
- "Specific subgroup to display info for\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_subgroup_id = 3;
- int idx_type = 4;
- uint64_t subgrp_id;
-
- subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10);
-
- show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST,
- argv[idx_type]->arg, subgrp_id);
- return CMD_SUCCESS;
-}
-
-DEFUN (show_bgp_instance_updgrps_adj_s,
- show_bgp_instance_updgrps_adj_s_cmd,
- "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
- SHOW_STR
- IP_STR
- BGP_STR
- BGP_INSTANCE_HELP_STR
- "Detailed info about dynamic update groups\n"
- "Specific subgroup to display info for\n"
- "Advertisement queue\n"
- "Announced routes\n"
- "Packet queue\n")
-{
- int idx_vrf = 3;
- int idx_subgroup_id = 5;
- int idx_type = 6;
- uint64_t subgrp_id;
+ uint64_t subgrp_id = 0;
+ afi_t afiz;
+ safi_t safiz;
+ if (sgid)
+ subgrp_id = strtoull(sgid, NULL, 10);
+
+ if (!ip && !afi)
+ afiz = AFI_IP6;
+ if (!ip && afi)
+ afiz = bgp_vty_afi_from_str(afi);
+ if (ip && !afi)
+ afiz = AFI_IP;
+ if (ip && afi) {
+ afiz = bgp_vty_afi_from_str(afi);
+ if (afiz != AFI_IP)
+ vty_out(vty,
+ "%% Cannot specify both 'ip' and 'ipv6'\n");
+ return CMD_WARNING;
+ }
- subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10);
+ safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST;
- show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6,
- SAFI_UNICAST, argv[idx_type]->arg,
- subgrp_id);
+ show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id);
return CMD_SUCCESS;
}
-
static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group)
{
struct listnode *node, *nnode;
@@ -12422,19 +12238,10 @@ void bgp_vty_init(void)
/* "show [ip] bgp summary" commands. */
install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
- install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
- install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd);
- install_element(VIEW_NODE, &show_bgp_updgrps_adj_cmd);
- install_element(VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
- install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
- install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd);
- install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
install_element(VIEW_NODE, &show_ip_bgp_summary_cmd);
- install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
- install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd);
/* "show [ip] bgp neighbors" commands. */