Support getting fwmark for a network

NetworkStack will use the tcp info queried from kernel to
diagnose internet health. The diagnosis should only focus on
specific network, e.g. default network. NetworkStack needs a way
to filter the target network. The only identifier is the fwmark
value for each socket. The fwmark calculation may be modified
in native and may not sync with NetworkStack. Thus, NetworkStack
will need a way to get the netId mask and the network fwmark to
know the network information contained in the fwmark. Expose this
function to ensure the fwmark implementation is aligned wih netd.

Bug: 130325409
Test: cd system/netd; atest
Change-Id: I52fba39e041490016224beffb273693e64ce4338
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 9aec5e2..9e217f5 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -37,6 +37,7 @@
 
 #include "BinderUtil.h"
 #include "Controllers.h"
+#include "Fwmark.h"
 #include "InterfaceController.h"
 #include "NetdNativeService.h"
 #include "NetdPermissions.h"
@@ -1188,5 +1189,15 @@
     return binder::Status::ok();
 }
 
+binder::Status NetdNativeService::getFwmarkForNetwork(int32_t netId, MarkMaskParcel* markMask) {
+    ENFORCE_NETWORK_STACK_PERMISSIONS();
+
+    Fwmark fwmark;
+    fwmark.netId = netId;
+    markMask->mask = FWMARK_NET_ID_MASK;
+    markMask->mark = fwmark.intValue;
+    return binder::Status::ok();
+}
+
 }  // namespace net
 }  // namespace android