]> git.proxmox.com Git - mirror_frr.git/blobdiff - vrrpd/vrrp_vty.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / vrrpd / vrrp_vty.c
index aea7d9abc713f1184c5eb5e888ef07e6b9a7bc0a..7a17de747ce79cd25c64871b56831b37462f639c 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * VRRP CLI commands.
  * Copyright (C) 2018-2019 Cumulus Networks, Inc.
  * Quentin Young
- *
- * 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>
 
@@ -33,9 +20,7 @@
 #include "vrrp_debug.h"
 #include "vrrp_vty.h"
 #include "vrrp_zebra.h"
-#ifndef VTYSH_EXTRACT_PL
 #include "vrrpd/vrrp_vty_clippy.c"
-#endif
 
 
 #define VRRP_STR "Virtual Router Redundancy Protocol\n"
@@ -283,6 +268,35 @@ void cli_show_preempt(struct vty *vty, const struct lyd_node *dnode,
        vty_out(vty, " %svrrp %s preempt\n", pre ? "" : "no ", vrid);
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-vrrpd:vrrp/vrrp-group/checksum-with-
+ *        ipv4-pseudoheader
+ */
+DEFPY_YANG(vrrp_checksum_with_ipv4_pseudoheader,
+      vrrp_checksum_with_ipv4_pseudoheader_cmd,
+      "[no] vrrp (1-255)$vrid checksum-with-ipv4-pseudoheader",
+      NO_STR
+      VRRP_STR
+      VRRP_VRID_STR
+      "Checksum mode in VRRPv3\n")
+{
+       nb_cli_enqueue_change(vty, "./checksum-with-ipv4-pseudoheader",
+                             NB_OP_MODIFY, no ? "false" : "true");
+
+       return nb_cli_apply_changes(vty, VRRP_XPATH_ENTRY, vrid);
+}
+
+void cli_show_checksum_with_ipv4_pseudoheader(struct vty *vty,
+                                             const struct lyd_node *dnode,
+                                             bool show_defaults)
+{
+       const char *vrid = yang_dnode_get_string(dnode, "../virtual-router-id");
+       const bool pre = yang_dnode_get_bool(dnode, NULL);
+
+       vty_out(vty, " %svrrp %s checksum-with-ipv4-pseudoheader\n",
+               pre ? "" : "no ", vrid);
+}
+
 /* XXX: yang conversion */
 DEFPY_YANG(vrrp_autoconfigure,
       vrrp_autoconfigure_cmd,
@@ -306,7 +320,7 @@ DEFPY_YANG(vrrp_autoconfigure,
 /* XXX: yang conversion */
 DEFPY_YANG(vrrp_default,
       vrrp_default_cmd,
-      "[no] vrrp default <advertisement-interval$adv (10-40950)$advint|preempt$p|priority$prio (1-254)$prioval|shutdown$s>",
+      "[no] vrrp default <advertisement-interval$adv (10-40950)$advint|preempt$p|priority$prio (1-254)$prioval|checksum-with-ipv4-pseudoheader$ipv4ph|shutdown$s>",
       NO_STR
       VRRP_STR
       "Configure defaults for new VRRP instances\n"
@@ -315,6 +329,7 @@ DEFPY_YANG(vrrp_default,
       "Preempt mode\n"
       VRRP_PRIORITY_STR
       "Priority value\n"
+      "Checksum mode in VRRPv3\n"
       "Force VRRP router into administrative shutdown\n")
 {
        if (adv) {
@@ -331,6 +346,8 @@ DEFPY_YANG(vrrp_default,
                vd.preempt_mode = !no;
        if (prio)
                vd.priority = no ? VRRP_DEFAULT_PRIORITY : prioval;
+       if (ipv4ph)
+               vd.checksum_with_ipv4_pseudoheader = !no;
        if (s)
                vd.shutdown = !no;
 
@@ -376,6 +393,8 @@ static struct json_object *vrrp_build_json(struct vrrp_vrouter *vr)
        json_object_boolean_add(j, "shutdown", vr->shutdown);
        json_object_boolean_add(j, "preemptMode", vr->preempt_mode);
        json_object_boolean_add(j, "acceptMode", vr->accept_mode);
+       json_object_boolean_add(j, "checksumWithIpv4Pseudoheader",
+                               vr->checksum_with_ipv4_pseudoheader);
        json_object_string_add(j, "interface", vr->ifp->name);
        json_object_int_add(j, "advertisementInterval",
                            vr->advertisement_interval * CS2MS);
@@ -501,6 +520,8 @@ static void vrrp_show(struct vty *vty, struct vrrp_vrouter *vr)
                       vr->preempt_mode ? "Yes" : "No");
        ttable_add_row(tt, "%s|%s", "Accept Mode",
                       vr->accept_mode ? "Yes" : "No");
+       ttable_add_row(tt, "%s|%s", "Checksum with IPv4 Pseudoheader",
+                      vr->checksum_with_ipv4_pseudoheader ? "Yes" : "No");
        ttable_add_row(tt, "%s|%d ms", "Advertisement Interval",
                       vr->advertisement_interval * CS2MS);
        ttable_add_row(tt, "%s|%d ms (stale)",
@@ -754,4 +775,6 @@ void vrrp_vty_init(void)
        install_element(INTERFACE_NODE, &vrrp_ip_cmd);
        install_element(INTERFACE_NODE, &vrrp_ip6_cmd);
        install_element(INTERFACE_NODE, &vrrp_preempt_cmd);
+       install_element(INTERFACE_NODE,
+                       &vrrp_checksum_with_ipv4_pseudoheader_cmd);
 }