summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-08-04 14:30:52 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-10-03 23:04:20 +0900
commite559d6f3dd570d17282aa2a7caca935171e5a860 (patch)
tree6dcf0c0fcd116ab0c07cfa1257e47259515d9434
parent17c3694fca334c3c0413e9463bc41fabdd52eb8c (diff)
server: Add config.Neighbor into WatchEventUpdate
This patch adds a field of config.Neighbor into WatchEventUpdate in order to get config/state info of the neighbor which sent the UPDATE message. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--server/server.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index d4b790a1..46776e03 100644
--- a/server/server.go
+++ b/server/server.go
@@ -516,6 +516,7 @@ func (server *BgpServer) notifyPostPolicyUpdateWatcher(peer *Peer, pathList []*t
Timestamp: cloned[0].GetTimestamp(),
PostPolicy: true,
PathList: cloned,
+ Neighbor: peer.ToConfig(false),
}
server.notifyWatcher(WATCH_EVENT_TYPE_POST_UPDATE, ev)
}
@@ -994,6 +995,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
Payload: e.payload,
PostPolicy: false,
PathList: clonePathList(pathList),
+ Neighbor: peer.ToConfig(false),
}
server.notifyWatcher(WATCH_EVENT_TYPE_PRE_UPDATE, ev)
}
@@ -2366,6 +2368,7 @@ type WatchEventUpdate struct {
Payload []byte
PostPolicy bool
PathList []*table.Path
+ Neighbor *config.Neighbor
}
type WatchEventPeerState struct {
@@ -2634,6 +2637,7 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED {
continue
}
+ configNeighbor := peer.ToConfig(false)
for _, rf := range peer.configuredRFlist() {
_, y := peer.fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]
l, _ := peer.fsm.LocalHostPort()
@@ -2651,6 +2655,7 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
Timestamp: path.GetTimestamp(),
Payload: buf,
PostPolicy: false,
+ Neighbor: configNeighbor,
})
}
eor := bgp.NewEndOfRib(rf)
@@ -2666,6 +2671,7 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
Timestamp: time.Now(),
Payload: eorBuf,
PostPolicy: false,
+ Neighbor: configNeighbor,
})
}
}
@@ -2680,6 +2686,11 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
pathsByPeer[path.GetSource()] = append(pathsByPeer[path.GetSource()], path)
}
for peerInfo, paths := range pathsByPeer {
+ // create copy which can be access to without mutex
+ var configNeighbor *config.Neighbor
+ if peer, ok := s.neighborMap[peerInfo.Address.String()]; ok {
+ configNeighbor = peer.ToConfig(false)
+ }
for _, path := range paths {
msgs := table.CreateUpdateMsgFromPaths([]*table.Path{path})
buf, _ := msgs[0].Serialize()
@@ -2691,6 +2702,7 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
Timestamp: path.GetTimestamp(),
Payload: buf,
PostPolicy: true,
+ Neighbor: configNeighbor,
})
}
eor := bgp.NewEndOfRib(rf)
@@ -2703,6 +2715,7 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
Timestamp: time.Now(),
Payload: eorBuf,
PostPolicy: true,
+ Neighbor: configNeighbor,
})
}
}