Add general /proc/sys/net/ipv[46]/{conf,neigh}/ interface
Bug: 21859053
Bug: 28135208
(cherry picked from commit b218a87e0777d3d2c93231e03ef7315d783e3279)
Change-Id: Ie32c86511b97358d208a4c84a1c69a75c703bf3b
diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp
index 9909aef..fd94d2e 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -617,3 +617,40 @@
EXPECT_FALSE(interfaceHasAddress(sTunIfName, td.addrString, -1));
}
}
+
+TEST_F(BinderTest, TestSetProcSysNet) {
+ static const struct TestData {
+ const int family;
+ const int which;
+ const char *ifname;
+ const char *parameter;
+ const char *value;
+ const int expectedReturnCode;
+ } kTestData[] = {
+ { INetd::IPV4, INetd::CONF, sTunIfName.c_str(), "arp_ignore", "1", 0 },
+ { -1, INetd::CONF, sTunIfName.c_str(), "arp_ignore", "1", EAFNOSUPPORT },
+ { INetd::IPV4, -1, sTunIfName.c_str(), "arp_ignore", "1", EINVAL },
+ { INetd::IPV4, INetd::CONF, "..", "conf/lo/arp_ignore", "1", EINVAL },
+ { INetd::IPV4, INetd::CONF, ".", "lo/arp_ignore", "1", EINVAL },
+ { INetd::IPV4, INetd::CONF, sTunIfName.c_str(), "../all/arp_ignore", "1", EINVAL },
+ { INetd::IPV6, INetd::NEIGH, sTunIfName.c_str(), "ucast_solicit", "7", 0 },
+ };
+
+ for (unsigned int i = 0; i < arraysize(kTestData); i++) {
+ const auto &td = kTestData[i];
+
+ const binder::Status status = mNetd->setProcSysNet(
+ td.family, td.which, td.ifname, td.parameter,
+ td.value);
+
+ if (td.expectedReturnCode == 0) {
+ SCOPED_TRACE(String8::format("test case %d should have passed", i));
+ EXPECT_EQ(0, status.exceptionCode());
+ EXPECT_EQ(0, status.serviceSpecificErrorCode());
+ } else {
+ SCOPED_TRACE(String8::format("test case %d should have failed", i));
+ EXPECT_EQ(binder::Status::EX_SERVICE_SPECIFIC, status.exceptionCode());
+ EXPECT_EQ(td.expectedReturnCode, status.serviceSpecificErrorCode());
+ }
+ }
+}