diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-05-26 10:50:29 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-06-03 18:18:23 +0900 |
commit | 76e2fbd5f03901dedf3cdbe4cf747d690cef2ab2 (patch) | |
tree | 3a9db6287170ea1e2d8b2de6ad6fcc5ef35f0c29 /server | |
parent | bbf4b7c2a9bf53c560168427f632edd7bd06506f (diff) |
bmp: Enable to send BMP Route Mirroring messages
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server')
-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 { |