Skip to content

Commit 9d9bb5d

Browse files
committed
BGP: resolve lifecycle-node check via getContainingNode(), document the FSM gating
Move BgpRouter::isLifecycleNode() out of line and look up the node with getContainingNode() instead of getParentModule(), and document why the FSM only re-arms reconnection on lifecycle-capable nodes: enabling auto-reconnect unconditionally re-opens a listening socket on an already-bound port and crashes plain (non-lifecycle) BGP scenarios.
1 parent 943ba6e commit 9d9bb5d

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/inet/routing/bgpv4/BgpRouter.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ void BgpRouter::recordStatistics()
7878
bgpModule->recordScalar("UpdateMsgRcv", statTab[5]);
7979
}
8080

81+
// A node is "lifecycle-capable" if it contains a NodeStatus ("status") submodule,
82+
// i.e. it can be shut down, restarted or crashed at runtime. Only on such nodes does
83+
// the FSM re-arm a connection after a loss (see BgpFsm.cc): a restarted node must
84+
// reconnect, whereas a plain BGP router keeps its historical behavior of not
85+
// auto-reconnecting. Enabling auto-reconnect unconditionally would also re-open a
86+
// listening socket on an already-bound port, crashing non-lifecycle scenarios.
87+
bool BgpRouter::isLifecycleNode() const
88+
{
89+
return getContainingNode(bgpModule)->getSubmodule("status") != nullptr;
90+
}
91+
8192
void BgpRouter::closeSessions(bool abort)
8293
{
8394
for (auto& elem : _BGPSessions) {

src/inet/routing/bgpv4/BgpRouter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class INET_API BgpRouter : public TcpSocket::BufferingCallback
120120
cMessage *getCancelEvent(cMessage *msg) { return bgpModule->cancelEvent(msg); }
121121
IIpv4RoutingTable *getIPRoutingTable() { return rt; }
122122
std::vector<BgpRoutingTableEntry *> getBGPRoutingTable() { return bgpRoutingTable; }
123-
bool isLifecycleNode() const { return bgpModule->getParentModule()->getSubmodule("status") != nullptr; }
123+
bool isLifecycleNode() const;
124124

125125
/**
126126
* \brief active listenSocket for a given session (used by fsm)

0 commit comments

Comments
 (0)