-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bgpd: Send "Peer De-configured" notification before closing the socket #5273
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1181,6 +1181,19 @@ int bgp_stop(struct peer *peer) | |
} | ||
} | ||
|
||
/* If a BGP speaker decides to de-configure a peer, then | ||
* the speaker SHOULD send a NOTIFICATION message with the | ||
* Error Code Cease and the Error Subcode "Peer De-configured". | ||
* | ||
* Make sure this is sent only after all the timers are stopped | ||
* and before the peer's socket is closed to avoid race condition | ||
* when you send a notification, FSM Connect fires before | ||
* closing the socket and you still see `Peer closed the session`. | ||
*/ | ||
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sending notification inside bgp_stop() would lead to generating a "BGP_Stop" event inside the function bgp_write_notify(), there by calling bgp_stop() again ? BGP_XYZ_State --> Idle ----> Idle This can be solved by moving the bgp stop event generation from bgp_write_notify() (--> BGP_EVENT_ADD(peer, BGP_Stop) )to the respective calling function. |
||
bgp_notify_send(peer, BGP_NOTIFY_CEASE, | ||
BGP_NOTIFY_CEASE_PEER_UNCONFIG); | ||
|
||
/* Close of file descriptor. */ | ||
if (peer->fd >= 0) { | ||
close(peer->fd); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bgp_stop() would be called when "BGP_Stop" even is raised. And "BGP_Stop" event can be raised at different states of bgp and for various reasons, not only for "Peer De-configured".
Eg clear bgp cmd
so we would end up