Skip to content

Commit

Permalink
[active-active] Fix extra toggle after default route N/A (#279)
Browse files Browse the repository at this point in the history
Approach
What is the motivation for this PR?
Fixes #278

Fix the extra toggle after the default route N/A.

(active, active, up), ok                        <- default route n/a
                                                -> toggle to standby
(active, standby, up), n/a                      <- mux probe active from the periodically probe
(active, active, up), n/a                       <- mux state standby returned from the toggle to standby
(active, standby, up), n/a                      -> toggle to active
(active, active, up), n/a                       <- mux state active returned from the toggle to active
(active, active, up), n/a                       <- link prober unknown
(unknown, active, up), n/a                      -> toggle to standby
(unknown, standby, up), n/a                     <- mux state standby returned from toggle to standby
Signed-off-by: Longxiang Lyu [email protected]

Work item tracking
Microsoft ADO (number only): 30186968
How did you do it?
Let's check the default route state when the mux transits into (active, standby, up), if the default route state is N/A, skip the toggle to active.

How did you verify/test it?
UT
  • Loading branch information
lolyu authored Nov 13, 2024
1 parent 287dbd7 commit f3fbf09
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/link_manager/LinkManagerStateMachineActiveActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ void ActiveActiveStateMachine::LinkProberActiveMuxStandbyLinkUpTransitionFunctio
// last siwtch mux state to standby failed, try again
switchMuxState(nextState, mux_state::MuxState::Label::Standby, true);
}
} else {
} else if (mDefaultRouteState != DefaultRoute::NA) {
switchMuxState(nextState, mux_state::MuxState::Label::Active);
}
}
Expand Down
29 changes: 29 additions & 0 deletions test/LinkManagerStateMachineActiveActiveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,35 @@ TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActivDefaultRouteState)
EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mRestartTxProbeCallCount, 3);
}

TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActivDefaultRouteStateNALMuxProbeActiveAfterToggle)
{
setMuxActive();

mMuxConfig.enableDefaultRouteFeature(true);
postDefaultRouteEvent("na", 1);
EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mShutdownTxProbeCallCount, 1);
EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mRestartTxProbeCallCount, 0);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 2);
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Standby);
VALIDATE_STATE(Active, Standby, Up);

// misleading mux state active from periodically probe
handleProbeMuxState("active", 3);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 2);
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Standby);
VALIDATE_STATE(Active, Active, Up);

handleMuxState("standby", 3);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 2);
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Standby);
VALIDATE_STATE(Active, Standby, Up);

postLinkProberEvent(link_prober::LinkProberState::Unknown, 3);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 2);
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Standby);
VALIDATE_STATE(Unknown, Standby, Up);
}

TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActivDefaultRouteStateMuxConfigActive)
{
setMuxActive();
Expand Down

0 comments on commit f3fbf09

Please sign in to comment.