Skip to content

Commit

Permalink
[active-active] Fix extra toggle after default route N/A
Browse files Browse the repository at this point in the history
Signed-off-by: Longxiang Lyu <[email protected]>
  • Loading branch information
lolyu committed Nov 12, 2024
1 parent 287dbd7 commit d36ee2b
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 d36ee2b

Please sign in to comment.