31112 Commits

Author SHA1 Message Date
Hugo Benichi
4f6f139869 Nat464Xlat: internal state guards cleanup + state enum
This patch does some cleanup of Nat464Xlat internal state guards
against the Nat464Xlat state Idle | Started | Running, which reduces
code nesting.

It also replaces introspection of internal state for distinguishing
between different stages in 464xlat lifecycle with an enum explicitly
introducing these three Idle | Started | Running states.

Bug: 62997041
Bug: 64571917
Test:  runtest frameworks-net
       manually connected to ipv6 network and went to test-ipv6.com
Change-Id: I6efc9fed2420ca488731a2b9b9c3c025b16eca10
2017-08-28 15:29:27 +09:00
Hugo Benichi
b577d65825 Nat464Xlat: clat management cleanup
This patch does some minor refactoring of clat starting/stopping code:
 - remove unused LinkProperties arguments in updateClat
 - remove unused Context argument in Nat464Xlat ctor
 - introduce ensureClatIsStarted and ensureClatIsStopped methods and
   simplify updateClat
 - add clatd to NetworkAgentInfo toString() method
 - clarify some comments

This changes prepare for moving BaseNetworkObserver callbacks to
ConnectivityService.

Bug: 62997041
Bug: 64571917
Test: runtest frameworks-net
      manually connected to IPv6 only network and went to test-ipv6.com
Change-Id: Idb204784614cfe700f73255a7a7b78c5e9ee6eca
2017-08-28 15:29:23 +09:00
Mark Salyzyn
0172ce8dbf Merge "Switch /data/misc/reboot/last_reboot_reason to persistent property" 2017-08-25 14:16:12 +00:00
Treehugger Robot
b09cf3fbf1 Merge changes from topic "offload_cherrypick"
* changes:
  Send add/removeDownstream info to offload HAL
  Don't completely stop offload if setting data limit fails.
2017-08-24 05:18:23 +00:00
Erik Kline
b3bb26eaa7 Send add/removeDownstream info to offload HAL
Test: as follows
    - built
    - flashed
    - booted
    - "runtest frameworks-net" passed
Bug: 29337859
Bug: 32163131

Merged-In: I0cb81ac054fc2bf6c8b8bfe658e9404a15091d7a
Merged-In: I7abcdcc2d7d967179c47081a6db2b417164891f3
Change-Id: I6c59aa7cb80b54f376f294b24c1409710c553d74
(cherry picked from commit ed962a84122ab950a103fbbc0bf911f61b6b9500)
2017-08-23 20:55:47 -07:00
Lorenzo Colitti
ddce7ee20f Don't completely stop offload if setting data limit fails.
Currently, if setting a data limit fails, we completely stop
offload in order to avoid data overages. However, the next thing
we do is try to fetch the stats and crash, because once offload
is stopped all our local state is cleared.

Fix this by fetching stats before we stop offload.

Bug: 29337859
Bug: 32163131
Bug: 64867836
Test: OffloadControllerTest passes
Test: no crash when disabling wifi tethering with BT tethering active
Merged-In: I7fc47e60b2da5f39c26fb22c1325618f9948dd38
Merged-In: I464dd2a6d1996b1cfb8bbf82b6ee453fd0747569
Change-Id: I260f5450f8b67f055983af68fb23a5f3cfc0bc69
(cherry picked from commit d743601a002ac12c02da58e92ebd0544ab0b77ea)
2017-08-23 20:51:35 -07:00
Hugo Benichi
29b1826ff2 Merge "Make NetworkManagementServiceTest pass again." 2017-08-24 03:36:20 +00:00
Hugo Benichi
752c1287bd Tethering offload stats updates are eventually consistent
This patch removes the call to runWithScissors() in
OffloadController#getTetherStats() that was causing a deadlock when
NetworkStatsService would be polled for stats in certain threading
contexts.

Instead of trying to query the tethering offload HAL synchronously all
the time, this patch:
 - changes getTetherStats() to only call into the offload HAL when it
   detects that it is called on the same thread as the Tethering handler
   thread.
 - changes the map of interface to accumulated tethering forwarded stats
   to be concurrent.

This makes stats reading from getTetherStats() eventually consistent.
From the point of view of getTetherStats(), it preserves the guarantees
that tethering stats are monotonically increasing, and also guarantees
no tearing between rx bytes and tx bytes.

Bug: 29337859
Bug: 32163131
Bug: 64771555
Test: runtest frameworks-net
Merged-In: Ibcd351ad0225ef146b00a807833f76d2a886f6c1
Merged-In: I61786d61fe1422e429c0dd9eadaff6f02eb850e7
Merged-In: I999d1d1bf72e7ab02c5d17f37aad00bc711d3fc5

(cherry pick from commit eb5e465edd78bea26289f779b635c7e94d934854)

Change-Id: I28646b962cee8c8a6efd66059f84873c02ac5810
2017-08-23 09:58:09 +09:00
Lorenzo Colitti
a086800e04 Make NetworkManagementServiceTest pass again.
1. Mock the service manager so that NMS can fetch mock versions
   of INetd and IBatteryStats.
2. Call LocalServices.removeServiceForTest to avoid a duplicate
   service registration error. // check this
3. Change the timeout from 100ms to 200ms, as otherwise the tests
   that check for IfaceClass fail.
4. Convert NetworkManagementServiceTest to JUnit 4.
5. Move NetworkManagementServiceTest to tests/net

Bug: 29337859
Bug: 32163131
Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net
Change-Id: Ic7371b427b35809ccd446addf35c9d8ae99ccfd3
2017-08-23 09:49:05 +09:00
Mark Salyzyn
e65c0c61b7 Switch /data/misc/reboot/last_reboot_reason to persistent property
Switch from /data/misc/reboot/last_reboot_reason to persistent
Android property persist.sys.boot.reason for indicating why the
device is rebooted or shutdown.

persist.sys.boot.reason has a standard as outlined in b/63736262 and
the associated investigation. Made adjustments to the values so that
we did not create a problem even before we started. Compliance is
part of the tests in boot_reason_test.sh.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 64687998
Change-Id: Iba69acf2105f4446411d86cdb8097a1755a20f15
2017-08-22 13:29:27 -07:00
Lorenzo Colitti
345a2f98a1 Merge "Fix transitioning between non-accept strict policies."
am: bef2c91bb5

Change-Id: Iacf9f43f88ac77cb2a6094348cf52107f7ef0817
2017-08-22 06:42:19 +00:00
Treehugger Robot
bef2c91bb5 Merge "Fix transitioning between non-accept strict policies." 2017-08-22 06:28:30 +00:00
Lorenzo Colitti
26364f1dea Fix transitioning between non-accept strict policies.
https://android-review.googlesource.com/438278/ attempted
to fix changing between two non-accept StrictMode policies (which
is not supported by netd) by ensuring that if neither the old nor
the new policy were accept, we'd first set an accept policy.

Unfortunately, while this is what the comment says, what the
code actually does is send the new policy twice. Fix the code to
match the comment and the intent of the CL.

While I'm at it, also move applyUidCleartextNetworkPolicy into
the synchronized block, so multiple concurrent calls to
setUidCleartextNetworkPolicy don't result in NMS state going out
of sync with netd state.

Bug: 28362720
Test: builds
Change-Id: I8d876ba0786c4d6325d26a84378fc6afcf47ab84
2017-08-20 12:16:29 +09:00
Lorenzo Colitti
9335d2d0b1 Merge changes I325b13d5,I89719fe7
am: 23868e9c09

Change-Id: Iaced543ab17ea87c8f701975764d957bc1b17fc7
2017-08-19 03:15:08 +00:00
Treehugger Robot
23868e9c09 Merge changes I325b13d5,I89719fe7
* changes:
  Add tether offload traffic to interface stats as well.
  Tell the system when tethering offload hits a limit.
2017-08-19 03:05:14 +00:00
Lorenzo Colitti
f1912ca49a Add tether offload traffic to interface stats as well.
Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

