OSDN Git Service

android-x86/system-netd.git
7 years agoMake the socketDestroy tests use a fake tun interface.
Lorenzo Colitti [Thu, 28 Jul 2016 11:24:07 +0000 (11:24 +0000)]
Make the socketDestroy tests use a fake tun interface.
am: 549a0f7058

Change-Id: I9e65b849c0e57acfdd55b09152710b2195a4dee1

7 years agoMake the socketDestroy tests use a fake tun interface.
Lorenzo Colitti [Wed, 27 Jul 2016 13:10:49 +0000 (22:10 +0900)]
Make the socketDestroy tests use a fake tun interface.

On real devices, we often don't want to destroy sockets that
are on loopback. This CL makes our integration tests use
sockets that don't look like they're on loopback, making it
possible to test code that does not destroy sockets that are
on loopback.

Bug: 30186506
Change-Id: I1ea56f069f528f25dddd5898b2269a638318f820

7 years agoAdd tetherApplyDnsInterfaces() binder interface.
Erik Kline [Sun, 17 Jul 2016 19:02:07 +0000 (04:02 +0900)]
Add tetherApplyDnsInterfaces() binder interface.

Bug: 9580643
Change-Id: I781a422c969deb153bc8370edda4578612af6dc6

7 years agoParse IPv6 tethering counters.
Lorenzo Colitti [Mon, 11 Jul 2016 02:36:25 +0000 (11:36 +0900)]
Parse IPv6 tethering counters.

Bug: 9580643
Change-Id: Icbfd8c6480a4e14433004e90b71a104ae4da9c5d

7 years agoAdd counters for IPv6 tethering.
Lorenzo Colitti [Sun, 10 Jul 2016 14:15:46 +0000 (23:15 +0900)]
Add counters for IPv6 tethering.

Bug: 9580643
Change-Id: I60ff10cea8e8e90eeaf5412f1b6254696073506d

7 years agoRefactor getTetherStats in preparation for IPv6 tether counters.
Lorenzo Colitti [Fri, 8 Jul 2016 09:24:53 +0000 (18:24 +0900)]
Refactor getTetherStats in preparation for IPv6 tether counters.

Bug: 9580643
Change-Id: I11565cafbefbc06a7992d1ff18c707165d5b31ed

7 years agoMore test coverage for tethering counter parsing.
Lorenzo Colitti [Mon, 11 Jul 2016 16:19:49 +0000 (01:19 +0900)]
More test coverage for tethering counter parsing.

Bug: 9580643
Change-Id: Ia2f273b518399f42bfa8efb98445f1ff043bc07e

7 years agoAdd a test for NatController.
Lorenzo Colitti [Sat, 9 Jul 2016 05:24:08 +0000 (14:24 +0900)]
Add a test for NatController.

Bug: 9580643
Change-Id: I6ac3b754ec0b720674c6221e3a776314e86fe58c

7 years agoAdd a test for getTetherStats.
Lorenzo Colitti [Fri, 8 Jul 2016 09:24:26 +0000 (18:24 +0900)]
Add a test for getTetherStats.

Bug: 9580643
Change-Id: I26f7adb9639f1ddf4eda0c98bcc6cd3a83d3ba0b

7 years agoSetup interfaces for IPv6 tethering
Erik Kline [Wed, 8 Jun 2016 04:24:45 +0000 (13:24 +0900)]
Setup interfaces for IPv6 tethering

Including:
    - set the interface for router mode (accept_ra = 0)
    - reset the interface for client mode (accept_ra = 1)
    - InterfaceController::setAcceptIPv6Ra()
    - InterfaceController::setAcceptIPv6Dad()
    - make InterfaceController static
    - refactor for more modern C++ usage here and there
    - sporadic style guide fixes

Bug: 9580643
Change-Id: Ia557c8770e18c58b12ad16d982c63b6ebd525516

7 years agoAlways use the default network DNS servers if a VPN does not set any.
Lorenzo Colitti [Wed, 22 Jun 2016 10:53:56 +0000 (10:53 +0000)]
Always use the default network DNS servers if a VPN does not set any.
am: c63059c8a7

Change-Id: I2e7f91b5c50cee056c97e75b65b2683285582899

7 years agoAlways use the default network DNS servers if a VPN does not set any.
Lorenzo Colitti [Tue, 21 Jun 2016 14:54:12 +0000 (23:54 +0900)]
Always use the default network DNS servers if a VPN does not set any.

