Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/MuxPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/common/MuxPortConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class MuxPortConfig
Auto,
Manual,
Active,
Standby
Standby,
Detached // mux mode for active-active cable type only
};

/**
Expand Down
21 changes: 12 additions & 9 deletions src/link_manager/LinkManagerStateMachineActiveActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() %
Expand All @@ -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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the detach mode, could you please point , where is the actual logic to not query the peer ToR's gRPC API's ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently querying SELF & PEER is using a same DB table entry. Per offline discussion, will make another PR to separate in the future.

This PR only avoids setting PEER's state.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the detach mode, could you please point , where is the actual logic to not query the peer ToR's gRPC API's ?

}
}

//
Expand Down
14 changes: 14 additions & 0 deletions test/LinkManagerStateMachineActiveActiveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down