summaryrefslogtreecommitdiff
path: root/pimd/pim_rp.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_rp.c')
-rw-r--r--pimd/pim_rp.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index f35adb0cea..702eace3c0 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -362,8 +362,8 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)
{
struct pim_rpf old_rpf;
enum pim_rpf_result rpf_result;
- struct in_addr old_upstream_addr;
- struct in_addr new_upstream_addr;
+ pim_addr old_upstream_addr;
+ pim_addr new_upstream_addr;
struct prefix nht_p;
old_upstream_addr = up->upstream_addr;
@@ -374,7 +374,7 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)
zlog_debug("%s: pim upstream update for old upstream %pI4",
__func__, &old_upstream_addr);
- if (old_upstream_addr.s_addr == new_upstream_addr.s_addr)
+ if (!pim_addr_cmp(old_upstream_addr, new_upstream_addr))
return;
/* Lets consider a case, where a PIM upstream has a better RP as a
@@ -382,11 +382,9 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)
* This upstream has to be added to the upstream hash of new RP's
* NHT(pnc) and has to be removed from old RP's NHT upstream hash
*/
- if (old_upstream_addr.s_addr != INADDR_ANY) {
+ if (!pim_addr_is_any(old_upstream_addr)) {
/* Deregister addr with Zebra NHT */
- nht_p.family = AF_INET;
- nht_p.prefixlen = IPV4_MAX_BITLEN;
- nht_p.u.prefix4 = old_upstream_addr;
+ pim_addr_to_prefix(&nht_p, old_upstream_addr);
if (PIM_DEBUG_PIM_TRACE)
zlog_debug(
"%s: Deregister upstream %s addr %pFX with Zebra NHT",
@@ -541,9 +539,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
struct prefix grp;
struct rp_info *trp_info;
- grp.family = AF_INET;
- grp.prefixlen = IPV4_MAX_BITLEN;
- grp.u.prefix4 = up->sg.grp;
+ pim_addr_to_prefix(&grp, up->sg.grp);
trp_info = pim_rp_find_match_group(
pim, &grp);
if (trp_info == rp_all) {
@@ -632,9 +628,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
struct prefix grp;
struct rp_info *trp_info;
- grp.family = AF_INET;
- grp.prefixlen = IPV4_MAX_BITLEN;
- grp.u.prefix4 = up->sg.grp;
+ pim_addr_to_prefix(&grp, up->sg.grp);
trp_info = pim_rp_find_match_group(pim, &grp);
if (trp_info == rp_info) {
@@ -782,9 +776,8 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
rp_info->rp.rpf_addr.u.prefix4.s_addr) &&
pim_addr_is_any(up->sg.src)) {
struct prefix grp;
- grp.family = AF_INET;
- grp.prefixlen = IPV4_MAX_BITLEN;
- grp.u.prefix4 = up->sg.grp;
+
+ pim_addr_to_prefix(&grp, up->sg.grp);
trp_info = pim_rp_find_match_group(pim, &grp);
if (trp_info == rp_all) {
pim_upstream_rpf_clear(pim, up);
@@ -831,10 +824,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
pim_addr_is_any(up->sg.src)) {
struct prefix grp;
- grp.family = AF_INET;
- grp.prefixlen = IPV4_MAX_BITLEN;
- grp.u.prefix4 = up->sg.grp;
-
+ pim_addr_to_prefix(&grp, up->sg.grp);
trp_info = pim_rp_find_match_group(pim, &grp);
/* RP not found for the group grp */
@@ -918,9 +908,7 @@ int pim_rp_change(struct pim_instance *pim, struct in_addr new_rp_addr,
struct prefix grp;
struct rp_info *trp_info;
- grp.family = AF_INET;
- grp.prefixlen = IPV4_MAX_BITLEN;
- grp.u.prefix4 = up->sg.grp;
+ pim_addr_to_prefix(&grp, up->sg.grp);
trp_info = pim_rp_find_match_group(pim, &grp);
if (trp_info == rp_info) {
@@ -1064,13 +1052,14 @@ void pim_i_am_rp_re_evaluate(struct pim_instance *pim)
}
}
+#if PIM_IPV == 4
/*
* I_am_RP(G) is true if the group-to-RP mapping indicates that
* this router is the RP for the group.
*
* Since we only have static RP, all groups are part of this RP
*/
-int pim_rp_i_am_rp(struct pim_instance *pim, struct in_addr group)
+int pim_rp_i_am_rp(struct pim_instance *pim, pim_addr group)
{
struct prefix g;
struct rp_info *rp_info;
@@ -1084,7 +1073,6 @@ int pim_rp_i_am_rp(struct pim_instance *pim, struct in_addr group)
if (rp_info)
return rp_info->i_am_rp;
-
return 0;
}
@@ -1093,7 +1081,7 @@ int pim_rp_i_am_rp(struct pim_instance *pim, struct in_addr group)
*
* Return the RP that the Group belongs too.
*/
-struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)
+struct pim_rpf *pim_rp_g(struct pim_instance *pim, pim_addr group)
{
struct prefix g;
struct rp_info *rp_info;
@@ -1135,8 +1123,8 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)
* then set the upstream addr as INADDR_ANY and return failure.
*
*/
-int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up,
- struct in_addr source, struct in_addr group)
+int pim_rp_set_upstream_addr(struct pim_instance *pim, pim_addr *up,
+ pim_addr source, pim_addr group)
{
struct rp_info *rp_info;
struct prefix g;
@@ -1162,6 +1150,25 @@ int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up,
return 1;
}
+#else
+CPP_NOTICE("functions stubbed out for IPv6");
+
+int pim_rp_i_am_rp(struct pim_instance *pim, pim_addr group)
+{
+ return 0;
+}
+
+struct pim_rpf *pim_rp_g(struct pim_instance *pim, pim_addr group)
+{
+ return NULL;
+}
+
+int pim_rp_set_upstream_addr(struct pim_instance *pim, pim_addr *up,
+ pim_addr source, pim_addr group)
+{
+ return 0;
+}
+#endif
int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
const char *spaces)