From: Donald Sharp Date: Tue, 14 Feb 2017 17:23:28 +0000 (-0500) Subject: pimd: Refactor pim_joinprune_send X-Git-Tag: frr-3.0-branchpoint~16^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b5e2377cca8d2e7339927389e6f05a2f4a1e209d;p=matthieu%2Ffrr.git pimd: Refactor pim_joinprune_send Refactor pim_joinprune_send to use 'struct rpf' Signed-off-by: Donald Sharp --- diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 021e43a4ad..891bdc448d 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -597,8 +597,13 @@ static int on_ifjoin_prune_pending_timer(struct thread *t) /* from here ch may have been deleted */ if (send_prune_echo) - pim_joinprune_send (ifp, pim_ifp->primary_address, - ch->upstream, 0); + { + struct pim_rpf rpf; + + rpf.source_nexthop.interface = ifp; + rpf.rpf_addr.u.prefix4 = pim_ifp->primary_address; + pim_joinprune_send (&rpf, ch->upstream, 0); + } } else { diff --git a/pimd/pim_join.c b/pimd/pim_join.c index cedce8165c..783dd75075 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -303,37 +303,33 @@ int pim_joinprune_recv(struct interface *ifp, return 0; } -int pim_joinprune_send(struct interface *ifp, - struct in_addr upstream_addr, - struct pim_upstream *up, - int send_join) +int pim_joinprune_send(struct pim_rpf *rpf, + struct pim_upstream *up, + int send_join) { struct pim_interface *pim_ifp; uint8_t pim_msg[9000]; int pim_msg_size; - on_trace (__PRETTY_FUNCTION__, ifp, upstream_addr); + on_trace (__PRETTY_FUNCTION__, rpf->source_nexthop.interface, rpf->rpf_addr.u.prefix4); - zassert(ifp); - - pim_ifp = ifp->info; + pim_ifp = rpf->source_nexthop.interface->info; if (!pim_ifp) { zlog_warn("%s: multicast not enabled on interface %s", - __PRETTY_FUNCTION__, - ifp->name); + __PRETTY_FUNCTION__, + rpf->source_nexthop.interface->name); return -1; } - - if (PIM_INADDR_IS_ANY(upstream_addr)) { + if (PIM_INADDR_IS_ANY(rpf->rpf_addr.u.prefix4)) { if (PIM_DEBUG_PIM_J_P) { char dst_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", upstream_addr, dst_str, sizeof(dst_str)); + pim_inet4_dump("", rpf->rpf_addr.u.prefix4, dst_str, sizeof(dst_str)); zlog_debug("%s: %s(S,G)=%s: upstream=%s is myself on interface %s", __PRETTY_FUNCTION__, send_join ? "Join" : "Prune", - up->sg_str, dst_str, ifp->name); + up->sg_str, dst_str, rpf->source_nexthop.interface->name); } return 0; } @@ -347,24 +343,24 @@ int pim_joinprune_send(struct interface *ifp, relevant Hello message without waiting for the Hello Timer to expire, followed by the Join/Prune or Assert message. */ - pim_hello_require(ifp); + pim_hello_require(rpf->source_nexthop.interface); /* Build PIM message */ pim_msg_size = pim_msg_join_prune_encode (pim_msg, 9000, send_join, - up, upstream_addr, PIM_JP_HOLDTIME); + up, rpf->rpf_addr.u.prefix4, PIM_JP_HOLDTIME); if (pim_msg_size < 0) return pim_msg_size; if (PIM_DEBUG_PIM_J_P) { char dst_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", upstream_addr, dst_str, sizeof(dst_str)); + pim_inet4_dump("", rpf->rpf_addr.u.prefix4, dst_str, sizeof(dst_str)); zlog_debug("%s: sending %s(S,G)=%s to upstream=%s on interface %s", __PRETTY_FUNCTION__, send_join ? "Join" : "Prune", - up->sg_str, dst_str, ifp->name); + up->sg_str, dst_str, rpf->source_nexthop.interface->name); } if (pim_msg_send(pim_ifp->pim_sock_fd, @@ -372,9 +368,9 @@ int pim_joinprune_send(struct interface *ifp, qpim_all_pim_routers_addr, pim_msg, pim_msg_size, - ifp->name)) { + rpf->source_nexthop.interface->name)) { zlog_warn("%s: could not send PIM message on interface %s", - __PRETTY_FUNCTION__, ifp->name); + __PRETTY_FUNCTION__, rpf->source_nexthop.interface->name); return -8; } diff --git a/pimd/pim_join.h b/pimd/pim_join.h index 1eeeef756f..4b76166328 100644 --- a/pimd/pim_join.h +++ b/pimd/pim_join.h @@ -32,9 +32,8 @@ int pim_joinprune_recv(struct interface *ifp, struct in_addr src_addr, uint8_t *tlv_buf, int tlv_buf_size); -int pim_joinprune_send(struct interface *ifp, - struct in_addr upstream_addr, - struct pim_upstream *up, - int send_join); +int pim_joinprune_send(struct pim_rpf *nexthop, + struct pim_upstream *up, + int send_join); #endif /* PIM_JOIN_H */ diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index b7526c290a..1712acaa1e 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -171,9 +171,7 @@ pim_upstream_del(struct pim_upstream *up, const char *name) THREAD_OFF(up->t_msdp_reg_timer); if (up->join_state == PIM_UPSTREAM_JOINED) { - pim_joinprune_send (up->rpf.source_nexthop.interface, - up->rpf.rpf_addr.u.prefix4, - up, 0); + pim_joinprune_send (&up->rpf, up, 0); if (up->sg.src.s_addr == INADDR_ANY) { /* if a (*, G) entry in the joined state is being deleted we * need to notify MSDP */ @@ -231,10 +229,7 @@ pim_upstream_send_join (struct pim_upstream *up) } /* send Join(S,G) to the current upstream neighbor */ - pim_joinprune_send(up->rpf.source_nexthop.interface, - up->rpf.rpf_addr.u.prefix4, - up, - 1 /* join */); + pim_joinprune_send(&up->rpf, up, 1 /* join */); } static int on_join_timer(struct thread *t) @@ -487,10 +482,7 @@ pim_upstream_switch(struct pim_upstream *up, forward_off(up); if (old_state == PIM_UPSTREAM_JOINED) pim_msdp_up_join_state_changed(up); - pim_joinprune_send(up->rpf.source_nexthop.interface, - up->rpf.rpf_addr.u.prefix4, - up, - 0 /* prune */); + pim_joinprune_send(&up->rpf, up, 0 /* prune */); if (up->t_join_timer) THREAD_OFF(up->t_join_timer); } diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index b96d812a62..0f92b4a7b0 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -411,14 +411,10 @@ static void scan_upstream_rpf_cache() /* send Prune(S,G) to the old upstream neighbor */ - pim_joinprune_send(old.source_nexthop.interface, old.rpf_addr.u.prefix4, - up, 0 /* prune */); + pim_joinprune_send(&old, up, 0 /* prune */); /* send Join(S,G) to the current upstream neighbor */ - pim_joinprune_send(up->rpf.source_nexthop.interface, - up->rpf.rpf_addr.u.prefix4, - up, - 1 /* join */); + pim_joinprune_send(&up->rpf, up, 1 /* join */); pim_upstream_join_timer_restart(up); } /* up->join_state == PIM_UPSTREAM_JOINED */