From b4786acd7ea88ec0a3da8edfc4e0ce71f67b5f12 Mon Sep 17 00:00:00 2001 From: anuradhak Date: Thu, 9 Mar 2017 10:47:50 -0800 Subject: [PATCH] pimd: simplify pim upstream state transitions This is another follow-up change to the reg-state and up-join-state separation. The upstream join state machine can now respond to JoinDesired macro changes independent of router role. I have also dropped the PRUNE state from the upstream-join-state enumeration. RFC4601 only defines JOINED and NOTJOINED states. And PRUNE can really be replace by NOTJOINED. Signed-off-by: Anuradha Karuppiah Reviewed-by: Donald Sharp Ticket: CM-14700 Testing Done: Register state machine in FHR only, combined FHR-RP and FHR-RP-LHR/all-in-one setups. Also ran pim-smoke. --- pimd/pim_register.c | 2 +- pimd/pim_upstream.c | 28 ++++------------------------ pimd/pim_upstream.h | 1 - 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 99ddd45d7f..46d8e3ec2e 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -358,7 +358,7 @@ pim_register_recv (struct interface *ifp, upstream->sg.src = sg.src; upstream->rpf.rpf_addr = upstream->rpf.source_nexthop.mrib_nexthop_addr; - upstream->join_state = PIM_UPSTREAM_PRUNE; + upstream->join_state = PIM_UPSTREAM_NOTJOINED; } diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 5324d555ec..19f7d3336c 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -473,26 +473,9 @@ pim_upstream_switch(struct pim_upstream *up, pim_upstream_state2str (new_state)); } - /* - * This code still needs work. - */ - switch (up->join_state) - { - case PIM_UPSTREAM_PRUNE: - if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) - { - up->join_state = new_state; - up->state_transition = pim_time_monotonic_sec (); - } - break; - case PIM_UPSTREAM_NOTJOINED: - case PIM_UPSTREAM_JOINED: - up->join_state = new_state; - if (old_state != new_state) - up->state_transition = pim_time_monotonic_sec(); - - break; - } + up->join_state = new_state; + if (old_state != new_state) + up->state_transition = pim_time_monotonic_sec(); pim_upstream_update_assert_tracking_desired(up); @@ -600,7 +583,7 @@ pim_upstream_new (struct prefix_sg *sg, up->t_ka_timer = NULL; up->t_rs_timer = NULL; up->t_msdp_reg_timer = NULL; - up->join_state = 0; + up->join_state = PIM_UPSTREAM_NOTJOINED; up->reg_state = PIM_REG_NOINFO; up->state_transition = pim_time_monotonic_sec(); up->channel_oil = NULL; @@ -1201,9 +1184,6 @@ pim_upstream_state2str (enum pim_upstream_state join_state) case PIM_UPSTREAM_JOINED: return "Joined"; break; - case PIM_UPSTREAM_PRUNE: - return "Prune"; - break; } return "Unknown"; } diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index cd7c16be75..b191fe9404 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -61,7 +61,6 @@ enum pim_upstream_state { PIM_UPSTREAM_NOTJOINED, PIM_UPSTREAM_JOINED, - PIM_UPSTREAM_PRUNE, }; enum pim_reg_state { -- 2.39.5