diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2022-03-02 10:42:17 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2022-03-02 10:42:17 +0100 |
commit | 6564f5e5a56bb4edf0827878d76e381f1ecf910f (patch) | |
tree | f8b0f51339c8251c960565a9cac7e16134e959da | |
parent | Merge pull request #10684 from mobash-rasool/join-prune (diff) | |
parent | pimd: fix stray comment referencing INADDR_NONE (diff) | |
download | frr-6564f5e5a56bb4edf0827878d76e381f1ecf910f.tar.xz frr-6564f5e5a56bb4edf0827878d76e381f1ecf910f.zip |
Merge pull request #10657 from patrasar/pim_remove_in_addr_none
[manual merge to edit comment, didn't want to incur another cycle]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r-- | pimd/pim_bsm.c | 9 | ||||
-rw-r--r-- | pimd/pim_mroute.c | 6 | ||||
-rw-r--r-- | pimd/pim_nht.c | 2 | ||||
-rw-r--r-- | pimd/pim_rp.c | 39 | ||||
-rw-r--r-- | pimd/pim_rpf.c | 15 | ||||
-rw-r--r-- | pimd/pim_rpf.h | 1 |
6 files changed, 26 insertions, 46 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index 4d1e700ab..c45823cb8 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -430,8 +430,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) @@ -634,8 +634,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 */ @@ -668,7 +667,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 af6f59824..f381a764c 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -163,7 +163,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", @@ -300,8 +300,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 ce5298e5b..48dd565b2 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -419,7 +419,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 0346a7067..06b221607 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)); @@ -514,10 +510,10 @@ 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 + * Take over the 224.0.0.0/4 group if the rp is INADDR_ANY */ - 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 c62a06f85..a99f5536b 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -67,7 +67,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; #endif @@ -393,19 +393,6 @@ static pim_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) { pim_addr rpf_addr = pim_addr_from_prefix(&rpf->rpf_addr); diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h index 662fd41a7..74aca43d5 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); |