From ea6d91c86bd8d5f7ad03b5e7e9527c4fcdfa6887 Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Thu, 15 Aug 2019 14:00:35 -0700 Subject: [PATCH] pimd: re-eval flow activity on kat expiry When the (S,G) KAT expires we need to poll for activity before dropping the entry as traffic may have been forwarded by the dataplane since the last periodic poll cycle. This only works if traffic is being forwarded by the kernel i.e. if the entries were HW accelerated via an ASIC we may still miss out on last minute activity on the mroute in the HW. Ticket: CM-26871 Signed-off-by: Anuradha Karuppiah --- pimd/pim_upstream.c | 88 ++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 998720e8f6..efa58c1b1f 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -57,6 +57,7 @@ static void join_timer_stop(struct pim_upstream *up); static void pim_upstream_update_assert_tracking_desired(struct pim_upstream *up); +static bool pim_upstream_sg_running_proc(struct pim_upstream *up); /* * A (*,G) or a (*,*) is going away @@ -1453,6 +1454,11 @@ static int pim_upstream_keep_alive_timer(struct thread *t) up = THREAD_ARG(t); + /* pull the stats and re-check */ + if (pim_upstream_sg_running_proc(up)) + /* kat was restarted because of new activity */ + return 0; + pim_upstream_keep_alive_timer_proc(up); return 0; } @@ -1965,39 +1971,14 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up) return false; } -/* - * Code to check and see if we've received packets on a S,G mroute - * and if so to set the SPT bit appropriately - */ -static void pim_upstream_sg_running(void *arg) +static bool pim_upstream_sg_running_proc(struct pim_upstream *up) { - struct pim_upstream *up = (struct pim_upstream *)arg; - struct pim_instance *pim = up->channel_oil->pim; + bool rv = false; + struct pim_instance *pim = up->pim; - // No packet can have arrived here if this is the case - if (!up->channel_oil->installed) { - if (PIM_DEBUG_PIM_TRACE) - zlog_debug("%s: %s%s is not installed in mroute", - __func__, up->sg_str, pim->vrf->name); - return; - } + if (!up->channel_oil->installed) + return rv; - /* - * This is a bit of a hack - * We've noted that we should rescan but - * we've missed the window for doing so in - * pim_zebra.c for some reason. I am - * only doing this at this point in time - * to get us up and working for the moment - */ - if (up->channel_oil->oil_inherited_rescan) { - if (PIM_DEBUG_PIM_TRACE) - zlog_debug( - "%s: Handling unscanned inherited_olist for %s[%s]", - __func__, up->sg_str, pim->vrf->name); - pim_upstream_inherited_olist_decide(pim, up); - up->channel_oil->oil_inherited_rescan = 0; - } pim_mroute_update_counters(up->channel_oil); // Have we seen packets? @@ -2011,7 +1992,7 @@ static void pim_upstream_sg_running(void *arg) up->channel_oil->cc.pktcnt, up->channel_oil->cc.lastused / 100); } - return; + return rv; } if (pim_upstream_kat_start_ok(up)) { @@ -2029,14 +2010,55 @@ static void pim_upstream_sg_running(void *arg) pim_upstream_fhr_kat_start(up); } pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time); - } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) + rv = true; + } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) { pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time); + rv = true; + } if ((up->sptbit != PIM_UPSTREAM_SPTBIT_TRUE) && (up->rpf.source_nexthop.interface)) { pim_upstream_set_sptbit(up, up->rpf.source_nexthop.interface); } - return; + + return rv; +} + +/* + * Code to check and see if we've received packets on a S,G mroute + * and if so to set the SPT bit appropriately + */ +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->installed) { + if (PIM_DEBUG_TRACE) + zlog_debug("%s: %s%s is not installed in mroute", + __func__, up->sg_str, pim->vrf->name); + return; + } + + /* + * This is a bit of a hack + * We've noted that we should rescan but + * we've missed the window for doing so in + * pim_zebra.c for some reason. I am + * only doing this at this point in time + * to get us up and working for the moment + */ + if (up->channel_oil->oil_inherited_rescan) { + if (PIM_DEBUG_TRACE) + zlog_debug( + "%s: Handling unscanned inherited_olist for %s[%s]", + __func__, up->sg_str, pim->vrf->name); + pim_upstream_inherited_olist_decide(pim, up); + up->channel_oil->oil_inherited_rescan = 0; + } + + pim_upstream_sg_running_proc(up); } void pim_upstream_add_lhr_star_pimreg(struct pim_instance *pim) -- 2.39.5