]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripd/rip_cli.c
ripd: fix null-pointer dereference
[mirror_frr.git] / ripd / rip_cli.c
index 58c28e54c0d4e0edc51c09d6393da55ea1fb7674..ac9fc4b1a818ba651e60f633bdbc5dee2bd0ddb5 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
  * Copyright (C) 2018  NetDEF, Inc.
  *                     Renato Westphal
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -30,9 +17,7 @@
 
 #include "ripd/ripd.h"
 #include "ripd/rip_nb.h"
-#ifndef VTYSH_EXTRACT_PL
 #include "ripd/rip_cli_clippy.c"
-#endif
 
 /*
  * XPath: /frr-ripd:ripd/instance
@@ -439,7 +424,7 @@ void cli_show_rip_non_passive_interface(struct vty *vty,
  */
 DEFPY_YANG (rip_redistribute,
        rip_redistribute_cmd,
-       "[no] redistribute " FRR_REDIST_STR_RIPD "$protocol [{metric (0-16)|route-map WORD}]",
+       "[no] redistribute " FRR_REDIST_STR_RIPD "$protocol [{metric (0-16)|route-map RMAP_NAME$route_map}]",
        NO_STR
        REDIST_STR
        FRR_REDIST_HELP_STR_RIPD
@@ -596,6 +581,42 @@ void cli_show_rip_version(struct vty *vty, const struct lyd_node *dnode,
        }
 }
 
+/*
+ * XPath: /frr-ripd:ripd/instance/default-bfd-profile
+ */
+DEFPY_YANG(rip_bfd_default_profile, rip_bfd_default_profile_cmd,
+          "bfd default-profile BFDPROF$profile",
+          "Bidirectional Forwarding Detection\n"
+          "BFD default profile\n"
+          "Profile name\n")
+{
+       nb_cli_enqueue_change(vty, "./default-bfd-profile", NB_OP_MODIFY,
+                             profile);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY_YANG(no_rip_bfd_default_profile, no_rip_bfd_default_profile_cmd,
+          "no bfd default-profile [BFDPROF]",
+          NO_STR
+          "Bidirectional Forwarding Detection\n"
+          "BFD default profile\n"
+          "Profile name\n")
+{
+       nb_cli_enqueue_change(vty, "./default-bfd-profile", NB_OP_DESTROY,
+                             NULL);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ripd_instance_default_bfd_profile(struct vty *vty,
+                                               const struct lyd_node *dnode,
+                                               bool show_defaults)
+{
+       vty_out(vty, " bfd default-profile %s\n",
+               yang_dnode_get_string(dnode, NULL));
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
  */
@@ -994,6 +1015,66 @@ void cli_show_ip_rip_authentication_key_chain(struct vty *vty,
                yang_dnode_get_string(dnode, NULL));
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable
+ */
+DEFPY_YANG(ip_rip_bfd, ip_rip_bfd_cmd, "[no] ip rip bfd",
+          NO_STR IP_STR
+          "Routing Information Protocol\n"
+          "Enable BFD support\n")
+{
+       nb_cli_enqueue_change(vty, "./bfd-monitoring/enable", NB_OP_MODIFY,
+                             no ? "false" : "true");
+
+       return nb_cli_apply_changes(vty, "./frr-ripd:rip");
+}
+
+void cli_show_ip_rip_bfd_enable(struct vty *vty, const struct lyd_node *dnode,
+                               bool show_defaults)
+{
+       vty_out(vty, " ip rip bfd\n");
+}
+
+/*
+ * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd/profile
+ */
+DEFPY_YANG(ip_rip_bfd_profile, ip_rip_bfd_profile_cmd,
+          "[no] ip rip bfd profile BFDPROF$profile",
+          NO_STR IP_STR
+          "Routing Information Protocol\n"
+          "Enable BFD support\n"
+          "Use a pre-configured profile\n"
+          "Profile name\n")
+{
+       if (no)
+               nb_cli_enqueue_change(vty, "./bfd-monitoring/profile",
+                                     NB_OP_DESTROY, NULL);
+       else
+               nb_cli_enqueue_change(vty, "./bfd-monitoring/profile",
+                                     NB_OP_MODIFY, profile);
+
+       return nb_cli_apply_changes(vty, "./frr-ripd:rip");
+}
+
+DEFPY_YANG(no_ip_rip_bfd_profile, no_ip_rip_bfd_profile_cmd,
+          "no ip rip bfd profile",
+          NO_STR IP_STR
+          "Routing Information Protocol\n"
+          "Enable BFD support\n"
+          "Use a pre-configured profile\n")
+{
+       nb_cli_enqueue_change(vty, "./bfd-monitoring/profile", NB_OP_DESTROY,
+                             NULL);
+       return nb_cli_apply_changes(vty, "./frr-ripd:rip");
+}
+
+void cli_show_ip_rip_bfd_profile(struct vty *vty, const struct lyd_node *dnode,
+                                bool show_defaults)
+{
+       vty_out(vty, " ip rip bfd profile %s\n",
+               yang_dnode_get_string(dnode, NULL));
+}
+
 /*
  * XPath: /frr-ripd:clear-rip-route
  */
@@ -1093,6 +1174,8 @@ void rip_cli_init(void)
        install_element(RIP_NODE, &no_rip_timers_cmd);
        install_element(RIP_NODE, &rip_version_cmd);
        install_element(RIP_NODE, &no_rip_version_cmd);
+       install_element(RIP_NODE, &rip_bfd_default_profile_cmd);
+       install_element(RIP_NODE, &no_rip_bfd_default_profile_cmd);
 
        install_element(INTERFACE_NODE, &ip_rip_split_horizon_cmd);
        install_element(INTERFACE_NODE, &ip_rip_v2_broadcast_cmd);
@@ -1107,6 +1190,9 @@ void rip_cli_init(void)
        install_element(INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd);
        install_element(INTERFACE_NODE,
                        &no_ip_rip_authentication_key_chain_cmd);
+       install_element(INTERFACE_NODE, &ip_rip_bfd_cmd);
+       install_element(INTERFACE_NODE, &ip_rip_bfd_profile_cmd);
+       install_element(INTERFACE_NODE, &no_ip_rip_bfd_profile_cmd);
 
        install_element(ENABLE_NODE, &clear_ip_rip_cmd);
 }