]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: merge four "show ip nht" commands into a single DEFPY
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 21 Jan 2019 14:47:10 +0000 (12:47 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 21 Jan 2019 15:26:54 +0000 (13:26 -0200)
This is mostly to be consistent with the "show ip import-check"
command, which is very similar.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
zebra/zebra_vty.c

index 83c12e2bdcfb183b01274565cfc9812c7c01fd30..87b279b1e9cdd44b99920e719cf6acbeac835653 100644 (file)
@@ -930,21 +930,35 @@ DEFPY (show_route_table_vrf,
        return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_nht,
+DEFPY (show_ip_nht,
        show_ip_nht_cmd,
-       "show ip nht [vrf NAME]",
+       "show <ip$ipv4|ipv6$ipv6> nht [vrf NAME$vrf_name|vrf all$vrf_all]",
        SHOW_STR
        IP_STR
+       IP6_STR
        "IP nexthop tracking table\n"
-       VRF_CMD_HELP_STR)
+       VRF_CMD_HELP_STR
+       VRF_ALL_CMD_HELP_STR)
 {
-       int idx_vrf = 4;
+       afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
        vrf_id_t vrf_id = VRF_DEFAULT;
 
-       if (argc == 5)
-               VRF_GET_ID(vrf_id, argv[idx_vrf]->arg, false);
+       if (vrf_all) {
+               struct vrf *vrf;
+               struct zebra_vrf *zvrf;
+
+               RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
+                       if ((zvrf = vrf->info) != NULL) {
+                               vty_out(vty, "\nVRF %s:\n", zvrf_name(zvrf));
+                               zebra_print_rnh_table(zvrf_id(zvrf), afi, vty,
+                                                     RNH_NEXTHOP_TYPE);
+                       }
+               return CMD_SUCCESS;
+       }
+       if (vrf_name)
+               VRF_GET_ID(vrf_id, vrf_name, false);
 
-       zebra_print_rnh_table(vrf_id, AFI_IP, vty, RNH_NEXTHOP_TYPE);
+       zebra_print_rnh_table(vrf_id, afi, vty, RNH_NEXTHOP_TYPE);
        return CMD_SUCCESS;
 }
 
@@ -981,67 +995,6 @@ DEFPY (show_ip_import_check,
        return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_nht_vrf_all,
-       show_ip_nht_vrf_all_cmd,
-       "show ip nht vrf all",
-       SHOW_STR
-       IP_STR
-       "IP nexthop tracking table\n"
-       VRF_ALL_CMD_HELP_STR)
-{
-       struct vrf *vrf;
-       struct zebra_vrf *zvrf;
-
-       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               if ((zvrf = vrf->info) != NULL) {
-                       vty_out(vty, "\nVRF %s:\n", zvrf_name(zvrf));
-                       zebra_print_rnh_table(zvrf_id(zvrf), AFI_IP, vty,
-                                             RNH_NEXTHOP_TYPE);
-               }
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_nht,
-       show_ipv6_nht_cmd,
-       "show ipv6 nht [vrf NAME]",
-       SHOW_STR
-       IPV6_STR
-       "IPv6 nexthop tracking table\n"
-       VRF_CMD_HELP_STR)
-{
-       int idx_vrf = 4;
-       vrf_id_t vrf_id = VRF_DEFAULT;
-
-       if (argc == 5)
-               VRF_GET_ID(vrf_id, argv[idx_vrf]->arg, false);
-
-       zebra_print_rnh_table(vrf_id, AFI_IP6, vty, RNH_NEXTHOP_TYPE);
-       return CMD_SUCCESS;
-}
-
-
-DEFUN (show_ipv6_nht_vrf_all,
-       show_ipv6_nht_vrf_all_cmd,
-       "show ipv6 nht vrf all",
-       SHOW_STR
-       IP_STR
-       "IPv6 nexthop tracking table\n"
-       VRF_ALL_CMD_HELP_STR)
-{
-       struct vrf *vrf;
-       struct zebra_vrf *zvrf;
-
-       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
-               if ((zvrf = vrf->info) != NULL) {
-                       vty_out(vty, "\nVRF %s:\n", zvrf_name(zvrf));
-                       zebra_print_rnh_table(zvrf_id(zvrf), AFI_IP6, vty,
-                                             RNH_NEXTHOP_TYPE);
-               }
-
-       return CMD_SUCCESS;
-}
-
 DEFUN (ip_nht_default_route,
        ip_nht_default_route_cmd,
        "ip nht resolve-via-default",
@@ -2954,9 +2907,6 @@ void zebra_vty_init(void)
        install_element(VIEW_NODE, &show_route_summary_cmd);
        install_element(VIEW_NODE, &show_ip_nht_cmd);
        install_element(VIEW_NODE, &show_ip_import_check_cmd);
-       install_element(VIEW_NODE, &show_ip_nht_vrf_all_cmd);
-       install_element(VIEW_NODE, &show_ipv6_nht_cmd);
-       install_element(VIEW_NODE, &show_ipv6_nht_vrf_all_cmd);
 
        install_element(VIEW_NODE, &show_ip_rpf_cmd);
        install_element(VIEW_NODE, &show_ip_rpf_addr_cmd);