From ead4524a3a885b09ce223972f0e9b26a5afc682b Mon Sep 17 00:00:00 2001
From: Oliver Herms <oliver.herms@exaring.de>
Date: Mon, 20 Jul 2020 09:16:31 +0200
Subject: [PATCH] Fix magic number

---
 protocols/bgp/packet/nlri.go          | 4 ++--
 protocols/bgp/server/update_sender.go | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/protocols/bgp/packet/nlri.go b/protocols/bgp/packet/nlri.go
index bd55739c..526ab712 100644
--- a/protocols/bgp/packet/nlri.go
+++ b/protocols/bgp/packet/nlri.go
@@ -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()
diff --git a/protocols/bgp/server/update_sender.go b/protocols/bgp/server/update_sender.go
index 095d5339..86c7601d 100644
--- a/protocols/bgp/server/update_sender.go
+++ b/protocols/bgp/server/update_sender.go
@@ -132,7 +132,7 @@ 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 {
-- 
GitLab