Commit graph android_packages_modules_Co.../service
Message SHA1
Revert "Revert "EthernetTetheringTest: add testTetherClatUdp""
This reverts commit 5bbd292bed.

Bug: 215655463
Change-Id: I06490001b06446b6a4ff3dc084ce11e8ebbe17f8
Test: atest ConnectivityCoverageTests

Remi NGUYEN VAN   commited 2022-06-03 02:55:26 +00:00
e78cfa130b
Revert "EthernetTetheringTest: add testTetherClatUdp"
This reverts commit b0274cf796.

Reason for revert: Breaks presubmit: b/234727688

Change-Id: I736752dca3707588a525f28d208bdb20f7280972

Remi NGUYEN VAN   commited 2022-06-03 02:32:48 +00:00
5bbd292bed
EthernetTetheringTest: add testTetherClatUdp
Bug: 215655463
Test: atest ConnectivityCoverageTests
Change-Id: Id5d237b96b1d171c1e353cfd0aeba5aa4606fcc7

Hungming Chen   commited 2022-06-02 12:07:13 +08:00
b0274cf796
Merge "tests: simplify BpfMap.reset(createMap()) -> BpfMap.resetMap()"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-06-01 09:00:46 +00:00
69777762e7
Merge changes I25158126,I99fcf77b
* changes:
  TrafficControllerTest - trivial simplification
  simplify bpf tests and check type correctness

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-06-01 08:59:19 +00:00
d9b378eeef
Merge "Add native test libclat_test to MTS."
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-06-01 08:32:56 +00:00
fbf49b29bf
Merge "Add IpConfigStore testcase to improve the code coverage."
Xiao Ma   authored and   Gerrit Code Review   commited 2022-06-01 07:47:07 +00:00
c0e80ee9f9
Add IpConfigStore testcase to improve the code coverage.
Add new testcase in IpConfigStoreTest to cover the readIpConfiguration
usage, improve the code coverage for connectivity module.

To reduce the flakyness of test, this cl refactors DelayedDiskWriter
constructors by allowing to pass in a Dependencies instance, then
waitForIdle can be used to check if the delayed write operation
associated with the passed-in HandlerThread has completed in tests.

Bug: 234315786
Test: atest com.android.server.net.IpConfigStoreTest
Change-Id: I57c8bd02a771f1cca815252ba502cda0210d1385

Xiao Ma   commited 2022-06-01 14:47:47 +09:00
b4a8fd534a
Merge "Remove logic from NetworkMonitorManager wrapper"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-06-01 01:20:03 +00:00
de9818fb81
Merge "Support more than 8 firewall chains / match types."
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-05-31 22:21:48 +00:00
4eacf772c2
tests: simplify BpfMap.reset(createMap()) -> BpfMap.resetMap()
BpfMap.reset(createMap()) is equivalent to newly added BpfMap.resetMap(),
except that the latter makes it impossible to screw up the Key/Value sizes.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I290986e9ae8660f3fc6f73b086d33f4ab93d6095

Maciej Żenczykowski   commited 2022-05-31 07:35:04 -07:00
439bac2e56
TrafficControllerTest - trivial simplification
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I25158126c968707f44f595f731547a8bd9bb503d

