Skip to content

Commit 65e530a

Browse files
zjswhhhmssonicbld
authored andcommitted
Enforce switchover when target state is standby AND mux mode is standby (#281)
Description of PR Summary: Fixes # (issue) Enforce switchover when target state is standby AND mux mode is standby. sign-off: Jing Zhang [email protected] Type of change Bug fix New feature Doc/Design Unit test Approach What is the motivation for this PR? Soc agent can always restart and set the forwarding state to default "active" on host side. If this happens during ToR maintenance ( mux mode != auto), we still need to correct the state to "standby". Work item tracking Microsoft ADO (number only): 30158450
1 parent f3fbf09 commit 65e530a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/link_manager/LinkManagerStateMachineActiveActive.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,8 @@ void ActiveActiveStateMachine::switchMuxState(
10341034
if (forceSwitch ||
10351035
mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Auto ||
10361036
mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Detached ||
1037-
(mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Active && label == mux_state::MuxState::Label::Active)) {
1037+
(mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Active && label == mux_state::MuxState::Label::Active) ||
1038+
(mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Standby && label == mux_state::MuxState::Label::Standby)) {
10381039
MUXLOGWARNING(
10391040
boost::format("%s: Switching MUX state to '%s'") %
10401041
mMuxPortConfig.getPortName() %

test/LinkManagerStateMachineActiveActiveTest.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,28 @@ TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveConfigStandby)
384384
VALIDATE_STATE(Active, Active, Up);
385385
}
386386

387+
TEST_F(LinkManagerStateMachineActiveActiveTest, ConfigStandbySocAgentRestart)
388+
{
389+
setMuxActive();
390+
391+
handleMuxConfig("standby", 1);
392+
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 2);
393+
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Standby);
394+
VALIDATE_STATE(Active, Standby, Up);
395+
396+
handleMuxState("standby", 3);
397+
VALIDATE_STATE(Active, Standby, Up);
398+
399+
handleMuxState("active", 3);
400+
VALIDATE_STATE(Active, Standby, Up);
401+
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 3);
402+
403+
handleMuxConfig("auto", 1);
404+
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 4);
405+
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Active);
406+
VALIDATE_STATE(Active, Active, Up);
407+
}
408+
387409
TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveLinkProberPeerActive)
388410
{
389411
setMuxActive();

0 commit comments

Comments
 (0)