(cherry picked from commit 5356a35c3bcfcdf2d184c620af6bfbf9bddf35c5)

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I325b13d50e88841dfb0db4c35e7e27f163ee72fe
Merged-In: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee
2017-08-19 10:12:05 +09:00
Lorenzo Colitti
9f0baa94ca Tell the system when tethering offload hits a limit.
Add a new tetherLimitReached method to INetworkManagementService,
and call it when the HAL notifies OffloadController because the
limit has been reached.

Bug: 29337859
Bug: 32163131
Test: builds
Test: OffloadControllerTest passes

(cherry picked from commit d66cf56ba662f10f2da1d0f844116632ad0a0dbb)

Change-Id: I89719fe7ec8bfd3c85d6cdca9c0d449aea86ef9d
Merged-In: I026e6aa9e7b371f316c0d97c3cf5e78abc1f5263
2017-08-19 00:15:31 +09:00
Hugo Benichi
461f4eb099 Merge "Really allow NetworkAgent immutable updates to NetworkCapabilities"
am: cb3c24e36b

Change-Id: Ifbdd005576b3f0fbf278ecec81ce3e4308c6276d
2017-08-18 11:59:02 +00:00
Hugo Benichi
a60c6eab42 Really allow NetworkAgent immutable updates to NetworkCapabilities
This patch completes commit bae105a5ccd11430bab14721d1325e2303a673da to
really allow updates of immutable capabilities to NetworkCapabilities of
NetworkAgents by using satisfiedByImmutableNetworkCapabilities instead
satisfiedByNetworkCapabilities.

Bug: 64125969
Test: runtest frameworks-net
Change-Id: I9beeb623792f0ee31abcd4ba9d0ba2451304fb2e
2017-08-18 14:51:03 +09:00
Di Lu
5bef43fb64 Merge "Add user quota information into the IpSecService dump"
am: fedd856546

Change-Id: I1f64ab03918ece154fe31a07b698825315d39c0f
2017-08-16 16:33:18 +00:00
Di Lu
fedd856546 Merge "Add user quota information into the IpSecService dump" 2017-08-16 16:20:18 +00:00
Hugo Benichi
2f9fd9df23 Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities"
am: b35719a057

Change-Id: I0ab76de59e87c46a6961229399ff7200bce49838
2017-08-16 11:50:55 +00:00
Treehugger Robot
b35719a057 Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities" 2017-08-16 11:34:24 +00:00
Hugo Benichi
bae105a5cc Allow NetworkAgent "immutable updates" to NetworkCapabilities
This patch loosens the validation checks when a NetworkAgent updates it
NetworkCapabilities: instead of checking that capabilities labeled as
"immutable" stay identical across updates, it is now accepted to change
immutable capabilities in a way that the new NetworkCapabilities
satisfies the old NetworkCapabilities.

This allows a NetworkAgent to update itself in order to match more
requests, but will still catch NetworkAgents that sends degradation
updates causing potentially requests to not match anymore.

Bug: 64125969
Test: runtest frameworks-net
Change-Id: I2a1b3f9c0be6415e40edc989d0c1b03b5631f7b1
2017-08-16 18:30:30 +09:00
Lorenzo Colitti
51c3d6a8bf Merge changes I82d3bee0,I9c9413d7
am: deb4eb5d05

Change-Id: Iaa6aecf3ec3a91dc04f4533c0ea5b649bdfeb83d
2017-08-15 02:07:36 +00:00
Lorenzo Colitti
deb4eb5d05 Merge changes I82d3bee0,I9c9413d7
* changes:
  Pass data usage limits to tethering offload code.
  Don't time out when fetching tether offload stats.
2017-08-15 01:57:28 +00:00
ludi
3e5ea23673 Add user quota information into the IpSecService dump
Bug: 64093788
Test: runtest frameworks-net
Change-Id: I6c5fc9e2db4ba57e0db4f6380a1251c4e444951b
2017-08-14 16:10:55 -07:00
Lorenzo Colitti
50b60fc34d Pass data usage limits to tethering offload code.
Bug: 29337859
Bug: 32163131
Test: builds
Test: OffloadControllerTest passes
Change-Id: I82d3bee030bafa8fe85855885b5fc3893e699181
2017-08-15 00:09:23 +09:00
Lorenzo Colitti
fef69a1267 Don't time out when fetching tether offload stats.
Currently, fetching tethering offload stats has a 1000ms timeout,
after which we return stats of zero. However, returning zero is
invalid and will cause various parts of the network stats
accounting code to complain that statistics are moving backwards,
causing at least a log.wtf, and possibly a crash.

