diff options
author | Jafar Al-Gharaibeh <Jafaral@users.noreply.github.com> | 2019-04-04 06:02:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-04 06:02:32 +0200 |
commit | dbf2f94c2cfd713b54f31becb9582c219463d507 (patch) | |
tree | 6897f394f2511aa36ca0ed2f47aaa08ecc54379f /pimd | |
parent | Merge pull request #4070 from donaldsharp/static_fixup (diff) | |
parent | pimd: pim_nexthop_lookup should return true/false (diff) | |
download | frr-dbf2f94c2cfd713b54f31becb9582c219463d507.tar.xz frr-dbf2f94c2cfd713b54f31becb9582c219463d507.zip |
Merge pull request #4060 from donaldsharp/pim_cherrybomb
Pim cherrybomb
Diffstat (limited to 'pimd')
-rw-r--r-- | pimd/pim_cmd.c | 2 | ||||
-rw-r--r-- | pimd/pim_igmp_mtrace.c | 14 | ||||
-rw-r--r-- | pimd/pim_mroute.c | 7 | ||||
-rw-r--r-- | pimd/pim_neighbor.c | 2 | ||||
-rw-r--r-- | pimd/pim_nht.c | 39 | ||||
-rw-r--r-- | pimd/pim_nht.h | 1 | ||||
-rw-r--r-- | pimd/pim_rp.c | 7 | ||||
-rw-r--r-- | pimd/pim_rp.h | 2 | ||||
-rw-r--r-- | pimd/pim_rpf.c | 14 | ||||
-rw-r--r-- | pimd/pim_rpf.h | 4 |
10 files changed, 21 insertions, 71 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 70b3ae10e..e002bfee5 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -5026,7 +5026,7 @@ DEFUN (show_ip_rib, return CMD_WARNING; } - if (pim_nexthop_lookup(vrf->info, &nexthop, addr, 0)) { + if (!pim_nexthop_lookup(vrf->info, &nexthop, addr, 0)) { vty_out(vty, "Failure querying RIB nexthop for unicast address %s\n", addr_str); diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index f51e0c0d2..0758e2f78 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -66,16 +66,13 @@ static bool mtrace_fwd_info_weak(struct pim_instance *pim, struct pim_nexthop nexthop; struct interface *ifp_in; struct in_addr nh_addr; - int ret; char nexthop_str[INET_ADDRSTRLEN]; nh_addr.s_addr = 0; memset(&nexthop, 0, sizeof(nexthop)); - ret = pim_nexthop_lookup(pim, &nexthop, mtracep->src_addr, 1); - - if (ret != 0) { + if (!pim_nexthop_lookup(pim, &nexthop, mtracep->src_addr, 1)) { if (PIM_DEBUG_MTRACE) zlog_debug("mtrace not found neighbor"); return false; @@ -418,9 +415,7 @@ static int mtrace_un_forward_packet(struct pim_instance *pim, struct ip *ip_hdr, if (interface == NULL) { memset(&nexthop, 0, sizeof(nexthop)); - ret = pim_nexthop_lookup(pim, &nexthop, ip_hdr->ip_dst, 0); - - if (ret != 0) { + if (!pim_nexthop_lookup(pim, &nexthop, ip_hdr->ip_dst, 0)) { close(fd); if (PIM_DEBUG_MTRACE) zlog_warn( @@ -568,7 +563,6 @@ static int mtrace_send_response(struct pim_instance *pim, struct igmp_mtrace *mtracep, size_t mtrace_len) { struct pim_nexthop nexthop; - int ret; mtracep->type = PIM_IGMP_MTRACE_RESPONSE; @@ -599,9 +593,7 @@ static int mtrace_send_response(struct pim_instance *pim, } else { memset(&nexthop, 0, sizeof(nexthop)); /* TODO: should use unicast rib lookup */ - ret = pim_nexthop_lookup(pim, &nexthop, mtracep->rsp_addr, 1); - - if (ret != 0) { + if (!pim_nexthop_lookup(pim, &nexthop, mtracep->rsp_addr, 1)) { if (PIM_DEBUG_MTRACE) zlog_warn( "Dropped response qid=%ud, no route to " diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index 999a1eb58..a2d50aba5 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -513,8 +513,7 @@ 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(pim_ifp->pim, &source, - up->upstream_register, 0) - == 0) { + up->upstream_register, 0)) { pim_register_stop_send(source.interface, &sg, pim_ifp->primary_address, up->upstream_register); @@ -531,8 +530,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, } else { if (I_am_RP(pim_ifp->pim, up->sg.grp)) { if (pim_nexthop_lookup(pim_ifp->pim, &source, - up->upstream_register, 0) - == 0) + up->upstream_register, + 0)) pim_register_stop_send( source.interface, &sg, pim_ifp->primary_address, diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index 436f2dec2..a63b09fc1 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -540,7 +540,7 @@ pim_neighbor_add(struct interface *ifp, struct in_addr source_addr, Upon PIM neighbor UP, iterate all RPs and update nexthop cache with this neighbor. */ - pim_resolve_rp_nh(pim_ifp->pim); + pim_resolve_rp_nh(pim_ifp->pim, neigh); pim_rp_setup(pim_ifp->pim); diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 9b5379384..5e550dfe8 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -264,45 +264,6 @@ static void pim_update_rp_nh(struct pim_instance *pim, } } -/* This API is used to traverse nexthop cache of RPF addr - of upstream entry whose IPv4 nexthop address is in - unresolved state and due to event like pim neighbor - UP event if it can be resolved. -*/ -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(pim, nht_p, NULL, NULL, &pnc)) - return; - - for (nh_node = pnc.nexthop; nh_node; nh_node = nh_node->next) { - if (nh_node->gate.ipv4.s_addr != 0) - continue; - - struct interface *ifp1 = - if_lookup_by_index(nh_node->ifindex, pim->vrf_id); - nbr = pim_neighbor_find_if(ifp1); - if (!nbr) - continue; - - nh_node->gate.ipv4 = nbr->source_addr; - if (PIM_DEBUG_PIM_NHT) { - char str[PREFIX_STRLEN]; - char str1[INET_ADDRSTRLEN]; - pim_inet4_dump("<nht_nbr?>", nbr->source_addr, str1, - sizeof(str1)); - pim_addr_dump("<nht_addr?>", nht_p, str, sizeof(str)); - zlog_debug( - "%s: addr %s new nexthop addr %s interface %s", - __PRETTY_FUNCTION__, str, str1, ifp1->name); - } - } -} - /* Update Upstream nexthop info based on Nexthop update received from Zebra.*/ static int pim_update_upstream_nh_helper(struct hash_bucket *bucket, void *arg) { diff --git a/pimd/pim_nht.h b/pimd/pim_nht.h index 6eff7bbc8..e3e9f578c 100644 --- a/pimd/pim_nht.h +++ b/pimd/pim_nht.h @@ -65,7 +65,6 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, struct prefix *grp, int neighbor_needed); void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient, struct pim_nexthop_cache *pnc, int command); -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 prefix *src, struct prefix *grp); void pim_rp_nexthop_del(struct rp_info *rp_info); diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index b7db7d041..4e285720a 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -1206,14 +1206,13 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj) } } -void pim_resolve_rp_nh(struct pim_instance *pim) +void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr) { struct listnode *node = NULL; struct rp_info *rp_info = NULL; struct nexthop *nh_node = NULL; struct prefix nht_p; struct pim_nexthop_cache pnc; - struct pim_neighbor *nbr = NULL; for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) { if (rp_info->rp.rpf_addr.u.prefix4.s_addr == INADDR_NONE) @@ -1233,8 +1232,8 @@ void pim_resolve_rp_nh(struct pim_instance *pim) struct interface *ifp1 = if_lookup_by_index( nh_node->ifindex, pim->vrf_id); - nbr = pim_neighbor_find_if(ifp1); - if (!nbr) + + if (nbr->interface != ifp1) continue; nh_node->gate.ipv4 = nbr->source_addr; diff --git a/pimd/pim_rp.h b/pimd/pim_rp.h index e0f8e16be..402ec30ab 100644 --- a/pimd/pim_rp.h +++ b/pimd/pim_rp.h @@ -68,7 +68,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group); void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj); -void pim_resolve_rp_nh(struct pim_instance *pim); +void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr); int pim_rp_list_cmp(void *v1, void *v2); struct rp_info *pim_rp_find_match_group(struct pim_instance *pim, const struct prefix *group); diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index ee145a5b5..55f788b5b 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -48,8 +48,8 @@ void pim_rpf_set_refresh_time(struct pim_instance *pim) pim->last_route_change_time); } -int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, - struct in_addr addr, int neighbor_needed) +bool 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; @@ -65,7 +65,7 @@ int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, * it will never work */ if (addr.s_addr == INADDR_NONE) - return -1; + return false; if ((nexthop->last_lookup.s_addr == addr.s_addr) && (nexthop->last_lookup_time > pim->last_route_change_time)) { @@ -83,7 +83,7 @@ int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, pim->last_route_change_time, nexthop_str); } pim->nexthop_lookups_avoided++; - return 0; + return true; } else { if (PIM_DEBUG_TRACE) { char addr_str[INET_ADDRSTRLEN]; @@ -107,7 +107,7 @@ int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, zlog_warn( "%s %s: could not find nexthop ifindex for address %s", __FILE__, __PRETTY_FUNCTION__, addr_str); - return -1; + return false; } while (!found && (i < num_ifindex)) { @@ -179,9 +179,9 @@ int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, nexthop->last_lookup = addr; nexthop->last_lookup_time = pim_time_monotonic_usec(); nexthop->nbr = nbr; - return 0; + return true; } else - return -1; + return false; } static int nexthop_mismatch(const struct pim_nexthop *nh1, diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h index a4793df66..57bb22674 100644 --- a/pimd/pim_rpf.h +++ b/pimd/pim_rpf.h @@ -59,8 +59,8 @@ struct pim_upstream; unsigned int pim_rpf_hash_key(void *arg); bool pim_rpf_equal(const void *arg1, const void *arg2); -int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop, - struct in_addr addr, int neighbor_needed); +bool 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_instance *pim, struct pim_upstream *up, struct pim_rpf *old, uint8_t is_new); |