mirror of https://github.com/slackhq/nebula.git
Fix a data race on message counter (#284)
3. ================== WARNING: DATA RACE Write at 0x00c00030e020 by goroutine 17: sync/atomic.AddInt64() runtime/race_amd64.s:276 +0xb github.com/slackhq/nebula.(*Interface).sendNoMetrics() github.com/slackhq/nebula/inside.go:226 +0x9c github.com/slackhq/nebula.(*Interface).send() github.com/slackhq/nebula/inside.go:214 +0x149 github.com/slackhq/nebula.(*Interface).readOutsidePackets() github.com/slackhq/nebula/outside.go:94 +0x1213 github.com/slackhq/nebula.(*udpConn).ListenOut() github.com/slackhq/nebula/udp_generic.go:109 +0x3b5 github.com/slackhq/nebula.(*Interface).listenOut() github.com/slackhq/nebula/interface.go:147 +0x15e Previous read at 0x00c00030e020 by goroutine 18: github.com/slackhq/nebula.(*Interface).consumeInsidePacket() github.com/slackhq/nebula/inside.go:58 +0x892 github.com/slackhq/nebula.(*Interface).listenIn() github.com/slackhq/nebula/interface.go:164 +0x178
This commit is contained in:
parent
68e3e84fdc
commit
0010db46e4
11
inside.go
11
inside.go
|
@ -54,8 +54,8 @@ func (f *Interface) consumeInsidePacket(packet []byte, fwPacket *FirewallPacket,
|
|||
|
||||
dropReason := f.firewall.Drop(packet, *fwPacket, false, hostinfo, trustedCAs)
|
||||
if dropReason == nil {
|
||||
f.sendNoMetrics(message, 0, ci, hostinfo, hostinfo.remote, packet, nb, out)
|
||||
if f.lightHouse != nil && *ci.messageCounter%5000 == 0 {
|
||||
mc := f.sendNoMetrics(message, 0, ci, hostinfo, hostinfo.remote, packet, nb, out)
|
||||
if f.lightHouse != nil && mc%5000 == 0 {
|
||||
f.lightHouse.Query(fwPacket.RemoteIP, f)
|
||||
}
|
||||
|
||||
|
@ -214,10 +214,10 @@ func (f *Interface) send(t NebulaMessageType, st NebulaMessageSubType, ci *Conne
|
|||
f.sendNoMetrics(t, st, ci, hostinfo, remote, p, nb, out)
|
||||
}
|
||||
|
||||
func (f *Interface) sendNoMetrics(t NebulaMessageType, st NebulaMessageSubType, ci *ConnectionState, hostinfo *HostInfo, remote *udpAddr, p, nb, out []byte) {
|
||||
func (f *Interface) sendNoMetrics(t NebulaMessageType, st NebulaMessageSubType, ci *ConnectionState, hostinfo *HostInfo, remote *udpAddr, p, nb, out []byte) uint64 {
|
||||
if ci.eKey == nil {
|
||||
//TODO: log warning
|
||||
return
|
||||
return 0
|
||||
}
|
||||
|
||||
var err error
|
||||
|
@ -237,7 +237,7 @@ func (f *Interface) sendNoMetrics(t NebulaMessageType, st NebulaMessageSubType,
|
|||
WithField("udpAddr", remote).WithField("counter", c).
|
||||
WithField("attemptedCounter", ci.messageCounter).
|
||||
Error("Failed to encrypt outgoing packet")
|
||||
return
|
||||
return c
|
||||
}
|
||||
|
||||
err = f.outside.WriteTo(out, remote)
|
||||
|
@ -245,6 +245,7 @@ func (f *Interface) sendNoMetrics(t NebulaMessageType, st NebulaMessageSubType,
|
|||
hostinfo.logger().WithError(err).
|
||||
WithField("udpAddr", remote).Error("Failed to write outgoing packet")
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func isMulticast(ip uint32) bool {
|
||||
|
|
Loading…
Reference in New Issue