diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-05-19 22:00:00 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-07-24 19:51:35 +0200 |
commit | 25b787a28780e33da3afef6130589dbe8fa3c243 (patch) | |
tree | 2e92ce8ff2d2af7f86a4b2132972cfc7b6a0b4fc | |
parent | pimd: More refactor for 'struct pim_instance *' for pim_nht.c (diff) | |
download | frr-25b787a28780e33da3afef6130589dbe8fa3c243.tar.xz frr-25b787a28780e33da3afef6130589dbe8fa3c243.zip |
pimd: Remove pimg from pim_nht.c in totality
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r-- | pimd/pim_cmd.c | 5 | ||||
-rw-r--r-- | pimd/pim_nht.c | 40 | ||||
-rw-r--r-- | pimd/pim_nht.h | 13 | ||||
-rw-r--r-- | pimd/pim_rp.c | 12 | ||||
-rw-r--r-- | pimd/pim_rpf.c | 11 | ||||
-rw-r--r-- | pimd/pim_zebra.c | 20 |
6 files changed, 56 insertions, 45 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 66cda198a..1c5571a2e 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -3600,9 +3600,10 @@ DEFUN (show_ip_pim_nexthop_lookup, memset(&nexthop, 0, sizeof(nexthop)); if (pim_find_or_track_nexthop(pimg, &nht_p, NULL, NULL, &pnc)) - pim_ecmp_nexthop_search(&pnc, &nexthop, &nht_p, &grp, 0); + pim_ecmp_nexthop_search(pimg, &pnc, &nexthop, &nht_p, &grp, 0); else - pim_ecmp_nexthop_lookup(&nexthop, vif_source, &nht_p, &grp, 0); + pim_ecmp_nexthop_lookup(pimg, &nexthop, vif_source, &nht_p, + &grp, 0); pim_addr_dump("<grp?>", &grp, grp_str, sizeof(grp_str)); pim_addr_dump("<nexthop?>", &nexthop.mrib_nexthop_addr, diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 7978ad671..ccb48aae5 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -261,7 +261,7 @@ void pim_delete_tracked_nexthop(struct pim_instance *pim, struct prefix *addr, } /* Update RP nexthop info based on Nexthop update received from Zebra.*/ -int pim_update_rp_nh(struct pim_nexthop_cache *pnc) +int pim_update_rp_nh(struct pim_instance *pim, struct pim_nexthop_cache *pnc) { struct listnode *node = NULL; struct rp_info *rp_info = NULL; @@ -273,9 +273,9 @@ int pim_update_rp_nh(struct pim_nexthop_cache *pnc) continue; // Compute PIM RPF using cached nexthop - ret = pim_ecmp_nexthop_search(pnc, &rp_info->rp.source_nexthop, - &rp_info->rp.rpf_addr, - &rp_info->group, 1); + ret = pim_ecmp_nexthop_search( + pim, pnc, &rp_info->rp.source_nexthop, + &rp_info->rp.rpf_addr, &rp_info->group, 1); if (PIM_DEBUG_TRACE) { char rp_str[PREFIX_STRLEN]; @@ -299,14 +299,14 @@ int pim_update_rp_nh(struct pim_nexthop_cache *pnc) unresolved state and due to event like pim neighbor UP event if it can be resolved. */ -void pim_resolve_upstream_nh(struct prefix *nht_p) +void pim_resolve_upstream_nh(struct pim_instance *pim, struct prefix *nht_p) { struct nexthop *nh_node = NULL; struct pim_nexthop_cache pnc; struct pim_neighbor *nbr = NULL; memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); - if (!pim_find_or_track_nexthop(pimg, nht_p, NULL, NULL, &pnc)) + if (!pim_find_or_track_nexthop(pim, nht_p, NULL, NULL, &pnc)) return; for (nh_node = pnc.nexthop; nh_node; nh_node = nh_node->next) { @@ -314,7 +314,7 @@ void pim_resolve_upstream_nh(struct prefix *nht_p) continue; struct interface *ifp1 = - if_lookup_by_index(nh_node->ifindex, pimg->vrf_id); + if_lookup_by_index(nh_node->ifindex, pim->vrf_id); nbr = pim_neighbor_find_if(ifp1); if (!nbr) continue; @@ -443,7 +443,7 @@ static int pim_update_upstream_nh(struct pim_instance *pim, } } /* for (pnc->upstream_list) */ - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pimg->vrf_id), ifnode, ifp)) + for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) if (ifp->info) { struct pim_interface *pim_ifp = ifp->info; struct pim_iface_upstream_switch *us; @@ -493,7 +493,8 @@ uint32_t pim_compute_ecmp_hash(struct prefix *src, struct prefix *grp) return hash_val; } -int pim_ecmp_nexthop_search(struct pim_nexthop_cache *pnc, +int pim_ecmp_nexthop_search(struct pim_instance *pim, + struct pim_nexthop_cache *pnc, struct pim_nexthop *nexthop, struct prefix *src, struct prefix *grp, int neighbor_needed) { @@ -574,7 +575,7 @@ int pim_ecmp_nexthop_search(struct pim_nexthop_cache *pnc, for (nh_node = pnc->nexthop; nh_node && (found == 0); nh_node = nh_node->next) { first_ifindex = nh_node->ifindex; - ifp = if_lookup_by_index(first_ifindex, pimg->vrf_id); + ifp = if_lookup_by_index(first_ifindex, pim->vrf_id); if (!ifp) { if (PIM_DEBUG_ZEBRA) { char addr_str[INET_ADDRSTRLEN]; @@ -706,7 +707,7 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient, rpf.rpf_addr.family = p.family; rpf.rpf_addr.prefixlen = p.prefixlen; rpf.rpf_addr.u.prefix4.s_addr = p.u.prefix4.s_addr; - pnc = pim_nexthop_cache_find(pimg, &rpf); + pnc = pim_nexthop_cache_find(pim, &rpf); if (!pnc) { if (PIM_DEBUG_TRACE) { char buf[PREFIX2STR_BUFFER]; @@ -754,7 +755,7 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient, stream_get(&nexthop->gate.ipv6, s, 16); nexthop->ifindex = stream_getl(s); ifp1 = if_lookup_by_index(nexthop->ifindex, - pimg->vrf_id); + pim->vrf_id); nbr = pim_neighbor_find_if(ifp1); /* Overwrite with Nbr address as NH addr */ if (nbr) { @@ -801,8 +802,7 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient, nexthop->type, distance, metric); } - ifp = if_lookup_by_index(nexthop->ifindex, - pimg->vrf_id); + ifp = if_lookup_by_index(nexthop->ifindex, pim->vrf_id); if (!ifp) { if (PIM_DEBUG_ZEBRA) { char buf[NEXTHOP_STRLEN]; @@ -869,14 +869,15 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient, pim_rpf_set_refresh_time(); if (listcount(pnc->rp_list)) - pim_update_rp_nh(pnc); + pim_update_rp_nh(pim, pnc); if (listcount(pnc->upstream_list)) pim_update_upstream_nh(pim, pnc); return 0; } -int pim_ecmp_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr, +int pim_ecmp_nexthop_lookup(struct pim_instance *pim, + struct pim_nexthop *nexthop, struct in_addr addr, struct prefix *src, struct prefix *grp, int neighbor_needed) { @@ -922,7 +923,7 @@ int pim_ecmp_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr, while (!found && (i < num_ifindex)) { first_ifindex = nexthop_tab[i].ifindex; - ifp = if_lookup_by_index(first_ifindex, pimg->vrf_id); + ifp = if_lookup_by_index(first_ifindex, pim->vrf_id); if (!ifp) { if (PIM_DEBUG_ZEBRA) { char addr_str[INET_ADDRSTRLEN]; @@ -1016,7 +1017,8 @@ int pim_ecmp_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr, return 0; } -int pim_ecmp_fib_lookup_if_vif_index(struct in_addr addr, struct prefix *src, +int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim, + struct in_addr addr, struct prefix *src, struct prefix *grp) { struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM]; @@ -1058,7 +1060,7 @@ int pim_ecmp_fib_lookup_if_vif_index(struct in_addr addr, struct prefix *src, zlog_debug( "%s %s: found nexthop ifindex=%d (interface %s) for address %s", __FILE__, __PRETTY_FUNCTION__, first_ifindex, - ifindex2ifname(first_ifindex, pimg->vrf_id), addr_str); + ifindex2ifname(first_ifindex, pim->vrf_id), addr_str); } vif_index = pim_if_find_vifindex_by_ifindex(first_ifindex); diff --git a/pimd/pim_nht.h b/pimd/pim_nht.h index 6ed57c9ec..01cfa6ff0 100644 --- a/pimd/pim_nht.h +++ b/pimd/pim_nht.h @@ -58,16 +58,19 @@ struct pim_nexthop_cache *pim_nexthop_cache_add(struct pim_instance *pim, struct pim_nexthop_cache *pim_nexthop_cache_find(struct pim_instance *pim, struct pim_rpf *rpf); uint32_t pim_compute_ecmp_hash(struct prefix *src, struct prefix *grp); -int pim_ecmp_nexthop_search(struct pim_nexthop_cache *pnc, +int pim_ecmp_nexthop_search(struct pim_instance *pim, + struct pim_nexthop_cache *pnc, struct pim_nexthop *nexthop, struct prefix *src, struct prefix *grp, int neighbor_needed); -int pim_ecmp_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr, +int pim_ecmp_nexthop_lookup(struct pim_instance *pim, + struct pim_nexthop *nexthop, struct in_addr addr, struct prefix *src, struct prefix *grp, int neighbor_needed); void pim_sendmsg_zebra_rnh(struct zclient *zclient, struct pim_instance *pim, struct pim_nexthop_cache *pnc, int command); -int pim_update_rp_nh(struct pim_nexthop_cache *pnc); -void pim_resolve_upstream_nh(struct prefix *nht_p); -int pim_ecmp_fib_lookup_if_vif_index(struct in_addr addr, struct prefix *src, +int pim_update_rp_nh(struct pim_instance *pim, struct pim_nexthop_cache *pnc); +void pim_resolve_upstream_nh(struct pim_instance *pim, struct prefix *nht_p); +int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim, + struct in_addr addr, struct prefix *src, struct prefix *grp); #endif diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 5c7915dfc..e235f7052 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -405,8 +405,9 @@ int pim_rp_new(const char *rp, const char *group_range, const char *plist) if (pim_find_or_track_nexthop(pimg, &nht_p, NULL, rp_all, &pnc)) { if (!pim_ecmp_nexthop_search( - &pnc, &rp_all->rp.source_nexthop, - &nht_p, &rp_all->group, 1)) + pimg, &pnc, + &rp_all->rp.source_nexthop, &nht_p, + &rp_all->group, 1)) return PIM_RP_NO_PATH; } else { if (pim_nexthop_lookup( @@ -472,7 +473,8 @@ int pim_rp_new(const char *rp, const char *group_range, const char *plist) memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); if (pim_find_or_track_nexthop(pimg, &nht_p, NULL, rp_info, &pnc)) { - if (!pim_ecmp_nexthop_search(&pnc, &rp_info->rp.source_nexthop, + if (!pim_ecmp_nexthop_search(pimg, &pnc, + &rp_info->rp.source_nexthop, &nht_p, &rp_info->group, 1)) return PIM_RP_NO_PATH; } else { @@ -566,7 +568,7 @@ void pim_rp_setup(void) memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); if (pim_find_or_track_nexthop(pimg, &nht_p, NULL, rp_info, &pnc)) - pim_ecmp_nexthop_search(&pnc, + pim_ecmp_nexthop_search(pimg, &pnc, &rp_info->rp.source_nexthop, &nht_p, &rp_info->group, 1); else { @@ -731,7 +733,7 @@ struct pim_rpf *pim_rp_g(struct in_addr group) memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); if (pim_find_or_track_nexthop(pimg, &nht_p, NULL, rp_info, &pnc)) - pim_ecmp_nexthop_search(&pnc, + pim_ecmp_nexthop_search(pimg, &pnc, &rp_info->rp.source_nexthop, &nht_p, &rp_info->group, 1); else { diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index 0946028e2..22741230d 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -221,7 +221,8 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct pim_rpf *old, if (pim_find_or_track_nexthop(pimg, &nht_p, up, NULL, &pnc)) { if (pnc.nexthop_num) { if (!pim_ecmp_nexthop_search( - &pnc, &up->rpf.source_nexthop, &src, &grp, + pimg, &pnc, &up->rpf.source_nexthop, &src, + &grp, !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( up->flags))) @@ -229,10 +230,10 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct pim_rpf *old, } } else { if (!pim_ecmp_nexthop_lookup( - &rpf->source_nexthop, up->upstream_addr, &src, &grp, - !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) - && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( - up->flags))) + pimg, &rpf->source_nexthop, up->upstream_addr, &src, + &grp, !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) + && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( + up->flags))) return PIM_RPF_FAILURE; } diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index a2ba0e8a2..c0c591f4a 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -364,7 +364,7 @@ static void scan_upstream_rpf_cache() nht_p.family = AF_INET; nht_p.prefixlen = IPV4_MAX_BITLEN; nht_p.u.prefix4.s_addr = up->upstream_addr.s_addr; - pim_resolve_upstream_nh(&nht_p); + pim_resolve_upstream_nh(pimg, &nht_p); old.source_nexthop.interface = up->rpf.source_nexthop.interface; old.source_nexthop.nbr = up->rpf.source_nexthop.nbr; @@ -484,7 +484,7 @@ void pim_scan_individual_oil(struct channel_oil *c_oil, int in_vif_index) __PRETTY_FUNCTION__, source_str, group_str); } input_iface_vif_index = pim_ecmp_fib_lookup_if_vif_index( - vif_source, &src, &grp); + c_oil->pim, vif_source, &src, &grp); } if (input_iface_vif_index < 1) { @@ -879,8 +879,9 @@ void igmp_source_forward_start(struct igmp_source *source) memcpy(&nexthop, &up->rpf.source_nexthop, sizeof(struct pim_nexthop)); - pim_ecmp_nexthop_search(&out_pnc, &nexthop, - &src, &grp, 0); + pim_ecmp_nexthop_search(pimg, &out_pnc, + &nexthop, &src, &grp, + 0); if (nexthop.interface) input_iface_vif_index = pim_if_find_vifindex_by_ifindex( @@ -903,8 +904,8 @@ void igmp_source_forward_start(struct igmp_source *source) } } else input_iface_vif_index = - pim_ecmp_fib_lookup_if_vif_index(vif_source, - &src, &grp); + pim_ecmp_fib_lookup_if_vif_index( + pimg, vif_source, &src, &grp); if (PIM_DEBUG_ZEBRA) { char buf2[INET_ADDRSTRLEN]; @@ -1116,8 +1117,9 @@ void pim_forward_start(struct pim_ifchannel *ch) grp.u.prefix4 = up->sg.grp; // Compute PIM RPF using Cached nexthop if (pim_ecmp_nexthop_search( - &out_pnc, &up->rpf.source_nexthop, - &src, &grp, 0)) + pimg, &out_pnc, + &up->rpf.source_nexthop, &src, &grp, + 0)) input_iface_vif_index = pim_if_find_vifindex_by_ifindex( up->rpf.source_nexthop @@ -1148,7 +1150,7 @@ void pim_forward_start(struct pim_ifchannel *ch) } else input_iface_vif_index = pim_ecmp_fib_lookup_if_vif_index( - up->upstream_addr, &src, &grp); + pimg, up->upstream_addr, &src, &grp); if (input_iface_vif_index < 1) { if (PIM_DEBUG_PIM_TRACE) { |