ebpf tethering - add a map to store data limit, part 1
This just defines the map, but doesn't populate it,
nor does it use the information yet.
Tested:
$ adb shell ls -l /sys/fs/bpf | egrep limit
-rw-rw---- 1 root network_stack 0 2020-05-05 02:06 map_offload_tether_limit_map
Bug: 150736748
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I665c14d8a3eeb949d5ae2f8ddb9f590040ddce10
Merged-In: I665c14d8a3eeb949d5ae2f8ddb9f590040ddce10
diff --git a/server/OffloadUtilsTest.cpp b/server/OffloadUtilsTest.cpp
index 1a71c98..1760c1d 100644
--- a/server/OffloadUtilsTest.cpp
+++ b/server/OffloadUtilsTest.cpp
@@ -192,6 +192,15 @@
close(fd);
}
+TEST_F(OffloadUtilsTest, GetTetherLimitMapFd) {
+ SKIP_IF_BPF_NOT_SUPPORTED;
+
+ int fd = getTetherLimitMapFd();
+ ASSERT_GE(fd, 3); // 0,1,2 - stdin/out/err, thus fd >= 3
+ EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
+ close(fd);
+}
+
// The SKIP_IF_BPF_NOT_SUPPORTED macro is effectively a check for 4.9+ kernel
// combined with a launched on P device. Ie. it's a test for 4.9-P or better.