diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-10-01 12:33:13 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-10-01 12:36:21 -0700 |
commit | 8603cce51d6d930aed128fff873591520dcb0853 (patch) | |
tree | 44a282bc23ea416d296b6cf470aa2f17a5a7ac69 /pkg/tcpip/stack/iptables_state.go | |
parent | eac4d9ab2ae6d5df294ac2c0b31af57552695936 (diff) |
Annotate checklocks on mutex protected fields
...to catch lock-related bugs in nogo tests.
Updates #6566.
PiperOrigin-RevId: 400265818
Diffstat (limited to 'pkg/tcpip/stack/iptables_state.go')
-rw-r--r-- | pkg/tcpip/stack/iptables_state.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/tcpip/stack/iptables_state.go b/pkg/tcpip/stack/iptables_state.go index 529e02a07..3d3c39c20 100644 --- a/pkg/tcpip/stack/iptables_state.go +++ b/pkg/tcpip/stack/iptables_state.go @@ -26,11 +26,15 @@ type unixTime struct { // saveLastUsed is invoked by stateify. func (cn *conn) saveLastUsed() unixTime { + cn.mu.Lock() + defer cn.mu.Unlock() return unixTime{cn.lastUsed.Unix(), cn.lastUsed.UnixNano()} } // loadLastUsed is invoked by stateify. func (cn *conn) loadLastUsed(unix unixTime) { + cn.mu.Lock() + defer cn.mu.Unlock() cn.lastUsed = time.Unix(unix.second, unix.nano) } |