Skip to content

Commit

Permalink
Keep incrementing sequence number when link prober is suspended and s…
Browse files Browse the repository at this point in the history
…hutdown #55 (#65)

### Description of PR
Unable to cherry-pick the commit below cleanly from master branch: 
13f4879 Jing Zhang      Sun Apr 3 21:56:33 2022 -0700   Keep incrementing sequence number when link prober is suspended and shutdown  (#55)

Summary:
Fixes # (issue)
This PR is fix the issue when both sides' link prober is suspended, LinkManager still appears to be healthy. 
When HB suspends, TX sequence number is not updated either, hence link prober won't post an `unknown` event. 

sign-off: Jing Zhang zhangjing@microsoft.com
### Type of change
- [x] Bug fix

### Approach
#### What is the motivation for this PR?
Make sure link prober is reporting `unknown` event when it's suspended or shutdown on both sides. 

#### How did you do it?
Increment sequence number even when HB is not sent. 

#### How did you verify/test it?
Tested on dualToR testbed.
  • Loading branch information
zjswhhh committed Apr 15, 2022
1 parent 8246eb8 commit 8282e78
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/link_prober/LinkProber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,10 @@ void LinkProber::sendHeartbeat()
{
MUXLOGTRACE(mMuxPortConfig.getPortName());

updateIcmpSequenceNo();

// check if suspend timer is running
if ((!mSuspendTx) && (!mShutdownTx)) {
updateIcmpSequenceNo();
boost::system::error_code errorCode;
mStream.write_some(boost::asio::buffer(mTxBuffer.data(), mTxPacketSize), errorCode);

Expand Down
11 changes: 11 additions & 0 deletions test/LinkProberTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ TEST_F(LinkProberTest, UpdateSequenceNo)

EXPECT_TRUE(getRxSelfSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence));
EXPECT_TRUE(getRxPeerSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence));

// sequence number should still be updated when heartbeat is suspended
EXPECT_EQ(getRxSelfSeqNo(), 0);
EXPECT_EQ(getRxPeerSeqNo(), 0);

handleSuspendTxProbes();
EXPECT_TRUE(getSuspendTx());

handleSendHeartbeat();
EXPECT_EQ(getRxSelfSeqNo(), 1);
EXPECT_EQ(getRxPeerSeqNo(), 1);
}

TEST_F(LinkProberTest, GenerateGuid)
Expand Down
3 changes: 3 additions & 0 deletions test/LinkProberTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class LinkProberTest: public ::testing::Test
void initializeSendBuffer() {mLinkProber.initializeSendBuffer();};
void handleUpdateEthernetFrame() {mLinkProber.handleUpdateEthernetFrame();};
void handleUpdateSequenceNumber() {mLinkProber.updateIcmpSequenceNo();};
void handleSuspendTxProbes() {mLinkProber.suspendTxProbes(300);};
void handleSendHeartbeat() {mLinkProber.sendHeartbeat();};
void resetTxBufferTlv() {mLinkProber.resetTxBufferTlv();};
size_t getTxPacketSize() {return mLinkProber.mTxPacketSize;};
size_t appendTlvCommand(link_prober::Command commandType);
Expand All @@ -54,6 +56,7 @@ class LinkProberTest: public ::testing::Test

uint16_t getRxSelfSeqNo() {return mLinkProber.mRxSelfSeqNo;};
uint16_t getRxPeerSeqNo() {return mLinkProber.mRxPeerSeqNo;};
bool getSuspendTx() {return mLinkProber.mSuspendTx;};

boost::asio::io_service mIoService;
common::MuxConfig mMuxConfig;
Expand Down

0 comments on commit 8282e78

Please sign in to comment.