]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge branch 'master' into bgpd-debug-updates-prefix
authorDaniel Walton <dwalton76@gmail.com>
Wed, 27 Sep 2017 13:21:26 +0000 (09:21 -0400)
committerGitHub <noreply@github.com>
Wed, 27 Sep 2017 13:21:26 +0000 (09:21 -0400)
bgpd/Makefile.am
bgpd/bgp_debug.c
lib/command.h
tools/frr-reload.py
watchfrr/watchfrr_vty.c
zebra/debug.c

index 0ec5a778bb1d53bc830fc34946d42b9c73135464..1f2602c05991c645cdc10d9115b3517d8ee4245b 100644 (file)
@@ -119,7 +119,6 @@ dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2 \
        bgpd.conf.vnc.sample
 
 bgp_vty.o: bgp_vty_clippy.c
-bgp_debug.o: bgp_debug_clippy.c
 
 EXTRA_DIST = BGP4-MIB.txt
 
index c1c4f2b39cda7ffe1ed3e291543a427ac8f1eb50..6de9ba3cc61a096e88256c47017fd096924031ab 100644 (file)
@@ -865,39 +865,42 @@ DEFUN (no_debug_bgp_keepalive_peer,
        return CMD_SUCCESS;
 }
 
-#ifndef VTYSH_EXTRACT_PL
-#include "bgp_debug_clippy.c"
-#endif
-
 /* debug bgp bestpath */
-DEFPY (debug_bgp_bestpath_prefix,
+DEFUN (debug_bgp_bestpath_prefix,
        debug_bgp_bestpath_prefix_cmd,
-       "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>$bestpath",
+       "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
        DEBUG_STR
        BGP_STR
        "BGP bestpath\n"
        "IPv4 prefix\n"
        "IPv6 prefix\n")
 {
+       struct prefix *argv_p;
+       int idx_ipv4_ipv6_prefixlen = 3;
+
+       argv_p = prefix_new();
+       (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
+       apply_mask(argv_p);
+
        if (!bgp_debug_bestpath_prefixes)
                bgp_debug_bestpath_prefixes = list_new();
 
        if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL,
-                                    bestpath)) {
+                                    argv_p)) {
                vty_out(vty,
                        "BGP bestpath debugging is already enabled for %s\n",
-                       bestpath_str);
+                       argv[idx_ipv4_ipv6_prefixlen]->arg);
                return CMD_SUCCESS;
        }
 
-       bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes, NULL, bestpath);
+       bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes, NULL, argv_p);
 
        if (vty->node == CONFIG_NODE) {
                DEBUG_ON(bestpath, BESTPATH);
        } else {
                TERM_DEBUG_ON(bestpath, BESTPATH);
                vty_out(vty, "BGP bestpath debugging is on for %s\n",
-                       bestpath_str);
+                       argv[idx_ipv4_ipv6_prefixlen]->arg);
        }
 
        return CMD_SUCCESS;
