]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_cmd.c
Merge pull request #1069 from donaldsharp/rfc_plist
[mirror_frr.git] / pimd / pim_cmd.c
index 6111eed5885bfa22170f7ba94593d0f07a848436..396b949e4f905237fb7211bcca411ecba525e0fc 100644 (file)
@@ -28,6 +28,7 @@
 #include "hash.h"
 #include "nexthop.h"
 #include "vrf.h"
+#include "ferr.h"
 
 #include "pimd.h"
 #include "pim_mroute.h"
@@ -227,7 +228,7 @@ static void pim_show_assert(struct pim_instance *pim, struct vty *vty)
                if (!pim_ifp)
                        continue;
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
                        pim_show_assert_helper(vty, pim_ifp, ch, now);
                } /* scan interface channels */
        }
@@ -279,7 +280,7 @@ static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty)
                if (!pim_ifp)
                        continue;
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
                        pim_show_assert_internal_helper(vty, pim_ifp, ch);
                } /* scan interface channels */
        }
@@ -328,7 +329,7 @@ static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
                if (!pim_ifp)
                        continue;
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
                        pim_show_assert_metric_helper(vty, pim_ifp, ch);
                } /* scan interface channels */
        }
@@ -391,7 +392,7 @@ static void pim_show_assert_winner_metric(struct pim_instance *pim,
                if (!pim_ifp)
                        continue;
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
                        pim_show_assert_winner_metric_helper(vty, pim_ifp, ch);
                } /* scan interface channels */
        }
@@ -481,7 +482,7 @@ static void pim_show_membership(struct pim_instance *pim, struct vty *vty,
                if (!pim_ifp)
                        continue;
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
                        pim_show_membership_helper(vty, pim_ifp, ch, json);
                } /* scan interface channels */
        }
@@ -1697,9 +1698,8 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)
                if (!pim_ifp)
                        continue;
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
-                       pim_show_join_helper(vty, pim_ifp,
-                                            ch, json, now, uj);
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+                       pim_show_join_helper(vty, pim_ifp, ch, json, now, uj);
                } /* scan interface channels */
        }
 
@@ -2527,7 +2527,7 @@ static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,
                        continue;
 
 
