ctmap: Fix data race for accessing nat maps
ctmap: Fix data race for accessing nat maps

Commit c9810bf7b2 introduced garbage collection for cleaning orphan entries
in the nat maps whereby concurrent accesses to the maps weren't serialized.

The nat maps accessed via ct map construct are susceptible
to data races in asynchronously running goroutines upon
agent restart when endpoints are restored -

```
2022-02-21T02:42:13.757888057Z WARNING: DATA RACE
2022-02-21T02:42:13.757895621Z Write at 0x00c00081a830 by goroutine 360:
2022-02-21T02:42:13.757912783Z   github.com/cilium/cilium/pkg/bpf.(*Map).Close()
2022-02-21T02:42:13.757920669Z       /go/src/github.com/cilium/cilium/pkg/bpf/map_linux.go:581 +0x1c4
2022-02-21T02:42:13.757927597Z   github.com/cilium/cilium/pkg/maps/ctmap.doGC4·dwrap·4()
2022-02-21T02:42:13.757934561Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/ctmap.go:422 +0x39
2022-02-21T02:42:13.757941184Z   github.com/cilium/cilium/pkg/maps/ctmap.doGC4()
2022-02-21T02:42:13.757947352Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/ctmap.go:482 +0x4d5
2022-02-21T02:42:13.757953881Z   github.com/cilium/cilium/pkg/maps/ctmap.doGC()
2022-02-21T02:42:13.757960362Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/ctmap.go:517 +0x17e
2022-02-21T02:42:13.757966185Z   github.com/cilium/cilium/pkg/maps/ctmap.GC()
2022-02-21T02:42:13.757972307Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/ctmap.go:537 +0xc6
2022-02-21T02:42:13.757978599Z   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).garbageCollectConntrack()
2022-02-21T02:42:13.757986321Z       /go/src/github.com/cilium/cilium/pkg/endpoint/bpf.go:1034 +0x804
2022-02-21T02:42:13.757992160Z   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).scrubIPsInConntrackTableLocked()
2022-02-21T02:42:13.757998853Z       /go/src/github.com/cilium/cilium/pkg/endpoint/bpf.go:1039 +0x173
2022-02-21T02:42:13.758004601Z   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).scrubIPsInConntrackTable()
2022-02-21T02:42:13.758010701Z       /go/src/github.com/cilium/cilium/pkg/endpoint/bpf.go:1049 +0x44
2022-02-21T02:42:13.758016604Z   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).runPreCompilationSteps.func1()
2022-02-21T02:42:13.758022804Z       /go/src/github.com/cilium/cilium/pkg/endpoint/bpf.go:761 +0x132

2022-02-21T02:42:13.758034551Z Previous read at 0x00c00081a830 by goroutine 100:
2022-02-21T02:42:13.758040659Z   github.com/cilium/cilium/pkg/bpf.(*Map).DumpReliablyWithCallback()
2022-02-21T02:42:13.758046461Z       /go/src/github.com/cilium/cilium/pkg/bpf/map_linux.go:756 +0x804
2022-02-21T02:42:13.758053696Z   github.com/cilium/cilium/pkg/maps/nat.(*Map).DumpReliablyWithCallback()
2022-02-21T02:42:13.758059818Z       /go/src/github.com/cilium/cilium/pkg/maps/nat/nat.go:121 +0x7b7
2022-02-21T02:42:13.758065580Z   github.com/cilium/cilium/pkg/maps/ctmap.PurgeOrphanNATEntries()
2022-02-21T02:42:13.758072272Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/ctmap.go:612 +0x790
2022-02-21T02:42:13.758078005Z   github.com/cilium/cilium/pkg/maps/ctmap/gc.runGC()
2022-02-21T02:42:13.758084196Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/gc/gc.go:214 +0xb0c
2022-02-21T02:42:13.758090362Z   github.com/cilium/cilium/pkg/maps/ctmap/gc.runGC()
2022-02-21T02:42:13.758096712Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/gc/gc.go:189 +0x6a5
2022-02-21T02:42:13.758103134Z   github.com/cilium/cilium/pkg/maps/ctmap/gc.runGC()
2022-02-21T02:42:13.758109338Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/gc/gc.go:189 +0x6a5
2022-02-21T02:42:13.758127517Z   github.com/cilium/cilium/pkg/maps/ctmap/gc.Enable.func1()
2022-02-21T02:42:13.758135513Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/gc/gc.go:90 +0x40a
2022-02-21T02:42:13.758141621Z   github.com/cilium/cilium/pkg/maps/ctmap/gc.runGC()
2022-02-21T02:42:13.758147715Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/gc/gc.go:189 +0x6a5
2022-02-21T02:42:13.758153712Z   github.com/cilium/cilium/pkg/maps/ctmap/gc.Enable.func1()
2022-02-21T02:42:13.758160127Z       /go/src/github.com/cilium/cilium/pkg/maps/ctmap/gc/gc.go:90 +0x40a

```

Fixes: c9810bf7b2 ("ctmap: GC orphan SNAT entries")

Signed-off-by: Aditi Ghag <436242e0c0af36e461a395c937165372864a99f9@cilium.io>

cilium/cilium,cilium/cilium,michi-covalent/cilium,michi-covalent/cilium,cilium/cilium,cilium/cilium,cilium/cilium,michi-covalent/cilium,michi-covalent/cilium,michi-covalent/cilium