pimd: Add "show ip pim rp-info" command

List the RP information we have configured.

Fix bug where we were not properly initializing some code

Ticket: CM-12617
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-08-23 16:22:14 -04:00 committed by Donald Sharp
parent bb6e291f3b
commit 00d07c6fda
4 changed files with 60 additions and 0 deletions

View file

@ -2004,6 +2004,19 @@ DEFUN (show_ip_pim_upstream_rpf,
return CMD_SUCCESS;
}
DEFUN (show_ip_pim_rp,
show_ip_pim_rp_cmd,
"show ip pim rp-info ",
SHOW_STR
IP_STR
PIM_STR
"PIM RP information\n")
{
pim_rp_show_information (vty);
return CMD_SUCCESS;
}
DEFUN (show_ip_pim_rpf,
show_ip_pim_rpf_cmd,
"show ip pim rpf",
@ -4863,6 +4876,7 @@ void pim_cmd_init()
install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
install_element (VIEW_NODE, &show_ip_pim_rp_cmd);
install_element (VIEW_NODE, &show_ip_multicast_cmd);
install_element (VIEW_NODE, &show_ip_mroute_cmd);
install_element (VIEW_NODE, &show_ip_mroute_count_cmd);

View file

@ -26,6 +26,8 @@
#include "linklist.h"
#include "prefix.h"
#include "memory.h"
#include "vty.h"
#include "vrf.h"
#include "pimd.h"
#include "pim_vty.h"
@ -35,6 +37,7 @@
#include "pim_rpf.h"
#include "pim_sock.h"
#include "pim_memory.h"
#include "pim_iface.h"
struct rp_info
{
@ -148,6 +151,24 @@ pim_rp_find_match_group (struct prefix *group)
return NULL;
}
static void
pim_rp_check_interfaces (struct rp_info *rp_info)
{
struct listnode *node;
struct interface *ifp;
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
{
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp)
continue;
if (pim_ifp->primary_address.s_addr == rp_info->rp.rpf_addr.s_addr)
rp_info->i_am_rp = 1;
}
}
int
pim_rp_new (const char *rp, const char *group_range)
{
@ -185,6 +206,7 @@ pim_rp_new (const char *rp, const char *group_range)
XFREE (MTYPE_PIM_RP, rp_info);
if (!pim_rp_setup ())
return -2;
pim_rp_check_interfaces (rp_all);
return 0;
}
@ -210,6 +232,7 @@ pim_rp_new (const char *rp, const char *group_range)
if (!pim_rp_setup ())
return -2;
pim_rp_check_interfaces (rp_info);
return 0;
}
@ -453,3 +476,22 @@ pim_rp_check_is_my_ip_address (struct in_addr group, struct in_addr dest_addr)
return 0;
}
void
pim_rp_show_information (struct vty *vty)
{
struct rp_info *rp_info;
struct listnode *node;
vty_out (vty, "RP Addr Group Oif I_am_RP%s", VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO (qpim_rp_list, node, rp_info))
{
char buf[48];
vty_out (vty, "%-10s %-10s %-10s%-10d%s",
inet_ntoa (rp_info->rp.rpf_addr),
prefix2str(&rp_info->group, buf, 48),
rp_info->rp.source_nexthop.interface->name,
rp_info->i_am_rp, VTY_NEWLINE);
}
return;
}

View file

@ -42,4 +42,6 @@ struct pim_rpf *pim_rp_g (struct in_addr group);
#define I_am_RP(G) pim_rp_i_am_rp ((G))
#define RP(G) pim_rp_g ((G))
void pim_rp_show_information (struct vty *vty);
#endif

View file

@ -506,6 +506,7 @@ static int on_rpf_cache_refresh(struct thread *t)
qpim_rpf_cache_refresh_last = pim_time_monotonic_sec();
++qpim_rpf_cache_refresh_events;
pim_rp_setup ();
return 0;
}
@ -659,6 +660,7 @@ static int redist_read_ipv4_route(int command, struct zclient *zclient,
sched_rpf_cache_refresh();
pim_rp_setup ();
return 0;
}