summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsarita patra <saritap@vmware.com>2022-02-25 14:17:08 +0100
committersarita patra <saritap@vmware.com>2022-03-01 18:45:56 +0100
commitcc144e8b6b11e7e44f34871dd24b1ab21107b4b8 (patch)
treecc3c985c57a6ff7393d38c422e5ebc6e556f1ac6
parentMerge pull request #10615 from mobash-rasool/fixes (diff)
downloadfrr-cc144e8b6b11e7e44f34871dd24b1ab21107b4b8.tar.xz
frr-cc144e8b6b11e7e44f34871dd24b1ab21107b4b8.zip
pimd: replace inaddr_none with PIMADDR_ANY
We can use PIMADDR_ANY instead of INADDR_NONE to initalize rp->rpf_addr when there is no rp configured for group_all. Signed-off-by: sarita patra <saritap@vmware.com>
-rw-r--r--pimd/pim_bsm.c9
-rw-r--r--pimd/pim_mroute.c6
-rw-r--r--pimd/pim_nht.c2
-rw-r--r--pimd/pim_rp.c37
-rw-r--r--pimd/pim_rpf.c17
-rw-r--r--pimd/pim_rpf.h1
6 files changed, 26 insertions, 46 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index 0b993ec05..1ac604686 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -433,8 +433,8 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)
* install the rp from head(if exists) of partial list. List is
* is sorted such that head is the elected RP for the group.
*/
- if (!rn || (prefix_same(&rp_all->group, &bsgrp_node->group)
- && pim_rpf_addr_is_inaddr_none(&rp_all->rp))) {
+ if (!rn || (prefix_same(&rp_all->group, &bsgrp_node->group) &&
+ pim_rpf_addr_is_inaddr_any(&rp_all->rp))) {
if (PIM_DEBUG_BSM)
zlog_debug("%s: Route node doesn't exist", __func__);
if (pend)
@@ -637,8 +637,7 @@ void pim_bsm_clear(struct pim_instance *pim)
rp_all = pim_rp_find_match_group(pim, &g_all);
if (rp_all == rp_info) {
- rp_all->rp.rpf_addr.family = AF_INET;
- rp_all->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE;
+ pim_addr_to_prefix(&rp_all->rp.rpf_addr, PIMADDR_ANY);
rp_all->i_am_rp = 0;
} else {
/* Delete the rp_info from rp-list */
@@ -671,7 +670,7 @@ void pim_bsm_clear(struct pim_instance *pim)
trp_info = pim_rp_find_match_group(pim, &grp);
/* RP not found for the group grp */
- if (pim_rpf_addr_is_inaddr_none(&trp_info->rp)) {
+ if (pim_rpf_addr_is_inaddr_any(&trp_info->rp)) {
pim_upstream_rpf_clear(pim, up);
pim_rp_set_upstream_addr(pim, &up->upstream_addr,
up->sg.src, up->sg.grp);
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 91b997f44..efd4dc1eb 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -162,7 +162,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,
* the Interface type is SSM we don't need to
* do anything here
*/
- if (!rpg || pim_rpf_addr_is_inaddr_none(rpg)) {
+ if (!rpg || pim_rpf_addr_is_inaddr_any(rpg)) {
if (PIM_DEBUG_MROUTE_DETAIL)
zlog_debug(
"%s: Interface is not configured correctly to handle incoming packet: Could be !pim_ifp, !SM, !RP",
@@ -299,8 +299,8 @@ static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp,
rpg = pim_ifp ? RP(pim_ifp->pim, sg.grp) : NULL;
- if ((pim_rpf_addr_is_inaddr_none(rpg)) || (!pim_ifp)
- || (!(PIM_I_am_DR(pim_ifp)))) {
+ if ((pim_rpf_addr_is_inaddr_any(rpg)) || (!pim_ifp) ||
+ (!(PIM_I_am_DR(pim_ifp)))) {
if (PIM_DEBUG_MROUTE) {
zlog_debug("%s: Failed Check send packet", __func__);
}
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index beaa5c802..263deb106 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -426,7 +426,7 @@ static void pim_update_rp_nh(struct pim_instance *pim,
/*Traverse RP list and update each RP Nexthop info */
for (ALL_LIST_ELEMENTS_RO(pnc->rp_list, node, rp_info)) {
- if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE)
+ if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
// Compute PIM RPF using cached nexthop
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index a5183c9e9..c062d5488 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -122,9 +122,7 @@ void pim_rp_init(struct pim_instance *pim)
return;
}
rp_info->group.family = AF_INET;
- rp_info->rp.rpf_addr.family = AF_INET;
- rp_info->rp.rpf_addr.prefixlen = IPV4_MAX_BITLEN;
- rp_info->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE;
+ pim_addr_to_prefix(&rp_info->rp.rpf_addr, PIMADDR_ANY);
listnode_add(pim->rp_list, rp_info);
@@ -414,9 +412,8 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)
}
-int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
- struct prefix group, const char *plist,
- enum rp_source rp_src_flag)
+int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr, struct prefix group,
+ const char *plist, enum rp_source rp_src_flag)
{
int result = 0;
char rp[INET_ADDRSTRLEN];
@@ -431,8 +428,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
struct pim_upstream *up;
bool upstream_updated = false;
- if (rp_addr.s_addr == INADDR_ANY ||
- rp_addr.s_addr == INADDR_NONE)
+ if (rp_addr.s_addr == INADDR_ANY)
return PIM_RP_BAD_ADDRESS;
rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info));
@@ -516,8 +512,8 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,
/*
* Take over the 224.0.0.0/4 group if the rp is INADDR_NONE
*/
- if (prefix_same(&rp_all->group, &rp_info->group)
- && pim_rpf_addr_is_inaddr_none(&rp_all->rp)) {
+ if (prefix_same(&rp_all->group, &rp_info->group) &&
+ pim_rpf_addr_is_inaddr_any(&rp_all->rp)) {
rp_all->rp.rpf_addr = rp_info->rp.rpf_addr;
rp_all->rp_src = rp_src_flag;
XFREE(MTYPE_PIM_RP, rp_info);
@@ -789,8 +785,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
}
}
}
- rp_all->rp.rpf_addr.family = AF_INET;
- rp_all->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE;
+ pim_addr_to_prefix(&rp_all->rp.rpf_addr, PIMADDR_ANY);
rp_all->i_am_rp = 0;
return PIM_SUCCESS;
}
@@ -834,7 +829,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,
trp_info = pim_rp_find_match_group(pim, &grp);
/* RP not found for the group grp */
- if (pim_rpf_addr_is_inaddr_none(&trp_info->rp)) {
+ if (pim_rpf_addr_is_inaddr_any(&trp_info->rp)) {
pim_upstream_rpf_clear(pim, up);
pim_rp_set_upstream_addr(
pim, &up->upstream_addr, up->sg.src,
@@ -956,7 +951,7 @@ void pim_rp_setup(struct pim_instance *pim)
struct prefix nht_p;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
- if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE)
+ if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
nht_p.family = AF_INET;
@@ -987,7 +982,7 @@ void pim_rp_check_on_if_add(struct pim_interface *pim_ifp)
return;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
- if (pim_rpf_addr_is_inaddr_none(&rp_info->rp))
+ if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
/* if i_am_rp is already set nothing to be done (adding new
@@ -1029,7 +1024,7 @@ void pim_i_am_rp_re_evaluate(struct pim_instance *pim)
return;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
- if (pim_rpf_addr_is_inaddr_none(&rp_info->rp))
+ if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
old_i_am_rp = rp_info->i_am_rp;
@@ -1142,8 +1137,8 @@ int pim_rp_set_upstream_addr(struct pim_instance *pim, pim_addr *up,
rp_info = pim_rp_find_match_group(pim, &g);
- if (!rp_info || ((pim_rpf_addr_is_inaddr_none(&rp_info->rp))
- && (source.s_addr == INADDR_ANY))) {
+ if (!rp_info || ((pim_rpf_addr_is_inaddr_any(&rp_info->rp)) &&
+ (source.s_addr == INADDR_ANY))) {
if (PIM_DEBUG_PIM_NHT_RP)
zlog_debug("%s: Received a (*,G) with no RP configured",
__func__);
@@ -1185,7 +1180,7 @@ int pim_rp_config_write(struct pim_instance *pim, struct vty *vty,
int count = 0;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
- if (pim_rpf_addr_is_inaddr_none(&rp_info->rp))
+ if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
if (rp_info->rp_src == RP_SRC_BSR)
@@ -1227,7 +1222,7 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
vty_out(vty,
"RP address group/prefix-list OIF I am RP Source\n");
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
- if (!pim_rpf_addr_is_inaddr_none(&rp_info->rp)) {
+ if (!pim_rpf_addr_is_inaddr_any(&rp_info->rp)) {
char buf[48];
if (rp_info->rp_src == RP_SRC_STATIC)
@@ -1345,7 +1340,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)
struct pim_nexthop_cache pnc;
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
- if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE)
+ if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
nht_p.family = AF_INET;
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c
index 2e8fc8e66..2741b5bf4 100644
--- a/pimd/pim_rpf.c
+++ b/pimd/pim_rpf.c
@@ -51,7 +51,7 @@ void pim_rpf_set_refresh_time(struct pim_instance *pim)
}
bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
- struct in_addr addr, int neighbor_needed)
+ pim_addr addr, int neighbor_needed)
{
struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
struct pim_neighbor *nbr = NULL;
@@ -66,7 +66,7 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
* 255.255.255.255 address, since
* it will never work
*/
- if (addr.s_addr == INADDR_NONE)
+ if (pim_addr_is_any(addr))
return false;
if ((nexthop->last_lookup.s_addr == addr.s_addr)
@@ -405,19 +405,6 @@ static struct in_addr pim_rpf_find_rpf_addr(struct pim_upstream *up)
return rpf_addr;
}
-int pim_rpf_addr_is_inaddr_none(struct pim_rpf *rpf)
-{
- switch (rpf->rpf_addr.family) {
- case AF_INET:
- return rpf->rpf_addr.u.prefix4.s_addr == INADDR_NONE;
- case AF_INET6:
- zlog_warn("%s: v6 Unimplmeneted", __func__);
- return 1;
- default:
- return 0;
- }
-}
-
int pim_rpf_addr_is_inaddr_any(struct pim_rpf *rpf)
{
switch (rpf->rpf_addr.family) {
diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h
index d6a8880ff..92e482db8 100644
--- a/pimd/pim_rpf.h
+++ b/pimd/pim_rpf.h
@@ -64,7 +64,6 @@ enum pim_rpf_result pim_rpf_update(struct pim_instance *pim,
struct pim_rpf *old, const char *caller);
void pim_upstream_rpf_clear(struct pim_instance *pim,
struct pim_upstream *up);
-int pim_rpf_addr_is_inaddr_none(struct pim_rpf *rpf);
int pim_rpf_addr_is_inaddr_any(struct pim_rpf *rpf);
int pim_rpf_is_same(struct pim_rpf *rpf1, struct pim_rpf *rpf2);