Skip to content

Commit 8d37699

Browse files
committed
BGP: Fix sessionEstablished flag not reset when transitioning to Idle state (#1050)
When BGP FSM transitions from any state to Idle state (due to timeouts, connection failures, etc.), the sessionEstablished flag was not being reset to false. This caused BgpRouter::updateSendProcess to continue attempting to send update messages over closed TCP sockets, resulting in "TcpSocket::send(): socket not connected or connecting, state is CLOSED" errors. This issue was particularly visible in simulations with 10+ BGP routers where sessions would timeout (connectRetryTime = 120s) before completing information exchange. Fixed by ensuring sessionEstablished is set to false in all FSM state transition functions that call setState<Idle>(). Fixes: BGP session timeout causing socket send errors
1 parent 1463db0 commit 8d37699

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/inet/routing/bgpv4/BgpFsm.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void Connect::HoldTimer_Expires()
7676
++session._connectRetryCounter;
7777
// - performs peer oscillation damping if the DampPeerOscillations attribute is set to True, and
7878
// - changes its state to Idle.
79+
session._info.sessionEstablished = false;
7980
setState<Idle>();
8081
}
8182

@@ -153,6 +154,7 @@ void Active::HoldTimer_Expires()
153154
// - increments the ConnectRetryCounter by one,
154155
++session._connectRetryCounter;
155156
// - changes its state to Idle.
157+
session._info.sessionEstablished = false;
156158
setState<Idle>();
157159
}
158160

@@ -180,6 +182,8 @@ void Active::TcpConnectionConfirmed()
180182

181183
void Active::TcpConnectionFails()
182184
{
185+
BgpSession& session = TopState::box().getModule();
186+
session._info.sessionEstablished = false;
183187
setState<Idle>();
184188
}
185189

@@ -223,6 +227,7 @@ void OpenSent::ConnectRetryTimer_Expires()
223227
++session._connectRetryCounter;
224228
// - (optionally) performs peer oscillation damping if the DampPeerOscillations attribute is set to TRUE, and
225229
// - changes its state to Idle.
230+
session._info.sessionEstablished = false;
226231
setState<Idle>();
227232
}
228233

@@ -240,6 +245,7 @@ void OpenSent::HoldTimer_Expires()
240245
++session._connectRetryCounter;
241246
// - (optionally) performs peer oscillation damping if the DampPeerOscillations attribute is set to TRUE, and
242247
// - changes its state to Idle.
248+
session._info.sessionEstablished = false;
243249
setState<Idle>();
244250
}
245251

@@ -314,6 +320,7 @@ void OpenConfirm::ConnectRetryTimer_Expires()
314320
// - increments the ConnectRetryCounter by 1,
315321
++session._connectRetryCounter;
316322
// - changes its state to Idle.
323+
session._info.sessionEstablished = false;
317324
setState<Idle>();
318325
}
319326

@@ -330,6 +337,7 @@ void OpenConfirm::HoldTimer_Expires()
330337
// - increments the ConnectRetryCounter by 1,
331338
++session._connectRetryCounter;
332339
// - changes its state to Idle.
340+
session._info.sessionEstablished = false;
333341
setState<Idle>();
334342
}
335343

@@ -348,6 +356,8 @@ void OpenConfirm::KeepaliveTimer_Expires()
348356
void OpenConfirm::TcpConnectionFails()
349357
{
350358
EV_TRACE << "OpenConfirm::TcpConnectionFails" << std::endl;
359+
BgpSession& session = TopState::box().getModule();
360+
session._info.sessionEstablished = false;
351361
setState<Idle>();
352362
}
353363

@@ -432,6 +442,7 @@ void Established::ConnectRetryTimer_Expires()
432442
// - increments the ConnectRetryCounter by 1,
433443
++session._connectRetryCounter;
434444
// - changes its state to Idle.
445+
session._info.sessionEstablished = false;
435446
setState<Idle>();
436447
}
437448

@@ -448,6 +459,7 @@ void Established::HoldTimer_Expires()
448459
// - increments the ConnectRetryCounter by 1,
449460
++session._connectRetryCounter;
450461
// - changes its state to Idle.
462+
session._info.sessionEstablished = false;
451463
setState<Idle>();
452464
}
453465

@@ -504,4 +516,3 @@ void Established::UpdateMsgEvent()
504516
} // namespace bgp
505517

506518
} // namespace inet
507-

0 commit comments

Comments
 (0)