summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-05-20 19:43:58 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-07-24 19:51:36 +0200
commitd9c9a9ee063076ebc5df578049bf95cc19a35d2d (patch)
tree44419e3a6dd73941403b5caa08d16b08952933ac
parentpimd: Remove pimg from pim_upstream.c (diff)
downloadfrr-d9c9a9ee063076ebc5df578049bf95cc19a35d2d.tar.xz
frr-d9c9a9ee063076ebc5df578049bf95cc19a35d2d.zip
pimd: Convert pim_rp.c to use 'struct pim_instance *'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--pimd/pim_cmd.c6
-rw-r--r--pimd/pim_instance.c5
-rw-r--r--pimd/pim_instance.h2
-rw-r--r--pimd/pim_mroute.c8
-rw-r--r--pimd/pim_msdp.c4
-rw-r--r--pimd/pim_register.c2
-rw-r--r--pimd/pim_rp.c121
-rw-r--r--pimd/pim_rp.h21
-rw-r--r--pimd/pim_rpf.c4
-rw-r--r--pimd/pim_rpf.h4
-rw-r--r--pimd/pim_upstream.c15
-rw-r--r--pimd/pim_vty.c2
-rw-r--r--pimd/pim_zebra.c7
-rw-r--r--pimd/pimd.c19
14 files changed, 120 insertions, 100 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index cb72dbd45..d497f9967 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -3506,7 +3506,7 @@ DEFUN (show_ip_pim_rp,
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- pim_rp_show_information(vty, uj);
+ pim_rp_show_information(pimg, vty, uj);
return CMD_SUCCESS;
}
@@ -3588,7 +3588,7 @@ DEFUN (show_ip_pim_nexthop_lookup,
return CMD_WARNING;
}
- if (!pim_rp_set_upstream_addr(&vif_source, src_addr, grp_addr))
+ if (!pim_rp_set_upstream_addr(pimg, &vif_source, src_addr, grp_addr))
return CMD_SUCCESS;
memset(&pnc, 0, sizeof(struct pim_nexthop_cache));
@@ -4210,7 +4210,7 @@ DEFUN (show_ip_rib,
return CMD_WARNING;
}
- if (pim_nexthop_lookup(&nexthop, addr, 0)) {
+ if (pim_nexthop_lookup(pimg, &nexthop, addr, 0)) {
vty_out(vty,
"Failure querying RIB nexthop for unicast address %s\n",
addr_str);
diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c
index c2ca20d81..398cf85fc 100644
--- a/pimd/pim_instance.c
+++ b/pimd/pim_instance.c
@@ -48,6 +48,8 @@ static void pim_instance_terminate(struct pim_instance *pim)
if (pim->static_routes)
list_free(pim->static_routes);
+ pim_rp_free(pim);
+
pim_upstream_terminate(pim);
XFREE(MTYPE_PIM_PIM_INSTANCE, pimg);
@@ -95,7 +97,10 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
pim_mroute_socket_enable(pim);
+ pim_rp_init(pim);
+
pim_upstream_init(pim);
+
return pim;
}
diff --git a/pimd/pim_instance.h b/pimd/pim_instance.h
index 79a0de79b..5df76952a 100644
--- a/pimd/pim_instance.h
+++ b/pimd/pim_instance.h
@@ -61,6 +61,8 @@ struct pim_instance {
struct list *upstream_list;
struct hash *upstream_hash;
struct timer_wheel *upstream_sg_wheel;
+
+ struct list *rp_list;
};
void pim_vrf_init(void);
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index c77f312c9..8b9269518 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -462,8 +462,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
*/
if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) {
// No if channel, but upstream we are at the RP.
- if (pim_nexthop_lookup(&source, up->upstream_register,
- 0)
+ if (pim_nexthop_lookup(pim_ifp->pim, &source,
+ up->upstream_register, 0)
== 0)
pim_register_stop_send(source.interface, &sg,
pim_ifp->primary_address,
@@ -477,8 +477,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
__PRETTY_FUNCTION__);
pim_upstream_set_sptbit(up, ifp);
} else {
- if (I_am_RP(up->sg.grp)) {
- if (pim_nexthop_lookup(&source,
+ if (I_am_RP(pim_ifp->pim, up->sg.grp)) {
+ if (pim_nexthop_lookup(pim_ifp->pim, &source,
up->upstream_register, 0)
== 0)
pim_register_stop_send(
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 3f8ab3749..8e118ae3a 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -138,7 +138,7 @@ static bool pim_msdp_sa_upstream_add_ok(struct pim_msdp_sa *sa,
return false;
}
/* check if we are RP */
- if (!I_am_RP(sa->sg.grp)) {
+ if (!I_am_RP(pimg, sa->sg.grp)) {
return false;
}
@@ -447,7 +447,7 @@ static bool pim_msdp_sa_local_add_ok(struct pim_upstream *up)
return false;
}
- if (!I_am_RP(up->sg.grp)) {
+ if (!I_am_RP(pimg, up->sg.grp)) {
/* we are not RP for the group */
return false;
}
diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index ce81db954..bc7c5e3e0 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -320,7 +320,7 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
sg.src = ip_hdr->ip_src;
sg.grp = ip_hdr->ip_dst;
- i_am_rp = I_am_RP(sg.grp);
+ i_am_rp = I_am_RP(pim_ifp->pim, sg.grp);
if (PIM_DEBUG_PIM_REG) {
char src_str[INET_ADDRSTRLEN];
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 0b154fb55..969b28f7f 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -45,9 +45,6 @@
#include "pim_nht.h"
-static struct list *qpim_rp_list = NULL;
-static struct rp_info *tail = NULL;
-
/* Cleanup pim->rpf_hash each node data */
void pim_rp_list_hash_clean(void *data)
{
@@ -93,13 +90,13 @@ int pim_rp_list_cmp(void *v1, void *v2)
return 0;
}
-void pim_rp_init(void)
+void pim_rp_init(struct pim_instance *pim)
{
struct rp_info *rp_info;
- qpim_rp_list = list_new();
- qpim_rp_list->del = (void (*)(void *))pim_rp_info_free;
- qpim_rp_list->cmp = pim_rp_list_cmp;
+ pim->rp_list = list_new();
+ pim->rp_list->del = (void (*)(void *))pim_rp_info_free;
+ pim->rp_list->cmp = pim_rp_list_cmp;
rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info));
@@ -114,28 +111,28 @@ void pim_rp_init(void)
rp_info->rp.rpf_addr.family = AF_INET;
rp_info->rp.rpf_addr.prefixlen = IPV4_MAX_PREFIXLEN;
rp_info->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE;
- tail = rp_info;
- listnode_add(qpim_rp_list, rp_info);
+ listnode_add(pim->rp_list, rp_info);
}
-void pim_rp_free(void)
+void pim_rp_free(struct pim_instance *pim)
{
- if (qpim_rp_list)
- list_delete(qpim_rp_list);
- qpim_rp_list = NULL;
+ if (pim->rp_list)
+ list_delete(pim->rp_list);
+ pim->rp_list = NULL;
}
/*
* Given an RP's prefix-list, return the RP's rp_info for that prefix-list
*/
-static struct rp_info *pim_rp_find_prefix_list(struct in_addr rp,
+static struct rp_info *pim_rp_find_prefix_list(struct pim_instance *pim,
+ struct in_addr rp,
const char *plist)
{
struct listnode *node;
struct rp_info *rp_info;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp.s_addr == rp_info->rp.rpf_addr.u.prefix4.s_addr
&& rp_info->plist && strcmp(rp_info->plist, plist) == 0) {
return rp_info;
@@ -148,12 +145,12 @@ static struct rp_info *pim_rp_find_prefix_list(struct in_addr rp,
/*
* Return true if plist is used by any rp_info
*/
-static int pim_rp_prefix_list_used(const char *plist)
+static int pim_rp_prefix_list_used(struct pim_instance *pim, const char *plist)
{
struct listnode *node;
struct rp_info *rp_info;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->plist && strcmp(rp_info->plist, plist) == 0) {
return 1;
}
@@ -166,13 +163,14 @@ static int pim_rp_prefix_list_used(const char *plist)
* Given an RP's address, return the RP's rp_info that is an exact match for
* 'group'
*/
-static struct rp_info *pim_rp_find_exact(struct in_addr rp,
+static struct rp_info *pim_rp_find_exact(struct pim_instance *pim,
+ struct in_addr rp,
struct prefix *group)
{
struct listnode *node;
struct rp_info *rp_info;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp.s_addr == rp_info->rp.rpf_addr.u.prefix4.s_addr
&& prefix_same(&rp_info->group, group))
return rp_info;
@@ -184,13 +182,14 @@ static struct rp_info *pim_rp_find_exact(struct in_addr rp,
/*
* Given a group, return the rp_info for that group
*/
-static struct rp_info *pim_rp_find_match_group(struct prefix *group)
+static struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
+ struct prefix *group)
{
struct listnode *node;
struct rp_info *rp_info;
struct prefix_list *plist;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->plist) {
plist = prefix_list_lookup(AFI_IP, rp_info->plist);
@@ -218,13 +217,14 @@ static void pim_rp_refresh_group_to_rp_mapping()
pim_msdp_i_am_rp_changed();
}
-void pim_rp_prefix_list_update(struct prefix_list *plist)
+void pim_rp_prefix_list_update(struct pim_instance *pim,
+ struct prefix_list *plist)
{
struct listnode *node;
struct rp_info *rp_info;
int refresh_needed = 0;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->plist
&& strcmp(rp_info->plist, prefix_list_name(plist)) == 0) {
refresh_needed = 1;
@@ -319,7 +319,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
/*
* Return if the prefix-list is already configured for this RP
*/
- if (pim_rp_find_prefix_list(rp_info->rp.rpf_addr.u.prefix4,
+ if (pim_rp_find_prefix_list(pim, rp_info->rp.rpf_addr.u.prefix4,
plist)) {
XFREE(MTYPE_PIM_RP, rp_info);
return PIM_SUCCESS;
@@ -328,7 +328,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
/*
* Barf if the prefix-list is already configured for an RP
*/
- if (pim_rp_prefix_list_used(plist)) {
+ if (pim_rp_prefix_list_used(pim, plist)) {
XFREE(MTYPE_PIM_RP, rp_info);
return PIM_RP_PFXLIST_IN_USE;
}
@@ -336,7 +336,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
/*
* Free any existing rp_info entries for this RP
*/
- for (ALL_LIST_ELEMENTS(qpim_rp_list, node, nnode,
+ for (ALL_LIST_ELEMENTS(pim->rp_list, node, nnode,
tmp_rp_info)) {
if (rp_info->rp.rpf_addr.u.prefix4.s_addr
== tmp_rp_info->rp.rpf_addr.u.prefix4.s_addr) {
@@ -358,7 +358,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
XFREE(MTYPE_PIM_RP, rp_info);
return PIM_GROUP_BAD_ADDRESS;
}
- rp_all = pim_rp_find_match_group(&group_all);
+ rp_all = pim_rp_find_match_group(pim, &group_all);
/*
* Barf if group is a non-multicast subnet
@@ -371,7 +371,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
/*
* Remove any prefix-list rp_info entries for this RP
*/
- for (ALL_LIST_ELEMENTS(qpim_rp_list, node, nnode,
+ for (ALL_LIST_ELEMENTS(pim->rp_list, node, nnode,
tmp_rp_info)) {
if (tmp_rp_info->plist
&& rp_info->rp.rpf_addr.u.prefix4.s_addr
@@ -413,7 +413,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
return PIM_RP_NO_PATH;
} else {
if (pim_nexthop_lookup(
- &rp_all->rp.source_nexthop,
+ pim, &rp_all->rp.source_nexthop,
rp_all->rp.rpf_addr.u.prefix4, 1)
!= 0)
return PIM_RP_NO_PATH;
@@ -426,7 +426,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
/*
* Return if the group is already configured for this RP
*/
- if (pim_rp_find_exact(rp_info->rp.rpf_addr.u.prefix4,
+ if (pim_rp_find_exact(pim, rp_info->rp.rpf_addr.u.prefix4,
&rp_info->group)) {
XFREE(MTYPE_PIM_RP, rp_info);
return PIM_SUCCESS;
@@ -435,7 +435,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
/*
* Barf if this group is already covered by some other RP
*/
- tmp_rp_info = pim_rp_find_match_group(&rp_info->group);
+ tmp_rp_info = pim_rp_find_match_group(pim, &rp_info->group);
if (tmp_rp_info) {
if (tmp_rp_info->plist) {
@@ -458,7 +458,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
}
}
- listnode_add_sort(qpim_rp_list, rp_info);
+ listnode_add_sort(pim->rp_list, rp_info);
/* Register addr with Zebra NHT */
nht_p.family = AF_INET;
@@ -480,7 +480,7 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,
&nht_p, &rp_info->group, 1))
return PIM_RP_NO_PATH;
} else {
- if (pim_nexthop_lookup(&rp_info->rp.source_nexthop,
+ if (pim_nexthop_lookup(pim, &rp_info->rp.source_nexthop,
rp_info->rp.rpf_addr.u.prefix4, 1)
!= 0)
return PIM_RP_NO_PATH;
@@ -515,9 +515,9 @@ int pim_rp_del(struct pim_instance *pim, const char *rp,
return PIM_RP_BAD_ADDRESS;
if (plist)
- rp_info = pim_rp_find_prefix_list(rp_addr, plist);
+ rp_info = pim_rp_find_prefix_list(pim, rp_addr, plist);
else
- rp_info = pim_rp_find_exact(rp_addr, &group);
+ rp_info = pim_rp_find_exact(pim, rp_addr, &group);
if (!rp_info)
return PIM_RP_NOT_FOUND;
@@ -540,7 +540,7 @@ int pim_rp_del(struct pim_instance *pim, const char *rp,
pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info);
str2prefix("224.0.0.0/4", &g_all);
- rp_all = pim_rp_find_match_group(&g_all);
+ rp_all = pim_rp_find_match_group(pim, &g_all);
if (rp_all == rp_info) {
rp_all->rp.rpf_addr.family = AF_INET;
@@ -549,7 +549,7 @@ int pim_rp_del(struct pim_instance *pim, const char *rp,
return PIM_SUCCESS;
}
- listnode_delete(qpim_rp_list, rp_info);
+ listnode_delete(pim->rp_list, rp_info);
pim_rp_refresh_group_to_rp_mapping();
return PIM_SUCCESS;
}
@@ -561,7 +561,7 @@ void pim_rp_setup(struct pim_instance *pim)
struct prefix nht_p;
struct pim_nexthop_cache pnc;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE)
continue;
@@ -581,10 +581,9 @@ void pim_rp_setup(struct pim_instance *pim)
"%s: NHT Local Nexthop not found for RP %s ",
__PRETTY_FUNCTION__, buf);
}
- if (pim_nexthop_lookup(&rp_info->rp.source_nexthop,
- rp_info->rp.rpf_addr.u.prefix4,
- 1)
- != 0)
+ if (!pim_nexthop_lookup(
+ pim, &rp_info->rp.source_nexthop,
+ rp_info->rp.rpf_addr.u.prefix4, 1))
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"Unable to lookup nexthop for rp specified");
@@ -601,11 +600,12 @@ void pim_rp_check_on_if_add(struct pim_interface *pim_ifp)
struct listnode *node;
struct rp_info *rp_info;
bool i_am_rp_changed = false;
+ struct pim_instance *pim = pim_ifp->pim;
- if (qpim_rp_list == NULL)
+ if (pim->rp_list == NULL)
return;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (pim_rpf_addr_is_inaddr_none(&rp_info->rp))
continue;
@@ -643,10 +643,10 @@ void pim_i_am_rp_re_evaluate(struct pim_instance *pim)
bool i_am_rp_changed = false;
int old_i_am_rp;
- if (qpim_rp_list == NULL)
+ if (pim->rp_list == NULL)
return;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (pim_rpf_addr_is_inaddr_none(&rp_info->rp))
continue;
@@ -681,7 +681,7 @@ void pim_i_am_rp_re_evaluate(struct pim_instance *pim)
*
* Since we only have static RP, all groups are part of this RP
*/
-int pim_rp_i_am_rp(struct in_addr group)
+int pim_rp_i_am_rp(struct pim_instance *pim, struct in_addr group)
{
struct prefix g;
struct rp_info *rp_info;
@@ -691,7 +691,7 @@ int pim_rp_i_am_rp(struct in_addr group)
g.prefixlen = 32;
g.u.prefix4 = group;
- rp_info = pim_rp_find_match_group(&g);
+ rp_info = pim_rp_find_match_group(pim, &g);
if (rp_info)
return rp_info->i_am_rp;
@@ -714,7 +714,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)
g.prefixlen = 32;
g.u.prefix4 = group;
- rp_info = pim_rp_find_match_group(&g);
+ rp_info = pim_rp_find_match_group(pim, &g);
if (rp_info) {
struct prefix nht_p;
@@ -748,7 +748,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)
__PRETTY_FUNCTION__, buf, buf1);
}
pim_rpf_set_refresh_time();
- pim_nexthop_lookup(&rp_info->rp.source_nexthop,
+ pim_nexthop_lookup(pim, &rp_info->rp.source_nexthop,
rp_info->rp.rpf_addr.u.prefix4, 1);
}
return (&rp_info->rp);
@@ -766,8 +766,8 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)
* then return failure.
*
*/
-int pim_rp_set_upstream_addr(struct in_addr *up, struct in_addr source,
- struct in_addr group)
+int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up,
+ struct in_addr source, struct in_addr group)
{
struct rp_info *rp_info;
struct prefix g;
@@ -777,7 +777,7 @@ int pim_rp_set_upstream_addr(struct in_addr *up, struct in_addr source,
g.prefixlen = 32;
g.u.prefix4 = group;
- rp_info = pim_rp_find_match_group(&g);
+ rp_info = pim_rp_find_match_group(pim, &g);
if ((pim_rpf_addr_is_inaddr_none(&rp_info->rp))
&& (source.s_addr == INADDR_ANY)) {
@@ -793,7 +793,7 @@ int pim_rp_set_upstream_addr(struct in_addr *up, struct in_addr source,
return 1;
}
-int pim_rp_config_write(struct vty *vty)
+int pim_rp_config_write(struct pim_instance *pim, struct vty *vty)
{
struct listnode *node;
struct rp_info *rp_info;
@@ -801,7 +801,7 @@ int pim_rp_config_write(struct vty *vty)
char group_buffer[32];
int count = 0;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (pim_rpf_addr_is_inaddr_none(&rp_info->rp))
continue;
@@ -835,14 +835,14 @@ int pim_rp_check_is_my_ip_address(struct pim_instance *pim,
g.prefixlen = 32;
g.u.prefix4 = group;
- rp_info = pim_rp_find_match_group(&g);
+ rp_info = pim_rp_find_match_group(pim, &g);
/*
* See if we can short-cut some?
* This might not make sense if we ever leave a static RP
* type of configuration.
* Note - Premature optimization might bite our patooeys' here.
*/
- if (I_am_RP(group)) {
+ if (I_am_RP(pim, group)) {
if (dest_addr.s_addr == rp_info->rp.rpf_addr.u.prefix4.s_addr)
return 1;
}
@@ -853,7 +853,8 @@ int pim_rp_check_is_my_ip_address(struct pim_instance *pim,
return 0;
}
-void pim_rp_show_information(struct vty *vty, u_char uj)
+void pim_rp_show_information(struct pim_instance *pim, struct vty *vty,
+ u_char uj)
{
struct rp_info *rp_info;
struct rp_info *prev_rp_info = NULL;
@@ -869,7 +870,7 @@ void pim_rp_show_information(struct vty *vty, u_char uj)
vty_out(vty,
"RP address group/prefix-list OIF I am RP\n");
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (!pim_rpf_addr_is_inaddr_none(&rp_info->rp)) {
char buf[48];
@@ -968,7 +969,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim)
struct pim_nexthop_cache pnc;
struct pim_neighbor *nbr = NULL;
- for (ALL_LIST_ELEMENTS_RO(qpim_rp_list, node, rp_info)) {
+ for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE)
continue;
diff --git a/pimd/pim_rp.h b/pimd/pim_rp.h
index 10346a3c3..40062c3d5 100644
--- a/pimd/pim_rp.h
+++ b/pimd/pim_rp.h
@@ -34,21 +34,23 @@ struct rp_info {
char *plist;
};
-void pim_rp_init(void);
-void pim_rp_free(void);
+void pim_rp_init(struct pim_instance *pim);
+void pim_rp_free(struct pim_instance *pim);
+
void pim_rp_list_hash_clean(void *data);
int pim_rp_new(struct pim_instance *pim, const char *rp, const char *group,
const char *plist);
int pim_rp_del(struct pim_instance *pim, const char *rp, const char *group,
const char *plist);
-void pim_rp_prefix_list_update(struct prefix_list *plist);
+void pim_rp_prefix_list_update(struct pim_instance *pim,
+ struct prefix_list *plist);
-int pim_rp_config_write(struct vty *vty);
+int pim_rp_config_write(struct pim_instance *pim, struct vty *vty);
void pim_rp_setup(struct pim_instance *pim);
-int pim_rp_i_am_rp(struct in_addr group);
+int pim_rp_i_am_rp(struct pim_instance *pim, struct in_addr group);
void pim_rp_check_on_if_add(struct pim_interface *pim_ifp);
void pim_i_am_rp_re_evaluate(struct pim_instance *pim);
@@ -56,15 +58,16 @@ int pim_rp_check_is_my_ip_address(struct pim_instance *pim,
struct in_addr group,
struct in_addr dest_addr);
-int pim_rp_set_upstream_addr(struct in_addr *up, struct in_addr source,
- struct in_addr group);
+int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up,
+ struct in_addr source, struct in_addr group);
struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group);
-#define I_am_RP(G) pim_rp_i_am_rp ((G))
+#define I_am_RP(P, G) pim_rp_i_am_rp ((P), (G))
#define RP(P, G) pim_rp_g ((P), (G))
-void pim_rp_show_information(struct vty *vty, u_char uj);
+void pim_rp_show_information(struct pim_instance *pim, struct vty *vty,
+ u_char uj);
void pim_resolve_rp_nh(struct pim_instance *pim);
int pim_rp_list_cmp(void *v1, void *v2);
#endif
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c
index dfdf3b950..c5b9f7524 100644
--- a/pimd/pim_rpf.c
+++ b/pimd/pim_rpf.c
@@ -49,8 +49,8 @@ void pim_rpf_set_refresh_time(void)
__PRETTY_FUNCTION__, last_route_change_time);
}
-int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr,
- int neighbor_needed)
+int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
+ struct in_addr addr, int neighbor_needed)
{
struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
struct pim_neighbor *nbr = NULL;
diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h
index 3a688a483..9f7ae8679 100644
--- a/pimd/pim_rpf.h
+++ b/pimd/pim_rpf.h
@@ -61,8 +61,8 @@ extern long long nexthop_lookups_avoided;
unsigned int pim_rpf_hash_key(void *arg);
int pim_rpf_equal(const void *arg1, const void *arg2);
-int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr,
- int neighbor_needed);
+int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
+ struct in_addr addr, int neighbor_needed);
enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct pim_rpf *old,
uint8_t is_new);
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index bedfe0e93..96f49ec53 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -561,7 +561,7 @@ void pim_upstream_switch(struct pim_upstream *up,
RP.
If I am RP for G then send S,G prune to its IIF. */
if (pim_upstream_is_sg_rpt(up) && up->parent
- && !I_am_RP(up->sg.grp)) {
+ && !I_am_RP(up->channel_oil->pim, up->sg.grp)) {
if (PIM_DEBUG_PIM_TRACE_DETAIL)
zlog_debug(
"%s: *,G IIF %s S,G IIF %s ",
@@ -619,7 +619,8 @@ pim_upstream_new(struct prefix_sg *sg, struct interface *incoming, int flags)
up->sg = *sg;
pim_str_sg_set(sg, up->sg_str);
up = hash_get(pim->upstream_hash, up, hash_alloc_intern);
- if (!pim_rp_set_upstream_addr(&up->upstream_addr, sg->src, sg->grp)) {
+ if (!pim_rp_set_upstream_addr(pim, &up->upstream_addr, sg->src,
+ sg->grp)) {
if (PIM_DEBUG_TRACE)
zlog_debug("%s: Received a (*,G) with no RP configured",
__PRETTY_FUNCTION__);
@@ -1083,7 +1084,7 @@ static int pim_upstream_keep_alive_timer(struct thread *t)
up = THREAD_ARG(t);
- if (I_am_RP(up->sg.grp)) {
+ if (I_am_RP(pimg, up->sg.grp)) {
pim_br_clear_pmbr(&up->sg);
/*
* We need to do more here :)
@@ -1176,7 +1177,7 @@ void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up)
*/
int pim_upstream_switch_to_spt_desired(struct prefix_sg *sg)
{
- if (I_am_RP(sg->grp))
+ if (I_am_RP(pimg, sg->grp))
return 1;
return 0;
@@ -1345,14 +1346,14 @@ static int pim_upstream_register_stop_timer(struct thread *t)
if (((up->channel_oil->cc.lastused / 100)
> PIM_KEEPALIVE_PERIOD)
- && (I_am_RP(up->sg.grp))) {
+ && (I_am_RP(pim_ifp->pim, up->sg.grp))) {
if (PIM_DEBUG_TRACE)
zlog_debug(
"%s: Stop sending the register, because I am the RP and we haven't seen a packet in a while",
__PRETTY_FUNCTION__);
return 0;
}
- rpg = RP(pimg, up->sg.grp);
+ rpg = RP(pim_ifp->pim, up->sg.grp);
memset(&ip_hdr, 0, sizeof(struct ip));
ip_hdr.ip_p = PIM_IP_PROTO_PIM;
ip_hdr.ip_hl = 5;
@@ -1576,7 +1577,7 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up)
* MUST be
* removed to handle spt turn-arounds correctly in a 3-tier clos
*/
- if (I_am_RP(up->sg.grp))
+ if (I_am_RP(pimg, up->sg.grp))
return true;
}
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index ad9432c0d..bcbceb75b 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -154,7 +154,7 @@ int pim_global_config_write(struct vty *vty)
++writes;
}
- writes += pim_rp_config_write(vty);
+ writes += pim_rp_config_write(pimg, vty);
if (qpim_register_suppress_time
!= PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index 11ec9eb35..f91129321 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -487,7 +487,8 @@ void pim_scan_individual_oil(struct channel_oil *c_oil, int in_vif_index)
int input_iface_vif_index;
int old_vif_index;
- if (!pim_rp_set_upstream_addr(&vif_source, c_oil->oil.mfcc_origin,
+ if (!pim_rp_set_upstream_addr(c_oil->pim, &vif_source,
+ c_oil->oil.mfcc_origin,
c_oil->oil.mfcc_mcastgrp))
return;
@@ -884,8 +885,8 @@ void igmp_source_forward_start(struct igmp_source *source)
struct pim_nexthop nexthop;
struct pim_upstream *up = NULL;
- if (!pim_rp_set_upstream_addr(&vif_source, source->source_addr,
- sg.grp))
+ if (!pim_rp_set_upstream_addr(pimg, &vif_source,
+ source->source_addr, sg.grp))
return;
/* Register addr with Zebra NHT */
diff --git a/pimd/pimd.c b/pimd/pimd.c
index 91cf17d74..58adff85d 100644
--- a/pimd/pimd.c
+++ b/pimd/pimd.c
@@ -73,9 +73,19 @@ int32_t qpim_register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT;
void pim_prefix_list_update(struct prefix_list *plist)
{
- pim_rp_prefix_list_update(plist);
- pim_ssm_prefix_list_update(plist);
- pim_upstream_spt_prefix_list_update(pimg, plist);
+ struct pim_instance *pim;
+ struct vrf *vrf;
+
+ RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
+ {
+ pim = vrf->info;
+ if (!pim)
+ continue;
+
+ pim_rp_prefix_list_update(pim, plist);
+ pim_ssm_prefix_list_update(plist);
+ pim_upstream_spt_prefix_list_update(pim, plist);
+ }
}
static void pim_free()
@@ -85,7 +95,6 @@ static void pim_free()
pim_oil_terminate();
pim_if_terminate();
- pim_rp_free();
pim_route_map_terminate();
@@ -98,8 +107,6 @@ void pim_init()
{
qpim_rp_keep_alive_time = PIM_RP_KEEPALIVE_PERIOD;
- pim_rp_init();
-
if (!inet_aton(PIM_ALL_PIM_ROUTERS, &qpim_all_pim_routers_addr)) {
zlog_err(
"%s %s: could not solve %s to group address: errno=%d: %s",