@@ -916,15 +919,10 @@ DEFUN (no_debug_bgp_bestpath_prefix,
        int idx_ipv4_ipv6_prefixlen = 4;
        struct prefix *argv_p;
        int found_prefix = 0;
-       int ret;
 
        argv_p = prefix_new();
-       ret = str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
-       if (!ret) {
-               prefix_free(argv_p);
-               vty_out(vty, "%% Malformed Prefix\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
+       (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
+       apply_mask(argv_p);
 
        if (bgp_debug_bestpath_prefixes
            && !list_isempty(bgp_debug_bestpath_prefixes)) {
@@ -1267,16 +1265,10 @@ DEFUN (debug_bgp_update_prefix,
 {
        int idx_ipv4_ipv6_prefixlen = 4;
        struct prefix *argv_p;
-       int ret;
 
        argv_p = prefix_new();
-       ret = str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
-       if (!ret) {
-               prefix_free(argv_p);
-               vty_out(vty, "%% Malformed Prefix\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
+       (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
+       apply_mask(argv_p);
 
        if (!bgp_debug_update_prefixes)
                bgp_debug_update_prefixes = list_new();
@@ -1315,15 +1307,10 @@ DEFUN (no_debug_bgp_update_prefix,
        int idx_ipv4_ipv6_prefixlen = 5;
        struct prefix *argv_p;
        int found_prefix = 0;
-       int ret;
 
        argv_p = prefix_new();
-       ret = str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
-       if (!ret) {
-               prefix_free(argv_p);
-               vty_out(vty, "%% Malformed Prefix\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
+       (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
+       apply_mask(argv_p);
 
        if (bgp_debug_update_prefixes
            && !list_isempty(bgp_debug_update_prefixes)) {
@@ -1411,15 +1398,10 @@ DEFUN (debug_bgp_zebra_prefix,
 {
        int idx_ipv4_ipv6_prefixlen = 4;
        struct prefix *argv_p;
-       int ret;
 
        argv_p = prefix_new();
-       ret = str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
-       if (!ret) {
-               prefix_free(argv_p);
-               vty_out(vty, "%% Malformed Prefix\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
+       (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
+       apply_mask(argv_p);
 
        if (!bgp_debug_zebra_prefixes)
                bgp_debug_zebra_prefixes = list_new();
@@ -1476,15 +1458,10 @@ DEFUN (no_debug_bgp_zebra_prefix,
        int idx_ipv4_ipv6_prefixlen = 5;
        struct prefix *argv_p;
        int found_prefix = 0;
-       int ret;
 
        argv_p = prefix_new();
-       ret = str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
-       if (!ret) {
-               prefix_free(argv_p);
-               vty_out(vty, "%% Malformed Prefix\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
+       (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
+       apply_mask(argv_p);
 
        if (bgp_debug_zebra_prefixes
            && !list_isempty(bgp_debug_zebra_prefixes)) {
index 1c6938523ccffd33699bc2d096d8da080084a768..8cccb62de33c59fa9a11bbec8fca10882ed570b1 100644 (file)
@@ -357,6 +357,7 @@ struct cmd_node {
 #define OSPF_RI_STR "OSPF Router Information specific commands\n"
 #define PCE_STR "PCE Router Information specific commands\n"
 #define MPLS_STR "MPLS information\n"
+#define WATCHFRR_STR "watchfrr information\n"
 
 #define CONF_BACKUP_EXT ".sav"
 
index 8f34b4cb3f0d73e214a66534e72082353848b464..afe66b6eafea5e818d937abc172eb767f1fda4ad 100755 (executable)
@@ -557,7 +557,15 @@ def line_for_vtysh_file(ctx_keys, line, delete):
             for ctx_key in ctx_keys:
                 cmd.append(ctx_key)
 
-    return '\n' + '\n'.join(cmd)
+    cmd = '\n' + '\n'.join(cmd)
+
+    # There are some commands that are on by default so their "no" form will be
+    # displayed in the config.  "no bgp default ipv4-unicast" is one of these.
+    # If we need to remove this line we do so by adding "bgp default ipv4-unicast",
+    # not by doing a "no no bgp default ipv4-unicast"
+    cmd = cmd.replace('no no ', '')
+
+    return cmd
 
 
 def get_normalized_ipv6_line(line):
@@ -931,6 +939,7 @@ def compare_context_objects(newconf, running):
 
     return (lines_to_add, lines_to_del)
 
+
 if __name__ == '__main__':
     # Command line options
     parser = argparse.ArgumentParser(description='Dynamically apply diff in frr configs')
@@ -1143,7 +1152,7 @@ if __name__ == '__main__':
 
                     while True:
                         try:
-                            _ = subprocess.check_output(cmd)
+                            _ = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 
                         except subprocess.CalledProcessError:
 
@@ -1188,7 +1197,7 @@ if __name__ == '__main__':
                             fh.write(line + '\n')
 
                     try:
-                        subprocess.check_output(['/usr/bin/vtysh', '-f', filename])
+                        subprocess.check_output(['/usr/bin/vtysh', '-f', filename], stderr=subprocess.STDOUT)
                     except subprocess.CalledProcessError as e:
                         log.warning("frr-reload.py failed due to\n%s" % e.output)
                         reload_ok = False
index fd9c017512c6edf690ffe3417f8ba40793a5dc7e..1f872c91ff08f796905d1d84ca52beb12d8bc810 100644 (file)
 pid_t integrated_write_pid;
 static int integrated_result_fd;
 
-DEFUN_NOSH(show_watchfrr_debugging,
-          show_watchfrr_debugging_cmd,
-          "show debugging [watchfrr]",
-          SHOW_STR
-          DEBUG_STR
-          "WatchFRR\n")
-{
-       return CMD_SUCCESS;
-}
-
 DEFUN(config_write_integrated,
       config_write_integrated_cmd,
       "write integrated",
@@ -111,6 +101,16 @@ DEFUN(config_write_integrated,
        exit(1);
 }
 
+DEFUN_NOSH (show_debugging_watchfrr,
+            show_debugging_watchfrr_cmd,
+            "show debugging [watchfrr]",
+            SHOW_STR
+            DEBUG_STR
+            WATCHFRR_STR)
+{
+       return CMD_SUCCESS;
+}
+
 void integrated_write_sigchld(int status)
 {
        uint8_t reply[4] = {0, 0, 0, CMD_WARNING};
@@ -144,5 +144,6 @@ void watchfrr_vty_init(void)
 {
        integrated_write_pid = -1;
        install_element(ENABLE_NODE, &config_write_integrated_cmd);
-       install_element(ENABLE_NODE, &show_watchfrr_debugging_cmd);
+       install_element(ENABLE_NODE, &show_debugging_watchfrr_cmd);
+       install_element(CONFIG_NODE, &show_debugging_watchfrr_cmd);
 }
index 4ba8585f3e86da135610f89db96ac766a6efd94f..ac96051abd8505b7101b94794aa91be4e9158494 100644 (file)
@@ -99,7 +99,7 @@ DEFUN (debug_zebra_events,
        "Debug option set for zebra events\n")
 {
        zebra_debug_event = ZEBRA_DEBUG_EVENT;
-       return CMD_WARNING_CONFIG_FAILED;
+       return CMD_SUCCESS;
 }
 
 DEFUN (debug_zebra_nht,
@@ -110,7 +110,7 @@ DEFUN (debug_zebra_nht,
        "Debug option set for zebra next hop tracking\n")
 {
        zebra_debug_nht = ZEBRA_DEBUG_NHT;
-       return CMD_WARNING_CONFIG_FAILED;
+       return CMD_SUCCESS;
 }
 
 DEFUN (debug_zebra_mpls,
@@ -121,7 +121,7 @@ DEFUN (debug_zebra_mpls,
        "Debug option set for zebra MPLS LSPs\n")
 {
        zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
-       return CMD_WARNING_CONFIG_FAILED;
+       return CMD_SUCCESS;
 }
 
 DEFUN (debug_zebra_vxlan,
@@ -132,7 +132,7 @@ DEFUN (debug_zebra_vxlan,
        "Debug option set for zebra VxLAN (EVPN)\n")
 {
        zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN;
-       return CMD_WARNING;
+       return CMD_SUCCESS;
 }
 
 DEFUN (debug_zebra_pw,
@@ -147,7 +147,7 @@ DEFUN (debug_zebra_pw,
                UNSET_FLAG(zebra_debug_pw, ZEBRA_DEBUG_PW);
        else
                SET_FLAG(zebra_debug_pw, ZEBRA_DEBUG_PW);
-       return CMD_WARNING;
+       return CMD_SUCCESS;
 }
 
 DEFUN (debug_zebra_packet,