From 04843ab5032cb6f8edebf1226acc9ba78c5ff1e2 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 24 Mar 2019 22:16:12 +0900 Subject: server: broadcast BMPPeerDownMessage for peer deletion Sends peerdown message when a peer is de-condigured and down. Signed-off-by: FUJITA Tomonori --- pkg/server/bmp.go | 2 ++ pkg/server/fsm.go | 1 + pkg/server/server.go | 13 +++++++++++++ 3 files changed, 16 insertions(+) (limited to 'pkg/server') 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) -- cgit v1.2.3