diff options
author | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-03-24 22:16:12 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-03-24 22:16:12 +0900 |
commit | 04843ab5032cb6f8edebf1226acc9ba78c5ff1e2 (patch) | |
tree | e57a0267a307015824a40c99cb1f0318518fd2ca /pkg/server | |
parent | c86c924bb3e93bda7dbdfa3d338de0fa47f8cbf6 (diff) |
server: broadcast BMPPeerDownMessage for peer deletion
Sends peerdown message when a peer is de-condigured and down.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg/server')
-rw-r--r-- | pkg/server/bmp.go | 2 | ||||
-rw-r--r-- | pkg/server/fsm.go | 1 | ||||
-rw-r--r-- | pkg/server/server.go | 13 |
3 files changed, 16 insertions, 0 deletions
diff --git a/pkg/server/bmp.go b/pkg/server/bmp.go index 6742a813..724101ff 100644 --- a/pkg/server/bmp.go +++ b/pkg/server/bmp.go @@ -288,6 +288,8 @@ func bmpPeerDown(ev *watchEventPeerState, t uint8, policy bool, pd uint64) *bmp. reasonCode = bmp.BMP_PEER_DOWN_REASON_REMOTE_BGP_NOTIFICATION case fsmReadFailed, fsmWriteFailed: reasonCode = bmp.BMP_PEER_DOWN_REASON_REMOTE_NO_NOTIFICATION + case fsmDeConfigured: + reasonCode = bmp.BMP_PEER_DOWN_REASON_PEER_DE_CONFIGURED } return bmp.NewBMPPeerDownNotification(*ph, uint8(reasonCode), ev.StateReason.BGPNotification, ev.StateReason.Data) } diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go index e66054c7..178c9cd5 100644 --- a/pkg/server/fsm.go +++ b/pkg/server/fsm.go @@ -57,6 +57,7 @@ const ( fsmOpenMsgReceived fsmOpenMsgNegotiated fsmHardReset + fsmDeConfigured ) type fsmStateReason struct { diff --git a/pkg/server/server.go b/pkg/server/server.go index cdc557b5..9871d4ac 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -337,6 +337,19 @@ func (s *BgpServer) Serve() { "State": state, }).Debug("freed fsm.h") + if fsm.state == bgp.BGP_FSM_ESTABLISHED { + s.notifyWatcher(watchEventTypePeerState, &watchEventPeerState{ + PeerAS: fsm.peerInfo.AS, + PeerAddress: fsm.peerInfo.Address, + PeerID: fsm.peerInfo.ID, + State: bgp.BGP_FSM_IDLE, + Timestamp: time.Now(), + StateReason: &fsmStateReason{ + Type: fsmDeConfigured, + }, + }) + } + cleanInfiniteChannel(fsm.outgoingCh) cleanInfiniteChannel(fsm.incomingCh) s.delIncoming(fsm.incomingCh) |