Maciej Żenczykowski   commited 2022-05-31 07:35:04 -07:00
ced3531ad5
simplify bpf tests and check type correctness
We notice that:
  BpfMap.reset(dupFd_with_cloexec(BpfMap.getMap())
is equivalent to
  BpfMap = BpfMap
due to the current implementation of the BpfMap assignment operator.

Except the latter also verifies BpfMap<K,V> template types match.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I99fcf77bc6aa360b6a19e22c2cd58d67a1e62976

Maciej Żenczykowski   commited 2022-05-31 07:35:03 -07:00
55ab87aa49
Support more than 8 firewall chains / match types.
In the BPF code, per-UID network access (e.g., for doze mode,
standby, etc.) is stored in UidOwnerValue structures. Each of
these stores that UID's rules in a 32-bit bitmask of
UidOwnerMatchType values, so the code can support ~31 match
types.

However, which match types are enabled is stored in
configuration_map at index UID_RULES_CONFIGURATION_KEY, and
configuration_map only stores 8-bit values. So it's not
possible to define more than 7 match types.

Widen configuration_map to from 8 to 32 bits to match the width
of UidOwnerValue.rule. This doesn't impact memory because
configuration_map only has 2 entries.

Bug: 208371987
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7e1eee2daedd66d27965a2dd4ce6b4c3667892f7

Lorenzo Colitti   authored and   Maciej Żenczykowski   commited 2022-05-31 09:59:11 +00:00
60cbed385d
Remove logic from NetworkMonitorManager wrapper
NetworkMonitorManager should just be a passthrough wrapper for
INetworkMonitor. Move logic to choose the notifyNetworkConnected version
to call to its only caller, ConnectivityService.

This allows removing the dependency on modules-utils-build, which makes
the networkstack-client library less portable; for example it would add
duplicate classes if networkstack-client is included into service-wifi,
as service-wifi can already use modules-utils-build from framework-wifi.

Fixes: 227161380
Test: atest ConnectivityServiceTest
Change-Id: Ie50f586c5d1ffe021cb0a96294f13f478fd3a2dd

Remi NGUYEN VAN   commited 2022-05-31 18:50:50 +09:00
9ada184a2b
Merge "Remove unused variable"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-05-31 01:30:56 +00:00
913b20ba5f
Add native test libclat_test to MTS.
In order to get counted by mts code coverage, this native test needs to
be run as part of mts.

Bug: 233904825
Test: m mts && mts-tradefed run mts-tethering-coverage
Change-Id: I4ec7108577a8a50d4419bbf387535f92f2f6d099

Hungming Chen   commited 2022-05-30 15:37:25 +08:00
14575d38cc
Merge "Add traffic_controller, networkstats, netd_updatable tests to MTS."
Ken Chen   authored and   Gerrit Code Review   commited 2022-05-27 17:46:54 +00:00
93ea4c3f5c
Add traffic_controller, networkstats, netd_updatable tests to MTS.
In order to get counted by mts code coverage, these native tests need to
be run as part of mts.

Bug: 233904825
Test: m mts && mts-tradefed run mts-tethering-coverage
Change-Id: I79313197b146c7043ffb5e164faa46c2e16dd1d2

Ken Chen   commited 2022-05-27 15:00:18 +00:00
b9266bf507
Remove unused variable
Clean up to remove unused variable.

Change-Id: Iad05d6db2fccdaff7419de02b29d74a18b00c3b4
Test: TH

Chiachang Wang   commited 2022-05-27 08:24:19 +00:00
589bfc1c04
BpfNetMaps - minor jni code fixups
(a) jni static methods take 'jclass clazz' as 2nd argument,
while non-static methods take 'jobject this/thiz/self'

(b) use a macro for error handling to remove duplicate code

(c) also fix some whitespace

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2773617dc7129efb87e28266f97ec3e01a35efc3

Maciej Żenczykowski   commited 2022-05-24 16:01:12 +00:00
932ef5b220
Merge "remove spurious newlines on ALOG lines"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-24 00:09:43 +00:00
7ded34d8fc
remove spurious newlines on ALOG lines
(for consistency with rest of code base)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5660615f24daf4285e2b6cbacecb7cd99061c5f5

Maciej Żenczykowski   commited 2022-05-23 20:53:12 +00:00
e0f5846897
[NetworkStats] Return error on invalid value
Configuration map index 1(CURRENT_STATS_MAP_CONFIGURATION_KEY) can only
have value 0(SELECT_MAP_A) or 1(SELECT_MAP_B). Return error if it is any
other values. Otherwise, read out of array boundary can cause memory
corruption or security issues.

Bug: 231420457
Test: TH
Change-Id: Ia800ad78781f72b8118469c0230cc550796d334e

Ken Chen   commited 2022-05-23 22:27:40 +08:00
322ffcb724
Merge "Changing automotive ethernet allowed UIDs check"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-19 13:29:16 +00:00
36cae536f0
Merge "Clat dump information improvement"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-19 06:35:16 +00:00
2438b2f5c6
Changing automotive ethernet allowed UIDs check
Updating the automotive allowed UIDs check to only work if the
capabilities have a single transport equal to ethernet.

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I91e987d6b943a3c5986ab88553a6eef0d479b079

James Mattis   commited 2022-05-18 22:18:14 -07:00
4eff0efb57
Merge changes Ide01c994,Ia9f12a7b
* changes:
  Revert "Autogenerate connectivity jarjar rules"
  Revert "Clarify comment in gen_jarjar.py"

Colin Cross   authored and   Gerrit Code Review   commited 2022-05-18 18:34:32 +00:00
708b1ab707
Revert "Autogenerate connectivity jarjar rules"
This reverts commit 53eb35cd82.

Reason for revert: b/233081774, caused long build times in FrameworkNetTests

Change-Id: Ide01c994f694b55fc0e87bb0e81584ac44196e68

Colin Cross   commited 2022-05-18 18:30:27 +00:00
ece3171cf0
Clat dump information improvement
This is a followup commit for aosp/2017317.

1. Reorder the NAT464 information in dumpsys connectivity
2. Reword message when clat not started

Bug: 212345928
Test: dumpsys connectivity
Change-Id: I31c7066787dc7db8e5fe225f3918368b25bb7f5e

Hungming Chen   authored and   Nucca Chen   commited 2022-05-18 14:49:57 +00:00
c6e00ea74e
Merge changes I03e7cda7,I675c4ef5
* changes:
  Allow ethernet on automotive to set allowed UIDs
  Updating Eth CTS to account for existing ifaces

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-18 02:52:24 +00:00
af7101ff0f
Allow ethernet on automotive to set allowed UIDs
Allow ethernet factories on automotive devices to set the allowed UIDs
on NetworkCapabilities.

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I03e7cda75f1c530e0d0e4a756330bc9847a96668

James Mattis   commited 2022-05-17 15:32:13 -07:00
46491d7546
Merge changes I5ffa2faf,Id5f14d6e
* changes:
  add proper minimum bpfloader version annotations for block/clatd/dscp_policy/netd
  move netd maps and progs into /sys/fs/bpf/netd_shared/...

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-17 15:39:02 +00:00
b6ac308b50
Merge changes If52ece61,Iedf344f6
* changes:
  Block incoming packets in VPN Lockdown mode.
  Refactor VPN interface filtering necessity check

Motomu Utsumi   authored and   Gerrit Code Review   commited 2022-05-17 01:42:00 +00:00
f6131c483b
move netd maps and progs into /sys/fs/bpf/netd_shared/...
(out of current /sys/fs/bpf/net_shared/...)

This will allow genfscon regexp changes in a followup selinux commit.

Note that this has a hard dependency on system/bpf change
  'bpfloader: add support for netd_shared and net_private subdirs'
which also bumps bpfloader to v0.13.

This was merged May 12, 2022 (into both aosp/master and tm-dev)
and it is in Android T starting with Beta 3 release.

This isn't really an issue since amusingly T Beta 2 is already
incompatible with current mainline releases due to the snap
reverting a previous required bpfloader system/bpf change:
  move net_shared bpf programs into net_shared subdirectory
See: http://b/232050459#comment14

So this doesn't break T Beta1/2, since they already don't work,
and Beta3 will work.

Bug: 218408035
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id5f14d6e3f11cfe35d9d8a9496548a2bc4d022ec

Maciej Żenczykowski   commited 2022-05-16 23:24:37 +00:00
6d116d0f38
Block incoming packets in VPN Lockdown mode.
Currently, even when VPN Lockdown mode is enabled, incoming packets are
not dropped if VPN is not connected.

This commit fixed this issue.
After this commit, If VPN Lockdown mode is enabled, incoming packets
are dropped regardless of the VPN connectivity.

Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest PermissionMonitorTest
Change-Id: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d

Motomu Utsumi   commited 2022-05-16 10:40:59 +00:00
b08654ca04
Refactor VPN interface filtering necessity check
Test: atest ConnectivityServiceTest
Change-Id: Iedf344f6275d4c6b23716eb11e3eecf54c6a2f9a

Motomu Utsumi   commited 2022-05-16 10:38:01 +00:00
77a794868f
Merge "Autogenerate connectivity jarjar rules"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-05-16 09:06:33 +00:00
4cd92adf0e
Merge "Use stable shims in service-connectivity"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-16 07:11:46 +00:00
853d3f2ce9
Merge "Support 32 match types in UidOwnerValue rule"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-05-13 20:39:00 +00:00
ad5b0d96ef
Merge "Limit data usage request per uid"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-05-13 09:06:41 +00:00
fc938cf026
Autogenerate connectivity jarjar rules
Jarjar rules are hard to keep in sync with code, and hard to maintain
manually as the distinction between what should and should not be
jarjared is not always clear. This results in unsafe binaries that are
manually maintained, and developer frustration when something fails due
to incorrect jarjar rules.

Autogenerate jarjar rules at build time instead. This is achieved by
introducing a jarjar-rules-generator python-based library, which scans
pre-jarjar intermediate artifacts, and outputs jarjar rules for every
class to put it in a package specific to the module. The only exceptions
are:

 - Classes that are API (module-lib API is the largest API surface of
   the module)
 - Classes that have unsupportedappusage symbols
 - Classes that are excluded manually (for example, because they have
   hardcoded external references, like for
   ConnectivityServiceInitializer in SystemServer).

This change causes all classes in framework-connectivity(-t) and
service-connectivity to be jarjared into android.net.connectivity, but
still avoids jarjaring classes in com.android.server as before, to keep
it small.
For many classes this differs from the original jarjar rule.

Notes on implementation:

 - connectivity-jarjar-rules now has a subset
   framework-connectivity-jarjar-rules containing only the rules
   necessary for framework-connectivity. This is necessary because
   framework-connectivity cannot depend on rules generated based on
   service-connectivity, as there would be a dependency cycle
   (service-connectivity depends on framework-connectivity); Soong even
   crashes with a stack overflow.

 - framework-wifi.stubs.module_lib is added to
   framework-connectivity-pre-jarjar as it is necessary to build it (it
   is already in impl_only_libs in the defaults).
   It is unclear why framework-connectivity-pre-jarjar could build
   before that (possibly because it was only used as "lib" ?)

 - Fix package-private visibility; for example NattSocketKeepalive,
   TcpSocketKeepalive are not API so should be jarjared, but are used
   by ConnectivityManager which is not jarjared, so they are not in the
   same package after the change. Package-private members in the
   former 2 need to be public to be accessible. Changes in this commit
   are all that is needed, as demonstrated by followup commits that move
   the classes to a different package without further changes, and that
   enforce that no class in an API package gets jarjared.

 - framework-connectivity-internal-test-defaults is separated from
   framework-connectivity-test-defaults, for unit tests that need to
   access internal jarjared classes. Such tests need to use the jarjar
   rules themselves too, so this is only appropriate for connectivity
   internal unit tests.

Test: atest ConnectivityCoverageTests CtsNetTestCases
Bug: 217129444
Change-Id: Ied17c3955ea2fda130089265d02908937ad8af1e

Remi NGUYEN VAN   commited 2022-05-13 17:30:06 +09:00
53eb35cd82
Use stable shims in service-connectivity
service-connectivity should not be using "current" shims, but should be
using stable (T API at this point) shims.

Usage of the "current" shims was added as a workaround to allow
referencing T APIs, but is not necessary anymore.

Bug: 217129444
Test: m
Change-Id: Idde662fe404e32c8521d7bd03906b95245af46ee

Remi NGUYEN VAN   commited 2022-05-13 17:29:25 +09:00
ed02d61506
Support 32 match types in UidOwnerValue rule
Match type is also used in configuration_map at index
UID_RULES_CONFIGURATION_KEY.
However, this commit does not extend configuration_map and we can
not still use more than 8 match type in configuration_map.

Test: m
Change-Id: I0f20cc8034551806b5cb3da322a0ea7861983095

Motomu Utsumi   commited 2022-05-13 05:53:20 +00:00
42edc60627
Merge changes from topic "wrap_fd_to_parcelfiledescriptor"
* changes:
  Catch new exceptions from BpfMap
  Revert "Open and close clat bpf map while clat is starting and stoping"
  Revert "ClatCoordinator: replace BpfMap with IBpfMap"

Nucca Chen   authored and   Gerrit Code Review   commited 2022-05-12 13:42:23 +00:00
f889ed7a30
Merge "Enable optimizer on service-connectivity"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-12 10:18:22 +00:00
b1c08a00fc
Merge "Add service-nearby jarjar rules"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-12 10:18:19 +00:00
64a347b6a4
Merge "Add service.proto jarjar rule"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-12 10:18:16 +00:00
c1edc4cadd
Limit data usage request per uid
Currently, there is no limtation for an app to request
data usage callback, which is dangerous if the app fire
hundreds of thousands requests and potientially this might
cause OOM if the apps don't free them.

Test: atest NetworkStatsObserversTest#testRegister_limit
Bug: 229103088
Change-Id: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331

Junyu Lai   commited 2022-05-12 08:53:21 +08:00
f3c946278c
Merge "Fallback should be evaluated for each preference"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-05-11 21:05:18 +00:00
5ea6f517a6