This CL removes the timeout entirely.

An alternative would have been to keep the timeout and return
null if the stats fetch failed. However, this complicates the
code, and if the HAL is persistently slow, could cause no stats
to be counted, ever. Given the impact of such behaviour on users'
data plans it is likely better to block until the stats are
collected.

Bug: 29337859
Bug: 32163131
Test: builds
Test: OffloadControllerTest passes
Change-Id: I9c9413d757f44e87a51ea7ca82b657cc6aa0d4ba
2017-08-15 00:09:21 +09:00
Erik Kline
6ff0730158 Merge "Add future consideration for USB rndis notification handling"
am: 4263a5ed58

Change-Id: I7dd347447434214ecf3e5f9f8e2a603cd097f6c6
2017-08-09 22:23:24 +00:00
Erik Kline
7111c9145b Add future consideration for USB rndis notification handling
Test: builds
Bug: 63970368
Merged-In: If6afe1cdce9995251ba53fbf30acf9d6e31f9433
Merged-In: I78e280c2299ec3f4d97138ca648f9629ba82e87f
Merged-In: I891cd82b0e8af1049fa3ab9b0a95a2a9ab2e0b26
Change-Id: Ic9ca133a44123f281bd4cfeac57d426346c2b76d
(cherry picked from commit 1290568110405fd45f13824e67beeb98c30400a4)
2017-08-09 13:57:14 -07:00
Erik Kline
47f2cf5144 Merge "Always note the state of RNDIS from USB broadcasts."
am: d27af8af62

Change-Id: I33633e064a329b9094b0d279622febab6266e5cb
2017-08-09 19:12:23 +00:00
Treehugger Robot
d27af8af62 Merge "Always note the state of RNDIS from USB broadcasts." 2017-08-09 18:54:32 +00:00
nharold
3546a5ef92 Merge "Add UserQuotaTracker to IpSecService"
am: a0c97b3ddb

Change-Id: I43a9617b077ecd5fc2b445a1ade8b76c00562640
2017-08-09 17:49:42 +00:00
Lorenzo Colitti
25e0f60f54 Merge "Minor fixes for netd restarts and StrictController."
am: 2f5ca257b5

Change-Id: If9a156c516f35c48055012ec6ab7ed5ccaa6b259
2017-08-09 17:45:22 +00:00
Erik Kline
4f31c21787 Always note the state of RNDIS from USB broadcasts.
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 63970368

Merged-In: I53115deda25ca83a00bd9de12891a72028647d12
Merged-In: I317b694c3a8c76077c031c4410d5b97ed79c1bbc
Merged-In: Ie226534011d6439c24cfe1957c5cf47ba171b0c0
Change-Id: I273edbe21fea586f1353ff378515401efc6bb15e
(cherry picked from commit 3897dc179f23dfbaf10f0139160aa29a232144f5)
2017-08-09 10:45:08 -07:00
nharold
a0c97b3ddb Merge "Add UserQuotaTracker to IpSecService" 2017-08-09 17:05:49 +00:00
Treehugger Robot
2f5ca257b5 Merge "Minor fixes for netd restarts and StrictController." 2017-08-09 10:26:14 +00:00
Nathan Harold
a1afbd8dcc Add UserQuotaTracker to IpSecService
Add a small tracking object to enforce maximum
quotas for SPIs, Transforms, and Encap sockets. The
current quota limits are intentionally conservative
with the expectation that we can relax them more
easily than we can shrink them.

Bug: 37688603
Test: tbd
Change-Id: Iee59ac59ef9f4a7ab75a2e04f9ca72da82fc3229
2017-08-08 18:28:47 -07:00
Hugo Benichi
24f5d8f866 Merge "Add OWNERS to com.android.server.net"
am: 0a00151bd1

