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 (
)
const (
pathIdentifierLen = 4
PathIdentifierLen = 4
)
// NLRI represents a Network Layer Reachability Information
......@@ -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")
}
consumed += pathIdentifierLen
consumed += PathIdentifierLen
}
pfxLen, err := buf.ReadByte()
......
......@@ -117,11 +117,8 @@ func (u *UpdateSender) sender(aggrTime time.Duration) {
}
u.toSendMu.Lock()
overhead := u.updateOverhead()
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)
if err != nil {
......@@ -135,13 +132,13 @@ func (u *UpdateSender) sender(aggrTime time.Duration) {
budget -= int(packet.BytesInAddr(pfx.Pfxlen())) + 1
if u.options.UseAddPath {
budget -= 4
budget -= packet.PathIdentifierLen
}
if budget < 0 {
updatesPrefixes = append(updatesPrefixes, prefixes)
prefixes = make([]*bnet.Prefix, 0, 1)
budget = packet.MaxLen - int(pathNLRIs.path.BGPPath.Length()) - overhead
budget = u.getBudget(pathNLRIs)
}
prefixes = append(prefixes, pfx)
......@@ -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 {
if u.addressFamily.afi == packet.IPv4AFI && !u.addressFamily.multiProtocol {
return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment