summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Layher <mlayher@fastly.com>2021-08-24 15:01:00 -0400
committerMatt Layher <mlayher@fastly.com>2021-08-24 15:01:00 -0400
commit14b7bebfde4505b00701451427d6271cc266163b (patch)
tree5af2460f9e2112aff438cabefb416ebeb3ab7126
parent0b449fda7d993575cc141a2d822721fde4fcb0a4 (diff)
pkg/packet/bgp: add mutex to PrefixDefault to avoid data race
Signed-off-by: Matt Layher <mlayher@fastly.com>
-rw-r--r--pkg/packet/bgp/bgp.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go
index ac7b77d2..c46bc878 100644
--- a/pkg/packet/bgp/bgp.go
+++ b/pkg/packet/bgp/bgp.go
@@ -28,6 +28,7 @@ import (
"sort"
"strconv"
"strings"
+ "sync"
)
type MarshallingOption struct {
@@ -1229,23 +1230,36 @@ func LabelString(nlri AddrPrefixInterface) string {
}
type PrefixDefault struct {
+ mu sync.Mutex
id uint32
localId uint32
}
func (p *PrefixDefault) PathIdentifier() uint32 {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
return p.id
}
func (p *PrefixDefault) SetPathIdentifier(id uint32) {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
p.id = id
}
func (p *PrefixDefault) PathLocalIdentifier() uint32 {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
return p.localId
}
func (p *PrefixDefault) SetPathLocalIdentifier(id uint32) {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
p.localId = id
}