From dc64bdec917a18e64d8dd299f0d1c0a86801c825 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 1 Mar 2018 13:43:54 -0500 Subject: [PATCH] bgpd: fix update-group show commands Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 255 ++++++------------------------------------------- 1 file changed, 31 insertions(+), 224 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 15cc5673accf..b72b107ef69a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10300,227 +10300,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 ", - 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 VIEWVRFNAME update-groups ", - 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 ", - 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 ", - 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 VIEWVRFNAME update-groups ", - 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 ", - 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 [ VIEWVRFNAME$vrf] [$afi $safi] update-groups [SUBGROUP-ID]$sgid $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 VIEWVRFNAME update-groups SUBGROUP-ID ", - 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 ", - 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 ", - 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 VIEWVRFNAME update-groups SUBGROUP-ID ", - 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; @@ -12435,19 +12251,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. */