]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #8465 from opensourcerouting/vtysh-scan-snafu
authorMark Stapp <mjs@voltanet.io>
Fri, 16 Apr 2021 12:23:20 +0000 (08:23 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Apr 2021 12:23:20 +0000 (08:23 -0400)
fix vtysh_scan SNAFUs

lib/log_vty.c
lib/subdir.am
lib/thread.c
pathd/subdir.am
python/vtysh-cmd-check.py [new file with mode: 0644]
vtysh/extract.pl.in
vtysh/vtysh.c
zebra/subdir.am

index c26621ae99d1e3e1aac6e98ed6e8ff574160dce4..c6788dd35aaf9b33c500c9fc207d8b48a2dade1a 100644 (file)
@@ -146,11 +146,11 @@ void log_show_syslog(struct vty *vty)
                        zlog_progname);
 }
 
-DEFUN (show_logging,
-       show_logging_cmd,
-       "show logging",
-       SHOW_STR
-       "Show current logging configuration\n")
+DEFUN_NOSH (show_logging,
+           show_logging_cmd,
+           "show logging",
+           SHOW_STR
+           "Show current logging configuration\n")
 {
        log_show_syslog(vty);
 
index 0853d4bb2bb01705a24c3108376d281bf9333a32..b7efec488296a6e1f5552cc1c119274284a14372 100644 (file)
@@ -141,10 +141,14 @@ vtysh_scan += \
        lib/if_rmap.c \
        lib/keychain.c \
        lib/lib_vty.c \
+       lib/log_vty.c \
        lib/nexthop_group.c \
        lib/plist.c \
+       lib/resolver.c \
        lib/routemap.c \
        lib/routemap_cli.c \
+       lib/spf_backoff.c \
+       lib/thread.c \
        lib/vrf.c \
        lib/vty.c \
        # end
index 567516300d226f05880d5409fcf65bfdf1b88f3a..3d8b54467821f05229a47a7525ed4435512ac90e 100644 (file)
@@ -307,13 +307,13 @@ static uint8_t parse_filter(const char *filterstr)
 }
 
 #ifndef EXCLUDE_CPU_TIME
-DEFUN (show_thread_cpu,
-       show_thread_cpu_cmd,
-       "show thread cpu [FILTER]",
-       SHOW_STR
-       "Thread information\n"
-       "Thread CPU usage\n"
-       "Display filter (rwtex)\n")
+DEFUN_NOSH (show_thread_cpu,
+           show_thread_cpu_cmd,
+           "show thread cpu [FILTER]",
+           SHOW_STR
+           "Thread information\n"
+           "Thread CPU usage\n"
+           "Display filter (rwtex)\n")
 {
        uint8_t filter = (uint8_t)-1U;
        int idx = 0;
@@ -374,12 +374,12 @@ static void show_thread_poll_helper(struct vty *vty, struct thread_master *m)
        }
 }
 
