summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorEiichiro Watanabe <a16tochjp@gmail.com>2017-01-27 21:25:38 +0900
committerEiichiro Watanabe <a16tochjp@gmail.com>2017-01-29 17:38:09 +0900
commit7336d9d54fb013c1760ce18b6c1594746ca4b469 (patch)
tree8f78ea1b23456dfa1075df393e3785ec7d7f0745 /server/server.go
parent671b067a57a9199b0155ad1741b4ebab88a925f8 (diff)
Fix End of RIB handling
- All of EoR except IPv4 unicast have MP_UNREACH only. (RFC4724) - length of the MP_UNREACH attr. should be 3bytes. - length of the value should be 0bytes. - Should send EoR marker in initial exchange of BMP Route Monitoring. (RFC7854)
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go77
1 files changed, 57 insertions, 20 deletions
diff --git a/server/server.go b/server/server.go
index 4ac89039..902b6c8a 100644
--- a/server/server.go
+++ b/server/server.go
@@ -2323,41 +2323,78 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) {
if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED {
continue
}
- for _, path := range peer.adjRibIn.PathList(peer.configuredRFlist(), false) {
- msgs := table.CreateUpdateMsgFromPaths([]*table.Path{path})
- buf, _ := msgs[0].Serialize()
+ for _, rf := range peer.configuredRFlist() {
_, y := peer.fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]
l, _ := peer.fsm.LocalHostPort()
+ for _, path := range peer.adjRibIn.PathList([]bgp.RouteFamily{rf}, false) {
+ msgs := table.CreateUpdateMsgFromPaths([]*table.Path{path})
+ buf, _ := msgs[0].Serialize()
+ w.notify(&WatchEventUpdate{
+ Message: msgs[0],
+ PeerAS: peer.fsm.peerInfo.AS,
+ LocalAS: peer.fsm.peerInfo.LocalAS,
+ PeerAddress: peer.fsm.peerInfo.Address,
+ LocalAddress: net.ParseIP(l),
+ PeerID: peer.fsm.peerInfo.ID,
+ FourBytesAs: y,
+ Timestamp: path.GetTimestamp(),
+ Payload: buf,
+ PostPolicy: false,
+ })
+ }
+ eor := bgp.NewEndOfRib(rf)
+ eorBuf, _ := eor.Serialize()
w.notify(&WatchEventUpdate{
- Message: msgs[0],
+ Message: eor,
PeerAS: peer.fsm.peerInfo.AS,
LocalAS: peer.fsm.peerInfo.LocalAS,
PeerAddress: peer.fsm.peerInfo.Address,
LocalAddress: net.ParseIP(l),
PeerID: peer.fsm.peerInfo.ID,
FourBytesAs: y,
- Timestamp: path.GetTimestamp(),
- Payload: buf,
+ Timestamp: time.Now(),
+ Payload: eorBuf,
PostPolicy: false,
})
}
}
}
- if w.opts.postUpdate {
- for _, path := range s.globalRib.GetBestPathList(table.GLOBAL_RIB_NAME, s.globalRib.GetRFlist()) {
- msgs := table.CreateUpdateMsgFromPaths([]*table.Path{path})
- buf, _ := msgs[0].Serialize()
- w.notify(&WatchEventUpdate{
- PeerAS: path.GetSource().AS,
- PeerAddress: path.GetSource().Address,
- PeerID: path.GetSource().ID,
- Message: msgs[0],
- Timestamp: path.GetTimestamp(),
- Payload: buf,
- PostPolicy: true,
- })
+ if w.opts.initPostUpdate {
+ for _, rf := range s.globalRib.GetRFlist() {
+ if len(s.globalRib.Tables[rf].GetDestinations()) == 0 {
+ continue
+ }
+ pathsByPeer := make(map[*table.PeerInfo][]*table.Path)
+ for _, path := range s.globalRib.GetPathList(table.GLOBAL_RIB_NAME, []bgp.RouteFamily{rf}) {
+ pathsByPeer[path.GetSource()] = append(pathsByPeer[path.GetSource()], path)
+ }
+ for peerInfo, paths := range pathsByPeer {
+ for _, path := range paths {
+ msgs := table.CreateUpdateMsgFromPaths([]*table.Path{path})
+ buf, _ := msgs[0].Serialize()
+ w.notify(&WatchEventUpdate{
+ Message: msgs[0],
+ PeerAS: peerInfo.AS,
+ PeerAddress: peerInfo.Address,
+ PeerID: peerInfo.ID,
+ Timestamp: path.GetTimestamp(),
+ Payload: buf,
+ PostPolicy: true,
+ })
+ }
+ eor := bgp.NewEndOfRib(rf)
+ eorBuf, _ := eor.Serialize()
+ w.notify(&WatchEventUpdate{
+ Message: eor,
+ PeerAS: peerInfo.AS,
+ PeerAddress: peerInfo.Address,
+ PeerID: peerInfo.ID,
+ Timestamp: time.Now(),
+ Payload: eorBuf,
+ PostPolicy: true,
+ })
+ }
}
-
}
go w.loop()