Tighten up locking in NetworkController.

NetworkController uses read-write locking to protect readers
from network configuration changes, but is not fully thread-safe
in the presence of concurrent modification.

Currently concurrent modification almost never happens because
most netd commands are sent through CommandListener, which is
single-threaded. However, we need proper thread-safety to expose
NetworkController control via binder, which is inherently
multi-threaded.

Test: netd_{unit,integration}_test passes
Test: system boots, networking works.
Change-Id: Icc35c9173f342c8d0c45c6b47c0ebdb68de40073
diff --git a/server/NetworkController.h b/server/NetworkController.h
index ceb538e..08ba602 100644
--- a/server/NetworkController.h
+++ b/server/NetworkController.h
@@ -131,9 +131,14 @@
     void dump(DumpWriter& dw);
 
 private:
-    bool isValidNetwork(unsigned netId) const;
     bool isValidNetworkLocked(unsigned netId) const;
     Network* getNetworkLocked(unsigned netId) const;
+    uint32_t getNetworkForDnsLocked(unsigned* netId, uid_t uid) const;
+    unsigned getNetworkForUserLocked(uid_t uid) const;
+    unsigned getNetworkForConnectLocked(uid_t uid) const;
+    unsigned getNetworkForInterfaceLocked(const char* interface) const;
+    bool canProtectLocked(uid_t uid) const;
+
     VirtualNetwork* getVirtualNetworkForUserLocked(uid_t uid) const;
     Permission getPermissionForUserLocked(uid_t uid) const;
     int checkUserNetworkAccessLocked(uid_t uid, unsigned netId) const;