-DEFUN (show_thread_poll,
-       show_thread_poll_cmd,
-       "show thread poll",
-       SHOW_STR
-       "Thread information\n"
-       "Show poll FD's and information\n")
+DEFUN_NOSH (show_thread_poll,
+           show_thread_poll_cmd,
+           "show thread poll",
+           SHOW_STR
+           "Thread information\n"
+           "Show poll FD's and information\n")
 {
        struct listnode *node;
        struct thread_master *m;
index 38df326489ee542dcdf9ec930f523ce7de99e0b6..4eabdd2ac54fd8bc2a3da7d404a7497474a04b59 100644 (file)
@@ -5,13 +5,13 @@
 if PATHD
 noinst_LIBRARIES += pathd/libpath.a
 sbin_PROGRAMS += pathd/pathd
-vtysh_scan += $(top_srcdir)/pathd/path_cli.c
+vtysh_scan += pathd/path_cli.c
 vtysh_daemons += pathd
 # TODO add man page
 #man8 += $(MANBUILD)/pathd.8
 
 if PATHD_PCEP
-vtysh_scan += $(top_srcdir)/pathd/path_pcep_cli.c
+vtysh_scan += pathd/path_pcep_cli.c
 module_LTLIBRARIES += pathd/pathd_pcep.la
 endif
 
diff --git a/python/vtysh-cmd-check.py b/python/vtysh-cmd-check.py
new file mode 100644 (file)
index 0000000..ef9eea4
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+#
+# Quick demo program that checks whether files define commands that aren't
+# in vtysh.  Execute after building.
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to <http://unlicense.org/>
+
+import os
+import json
+import subprocess
+
+os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+with open("frr.xref", "r") as fd:
+    data = json.load(fd)
+
+vtysh_scan, _ = subprocess.Popen(
+    ["make", "var-vtysh_scan"], stdout=subprocess.PIPE
+).communicate()
+vtysh_scan = set(vtysh_scan.decode("US-ASCII").split())
+
+check = set()
+vtysh = {}
+
+for cmd, defs in data["cli"].items():
+    for binary, clidef in defs.items():
+        if clidef["defun"]["file"].startswith("vtysh/"):
+            vtysh[clidef["string"]] = clidef
+
+for cmd, defs in data["cli"].items():
+    for binary, clidef in defs.items():
+        if clidef["defun"]["file"].startswith("vtysh/"):
+            continue
+
+        if clidef["defun"]["file"] not in vtysh_scan:
+            vtysh_def = vtysh.get(clidef["string"])
+            if vtysh_def is not None:
+                print(
+                    "\033[33m%s defines %s, has a custom define in vtysh %s\033[m"
+                    % (clidef["defun"]["file"], cmd, vtysh_def["defun"]["file"])
+                )
+            else:
+                print(
+                    "\033[31m%s defines %s, not in vtysh_scan\033[m"
+                    % (clidef["defun"]["file"], cmd)
+                )
+                check.add(clidef["defun"]["file"])
+
+print("\nfiles to check:\n\t" + " ".join(sorted(check)))
index 4855c23f4b15ab837b37614c9b2278bb1a981c5a..af974771cc25da6fdf2b43dc10401d70d33d0fe7 100755 (executable)
@@ -103,7 +103,7 @@ sub scan_file {
         elsif ($file =~ /lib\/(filter|filter_cli)\.c$/) {
             $protocol = "VTYSH_ACL";
         }
-        elsif ($file =~ /lib\/lib_vty\.c$/) {
+        elsif ($file =~ /lib\/(lib|log)_vty\.c$/) {
             $protocol = "VTYSH_ALL";
         }
        elsif ($file =~ /lib\/agentx\.c$/) {
@@ -133,7 +133,13 @@ sub scan_file {
                 $protocol = "VTYSH_RIPD";
             }
         }
-        elsif ($file =~ /lib\/vty\.c$/) {
+       elsif ($file =~ /lib\/resolver\.c$/) {
+           $protocol = "VTYSH_NHRPD|VTYSH_BGPD";
+       }
+       elsif ($file =~ /lib\/spf_backoff\.c$/) {
+           $protocol = "VTYSH_ISISD";
+       }
+        elsif ($file =~ /lib\/(vty|thread)\.c$/) {
            $protocol = "VTYSH_ALL";
         }
         elsif ($file =~ /librfp\/.*\.c$/ || $file =~ /rfapi\/.*\.c$/) {
@@ -269,7 +275,7 @@ EOF
 foreach (sort keys %odefun) {
     my ($node, $str) = (split (/,/));
     $cmd = $ocmd{$_};
-    $cmd =~ s/_cmd/_cmd_vtysh/;
+    $cmd =~ s/_cmd$/_cmd_vtysh/;
     printf "  install_element ($node, &$cmd);\n";
 }
 
index 75fee1d2979e366310d1894ca74a462e0013cee4..a1417430ec47621b055d8ad156b8387316a8ea59 100644 (file)
@@ -2964,136 +2964,6 @@ DEFUN (vtysh_show_logging,
                               "Logging configuration for %s:\n");
 }
 
-DEFUNSH(VTYSH_ALL, vtysh_log_stdout, vtysh_log_stdout_cmd, "log stdout",
-       "Logging control\n"
-       "Set stdout logging level\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_stdout_level, vtysh_log_stdout_level_cmd,
-       "log stdout <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
-       "Logging control\n"
-       "Set stdout logging level\n" LOG_LEVEL_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, no_vtysh_log_stdout, no_vtysh_log_stdout_cmd,
-       "no log stdout [LEVEL]", NO_STR
-       "Logging control\n"
-       "Cancel logging to stdout\n"
-       "Logging level\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_file, vtysh_log_file_cmd, "log file FILENAME",
-       "Logging control\n"
-       "Logging to file\n"
-       "Logging filename\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_file_level, vtysh_log_file_level_cmd,
-       "log file FILENAME <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>",
-       "Logging control\n"
-       "Logging to file\n"
-       "Logging filename\n" LOG_LEVEL_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, no_vtysh_log_file, no_vtysh_log_file_cmd,
-       "no log file [FILENAME [LEVEL]]", NO_STR
-       "Logging control\n"
-       "Cancel logging to file\n"
-       "Logging file name\n"
-       "Logging level\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_monitor, vtysh_log_monitor_cmd,
-       "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
-       "Logging control\n"
-       "Set terminal line (monitor) logging level\n" LOG_LEVEL_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, no_vtysh_log_monitor, no_vtysh_log_monitor_cmd,
-       "no log monitor [LEVEL]", NO_STR
-       "Logging control\n"
-       "Disable terminal line (monitor) logging\n"
-       "Logging level\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_syslog, vtysh_log_syslog_cmd,
-       "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
-       "Logging control\n"
-       "Set syslog logging level\n" LOG_LEVEL_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, no_vtysh_log_syslog, no_vtysh_log_syslog_cmd,
-       "no log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
-       NO_STR
-       "Logging control\n"
-       "Cancel logging to syslog\n"
-       LOG_LEVEL_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_facility, vtysh_log_facility_cmd,
-       "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>",
-       "Logging control\n"
-       "Facility parameter for syslog messages\n" LOG_FACILITY_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, no_vtysh_log_facility, no_vtysh_log_facility_cmd,
-       "no log facility [<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>]",
-       NO_STR
-       "Logging control\n"
-       "Reset syslog facility to default (daemon)\n"
-       LOG_FACILITY_DESC)
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_record_priority, vtysh_log_record_priority_cmd,
-       "log record-priority",
-       "Logging control\n"
-       "Log the priority of the message within the message\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, no_vtysh_log_record_priority,
-       no_vtysh_log_record_priority_cmd, "no log record-priority", NO_STR
-       "Logging control\n"
-       "Do not log the priority of the message within the message\n")
-{
-       return CMD_SUCCESS;
-}
-
-DEFUNSH(VTYSH_ALL, vtysh_log_timestamp_precision,
-       vtysh_log_timestamp_precision_cmd, "log timestamp precision (0-6)",
-       "Logging control\n"
-       "Timestamp configuration\n"
-       "Set the timestamp precision\n"
-       "Number of subsecond digits\n")
-{
-       return CMD_SUCCESS;
-}
-
 DEFUNSH(VTYSH_ALL, vtysh_debug_memstats,
        vtysh_debug_memstats_cmd, "[no] debug memstats-at-exit",
        NO_STR
@@ -3103,16 +2973,6 @@ DEFUNSH(VTYSH_ALL, vtysh_debug_memstats,
        return CMD_SUCCESS;
 }
 
-DEFUNSH(VTYSH_ALL, no_vtysh_log_timestamp_precision,
-       no_vtysh_log_timestamp_precision_cmd, "no log timestamp precision",
-       NO_STR
-       "Logging control\n"
-       "Timestamp configuration\n"
-       "Reset the timestamp precision to the default value of 0\n")
-{
-       return CMD_SUCCESS;
-}
-
 DEFUNSH(VTYSH_ALL, vtysh_service_password_encrypt,
        vtysh_service_password_encrypt_cmd, "service password-encryption",
        "Set up miscellaneous service\n"
@@ -4605,22 +4465,6 @@ void vtysh_init_vty(void)
 
        /* Logging */
        install_element(VIEW_NODE, &vtysh_show_logging_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_stdout_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_stdout_level_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_stdout_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_file_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_file_level_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_file_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_monitor_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_monitor_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_syslog_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_syslog_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_facility_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_facility_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_record_priority_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
-       install_element(CONFIG_NODE, &vtysh_log_timestamp_precision_cmd);
-       install_element(CONFIG_NODE, &no_vtysh_log_timestamp_precision_cmd);
 
        install_element(CONFIG_NODE, &vtysh_service_password_encrypt_cmd);
        install_element(CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
index 80ea9ac7b8b272b0f65405a4ed5ff39b04d66fd4..f0d1c5844f32b16bba8b672a8f1ad6c254f29693 100644 (file)
@@ -232,7 +232,7 @@ zebra_dplane_fpm_nl_la_SOURCES = zebra/dplane_fpm_nl.c
 zebra_dplane_fpm_nl_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
 zebra_dplane_fpm_nl_la_LIBADD  =
 
-vtysh_scan += $(top_srcdir)/zebra/dplane_fpm_nl.c
+vtysh_scan += zebra/dplane_fpm_nl.c
 endif
 
 if NETLINK_DEBUG