summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2018-05-15 10:42:18 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-24 11:25:11 +0900
commita980a0237ebc4b4338d5d54257d5078e0772240a (patch)
treefa7c9c4444c2c26b6aed776ccfe6ac18f9d7d341 /server/server.go
parent76ef1163238a109bda09e019348de6550a5b3e61 (diff)
server/server: Add field to WatchEventPeerState for PeerDownEvent
To include the PeerDownReason and data in BMP messages, this commit adds some field to WatchEventPeerState. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/server/server.go b/server/server.go
index 82b6ee4b..7692ae4b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -708,12 +708,12 @@ func (server *BgpServer) notifyPostPolicyUpdateWatcher(peer *Peer, pathList []*t
server.notifyWatcher(WATCH_EVENT_TYPE_POST_UPDATE, ev)
}
-func createWatchEventPeerState(peer *Peer) *WatchEventPeerState {
+func newWatchEventPeerState(peer *Peer, m *FsmMsg) *WatchEventPeerState {
_, rport := peer.fsm.RemoteHostPort()
laddr, lport := peer.fsm.LocalHostPort()
sentOpen := buildopen(peer.fsm.gConf, peer.fsm.pConf)
recvOpen := peer.fsm.recvOpen
- return &WatchEventPeerState{
+ e := &WatchEventPeerState{
PeerAS: peer.fsm.peerInfo.AS,
LocalAS: peer.fsm.peerInfo.LocalAS,
PeerAddress: peer.fsm.peerInfo.Address,
@@ -728,12 +728,17 @@ func createWatchEventPeerState(peer *Peer) *WatchEventPeerState {
Timestamp: time.Now(),
PeerInterface: peer.fsm.pConf.Config.NeighborInterface,
}
+
+ if m != nil {
+ e.StateReason = m.StateReason
+ }
+ return e
}
func (server *BgpServer) broadcastPeerState(peer *Peer, oldState bgp.FSMState) {
newState := peer.fsm.state
if oldState == bgp.BGP_FSM_ESTABLISHED || newState == bgp.BGP_FSM_ESTABLISHED {
- server.notifyWatcher(WATCH_EVENT_TYPE_PEER_STATE, createWatchEventPeerState(peer))
+ server.notifyWatcher(WATCH_EVENT_TYPE_PEER_STATE, newWatchEventPeerState(peer))
}
}
@@ -2651,6 +2656,7 @@ type WatchEventPeerState struct {
SentOpen *bgp.BGPMessage
RecvOpen *bgp.BGPMessage
State bgp.FSMState
+ StateReason *FsmStateReason
AdminState AdminState
Timestamp time.Time
PeerInterface string
@@ -2895,7 +2901,7 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED {
continue
}
- w.notify(createWatchEventPeerState(peer))
+ w.notify(newWatchEventPeerState(peer))
}
}
if w.opts.initBest && s.active() == nil {