When a VPN provides no DNS servers, DNS lookups are usually sent
to the default network's DNS servers. However, if a DNS lookup
is explicitly made on the VPN (e.g., via Network#openConnection),
then it just fails.

This breaks system proxies which perform network traffic on VPNs
on behalf of other apps, e.g., the download manager.

Fix this by doing the query to the default DNS servers (via the
default network) instead. This is consistent with what we do with
DNS queries that do not specify a network. While this is a change
in behaviour, it shouldn't cause much breakage because the query
would previously just fail.

Bug: 29498052
Change-Id: Ie4002c9835bb1ff6d3d92c00c9c04e634fc3cda4

7 years agoListen to xt_quota2 kobject event for quota
Bryse Flowers [Wed, 1 Jun 2016 20:00:12 +0000 (13:00 -0700)]
Listen to xt_quota2 kobject event for quota

Allow quota limit reached notification to originate from both
qlog and xt_quota2 subsystem.  On 3.18 Kernel, modify xt_quota2
module to broadcast the Netlink notification via kobject.

Change-Id: Iaafe521e455d658ed8a2f95fb5114b029323d5ef
CRs-Fixed: 1008025
Bug: 24140541

7 years agoVerify expectations better in SockDiagTest.
Lorenzo Colitti [Thu, 9 Jun 2016 16:54:52 +0000 (01:54 +0900)]
Verify expectations better in SockDiagTest.

Currently SockDiagTest only checks for socket errors, it does not
check that the socket was closed via SOCK_DESTROY. This can cause
us to think that SOCK_DESTROY is working when it isn't.

Fix this by checking the error codes and expecting that at least
one socket was closed by SOCK_DESTROY.

Bug: 28508161
Change-Id: Iab423dba0aa30466481dd3a7304aa8f69c5cf605

7 years agoDon't fail the test if the iptables lock is held.
Lorenzo Colitti [Thu, 9 Jun 2016 05:20:08 +0000 (14:20 +0900)]
Don't fail the test if the iptables lock is held.

Change-Id: Ib4db989fdb35df3f517ce4db1526e5c1f78ad4b5

7 years agoDo not configure more DNS servers than supported.
Pierre Imai [Tue, 31 May 2016 00:57:19 +0000 (00:57 +0000)]
Do not configure more DNS servers than supported.
am: 0452cb569e

* commit '0452cb569ebeface13f77c548afb35cdfcbe48d5':
  Do not configure more DNS servers than supported.

Change-Id: I0893649176126b46fc493d353e32fba38226dd8e

7 years agoDo not configure more DNS servers than supported.
Pierre Imai [Mon, 30 May 2016 07:42:34 +0000 (16:42 +0900)]
Do not configure more DNS servers than supported.

BUG: 28984564
Change-Id: I1b580d725f0aafe887db894e19971cc29adf8951

8 years agoSilence spammy iptables rule at boot.
Pierre Imai [Fri, 27 May 2016 06:51:55 +0000 (15:51 +0900)]
Silence spammy iptables rule at boot.

BUG: 28529315
Change-Id: I4818b3833464502a44d9cdb92e3c59802882397b

8 years agoUpdate wlutil path
Erik Kline [Thu, 26 May 2016 14:40:14 +0000 (14:40 +0000)]
Update wlutil path
am: bdcba1127a

* commit 'bdcba1127a8709566fdec49bc303234e0e8ee924':
  Update wlutil path

Change-Id: Ieb82f51d47c33d10b32400e007322d35dc423b61

8 years agoUpdate wlutil path
Erik Kline [Thu, 26 May 2016 08:00:31 +0000 (17:00 +0900)]
Update wlutil path

The path to wlutil changed to /system/vendor/xbin with ag/893600 .

Bug: 28850734
Change-Id: I101517e7d849c288cbe9877e874b8d7914fbc1e9

8 years agoMerge "Drop PROHIBIT_NON_VPN priority 11500 -> 12500" into nyc-dev
Robin Lee [Tue, 17 May 2016 16:26:07 +0000 (16:26 +0000)]
Merge "Drop PROHIBIT_NON_VPN priority 11500 -> 12500" into nyc-dev
am: 5bbe13bdc4

* commit '5bbe13bdc4470d0af2786fc62ad40a8ba8ff5830':
  Drop PROHIBIT_NON_VPN priority 11500 -> 12500

Change-Id: I22e4e178b25d579eabde255da1d5b1a6c954556d

8 years agoMerge "Drop PROHIBIT_NON_VPN priority 11500 -> 12500" into nyc-dev
Robin Lee [Tue, 17 May 2016 16:19:40 +0000 (16:19 +0000)]
Merge "Drop PROHIBIT_NON_VPN priority 11500 -> 12500" into nyc-dev

8 years agoMerge changes Ifbd15bf9,I985e6861,I54860c7c into nyc-dev
Lorenzo Colitti [Mon, 16 May 2016 14:09:21 +0000 (14:09 +0000)]
Merge changes Ifbd15bf9,I985e6861,I54860c7c into nyc-dev
am: 7ad3c888e2

* commit '7ad3c888e2781321cf44cb101cdf180a9671ca1e':
  Make FirewallController::createChain use replaceUidChain.
  Make firewallReplaceUidChain match the behaviour of createChain.
  Don't crash the test if expecting more commands than were run.

Change-Id: Ib9dac62413187fc9b4978dfe14b7d29dbf328328

8 years agoMerge changes Ifbd15bf9,I985e6861,I54860c7c into nyc-dev
Lorenzo Colitti [Mon, 16 May 2016 14:02:00 +0000 (14:02 +0000)]
Merge changes Ifbd15bf9,I985e6861,I54860c7c into nyc-dev

* changes:
  Make FirewallController::createChain use replaceUidChain.
  Make firewallReplaceUidChain match the behaviour of createChain.
  Don't crash the test if expecting more commands than were run.

8 years agoMake FirewallController::createChain use replaceUidChain.
Lorenzo Colitti [Fri, 13 May 2016 08:03:42 +0000 (17:03 +0900)]
Make FirewallController::createChain use replaceUidChain.

This has two benefits:

1. It makes the behaviour of setting firewall chains via the
   firewallReplaceUidChain RPC match the behaviour of creating
   the chains on boot. (As a side effect, it reduces code
   duplication between the two.)
2. It makes creating firewall chains on boot use iptables-restore,
   which is substantially faster than running iptables commands
   one at a time.

This CL will allow the framework to switch to using
firewallReplaceUidChain when the framework starts, providing
substantial speedups over the current behaviour of running two
iptables commands for every app that is whitelisted or idle.

Bug: 26675191
Change-Id: Ifbd15bf9143efd526570dde8f88effc79d164630

8 years agoMake firewallReplaceUidChain match the behaviour of createChain.
Lorenzo Colitti [Fri, 13 May 2016 02:25:54 +0000 (11:25 +0900)]
Make firewallReplaceUidChain match the behaviour of createChain.

The behaviour of the firewallReplaceUidChain was incorrect in
several ways:

1. It was missing the "always allow TCP RST packets" rules which
   were added in http://ag/963000 .
2. It included a RETURN statement at the end of blacklist chains,
   which is superfluous since all user-defined chains implicitly
   return, and became incorrect when http://ag/963000 switched the
   behaviour of blacklist chains from inserting new rules at the
   beginning to appending them at the end.
3. It was missing the rules to allow the types of ICMPv6 packets
   that are critical in maintaining connectivity.

By itself, this change is a no-op since nothing currently calls
firewallReplaceUidRule.

Bug: 26675191
Change-Id: I985e6861812908cbe7eaf0f54ca0ad39c22bbfeb

8 years agoDon't crash the test if expecting more commands than were run.
Lorenzo Colitti [Fri, 13 May 2016 07:57:15 +0000 (16:57 +0900)]
Don't crash the test if expecting more commands than were run.

Bug: 26675191
Change-Id: I54860c7cf7b79bb6ace89c3130467ba7c0473e03

8 years agoMerge "Fix P2TP VPNs by adding an exception for VPN user." into nyc-dev
Pierre Imai [Mon, 16 May 2016 09:07:26 +0000 (09:07 +0000)]
Merge "Fix P2TP VPNs by adding an exception for VPN user." into nyc-dev
am: 4f88299120

* commit '4f88299120b076dc068a67cf0f0343660a2777fa':
  Fix P2TP VPNs by adding an exception for VPN user.

Change-Id: Ic8528dd6d589f08324ecbc69a4024086e9054a7f

8 years agoMerge "Fix P2TP VPNs by adding an exception for VPN user." into nyc-dev
TreeHugger Robot [Mon, 16 May 2016 09:02:17 +0000 (09:02 +0000)]
Merge "Fix P2TP VPNs by adding an exception for VPN user." into nyc-dev

8 years agoFix P2TP VPNs by adding an exception for VPN user.
Pierre Imai [Mon, 16 May 2016 07:32:17 +0000 (16:32 +0900)]
Fix P2TP VPNs by adding an exception for VPN user.

BUG: 27199751
Change-Id: I1144228febba0c4cce1333fb39ea186d2963ed10

8 years agoIncrease the DNS TTL to 5s to fix netd_test.
Pierre Imai [Fri, 13 May 2016 09:00:58 +0000 (09:00 +0000)]
Increase the DNS TTL to 5s to fix netd_test.
am: f581017c79

* commit 'f581017c7945ee024a2757925ff82861b34a069c':
  Increase the DNS TTL to 5s to fix netd_test.

Change-Id: Iffcb3527816269f1509df4f070d57742ee7a4f92

8 years agoIncrease the DNS TTL to 5s to fix netd_test.
Pierre Imai [Fri, 13 May 2016 07:28:28 +0000 (16:28 +0900)]
Increase the DNS TTL to 5s to fix netd_test.

Under some rare, but repeatable, conditions, the cache would expire
before the second getaddrinfo() call in the test was executed, thus causing
superfluous queries that made the test fail. Increasing the TTL fixes
this.

BUG: 28252032

Change-Id: I82919c147ca9c1b7a92f963556b27fb72e3d2222

8 years agoTest that changing the DNS search paths works.
Pierre Imai [Thu, 12 May 2016 07:54:46 +0000 (07:54 +0000)]
Test that changing the DNS search paths works.
am: ee335ef233

* commit 'ee335ef2333aaa09290ed8cf4a65f8e6e8b21c46':
  Test that changing the DNS search paths works.

Change-Id: I4c1bd059f3345e4442463352c178b8d7bd8d0680

8 years agoTest that changing the DNS search paths works.
Pierre Imai [Fri, 6 May 2016 02:56:45 +0000 (11:56 +0900)]
Test that changing the DNS search paths works.

Add a test to verify that changing the DNS search paths on their own,
without also changing the DNS servers, works as expected.

BUG: 28437641

Change-Id: Ie3b6be119f5d33c7782c250a83d24f26c776825e
(cherry picked from commit 592303cf22e1139ecb32fb7589abdc6bc6d14354)

8 years agoDrop PROHIBIT_NON_VPN priority 11500 -> 12500
Robin Lee [Tue, 3 May 2016 12:17:58 +0000 (13:17 +0100)]
Drop PROHIBIT_NON_VPN priority 11500 -> 12500

So that the rule can be kept up 100% of the time instead of dropping
it when VPN comes on.

Bug: 26694104
Change-Id: I1df6b8f588e54d72e34dbcbd15492513e07fac3d

8 years agoRestore ACT_UNREACHABLE
Robin Lee [Mon, 2 May 2016 11:17:30 +0000 (11:17 +0000)]
Restore ACT_UNREACHABLE
am: c125fe43c1

* commit 'c125fe43c194128167db7a2a82b736b1357945d8':
  Restore ACT_UNREACHABLE

Change-Id: Ibdc6df61ba87951cabb278250d9a646b27f42315

8 years agoRestore ACT_UNREACHABLE
Robin Lee [Mon, 2 May 2016 07:53:34 +0000 (08:53 +0100)]
Restore ACT_UNREACHABLE

This got lost in between
  I7d9752e86fa1a4564c622152a5be6ce2c1eda150 and
  If23df0760c6eb0ad137fc26c5124e48edf23b722.

Which broke creating the UNREACHABLE network, also breaking the dummy
network which should be created after it.

Fix: 28304838
Change-Id: I31c4ca9c3f53d6162b50e5bc46e27cfcd1b6a314

8 years agoAdd dumpsys support to ResolverController
Pierre Imai [Thu, 28 Apr 2016 13:39:12 +0000 (13:39 +0000)]
Add dumpsys support to ResolverController
am: 3a27207

* commit '3a272070fc318ef1a7a5a04e500483f1a7c629a8':
  Add dumpsys support to ResolverController

Change-Id: I61b0352be471f6631cf5b400fdce447cbf1f6526

8 years agoAdd two Netd binder calls to set/get resolver config.
Pierre Imai [Thu, 28 Apr 2016 13:39:12 +0000 (13:39 +0000)]
Add two Netd binder calls to set/get resolver config.
am: beedec3

* commit 'beedec3bc42d6f40a2c83a65522e85b5ff046f79':
  Add two Netd binder calls to set/get resolver config.

Change-Id: I32c2ee7d27207853a16ee110b712375d0446feb7

8 years agoAdd dumpsys support to ResolverController
Pierre Imai [Tue, 19 Apr 2016 07:17:07 +0000 (16:17 +0900)]
Add dumpsys support to ResolverController

BUG: 25731675

Change-Id: I1c715368b1f2d5e732528cd226b3f69792b75321

8 years agoAdd two Netd binder calls to set/get resolver config.
Pierre Imai [Tue, 12 Apr 2016 21:44:51 +0000 (06:44 +0900)]
Add two Netd binder calls to set/get resolver config.

setResolverConfiguration() sets the name servers, search domains,
and resolver parameters.
getResolverInfo() returns the configured information and also the
statistics for each server.
Also includes tests for the new functionality.

BUG: 25731675

Change-Id: Idde486f36bb731f9edd240d62dc1795f8e621fe6

8 years agoAllow TCP RSTs to make it through firewall rules.
Lorenzo Colitti [Tue, 26 Apr 2016 09:01:56 +0000 (09:01 +0000)]
Allow TCP RSTs to make it through firewall rules.
am: 932c44c

* commit '932c44c9bd875060219df7f2ad78769e65adbaca':
  Allow TCP RSTs to make it through firewall rules.

Change-Id: I34b136804e7eb1a4fb27314e51c4967de21da486

8 years agoAdd a binder IPC to close socket connections.
Lorenzo Colitti [Tue, 26 Apr 2016 09:01:55 +0000 (09:01 +0000)]
Add a binder IPC to close socket connections.
am: 563d98b

* commit '563d98b27d02a1d694fc4ed82b5554fd534c9daf':
  Add a binder IPC to close socket connections.

Change-Id: Idb7e6cf83e6134d390c3e505973e245c7dc718de

8 years agoAllow TCP RSTs to make it through firewall rules.
Lorenzo Colitti [Sun, 24 Apr 2016 07:58:02 +0000 (16:58 +0900)]
Allow TCP RSTs to make it through firewall rules.

This allows us to cleanly close apps' TCP connections when we
remove their network connectivity.

Bug: 27824851
Change-Id: I69ae0e860536139d30d14d580a36c82f79dc2f82

8 years agoAdd a binder IPC to close socket connections.
Lorenzo Colitti [Sun, 24 Apr 2016 04:13:14 +0000 (13:13 +0900)]
Add a binder IPC to close socket connections.

Bug: 27824851
Bug: 27867653
Change-Id: I2e63ccfb268db763ec732594a73c2908838468b8

8 years agoServer API to only allow networking by VPN apps
Robin Lee [Tue, 19 Apr 2016 19:40:30 +0000 (19:40 +0000)]
Server API to only allow networking by VPN apps
am: b808736

* commit 'b8087363143050d214d48e5620a330776ca95a69':
  Server API to only allow networking by VPN apps

Change-Id: I2dd017089226356eda452d6cc246f6e9b3e3166f

8 years agoHave modifyIpRule take an explicit action
Robin Lee [Tue, 19 Apr 2016 19:40:30 +0000 (19:40 +0000)]
Have modifyIpRule take an explicit action
am: 4ef9464

* commit '4ef94642636182e68495f606a65c00f8a830aad4':
  Have modifyIpRule take an explicit action

Change-Id: I9836350a8042622ca440ffdc057d799de561f71f

8 years agoMove UidRange aidl to create a native cpp version
Robin Lee [Tue, 19 Apr 2016 19:40:30 +0000 (19:40 +0000)]
Move UidRange aidl to create a native cpp version
am: 9f9aae9

* commit '9f9aae9102f62f5f96ccec670170ee1fb262ef09':
  Move UidRange aidl to create a native cpp version

Change-Id: Idc705f22d3eeeb8de90a1133e42e05c184518e25

8 years agoServer API to only allow networking by VPN apps
Robin Lee [Wed, 30 Mar 2016 17:43:08 +0000 (18:43 +0100)]
Server API to only allow networking by VPN apps

Secure virtual networks already create rules to route all traffic into
theirselves. This depends on the secure network already existing.

API creates an ip rule at a priority level below SECURE_VPN which
can catch traffic before VPN comes up, if it is a requirement that no
traffic ever leaves without first going through VPN.

Bug: 26694104
Bug: 26354134
Change-Id: If23df0760c6eb0ad137fc26c5124e48edf23b722

8 years agoHave modifyIpRule take an explicit action
Robin Lee [Fri, 1 Apr 2016 10:50:49 +0000 (11:50 +0100)]
Have modifyIpRule take an explicit action

Instead of inferring from the priority what the action should be.

Bug: 26694104
Change-Id: I7d9752e86fa1a4564c622152a5be6ce2c1eda150

8 years agoMove UidRange aidl to create a native cpp version
Robin Lee [Wed, 30 Mar 2016 17:33:07 +0000 (18:33 +0100)]
Move UidRange aidl to create a native cpp version

Moved from:
    //frameworks/base/core/java/android/net/
To:
    //system/netd/binder

Since frameworks/base depends on netd but not vice versa, it is cleaner
to keep the internal aidl in the same place as the native implementation
in netd.

Bug: 26694104
Change-Id: If21a72978ad5b93f0eed04c75143b55157c1a014

8 years agoNetd metrics logging for DNS queries
Lorenzo Colitti [Tue, 12 Apr 2016 14:28:50 +0000 (23:28 +0900)]
Netd metrics logging for DNS queries

This CL defines a new IDnsEventListener interface and instruments
DnsProxyListener to send log events to it after every DNS query.

Bug: 28204408
Change-Id: I7ef09d8fac2a583fb3dc8e392c4fff5649258b28

8 years agoMove the Stopwatch class to NetdConstants.
Lorenzo Colitti [Fri, 15 Apr 2016 01:22:37 +0000 (10:22 +0900)]
Move the Stopwatch class to NetdConstants.

Also implement TimedOperation by subclassing Stopwatch, since
it essentially does the same thing.

Change-Id: I68febcf1caa8a00b548790f9e3ccc10836877639

8 years agoMerge "Kill sockets when a VPN comes up." into nyc-dev
TreeHugger Robot [Thu, 14 Apr 2016 09:55:18 +0000 (09:55 +0000)]
Merge "Kill sockets when a VPN comes up." into nyc-dev

8 years agoKill sockets when a VPN comes up.
Lorenzo Colitti [Wed, 13 Apr 2016 15:56:01 +0000 (00:56 +0900)]
Kill sockets when a VPN comes up.

1. Change the SockDiag callback function to be a filter that
   returns a bool instead of a function that optionally kills a
   socket. All existing callbacks basically only existed to kill
   sockets under certain conditions, and making them return a
   boolean allows reusing the same callback function signature
   to filter sockets as well.
2. Add a new SockDiag method to kill sockets based on a UidRanges
   object (which contains a number of UID ranges) and a list of
   users to skip.
3. Add a new UIDRANGE mode to SockDiagTest to test the above.
4. When UID ranges are added or removed from the VPN, kill
   sockets in those UID ranges unless the socket UIDs are in
   mProtectableUsers and thus their creator might have set the
   protect bit on their mark.  Short of actually being
   able to see the socket mark on each socket and basing our
   decision on that, this is the best we can do.

Bug: 26976388
Change-Id: I53a30df3feb63254a6451a29fa6041c9b679f9bb

8 years agoMerge "Fix netd_test by removing flush cache call." into nyc-dev
Pierre Imai [Tue, 12 Apr 2016 02:35:47 +0000 (02:35 +0000)]
Merge "Fix netd_test by removing flush cache call." into nyc-dev

8 years agoMerge "Workaround ASan false positive in RouteController." into nyc-dev
Jon Larimer [Mon, 11 Apr 2016 16:43:41 +0000 (16:43 +0000)]
Merge "Workaround ASan false positive in RouteController." into nyc-dev

8 years agoFix netd_test by removing flush cache call.
Pierre Imai [Fri, 8 Apr 2016 04:15:27 +0000 (13:15 +0900)]
Fix netd_test by removing flush cache call.

Change-Id: Iba3ff9da55cbc709d12b12b9c65dbc565bbd2828

8 years agoDeduplicate test targets.
Lorenzo Colitti [Fri, 8 Apr 2016 04:33:38 +0000 (13:33 +0900)]
Deduplicate test targets.

netd_integration_test already runs all the tests in netd_test.

Change-Id: I44c2ffaecded071a54af1c54c823856ffc6eb0cf

8 years agoWorkaround ASan false positive in RouteController.
Evgenii Stepanov [Fri, 12 Feb 2016 00:55:56 +0000 (16:55 -0800)]
Workaround ASan false positive in RouteController.

Bug: 27037723

Change-Id: I40e7f0d07652aeb6484de5f963a7698b6805d582
(cherry picked from commit dfde1d6c6c397e437adf937a1718784d9cb2c0cf)

8 years agoMerge "Remove "resolver flushnet <netid>" command." into nyc-dev
Erik Kline [Wed, 6 Apr 2016 04:07:15 +0000 (04:07 +0000)]
Merge "Remove "resolver flushnet <netid>" command." into nyc-dev

8 years agoRemove "resolver flushnet <netid>" command.
Erik Kline [Wed, 6 Apr 2016 02:46:32 +0000 (11:46 +0900)]
Remove "resolver flushnet <netid>" command.

Change-Id: I117adc3c7e240597e7fd91c709898bbbbe988261

8 years agoDO NOT MERGE: Let netd to use the new set_nameservers_for_net call.
Pierre Imai [Wed, 9 Mar 2016 09:09:25 +0000 (18:09 +0900)]
DO NOT MERGE: Let netd to use the new set_nameservers_for_net call.

Also add more test for netd's resolver.

(cherry picked from commit 12f6baf16328cdeea8f079616c2c44ac28f82496)

Change-Id: I446f11b3462522ec3a18c2a3ec9401ad6cf77e8b

8 years agoMerge "Switch from android::netd::List to std::list" into nyc-dev
Erik Kline [Thu, 31 Mar 2016 05:57:24 +0000 (05:57 +0000)]
Merge "Switch from android::netd::List to std::list" into nyc-dev

8 years agoSwitch from android::netd::List to std::list
Erik Kline [Thu, 31 Mar 2016 02:39:53 +0000 (11:39 +0900)]
Switch from android::netd::List to std::list

Change-Id: I3e6560bbc46fd551d3501227250536cabeff4f71

8 years agoAdd mDNS TXT records to the resolve-call result.
Philip P. Moltmann [Wed, 16 Mar 2016 16:43:26 +0000 (09:43 -0700)]
Add mDNS TXT records to the resolve-call result.

I added binary value support. This changes the format of the
communication between the android framework and netd.

Bug: 27696905
Change-Id: I85122062d63f1047c618be0b16e6e95621790fd6

8 years agoUse iptables-restore in StrictController startup.
Lorenzo Colitti [Mon, 28 Mar 2016 15:53:45 +0000 (00:53 +0900)]
Use iptables-restore in StrictController startup.

Bug: 21725996
Change-Id: I2c049a934189f3c87ee15f052abc07d35814f0c9

8 years agoAdd a test for StrictController.
Lorenzo Colitti [Sun, 27 Mar 2016 17:34:54 +0000 (02:34 +0900)]
Add a test for StrictController.

Bug: 21725996
Bug: 25691379
Change-Id: I24b838161eaf98dede2ae897157ba42414fc926f

8 years agoMove iptables test code to a new IptablesBaseTest class.
Lorenzo Colitti [Sun, 27 Mar 2016 17:30:27 +0000 (02:30 +0900)]
Move iptables test code to a new IptablesBaseTest class.

Bug: 25691379
Bug: 21725996
Change-Id: Ia0598e60ad24714d53470e05849929831ba9dbf6

8 years agoUse iptables-restore in BandwidthController startup.
Lorenzo Colitti [Sun, 27 Mar 2016 08:46:30 +0000 (17:46 +0900)]
Use iptables-restore in BandwidthController startup.

This saves approximately 800ms on boot.

From the perspective of the rules, this change is a no-op. As the
unit test shows, the commands are the same, though some are in a
slightly different order because iptables-restore requires that
COMMIT be called between different tables (e.g., filter and
mangle).

For simplicity, enableBandwidthControl runs two iptables-restore
commands instead of one. This is not semantically different from
the previous code because the previous code just ran iptables
commands one by one, which provides no atomicity. Running two
commands is a bit slower than running one, but it's still much
faster than using iptables.

Using iptables-restore allows us to do things like ":<chain> -",
which both creates the chain (if it does not already exist) and
flushes it. This allows us to remove IPT_CLEANUP_COMMANDS and
IPT_SETUP_COMMANDS. Those two sets of commands, which basically
just did "-X bw_<foo>" and "-N bw_<foo>" were only necessary
because the preceding "-F bw_<foo>" command would not create
bw_<foo> if it did not already exist (e.g. in setupIptablesHooks,
which runs on netd startup).

Bug: 21725996
Change-Id: I6656aed4287dfcb2311c94800f430c143fb0b1a5

8 years agoAdd more test coverage for BandwidthController.
Lorenzo Colitti [Sat, 26 Mar 2016 13:42:07 +0000 (22:42 +0900)]
Add more test coverage for BandwidthController.

Bug: 25691379
Bug: 21725996
Change-Id: I196f568221b3bad98ba2d60e019c2b24c59a9cbc

8 years agoAttempt to make data saver mode work for real.
Lorenzo Colitti [Fri, 25 Mar 2016 04:38:19 +0000 (13:38 +0900)]
Attempt to make data saver mode work for real.

The data saver refactoring change was incorrect in >= two ways:

1. It relied on the bw_costly_shared chain, which is currently
   unused. NetworkManagementService just has a "TODO: support
   quota shared across interfaces" comment about it. What
   actually happens when setting quota is that each costly
   interface chain (e.g., bw_costly_rmnet_data0) directly hooks
   in the bw_penalty box chain.

2. Implementing app whitelisting using "RETURN" inside
   bw_happy_box was pointless because if data saver was enabled,
   there was a REJECT at the end of the bw_costly_shared chain
   that it was returning to.

Instead, go back to the previous approach which hooked
bw_happy_box at the end of bw_penalty_box. Also, add an
additional bw_data_saver rule at the end of bw_happy_box.
bw_data_saver only contains one rule: RETURN if data saver is
enabled or REJECT if data saver is disabled.

That way:

1. If the app is blacklisted, bw_penalty_box REJECTs. If not:
2. If the app is whitelisted (system apps are always whitelisted)
   bw_happy_box RETURNs to bw_costly_rmnet_data0, skipping
   bw_data_saver.
3. If an app is neither blacklisted nor whitelisted, bw_happy_box
   jumps to bw_data_saver. If data saver is enabled, it REJECTs
   the packet, and if not, it RETURNs to bw_costly_rmnet_data0.
4. When we RETURN to bw_costly_rmnet_data0, either because the
   app is whitelisted, or because data saver is off,
   bw_costly_rmnet_data0 applies mobile data usage limits,
   and then RETURNs to bw_OUTPUT, which calls xt_qtaguid, etc.

Bug: 26685616
Bug: 27506285
Change-Id: If15397afde6862d95827a1fdd30f60efd7fab66a

8 years agoSupport destroying sockets for UIDs.
Lorenzo Colitti [Thu, 24 Mar 2016 07:47:12 +0000 (16:47 +0900)]
Support destroying sockets for UIDs.

Bug: 27824851
Change-Id: Iab5ebfd1c3d463d60d3dbd3a271737c8bc824298

8 years agoRefactor SockDiagTest in preparation for per-UID SOCK_DESTROY.
Lorenzo Colitti [Thu, 24 Mar 2016 08:19:28 +0000 (17:19 +0900)]
Refactor SockDiagTest in preparation for per-UID SOCK_DESTROY.

Bug: 27824851
Change-Id: I98fa7aefdd9d0acf0a352970e3ba236227182da6

8 years agoAdd a binder RPC to enable/disable data saver.
Lorenzo Colitti [Tue, 22 Mar 2016 03:36:29 +0000 (12:36 +0900)]
Add a binder RPC to enable/disable data saver.

Bug: 26685616
Bug: 27506285
Change-Id: Id11ee717cfc1c79070b6bbec397986c25947646c

8 years agoMerge changes I149ccda5,I4457abd4,I67bff7c3,Ie15b0775,I8dd9fc60 into nyc-dev
Lorenzo Colitti [Tue, 22 Mar 2016 05:33:50 +0000 (05:33 +0000)]
Merge changes I149ccda5,I4457abd4,I67bff7c3,Ie15b0775,I8dd9fc60 into nyc-dev

* changes:
  Stop using SIOCKILLADDR in netd.
  Add a rudimentary unit test for BandwidthController.
  Slightly restructure the data saver iptables rules.
  Remove the ability to enable/disable the happy box.
  Don't keep naughty/nice app state in BandwidthController.

8 years agoStop using SIOCKILLADDR in netd.
Lorenzo Colitti [Tue, 22 Mar 2016 01:14:03 +0000 (10:14 +0900)]
Stop using SIOCKILLADDR in netd.

SOCK_DESTROY is now supported in all N device kernels.

Bug: 26976388
Change-Id: I149ccda56edacac28602daddb01b5fd0222d5fb0

8 years agoAdd a rudimentary unit test for BandwidthController.
Lorenzo Colitti [Fri, 18 Mar 2016 08:52:25 +0000 (17:52 +0900)]
Add a rudimentary unit test for BandwidthController.

Bug: 26685616
Bug: 27506285
Change-Id: I4457abd43697a0425f167b81c1432d743800abb8

8 years agoSlightly restructure the data saver iptables rules.
Lorenzo Colitti [Fri, 18 Mar 2016 03:36:03 +0000 (12:36 +0900)]
Slightly restructure the data saver iptables rules.

1. Make bw_costly_shared jump to bw_happy_box after
   bw_penalty_box. This allows the framework to manipulate
   whitelists and blacklists independently.
2. Make bw_happy box always whitelist system apps. Because
   bw_penalty_box is consulted before bw_happy_box, the
   framework can always blacklist certain system apps (e.g.,
   the media server) by putting them in the blacklist.
3. Add a method to add/remove a reject at the end of
   bw_costly_shared. This will allow the framework to
   enable/disable data saver by changing only one rule.

Bug: 26685616
Bug: 27506285
Change-Id: I67bff7c3c9ff5eb3f84fb84550cdf49f153e1b68

8 years agoAdd initial dump() method to NetdNativeService
Erik Kline [Tue, 15 Mar 2016 07:33:48 +0000 (16:33 +0900)]
Add initial dump() method to NetdNativeService

This is called by "dumpsys netd".

Bug: 27239233
Change-Id: I27fb308f8067243ff241a6f8fd6a83f406087d2a

8 years agonetd: softap: Ignore fwreload command if FW path is not defined
Dmitry Shmidt [Mon, 21 Mar 2016 21:02:54 +0000 (14:02 -0700)]
netd: softap: Ignore fwreload command if FW path is not defined

Some wlan solutions can not switch or do not need to switch FW.
In this case we don't want the function to fail and to prevent
Wifi to start in settings.

Bug: 27774657

Change-Id: I11f3cf709db6f17fc558454aa894e4a2211a9312
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
8 years agoRemove the ability to enable/disable the happy box.
Lorenzo Colitti [Fri, 18 Mar 2016 03:05:19 +0000 (12:05 +0900)]
Remove the ability to enable/disable the happy box.

This code is unused, and the plan is to have the happy box
enabled at all times.

Bug: 26685616
Bug: 27506285
Change-Id: Ie15b0775d535df7ca94547a7d8b8a5ed536e6dbd

8 years agoDon't keep naughty/nice app state in BandwidthController.
Lorenzo Colitti [Fri, 18 Mar 2016 02:55:56 +0000 (11:55 +0900)]
Don't keep naughty/nice app state in BandwidthController.

Copies of this state are already kept in NetworkManagementService,
NetworkPolicyManagerService, and iptables rules. A third copy of
this state is not necessary.

Bug: 26685616
Bug: 27506285
Change-Id: I8dd9fc60a28804ec95660092b13a2895f7480f56

8 years agoStart NetdNativeService before CommandListener.
Lorenzo Colitti [Thu, 17 Mar 2016 04:23:28 +0000 (13:23 +0900)]
Start NetdNativeService before CommandListener.

Starting CommandListener tells NetworkManagementService that netd
is ready to accept commands. Ensure that the binder service is
started (i.e., we have called startThreadPool) before we do this.

Bug: 27239233
Change-Id: Ica89e72f51eb4752cb5cea2e4096c6a9dc5776d7

8 years agoWhitelist system apps when using bw_happy_box.
Felipe Leme [Mon, 7 Mar 2016 17:25:50 +0000 (09:25 -0800)]
Whitelist system apps when using bw_happy_box.

BUG: 27506285
BUG: 26685616
Change-Id: I8352ebbab1778c85e0a1da79a0acede5aea144a1

8 years agoFix netd tests for use with APCT
Pierre Imai [Fri, 11 Mar 2016 08:54:48 +0000 (17:54 +0900)]
Fix netd tests for use with APCT

Change-Id: Ica37a812c37036ffecd45b8f078d8ed9928d01fc

8 years agoMore correctly set app_mark in getNetworkContext.
Erik Kline [Wed, 9 Mar 2016 05:56:00 +0000 (14:56 +0900)]
More correctly set app_mark in getNetworkContext.

Specifically: set explicitlySelected, protectedFromVpn and permissions.

Bug: 26256264
Change-Id: I1ebd2c1878fb7166ac63c061c8731e66b0050a30

8 years agoMerge changes I2dc1a074,Ic83d8160,I246696c4 into nyc-dev
Lorenzo Colitti [Wed, 2 Mar 2016 13:30:41 +0000 (13:30 +0000)]
Merge changes I2dc1a074,Ic83d8160,I246696c4 into nyc-dev

* changes:
  Move SockDiagTest into system/netd/server.
  Add an RPC to replace a UID firewall rule.
  Allow finer-grained locking, and use it in FirewallCmd.

8 years agoMove SockDiagTest into system/netd/server.
Lorenzo Colitti [Wed, 2 Mar 2016 05:09:38 +0000 (14:09 +0900)]
Move SockDiagTest into system/netd/server.

My recollection is that we decided to put unit tests next to
the corresponding code and integration tests into tests/.

Change-Id: I2dc1a074ba8d323253d9be3b2052d6b287bacc15

8 years agoAdd an RPC to replace a UID firewall rule.
Lorenzo Colitti [Fri, 26 Feb 2016 02:38:47 +0000 (11:38 +0900)]
Add an RPC to replace a UID firewall rule.

Also add a binder_test that exercises binder RPCs to the real
netd service running on the device

Bug: 21725996
Bug: 27239233
Change-Id: Ic83d81605021a0578d6cd32f889290be61d76125

8 years agoRemove unused costName variable
Erik Kline [Wed, 2 Mar 2016 04:52:36 +0000 (04:52 +0000)]
Remove unused costName variable
am: 87732125ef

* commit '87732125ef05808bf958530c8319026e7a1efbce':
  Remove unused costName variable

8 years agoRemove unused costName variable
Erik Kline [Wed, 2 Mar 2016 04:18:06 +0000 (13:18 +0900)]
Remove unused costName variable

Bug: 27432583
Change-Id: Ica6f8714eb6c40a4b6a94ac5e40144d0e781155e

8 years agoMerge "Created a firewall chain for power save mode." into nyc-dev
Felipe Leme [Tue, 1 Mar 2016 01:31:44 +0000 (01:31 +0000)]
Merge "Created a firewall chain for power save mode." into nyc-dev

8 years agoAllow finer-grained locking, and use it in FirewallCmd.
Lorenzo Colitti [Fri, 26 Feb 2016 02:30:59 +0000 (11:30 +0900)]
Allow finer-grained locking, and use it in FirewallCmd.

FirewallController is stateless and FirewallCmd does not access
any other controllers, so it is safe not to take the big netd
lock.

Bug: 27239233
Change-Id: I246696c4b17fa005c7d6b38ecd627747aa608831

8 years agoDon't use a manually-sized buffer for the PID.
Lorenzo Colitti [Tue, 23 Feb 2016 07:59:21 +0000 (16:59 +0900)]
Don't use a manually-sized buffer for the PID.

Change-Id: Ibdda590b828c61caa488e959f3e596dc981a2c65

8 years agoMinor improvements for netd_test
Pierre Imai [Thu, 25 Feb 2016 07:34:29 +0000 (16:34 +0900)]
Minor improvements for netd_test

Change-Id: Icd89045c7099949ea66bd88b2ce5551301366640

8 years agoWrap netd's controller to make them usable from other classes
Pierre Imai [Wed, 24 Feb 2016 09:00:03 +0000 (18:00 +0900)]
Wrap netd's controller to make them usable from other classes

Change-Id: Icb76b43e89c5a9e5806b95002d3653dd99912494

8 years agoRename the netd service from "android.net.INetd" to "netd".
Lorenzo Colitti [Tue, 23 Feb 2016 13:25:11 +0000 (22:25 +0900)]
Rename the netd service from "android.net.INetd" to "netd".

Bug: 27239233
Change-Id: I34a5554604e6d8b8a50838c6911c28503cbf4540

8 years agoInitial netd binder interface.
Lorenzo Colitti [Tue, 2 Feb 2016 08:19:04 +0000 (17:19 +0900)]
Initial netd binder interface.

In this change:

1. AIDL files for a new, android.net.INetd service, and
   corresponding implementation using generated code. For now the
   interface is just a prototype: it only has one trivial method.
2. Permission checking code to check for CONNECTIVITY_INTERNAL.
3. Add a Big Netd Lock and provide a wrapper that makes it easy
   to ensure that it is taken by every CommandListener command.

Bug: 27239233
Change-Id: I448d0ac233edd0e351a7fe7f13901fb6871683a2

8 years agoAdd test for DNS resolver code in netd.
Pierre Imai [Thu, 18 Feb 2016 04:13:12 +0000 (13:13 +0900)]
Add test for DNS resolver code in netd.

Change-Id: I92466868ae32ee67fb5d17c7758a7841f614e827