Skip to content
Snippets Groups Projects
Unverified Commit d8737e47 authored by Maximilian Wilhelm's avatar Maximilian Wilhelm Committed by GitHub
Browse files

Merge pull request #282 from bio-routing/fix/bgp_update_too_long

BGP: Fix calculation of maximum BGP update size for non first update
parents 8b9426ff ead4524a
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
) )
const ( const (
pathIdentifierLen = 4 PathIdentifierLen = 4
) )
// NLRI represents a Network Layer Reachability Information // NLRI represents a Network Layer Reachability Information
...@@ -63,7 +63,7 @@ func decodeNLRI(buf *bytes.Buffer, afi uint16, addPath bool) (*NLRI, uint8, erro ...@@ -63,7 +63,7 @@ func decodeNLRI(buf *bytes.Buffer, afi uint16, addPath bool) (*NLRI, uint8, erro
return nil, consumed, errors.Wrap(err, "Unable to decode path identifier") return nil, consumed, errors.Wrap(err, "Unable to decode path identifier")
} }
consumed += pathIdentifierLen consumed += PathIdentifierLen
} }
pfxLen, err := buf.ReadByte() pfxLen, err := buf.ReadByte()
......
...@@ -117,11 +117,8 @@ func (u *UpdateSender) sender(aggrTime time.Duration) { ...@@ -117,11 +117,8 @@ func (u *UpdateSender) sender(aggrTime time.Duration) {
} }
u.toSendMu.Lock() u.toSendMu.Lock()
overhead := u.updateOverhead()
for key, pathNLRIs := range u.toSend { for key, pathNLRIs := range u.toSend {
budget = packet.MaxLen - packet.HeaderLen - packet.MinUpdateLen - int(pathNLRIs.path.BGPPath.Length()) - overhead budget = u.getBudget(pathNLRIs)
pathAttrs, err = packet.PathAttributes(pathNLRIs.path, u.iBGP, u.rrClient) pathAttrs, err = packet.PathAttributes(pathNLRIs.path, u.iBGP, u.rrClient)
if err != nil { if err != nil {
...@@ -135,13 +132,13 @@ func (u *UpdateSender) sender(aggrTime time.Duration) { ...@@ -135,13 +132,13 @@ func (u *UpdateSender) sender(aggrTime time.Duration) {
budget -= int(packet.BytesInAddr(pfx.Pfxlen())) + 1 budget -= int(packet.BytesInAddr(pfx.Pfxlen())) + 1
if u.options.UseAddPath { if u.options.UseAddPath {
budget -= 4 budget -= packet.PathIdentifierLen
} }
if budget < 0 { if budget < 0 {
updatesPrefixes = append(updatesPrefixes, prefixes) updatesPrefixes = append(updatesPrefixes, prefixes)
prefixes = make([]*bnet.Prefix, 0, 1) prefixes = make([]*bnet.Prefix, 0, 1)
budget = packet.MaxLen - int(pathNLRIs.path.BGPPath.Length()) - overhead budget = u.getBudget(pathNLRIs)
} }
prefixes = append(prefixes, pfx) prefixes = append(prefixes, pfx)
...@@ -160,6 +157,10 @@ func (u *UpdateSender) sender(aggrTime time.Duration) { ...@@ -160,6 +157,10 @@ func (u *UpdateSender) sender(aggrTime time.Duration) {
} }
} }
func (u *UpdateSender) getBudget(pathNLRIs *pathPfxs) int {
return packet.MaxLen - packet.HeaderLen - packet.MinUpdateLen - int(pathNLRIs.path.BGPPath.Length()) - u.updateOverhead()
}
func (u *UpdateSender) updateOverhead() int { func (u *UpdateSender) updateOverhead() int {
if u.addressFamily.afi == packet.IPv4AFI && !u.addressFamily.multiProtocol { if u.addressFamily.afi == packet.IPv4AFI && !u.addressFamily.multiProtocol {
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment