[ipsec-qtaguid] Reserve mark, add ipsec bw exemptions

This change reserves a mark denoting that a packet has already been
accounted for, along with adding rules in BandwidthController to support
IPSec packets being billed correctly.

Bug: 62994731
Test: BandwidthControllerTest updated, passing. CTS tests also modified
and passing

Change-Id: I8b42975d1502a0d3b9e533bddc0892cfe1556bed
diff --git a/server/RouteControllerTest.cpp b/server/RouteControllerTest.cpp
index 090b383..5845652 100644
--- a/server/RouteControllerTest.cpp
+++ b/server/RouteControllerTest.cpp
@@ -18,10 +18,15 @@
 
 #include <gtest/gtest.h>
 
+#include "Fwmark.h"
 #include "IptablesBaseTest.h"
 #include "NetlinkCommands.h"
 #include "RouteController.h"
 
+#include <android-base/stringprintf.h>
+
+using android::base::StringPrintf;
+
 namespace android {
 namespace net {
 
@@ -85,14 +90,22 @@
 }
 
 TEST_F(RouteControllerTest, TestModifyIncomingPacketMark) {
-    static constexpr int TEST_NETID = 30;
-    EXPECT_EQ(0, modifyIncomingPacketMark(TEST_NETID, "netdtest0", PERMISSION_NONE, true));
-    expectIptablesRestoreCommands({
-        "-t mangle -A routectrl_mangle_INPUT -i netdtest0 -j MARK --set-mark 0x3001e" });
+  uint32_t mask = ~Fwmark::getUidBillingMask();
 
-    EXPECT_EQ(0, modifyIncomingPacketMark(TEST_NETID, "netdtest0", PERMISSION_NONE, false));
-    expectIptablesRestoreCommands({
-          "-t mangle -D routectrl_mangle_INPUT -i netdtest0 -j MARK --set-mark 0x3001e" });
+  static constexpr int TEST_NETID = 30;
+  EXPECT_EQ(0, modifyIncomingPacketMark(TEST_NETID, "netdtest0",
+                                        PERMISSION_NONE, true));
+  expectIptablesRestoreCommands({StringPrintf(
+      "-t mangle -A routectrl_mangle_INPUT -i netdtest0 -j MARK --set-mark "
+      "0x3001e/0x%x",
+      mask)});
+
+  EXPECT_EQ(0, modifyIncomingPacketMark(TEST_NETID, "netdtest0",
+                                        PERMISSION_NONE, false));
+  expectIptablesRestoreCommands({StringPrintf(
+      "-t mangle -D routectrl_mangle_INPUT -i netdtest0 -j MARK --set-mark "
+      "0x3001e/0x%x",
+      mask)});
 }
 
 }  // namespace net