diff --git a/src/MuxPort.cpp b/src/MuxPort.cpp index 422b7224..00eb7637 100644 --- a/src/MuxPort.cpp +++ b/src/MuxPort.cpp @@ -274,6 +274,12 @@ void MuxPort::handleMuxConfig(const std::string &config) mode = common::MuxPortConfig::Manual; } else if (config == "standby") { mode = common::MuxPortConfig::Standby; + } else if (config == "detach") { + if (mMuxPortConfig.getPortCableType() == common::MuxPortConfig::PortCableType::ActiveStandby) { + MUXLOGWARNING(boost::format("port: %s, detach mode is only supported for acitve-active cable type") % mMuxPortConfig.getPortName()); + return; + } + mode = common::MuxPortConfig::Detached; } boost::asio::io_service &ioService = mStrand.context(); diff --git a/src/common/MuxPortConfig.h b/src/common/MuxPortConfig.h index ae209238..3439de27 100644 --- a/src/common/MuxPortConfig.h +++ b/src/common/MuxPortConfig.h @@ -50,7 +50,8 @@ class MuxPortConfig Auto, Manual, Active, - Standby + Standby, + Detached // mux mode for active-active cable type only }; /** diff --git a/src/link_manager/LinkManagerStateMachineActiveActive.cpp b/src/link_manager/LinkManagerStateMachineActiveActive.cpp index dfcded86..a95db91d 100644 --- a/src/link_manager/LinkManagerStateMachineActiveActive.cpp +++ b/src/link_manager/LinkManagerStateMachineActiveActive.cpp @@ -695,7 +695,8 @@ void ActiveActiveStateMachine::switchMuxState( mux_state::MuxState::Label label ) { - if (mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Auto) { + if (mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Auto || + mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Detached) { MUXLOGWARNING( boost::format("%s: Switching MUX state to '%s'") % mMuxPortConfig.getPortName() % @@ -722,14 +723,16 @@ void ActiveActiveStateMachine::switchMuxState( // void ActiveActiveStateMachine::switchPeerMuxState(mux_state::MuxState::Label label) { - MUXLOGWARNING( - boost::format("%s: Switching peer MUX state to '%s'") % - mMuxPortConfig.getPortName() % - mMuxStateName[label] - ); - enterPeerMuxState(label); - mMuxPortPtr->setPeerMuxState(label); - startPeerMuxWaitTimer(); + if (mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Auto) { + MUXLOGWARNING( + boost::format("%s: Switching peer MUX state to '%s'") % + mMuxPortConfig.getPortName() % + mMuxStateName[label] + ); + enterPeerMuxState(label); + mMuxPortPtr->setPeerMuxState(label); + startPeerMuxWaitTimer(); + } } // diff --git a/test/LinkManagerStateMachineActiveActiveTest.cpp b/test/LinkManagerStateMachineActiveActiveTest.cpp index 949fe08f..fdd39261 100644 --- a/test/LinkManagerStateMachineActiveActiveTest.cpp +++ b/test/LinkManagerStateMachineActiveActiveTest.cpp @@ -355,6 +355,20 @@ TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveLinkProberPeerUnknown) VALIDATE_PEER_STATE(PeerUnknown, Standby); } +TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveConfigDetachedLinkProberPeerUnknown) +{ + setMuxActive(); + + postPeerLinkProberEvent(link_prober::LinkProberState::PeerActive); + VALIDATE_PEER_STATE(PeerActive, Active); + + handleMuxConfig("detach", 1); + postPeerLinkProberEvent(link_prober::LinkProberState::PeerUnknown, 3); + + VALIDATE_PEER_STATE(PeerUnknown, Active); + EXPECT_EQ(mDbInterfacePtr->mSetPeerMuxStateInvokeCount, 0); +} + TEST_F(LinkManagerStateMachineActiveActiveTest, MuxStandby) { setMuxStandby();