mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
bmp: Enable to send BMP Route Mirroring messages
Signed-off-by: IWASE Yusuke <[email protected]>
This commit is contained in:
committed by
FUJITA Tomonori
parent
bbf4b7c2a9
commit
76e2fbd5f0
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user