From 8e5f97e3c130d3d6c1dd0ddd7a93e5870128c24e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 21 May 2017 09:10:17 -0400 Subject: [PATCH] pimd: Cleanup pimg from pim_upstream.c Signed-off-by: Donald Sharp --- pimd/pim_register.c | 4 ++-- pimd/pim_upstream.c | 28 ++++++++++++++++++---------- pimd/pim_upstream.h | 5 +++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 8ba030d2dc..c753358ec0 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -377,7 +377,7 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr, } if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) - || ((SwitchToSptDesired(&sg)) + || ((SwitchToSptDesired(pim_ifp->pim, &sg)) && pim_upstream_inherited_olist(pim_ifp->pim, upstream) == 0)) { // pim_scan_individual_oil (upstream->channel_oil); @@ -389,7 +389,7 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr, upstream->sptbit); } if ((upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) - || (SwitchToSptDesired(&sg))) { + || (SwitchToSptDesired(pim_ifp->pim, &sg))) { if (sentRegisterStop) { pim_upstream_keep_alive_timer_start( upstream, qpim_rp_keep_alive_time); diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 9d46206758..cb0170767a 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -1081,10 +1081,12 @@ static void pim_upstream_fhr_kat_start(struct pim_upstream *up) static int pim_upstream_keep_alive_timer(struct thread *t) { struct pim_upstream *up; + struct pim_instance *pim; up = THREAD_ARG(t); + pim = up->channel_oil->pim; - if (I_am_RP(pimg, up->sg.grp)) { + if (I_am_RP(pim, up->sg.grp)) { pim_br_clear_pmbr(&up->sg); /* * We need to do more here :) @@ -1097,15 +1099,15 @@ static int pim_upstream_keep_alive_timer(struct thread *t) /* if entry was created because of activity we need to deref it */ if (PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(up->flags)) { - pim_upstream_fhr_kat_expiry(pimg, up); + pim_upstream_fhr_kat_expiry(pim, up); if (PIM_DEBUG_TRACE) zlog_debug("kat expired on %s; remove stream reference", up->sg_str); PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(up->flags); - pim_upstream_del(pimg, up, __PRETTY_FUNCTION__); + pim_upstream_del(pim, up, __PRETTY_FUNCTION__); } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) { PIM_UPSTREAM_FLAG_UNSET_SRC_LHR(up->flags); - pim_upstream_del(pimg, up, __PRETTY_FUNCTION__); + pim_upstream_del(pim, up, __PRETTY_FUNCTION__); } return 0; @@ -1175,9 +1177,10 @@ void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up) * SwitchToSptDesired(S,G) return true once a single packet has been * received for the source and group. */ -int pim_upstream_switch_to_spt_desired(struct prefix_sg *sg) +int pim_upstream_switch_to_spt_desired(struct pim_instance *pim, + struct prefix_sg *sg) { - if (I_am_RP(pimg, sg->grp)) + if (I_am_RP(pim, sg->grp)) return 1; return 0; @@ -1311,10 +1314,12 @@ const char *pim_reg_state2str(enum pim_reg_state reg_state, char *state_str) static int pim_upstream_register_stop_timer(struct thread *t) { struct pim_interface *pim_ifp; + struct pim_instance *pim; struct pim_upstream *up; struct pim_rpf *rpg; struct ip ip_hdr; up = THREAD_ARG(t); + pim = up->channel_oil->pim; if (PIM_DEBUG_TRACE) { char state_str[PIM_REG_STATE_STR_LEN]; @@ -1326,7 +1331,7 @@ static int pim_upstream_register_stop_timer(struct thread *t) switch (up->reg_state) { case PIM_REG_JOIN_PENDING: up->reg_state = PIM_REG_JOIN; - pim_channel_add_oif(up->channel_oil, pimg->regiface, + pim_channel_add_oif(up->channel_oil, pim->regiface, PIM_OIF_FLAG_PROTO_PIM); break; case PIM_REG_JOIN: @@ -1558,6 +1563,8 @@ static int pim_upstream_equal(const void *arg1, const void *arg2) */ static bool pim_upstream_kat_start_ok(struct pim_upstream *up) { + struct pim_instance *pim = up->channel_oil->pim; + /* "iif == RPF_interface(S)" check has to be done by the kernel or hw * so we will skip that here */ if (pim_if_connected_to_source(up->rpf.source_nexthop.interface, @@ -1577,7 +1584,7 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up) * MUST be * removed to handle spt turn-arounds correctly in a 3-tier clos */ - if (I_am_RP(pimg, up->sg.grp)) + if (I_am_RP(pim, up->sg.grp)) return true; } @@ -1591,9 +1598,10 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up) static void pim_upstream_sg_running(void *arg) { struct pim_upstream *up = (struct pim_upstream *)arg; + struct pim_instance *pim = up->channel_oil->pim; // No packet can have arrived here if this is the case - if (!up->channel_oil || !up->channel_oil->installed) { + if (!up->channel_oil->installed) { if (PIM_DEBUG_TRACE) zlog_debug("%s: %s is not installed in mroute", __PRETTY_FUNCTION__, up->sg_str); @@ -1613,7 +1621,7 @@ static void pim_upstream_sg_running(void *arg) zlog_debug( "%s: Handling unscanned inherited_olist for %s", __PRETTY_FUNCTION__, up->sg_str); - pim_upstream_inherited_olist_decide(pimg, up); + pim_upstream_inherited_olist_decide(pim, up); up->channel_oil->oil_inherited_rescan = 0; } pim_mroute_update_counters(up->channel_oil); diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index 62bd212e99..a9d84bb9b4 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -178,8 +178,9 @@ void pim_upstream_update_my_assert_metric(struct pim_upstream *up); void pim_upstream_keep_alive_timer_start(struct pim_upstream *up, uint32_t time); -int pim_upstream_switch_to_spt_desired(struct prefix_sg *sg); -#define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg) +int pim_upstream_switch_to_spt_desired(struct pim_instance *pim, + struct prefix_sg *sg); +#define SwitchToSptDesired(pim, sg) pim_upstream_switch_to_spt_desired (pim, sg) int pim_upstream_is_sg_rpt(struct pim_upstream *up); void pim_upstream_set_sptbit(struct pim_upstream *up, -- 2.39.5