diff options
-rw-r--r-- | server/bmp.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/bmp.go b/server/bmp.go index e7dc3ea2..2d0d5ec2 100644 --- a/server/bmp.go +++ b/server/bmp.go @@ -127,6 +127,9 @@ func (b *bmpClient) loop() { if b.c.RouteMonitoringPolicy == config.BMP_ROUTE_MONITORING_POLICY_TYPE_LOCAL_RIB || b.c.RouteMonitoringPolicy == config.BMP_ROUTE_MONITORING_POLICY_TYPE_ALL { ops = append(ops, WatchBestPath(true)) } + if b.c.RouteMirroringEnabled { + ops = append(ops, WatchMessage(false)) + } w := b.s.Watch(ops...) defer w.Stop() @@ -209,6 +212,15 @@ func (b *bmpClient) loop() { return false } } + case *WatchEventMessage: + info := &table.PeerInfo{ + Address: msg.PeerAddress, + AS: msg.PeerAS, + ID: msg.PeerID, + } + if err := write(bmpPeerRouteMirroring(bmp.BMP_PEER_TYPE_GLOBAL, 0, info, msg.Timestamp.Unix(), msg.Message)); err != nil { + return false + } } case <-tickerCh: neighborList := b.s.GetNeighbor("", true) @@ -287,6 +299,18 @@ func bmpPeerStats(peerType uint8, peerDist uint64, timestamp int64, neighConf *c ) } +func bmpPeerRouteMirroring(peerType uint8, peerDist uint64, peerInfo *table.PeerInfo, timestamp int64, msg *bgp.BGPMessage) *bmp.BMPMessage { + var peerFlags uint8 = 0 + ph := bmp.NewBMPPeerHeader(peerType, peerFlags, peerDist, peerInfo.Address.String(), peerInfo.AS, peerInfo.ID.String(), float64(timestamp)) + return bmp.NewBMPRouteMirroring( + *ph, + []bmp.BMPRouteMirrTLVInterface{ + // RFC7854: BGP Message TLV MUST occur last in the list of TLVs + bmp.NewBMPRouteMirrTLVBGPMsg(bmp.BMP_ROUTE_MIRRORING_TLV_TYPE_BGP_MSG, msg), + }, + ) +} + func (b *bmpClientManager) addServer(c *config.BmpServerConfig) error { host := net.JoinHostPort(c.Address, strconv.Itoa(int(c.Port))) if _, y := b.clientMap[host]; y { |