TetherController: Remove default data limit in tethering start
Don't need anymore because the tethering control plane is moved to
the tethering service and the data limit is applied since the first
rule is added. The tethering service has the responsibility to set
the rule and the data limit now.
Bug: 150736748
Test: manual, atest netd_integration_test:NetdBinderTest#TetherOffloadForwarding
Original-Change: https://android-review.googlesource.com/1325771
Merged-In: Ie2b8d57680025be903ebfb3d33e8ef1e2e819ddd
Change-Id: Ie2b8d57680025be903ebfb3d33e8ef1e2e819ddd
diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp
index cd7567a..f3667b9 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -3712,15 +3712,27 @@
status = mNetd->tetherOffloadRuleAdd(rule);
EXPECT_TRUE(status.isOk()) << status.exceptionMessage();
+ // Set data limit to one byte less than two packets.
+ // If you get rid of the '- 1' then the second packet will get forwarded
+ // and the EXPECT_FALSE(expectPacket(...)) a dozen lines down will fail.
+ status = mNetd->tetherOffloadSetInterfaceQuota(sTun.ifindex(), sizeof(pkt) * 2 - 1);
+ EXPECT_TRUE(status.isOk()) << status.exceptionMessage();
+
// Receive a packet on sTun.
EXPECT_EQ((ssize_t)sizeof(pkt), write(fd1, &pkt, sizeof(pkt)));
// Expect a packet identical to pkt, except with a TTL of 63.
struct packet pkt2 = pkt;
- ASSERT_EQ(1500U, sizeof(pkt));
+ ASSERT_EQ(1500U, sizeof(pkt2));
pkt2.hdr.hop_limit = pkt.hdr.hop_limit - 1;
EXPECT_TRUE(expectPacket(fd2, (uint8_t*)&pkt2, sizeof(pkt2)));
+ // Receive a second packet on sTun.
+ EXPECT_EQ((ssize_t)sizeof(pkt), write(fd1, &pkt, sizeof(pkt)));
+
+ // Should fail to forward due to quota limit.
+ EXPECT_FALSE(expectPacket(fd2, (uint8_t*)&pkt2, sizeof(pkt2)));
+
// Clean up.
EXPECT_TRUE(mNetd->tetherOffloadRuleRemove(rule).isOk());
EXPECT_TRUE(mNetd->ipfwdRemoveInterfaceForward(tap.name(), sTun.name()).isOk());