mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
bmp: use on-wire original update data
bgpd parse on-wire original update data to construct BGPMessage object and serialize it. Sometimes the both data is not idential. For example, the original data sets the extended length for attribute even if the length is less than 256. This commit fixes the above issue. Signed-off-by: FUJITA Tomonori <[email protected]>
This commit is contained in:
+5
-1
@@ -136,7 +136,8 @@ func (h *BMPPeerHeader) Serialize() ([]byte, error) {
|
||||
}
|
||||
|
||||
type BMPRouteMonitoring struct {
|
||||
BGPUpdate *BGPMessage
|
||||
BGPUpdate *BGPMessage
|
||||
BGPUpdatePayload []byte
|
||||
}
|
||||
|
||||
func NewBMPRouteMonitoring(p BMPPeerHeader, update *BGPMessage) *BMPMessage {
|
||||
@@ -162,6 +163,9 @@ func (body *BMPRouteMonitoring) ParseBody(msg *BMPMessage, data []byte) error {
|
||||
}
|
||||
|
||||
func (body *BMPRouteMonitoring) Serialize() ([]byte, error) {
|
||||
if body.BGPUpdatePayload != nil {
|
||||
return body.BGPUpdatePayload, nil
|
||||
}
|
||||
return body.BGPUpdate.Serialize()
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -126,7 +126,10 @@ func bmpPeerDown(reason uint8, t int, policy bool, pd uint64, peeri *table.PeerI
|
||||
return bgp.NewBMPPeerDownNotification(*ph, reason, nil, []byte{})
|
||||
}
|
||||
|
||||
func bmpPeerRoute(t int, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64, u *bgp.BGPMessage) *bgp.BMPMessage {
|
||||
func bmpPeerRoute(t int, policy bool, pd uint64, peeri *table.PeerInfo, timestamp int64, payload []byte) *bgp.BMPMessage {
|
||||
ph := bgp.NewBMPPeerHeader(uint8(t), policy, pd, peeri.Address.String(), peeri.AS, peeri.LocalID.String(), float64(timestamp))
|
||||
return bgp.NewBMPRouteMonitoring(*ph, u)
|
||||
m := bgp.NewBMPRouteMonitoring(*ph, nil)
|
||||
body := m.Body.(*bgp.BMPRouteMonitoring)
|
||||
body.BGPUpdatePayload = payload
|
||||
return m
|
||||
}
|
||||
|
||||
+3
-2
@@ -333,7 +333,8 @@ func (server *BgpServer) Serve() {
|
||||
for _, p := range targetPeer.adjRib.GetInPathList(targetPeer.configuredRFlist()) {
|
||||
// avoid to merge for timestamp
|
||||
u := table.CreateUpdateMsgFromPaths([]*table.Path{p})
|
||||
bmpMsgList = append(bmpMsgList, bmpPeerRoute(bgp.BMP_PEER_TYPE_GLOBAL, false, 0, targetPeer.fsm.peerInfo, p.GetTimestamp().Unix(), u[0]))
|
||||
buf, _ := u[0].Serialize()
|
||||
bmpMsgList = append(bmpMsgList, bmpPeerRoute(bgp.BMP_PEER_TYPE_GLOBAL, false, 0, targetPeer.fsm.peerInfo, p.GetTimestamp().Unix(), buf))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,7 +816,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg, incoming chan *
|
||||
if ch := server.bmpClient.send(); ch != nil {
|
||||
bm := &broadcastBMPMsg{
|
||||
ch: ch,
|
||||
msgList: []*bgp.BMPMessage{bmpPeerRoute(bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.fsm.peerInfo, e.timestamp.Unix(), m)},
|
||||
msgList: []*bgp.BMPMessage{bmpPeerRoute(bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.fsm.peerInfo, e.timestamp.Unix(), e.payload)},
|
||||
}
|
||||
server.broadcastMsgs = append(server.broadcastMsgs, bm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user