-               RB_FOREACH(ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
+               RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
                        /* scan all interfaces */
                        pim_show_join_desired_helper(pim, vty,
                                                     pim_ifp, ch,
@@ -3160,6 +3160,14 @@ static void clear_interfaces(struct pim_instance *pim)
        clear_pim_interfaces(pim);
 }
 
+#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp)                                     \
+       pim_ifp = ifp->info;                                                    \
+       if (!pim_ifp) {                                                         \
+               vty_out(vty,                                                    \
+                       "%% Enable PIM and/or IGMP on this interface first\n"); \
+               return CMD_WARNING_CONFIG_FAILED;                               \
+       }
+
 DEFUN (clear_ip_interfaces,
        clear_ip_interfaces_cmd,
        "clear ip interfaces [vrf NAME]",
@@ -3392,8 +3400,7 @@ DEFUN (show_ip_igmp_interface_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -3449,8 +3456,7 @@ DEFUN (show_ip_igmp_join_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -3504,8 +3510,7 @@ DEFUN (show_ip_igmp_groups_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -3710,8 +3715,7 @@ DEFUN (show_ip_pim_interface_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -3770,8 +3774,7 @@ DEFUN (show_ip_pim_join_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -3856,8 +3859,7 @@ DEFUN (show_ip_pim_neighbor_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -3963,8 +3965,7 @@ DEFUN (show_ip_pim_state_vrf_all,
                        group = argv[idx + 1]->arg;
        }
 
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -4018,8 +4019,7 @@ DEFUN (show_ip_pim_upstream_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -4115,8 +4115,7 @@ DEFUN (show_ip_pim_rp_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -4170,8 +4169,7 @@ DEFUN (show_ip_pim_rpf_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -4437,8 +4435,7 @@ DEFUN (show_ip_multicast_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -4813,8 +4810,7 @@ DEFUN (show_ip_mroute_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -4895,6 +4891,9 @@ DEFUN (show_ip_mroute_count,
        int idx = 2;
        struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
 
+       if (!vrf)
+               return CMD_WARNING;
+
        show_mroute_count(vrf->info, vty);
        return CMD_SUCCESS;
 }
@@ -4914,8 +4913,7 @@ DEFUN (show_ip_mroute_count_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -5836,13 +5834,8 @@ DEFUN (interface_ip_igmp_join,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
-       if (result) {
-               vty_out(vty,
-                       "%% Failure joining IGMP group %s source %s on interface %s: %d\n",
-                       group_str, source_str, ifp->name, result);
-               return CMD_WARNING_CONFIG_FAILED;
-       }
+       CMD_FERR_RETURN(pim_if_igmp_join_add(ifp, group_addr, source_addr),
+                       "Failure joining IGMP group: $ERR");
 
        return CMD_SUCCESS;
 }
@@ -6489,7 +6482,7 @@ DEFUN (interface_ip_mroute,
        struct in_addr src_addr;
        int result;
 
-       pim_ifp = iif->info;
+       PIM_GET_PIM_INTERFACE(pim_ifp, iif);
        pim = pim_ifp->pim;
 
        oifname = argv[idx_interface]->arg;
@@ -6540,7 +6533,7 @@ DEFUN (interface_ip_mroute_source,
        struct in_addr src_addr;
        int result;
 
-       pim_ifp = iif->info;
+       PIM_GET_PIM_INTERFACE(pim_ifp, iif);
        pim = pim_ifp->pim;
 
        oifname = argv[idx_interface]->arg;
@@ -6595,7 +6588,7 @@ DEFUN (interface_no_ip_mroute,
        struct in_addr src_addr;
        int result;
 
-       pim_ifp = iif->info;
+       PIM_GET_PIM_INTERFACE(pim_ifp, iif);
        pim = pim_ifp->pim;
 
        oifname = argv[idx_interface]->arg;
@@ -6647,7 +6640,7 @@ DEFUN (interface_no_ip_mroute_source,
        struct in_addr src_addr;
        int result;
 
-       pim_ifp = iif->info;
+       PIM_GET_PIM_INTERFACE(pim_ifp, iif);
        pim = pim_ifp->pim;
 
        oifname = argv[idx_interface]->arg;
@@ -6956,6 +6949,31 @@ DEFUN (no_debug_pim_nht,
        return CMD_SUCCESS;
 }
 
+DEFUN (debug_pim_nht_rp,
+       debug_pim_nht_rp_cmd,
+       "debug pim nht rp",
+       DEBUG_STR
+       DEBUG_PIM_STR
+       "Nexthop Tracking\n"
+       "RP Nexthop Tracking\n")
+{
+       PIM_DO_DEBUG_PIM_NHT_RP;
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_pim_nht_rp,
+       no_debug_pim_nht_rp_cmd,
+       "no debug pim nht rp",
+       NO_STR
+       DEBUG_STR
+       DEBUG_PIM_STR
+       "Nexthop Tracking\n"
+       "RP Nexthop Tracking\n")
+{
+       PIM_DONT_DEBUG_PIM_NHT_RP;
+       return CMD_SUCCESS;
+}
+
 DEFUN (debug_pim_events,
        debug_pim_events_cmd,
        "debug pim events",
@@ -7830,8 +7848,7 @@ DEFUN (show_ip_msdp_mesh_group_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -8059,8 +8076,7 @@ DEFUN (show_ip_msdp_peer_detail_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -8289,8 +8305,7 @@ DEFUN (show_ip_msdp_sa_detail_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
-       {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -8426,7 +8441,7 @@ DEFUN (show_ip_msdp_sa_sg_vrf_all,
 
        if (uj)
                vty_out(vty, "{ ");
-       RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                if (uj) {
                        if (!first)
                                vty_out(vty, ", ");
@@ -8625,6 +8640,8 @@ void pim_cmd_init(void)
        install_element(ENABLE_NODE, &no_debug_pim_cmd);
        install_element(ENABLE_NODE, &debug_pim_nht_cmd);
        install_element(ENABLE_NODE, &no_debug_pim_nht_cmd);
+       install_element(ENABLE_NODE, &debug_pim_nht_rp_cmd);
+       install_element(ENABLE_NODE, &no_debug_pim_nht_rp_cmd);
        install_element(ENABLE_NODE, &debug_pim_events_cmd);
        install_element(ENABLE_NODE, &no_debug_pim_events_cmd);
        install_element(ENABLE_NODE, &debug_pim_packets_cmd);
@@ -8669,6 +8686,8 @@ void pim_cmd_init(void)
        install_element(CONFIG_NODE, &no_debug_pim_cmd);
        install_element(CONFIG_NODE, &debug_pim_nht_cmd);
        install_element(CONFIG_NODE, &no_debug_pim_nht_cmd);
+       install_element(CONFIG_NODE, &debug_pim_nht_rp_cmd);
+       install_element(CONFIG_NODE, &no_debug_pim_nht_rp_cmd);
        install_element(CONFIG_NODE, &debug_pim_events_cmd);
        install_element(CONFIG_NODE, &no_debug_pim_events_cmd);
        install_element(CONFIG_NODE, &debug_pim_packets_cmd);