]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_vty.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_vty.c
index 58b0c9910a8d783786c0a3e4c36313689ddb19aa..6d6143002999e2c780be2d4ef8c85ca3f4e01057 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* Zebra VTY functions
  * Copyright (C) 2002 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra 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, or (at your option) any
- * later version.
- *
- * GNU Zebra 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>
@@ -34,6 +19,7 @@
 #include "srcdest_table.h"
 #include "vxlan.h"
 #include "termtable.h"
+#include "affinitymap.h"
 
 #include "zebra/zebra_router.h"
 #include "zebra/zserv.h"
@@ -41,6 +27,7 @@
 #include "zebra/zebra_mpls.h"
 #include "zebra/zebra_rnh.h"
 #include "zebra/redistribute.h"
+#include "zebra/zebra_affinitymap.h"
 #include "zebra/zebra_routemap.h"
 #include "lib/json.h"
 #include "lib/route_opaque.h"
@@ -144,11 +131,12 @@ DEFUN (no_ip_multicast_mode,
 }
 
 
-DEFUN (show_ip_rpf,
+DEFPY (show_ip_rpf,
        show_ip_rpf_cmd,
-       "show ip rpf [json]",
+       "show [ip$ip|ipv6$ipv6] rpf [json]",
        SHOW_STR
        IP_STR
+       IPV6_STR
        "Display RPF information for multicast source\n"
        JSON_STR)
 {
@@ -157,32 +145,46 @@ DEFUN (show_ip_rpf,
                .multi = false,
        };
 
-       return do_show_ip_route(vty, VRF_DEFAULT_NAME, AFI_IP, SAFI_MULTICAST,
-                               false, uj, 0, NULL, false, 0, 0, 0, false,
-                               &ctx);
+       return do_show_ip_route(vty, VRF_DEFAULT_NAME, ip ? AFI_IP : AFI_IP6,
+                               SAFI_MULTICAST, false, uj, 0, NULL, false, 0, 0,
+                               0, false, &ctx);
 }
 
-DEFUN (show_ip_rpf_addr,
+DEFPY (show_ip_rpf_addr,
        show_ip_rpf_addr_cmd,
-       "show ip rpf A.B.C.D",
+       "show ip rpf A.B.C.D$address",
        SHOW_STR
        IP_STR
        "Display RPF information for multicast source\n"
        "IP multicast source address (e.g. 10.0.0.0)\n")
 {
-       int idx_ipv4 = 3;
-       struct in_addr addr;
        struct route_node *rn;
        struct route_entry *re;
-       int ret;
 
-       ret = inet_aton(argv[idx_ipv4]->arg, &addr);
-       if (ret == 0) {
-               vty_out(vty, "%% Malformed address\n");
-               return CMD_WARNING;
-       }
+       re = rib_match_multicast(AFI_IP, VRF_DEFAULT, (union g_addr *)&address,
+                                &rn);
+
+       if (re)
+               vty_show_ip_route_detail(vty, rn, 1, false, false);
+       else
+               vty_out(vty, "%% No match for RPF lookup\n");
 
-       re = rib_match_ipv4_multicast(VRF_DEFAULT, addr, &rn);
+       return CMD_SUCCESS;
+}
+
+DEFPY (show_ipv6_rpf_addr,
+       show_ipv6_rpf_addr_cmd,
+       "show ipv6 rpf X:X::X:X$address",
+       SHOW_STR
+       IPV6_STR
+       "Display RPF information for multicast source\n"
+       "IPv6 multicast source address\n")
+{
+       struct route_node *rn;
+       struct route_entry *re;
+
+       re = rib_match_multicast(AFI_IP6, VRF_DEFAULT, (union g_addr *)&address,
+                                &rn);
 
        if (re)
                vty_show_ip_route_detail(vty, rn, 1, false, false);
@@ -4554,6 +4556,8 @@ void zebra_vty_init(void)
        /* Route-map */
        zebra_route_map_init();
 
+       zebra_affinity_map_init();
+
        install_node(&ip_node);
        install_node(&protocol_node);
 
@@ -4587,6 +4591,7 @@ void zebra_vty_init(void)
 
        install_element(VIEW_NODE, &show_ip_rpf_cmd);
        install_element(VIEW_NODE, &show_ip_rpf_addr_cmd);
+       install_element(VIEW_NODE, &show_ipv6_rpf_addr_cmd);
 
        install_element(CONFIG_NODE, &ip_nht_default_route_cmd);
        install_element(CONFIG_NODE, &no_ip_nht_default_route_cmd);