Change-Id: Ib9938dd15a173d459ca67e5dc19430da57c29115
2017-08-08 07:16:12 +00:00
Treehugger Robot
0a00151bd1 Merge "Add OWNERS to com.android.server.net" 2017-08-08 07:07:25 +00:00
Hugo Benichi
e4d461c0c8 Add OWNERS to com.android.server.net
Test: build
Change-Id: I9236489814103ab20b077ebfc30155dcdb66d411
2017-08-08 16:06:53 +09:00
Lorenzo Colitti
8c253ade20 Minor fixes for netd restarts and StrictController.
1. Ensure we don't change strict mode network policy for a given
   UID from a non-accept policy to another non-accept policy,
   as netd does not support this.
2. Move the "strict enable" and "bandwidth enable" commands
   inside the lock. This improves correctness, and it is safe to
   do now that those commands now only take a few milliseconds,
   instead of several hundred milliseconds.
3. Fix an NPE in connectNativeNetdService which causes the system
   to crash when netd crashes.

Bug: 28362720
Test: bullhead builds, boots
Test: "adb shell killall netd" no longer crashes the system
Change-Id: Icdaa9d1e2288accf35de21df56bc6bd2b0628255
2017-08-08 10:32:56 +09:00
Steven Moreland
e1b407d62e Merge "services.core: remove use of -static hidl java" 2017-08-04 19:14:48 +00:00
Steven Moreland
be4b610d98 services.core: remove use of -static hidl java
These libraries are being removed. Now, the regular java
library can be used as both a static and non-static library,
we are removing these duplicate libraries which cause
several types problems (such as undefined behavior when
both the static and non-static libs are loaded).

Bug: 36376126
Test: boot marlin device
Merged-In: I6acb6a41fd5c62a3070ada373aed11706c423463
Change-Id: Ic3a62e7be36b1efca10a9e2e2d0efc430578d061
2017-08-03 15:19:03 -07:00
Alexandru-Andrei Rotaru
5469504e6b Notify the user and turn off tethering when the service is disallowed.
Added UserRestrinctionListener for turning the service off one the
DISALLOW_CONFIG_TETHERING is on into Tethering.  Added notification
about
tethering being turned off. Also added Unit Tests to test the
functionality
of the UserRestrictionListener added.

Bug: 27936525
Test: Turn the tehering service on (either wifi, usb or bluetooth).
Automatically the system should send a notification about the service
being active.Close settings from recents. From TestDPC User Restrictions
switch on DISALLOW_CONFIG_TETHERING. The tethering should be turned off
and a notification should appear informing that the service is inactive.

Merged-In: Ib7ea8885cedc2a842ebd4487c8b366a6666996bc
Change-Id: Ib7ea8885cedc2a842ebd4487c8b366a6666996bc
(cherry picked from commit fa6d5c5ca02f1bfc454bd3cd82e6c043661e7aa7)
2017-08-03 13:51:36 +00:00
Treehugger Robot
5027dd1026 Merge "Notify the user and turn off tethering when the service is disallowed." 2017-08-03 10:29:55 +00:00
TreeHugger Robot
e79a0931f7 Merge "services.core: remove use of -static hidl java" into stage-aosp-master 2017-08-02 21:22:49 +00:00
Steven Moreland
f91ca58ec4 com.android.server: use proper nativehelper headers
libnativehelper exports headers under nativehelper. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: com.android.server finds headers
Bug: 63762847
Merged-In: Icb3018f520004f65e8dd565d6e1d563551548eba
Change-Id: Ib36fec53c30760af5dac4097b3eceda6c4c6c7f0
2017-08-02 14:19:20 -07:00
Steven Moreland
997ee258e7 services.core: remove use of -static hidl java
These libraries are being removed. Now, the regular java
library can be used as both a static and non-static library,
we are removing these duplicate libraries which cause
several types problems (such as undefined behavior when
both the static and non-static libs are loaded).

Bug: 36376126
Test: boot marlin device
Merged-In: I6acb6a41fd5c62a3070ada373aed11706c423463
Change-Id: I6acb6a41fd5c62a3070ada373aed11706c423463
2017-08-01 17:10:27 -07:00