diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-07 21:59:03 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-07 21:59:03 +0900 |
commit | 9da6e7c3a25cfaa1f33ed5ddcc0ad1699c430e17 (patch) | |
tree | 7081677b7ed3e4ba0bb0f4ac1f09cd71b6f84a82 /server/bmp.go | |
parent | da0f7cdc54180c03d762e97cdcb0ee3d6be95ef6 (diff) |
bmp: set A flag in Per-Peer Header
Needs to set set A flag in Per-Peer Header if the peer use the legacy
2-byte AS_PATH format.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/bmp.go')
-rw-r--r-- | server/bmp.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/bmp.go b/server/bmp.go index 1e12e372..dd5d102e 100644 --- a/server/bmp.go +++ b/server/bmp.go @@ -174,12 +174,12 @@ func (b *bmpClient) loop() { } for _, u := range table.CreateUpdateMsgFromPaths(pathList) { payload, _ := u.Serialize() - if err := write(bmpPeerRoute(bmp.BMP_PEER_TYPE_GLOBAL, msg.PostPolicy, 0, info, msg.Timestamp.Unix(), payload)); err != nil { + if err := write(bmpPeerRoute(bmp.BMP_PEER_TYPE_GLOBAL, msg.PostPolicy, 0, true, info, msg.Timestamp.Unix(), payload)); err != nil { return false } } } else { - if err := write(bmpPeerRoute(bmp.BMP_PEER_TYPE_GLOBAL, msg.PostPolicy, 0, info, msg.Timestamp.Unix(), msg.Payload)); err != nil { + if err := write(bmpPeerRoute(bmp.BMP_PEER_TYPE_GLOBAL, msg.PostPolicy, 0, msg.FourBytesAs, info, msg.Timestamp.Unix(), msg.Payload)); err != nil { return false } } @@ -193,7 +193,7 @@ func (b *bmpClient) loop() { u := table.CreateUpdateMsgFromPaths([]*table.Path{p})[0] if payload, err := u.Serialize(); err != nil { return false - } else if err = write(bmpPeerRoute(bmp.BMP_PEER_TYPE_LOCAL_RIB, false, 0, info, p.GetTimestamp().Unix(), payload)); err != nil { + } else if err = write(bmpPeerRoute(bmp.BMP_PEER_TYPE_LOCAL_RIB, false, 0, true, info, p.GetTimestamp().Unix(), payload)); err != nil { return false } } @@ -275,11 +275,14 @@ func bmpPeerDown(reason uint8, t uint8, policy bool, pd uint64, peeri *table.Pee return bmp.NewBMPPeerDownNotification(*ph, reason, nil, []byte{}) } -func bmpPeerRoute(t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64, payload []byte) *bmp.BMPMessage { +func bmpPeerRoute(t uint8, policy bool, pd uint64, fourBytesAs bool, peeri *table.PeerInfo, timestamp int64, payload []byte) *bmp.BMPMessage { var flags uint8 = 0 if policy { flags |= bmp.BMP_PEER_FLAG_POST_POLICY } + if !fourBytesAs { + flags |= bmp.BMP_PEER_FLAG_TWO_AS + } ph := bmp.NewBMPPeerHeader(t, flags, pd, peeri.Address.String(), peeri.AS, peeri.ID.String(), float64(timestamp)) m := bmp.NewBMPRouteMonitoring(*ph, nil) body := m.Body.(*bmp.BMPRouteMonitoring) |