summaryrefslogtreecommitdiff
path: root/netd/BpfHandlerTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netd/BpfHandlerTest.cpp')
-rw-r--r--netd/BpfHandlerTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/netd/BpfHandlerTest.cpp b/netd/BpfHandlerTest.cpp
index 925a92f301..66a2f803a3 100644
--- a/netd/BpfHandlerTest.cpp
+++ b/netd/BpfHandlerTest.cpp
@@ -188,6 +188,14 @@ TEST_F(BpfHandlerTest, TestTagInvalidSocket) {
expectMapEmpty(mFakeCookieTagMap);
}
+TEST_F(BpfHandlerTest, TestTagSocketWithUnsupportedProtocol) {
+ int rawSocket = socket(AF_INET, SOCK_RAW | SOCK_CLOEXEC, IPPROTO_RAW);
+ EXPECT_LE(0, rawSocket);
+ uint64_t sockCookie = getSocketCookie(rawSocket);
+ EXPECT_NE(NONEXISTENT_COOKIE, sockCookie);
+ EXPECT_EQ(-EPROTONOSUPPORT, mBh.tagSocket(rawSocket, TEST_TAG, TEST_UID, TEST_UID));
+}
+
TEST_F(BpfHandlerTest, TestTagSocketWithoutPermission) {
int sock = socket(AF_INET6, SOCK_STREAM | SOCK_CLOEXEC, 0);
ASSERT_NE(-1, sock);