Skip to content

Commit 8282e78

Browse files
authored
Keep incrementing sequence number when link prober is suspended and shutdown #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 [email protected] ### 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.
1 parent 8246eb8 commit 8282e78

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/link_prober/LinkProber.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ void LinkProber::sendHeartbeat()
271271
{
272272
MUXLOGTRACE(mMuxPortConfig.getPortName());
273273

274+
updateIcmpSequenceNo();
275+
274276
// check if suspend timer is running
275277
if ((!mSuspendTx) && (!mShutdownTx)) {
276-
updateIcmpSequenceNo();
277278
boost::system::error_code errorCode;
278279
mStream.write_some(boost::asio::buffer(mTxBuffer.data(), mTxPacketSize), errorCode);
279280

test/LinkProberTest.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ TEST_F(LinkProberTest, UpdateSequenceNo)
160160

161161
EXPECT_TRUE(getRxSelfSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence));
162162
EXPECT_TRUE(getRxPeerSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence));
163+
164+
// sequence number should still be updated when heartbeat is suspended
165+
EXPECT_EQ(getRxSelfSeqNo(), 0);
166+
EXPECT_EQ(getRxPeerSeqNo(), 0);
167+
168+
handleSuspendTxProbes();
169+
EXPECT_TRUE(getSuspendTx());
170+
171+
handleSendHeartbeat();
172+
EXPECT_EQ(getRxSelfSeqNo(), 1);
173+
EXPECT_EQ(getRxPeerSeqNo(), 1);
163174
}
164175

165176
TEST_F(LinkProberTest, GenerateGuid)

test/LinkProberTest.h

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class LinkProberTest: public ::testing::Test
4242
void initializeSendBuffer() {mLinkProber.initializeSendBuffer();};
4343
void handleUpdateEthernetFrame() {mLinkProber.handleUpdateEthernetFrame();};
4444
void handleUpdateSequenceNumber() {mLinkProber.updateIcmpSequenceNo();};
45+
void handleSuspendTxProbes() {mLinkProber.suspendTxProbes(300);};
46+
void handleSendHeartbeat() {mLinkProber.sendHeartbeat();};
4547
void resetTxBufferTlv() {mLinkProber.resetTxBufferTlv();};
4648
size_t getTxPacketSize() {return mLinkProber.mTxPacketSize;};
4749
size_t appendTlvCommand(link_prober::Command commandType);
@@ -54,6 +56,7 @@ class LinkProberTest: public ::testing::Test
5456

5557
uint16_t getRxSelfSeqNo() {return mLinkProber.mRxSelfSeqNo;};
5658
uint16_t getRxPeerSeqNo() {return mLinkProber.mRxPeerSeqNo;};
59+
bool getSuspendTx() {return mLinkProber.mSuspendTx;};
5760

5861
boost::asio::io_service mIoService;
5962
common::MuxConfig mMuxConfig;

0 commit comments

Comments
 (0)