diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-02-09 05:46:00 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-02-09 05:46:00 +0000 |
commit | b98fa348b6ee67d4272a79c83a810998646d50f9 (patch) | |
tree | 392ee7e1ca5540a392b1b5634cec5e0cead7ebe6 /pkg/tcpip/network | |
parent | ccf8cbfe805fefb8a8f549a9c9ecb65c66631b29 (diff) | |
parent | 6671a42d605d681e6aa63b610617523ab632e95a (diff) |
Merge release-20210201.0-61-g6671a42d6 (automated)
Diffstat (limited to 'pkg/tcpip/network')
-rw-r--r-- | pkg/tcpip/network/ipv6/ndp.go | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/pkg/tcpip/network/ipv6/ndp.go b/pkg/tcpip/network/ipv6/ndp.go index a55330b7e..53c043dcd 100644 --- a/pkg/tcpip/network/ipv6/ndp.go +++ b/pkg/tcpip/network/ipv6/ndp.go @@ -466,20 +466,6 @@ type ndpState struct { temporaryAddressDesyncFactor time.Duration } -type remainingCounter struct { - mu struct { - sync.Mutex - - remaining uint8 - } -} - -func (r *remainingCounter) init(max uint8) { - r.mu.Lock() - defer r.mu.Unlock() - r.mu.remaining = max -} - // defaultRouterState holds data associated with a default router discovered by // a Router Advertisement (RA). type defaultRouterState struct { @@ -1687,7 +1673,8 @@ func (ndp *ndpState) startSolicitingRouters() { return } - if ndp.configs.MaxRtrSolicitations == 0 { + remaining := ndp.configs.MaxRtrSolicitations + if remaining == 0 { return } @@ -1698,9 +1685,6 @@ func (ndp *ndpState) startSolicitingRouters() { delay = time.Duration(rand.Int63n(int64(ndp.configs.MaxRtrSolicitationDelay))) } - var remaining remainingCounter - remaining.init(ndp.configs.MaxRtrSolicitations) - // Protected by ndp.ep.mu. done := false @@ -1754,19 +1738,13 @@ func (ndp *ndpState) startSolicitingRouters() { panic(fmt.Sprintf("failed to add IP header: %s", err)) } - // Okay to hold this lock while writing packets since we use a different - // lock per router solicitaiton timer so there will not be any lock - // contention. - remaining.mu.Lock() - defer remaining.mu.Unlock() - if err := ndp.ep.nic.WritePacketToRemote(header.EthernetAddressFromMulticastIPv6Address(header.IPv6AllRoutersMulticastAddress), nil /* gso */, ProtocolNumber, pkt); err != nil { sent.dropped.Increment() // Don't send any more messages if we had an error. - remaining.mu.remaining = 0 + remaining = 0 } else { sent.routerSolicit.Increment() - remaining.mu.remaining-- + remaining-- } ndp.ep.mu.Lock() @@ -1777,7 +1755,7 @@ func (ndp *ndpState) startSolicitingRouters() { return } - if remaining.mu.remaining == 0 { + if remaining == 0 { // We are done soliciting routers. ndp.stopSolicitingRouters() return |