Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Merge "Remove filegroup connectivity-module-utils-srcs in connectivity."
Xiao Ma   authored and   Gerrit Code Review   commited 2022-08-12 09:06:58 +00:00
7f15ce1d9c
Remove ConnectivityService#PerUidCounter hack
Follow up from aosp/1781202 and aosp/1821293, creating nris
before removing old nris had been proven not necessary for
per-app API flow. Hence, the per-uid counter hack for system
uid that allows counter temporary go over limit does not
actually be used in the production code.

In other words, this CL is a no-op refactoring.

Test: testRequestCountLimits
Bug: 235771502
Change-Id: I8f71c6e4506fbec60cb503731aee64ab022b4634

Junyu Lai   commited 2022-08-11 11:06:07 +08:00
31d38bffdf
Make the temporary NC sanitized instead of inlining
This is a no-op refactoring. This will be useful to
mutate a member of the NC before sending it to the app.

Test: ConnectivityServiceTest
Change-Id: I1cf472bd7626d5ee2b163078a695c4a52ac39085

Chalard Jean   authored and   Paul Hu   commited 2022-08-04 06:45:39 +00:00
713e38cd31
Remove accessors for legacy int score from NAI
These are no longer useful. Also, NAI no longer needs to
be comparable, and it should no longer be – comparing 2
NAIs only make sense in the context of a specific request.

Bug: 238139913
Test: ConnectivityServiceTest IpConnectivityMetricsTest
Change-Id: I6967ad6f08380213c29f3d47d6422f8bbea1946c

Chalard Jean   authored and   Paul Hu   commited 2022-08-04 06:45:39 +00:00
aa5bc624f6
Show time taken by the rematch
Example log (short version) :

02-26 12:52:49.624  1751  2116 D ConnectivityService: NetReassign [22 :
  101 → 100, 25 : 101 → 100, 38 : 101 → 100, 27 : 101 → 100, 32 : 101 →
  100, 19 : 101 → 100, 17 : 101 → 100, 34 : 101 → 100, 36 : 101 → 100,
  15 : 101 → 100, 1 : 101 → 100, 7 : 101 → 100] [c 0] [a 37] [i 2]

Example log (long version) :

02-26 14:10:32.433  3876  3979 D ConnectivityService: Rematched networks [computed 0ms] [applied 33ms] [issued 2]
02-26 14:10:32.433  3876  3979 D ConnectivityService: NetworkReassignment :
02-26 14:10:32.433  3876  3979 D ConnectivityService:   15 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   17 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   40 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   1 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   34 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   19 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   38 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   22 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   7 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   32 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   36 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   2 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   25 : null → 100
02-26 14:10:32.433  3876  3979 D ConnectivityService:   27 : null → 100

Bug: 238139913
Test: manual
Change-Id: I0f220d1f73cb9b0ddab82842e918ce8101ef1038

Chalard Jean   authored and   Paul Hu   commited 2022-08-04 06:45:39 +00:00
ee3fa20a5a
Address some IDE warnings in ConnectivityService
Unused arguments, non-final members, unannotated members, typos.
This doesn't try to remove all warnings, but just opportunistically
fixes some.

Bug: 238139913
Test: ConnectivityServiceTest
Change-Id: Ia5e905a0244cfb5f72c06d0c0be3458c42b27a52

Chalard Jean   authored and   Paul Hu   commited 2022-08-04 06:45:39 +00:00
46bfbf0367
Copy arguments from NetworkAgent registration early
These objects have a non-trivial lifetime, as they will be
stored while the NetworkMonitor (which lives in another
process) starts. Agents that live in the system server will
still have a reference to the passed arguments and might
want to keep and mutate them for their own purposes. To
avoid bad surprises, ConnectivityService should copy these
objects before the function returns.

This patch should not cause any additional copies, because
the copies that used to happen after the monitor has started
are now not necessary and are removed.

Bug: 238139913
Test: FrameworksNetTests
Change-Id: I1cdd14e7a247dc01a3d73f528c3f3d77bd103be5

Chalard Jean   authored and   Paul Hu   commited 2022-08-04 06:45:39 +00:00
dbc46950f7
Force specifying sanitized/not sanitized in caps from agent
To make sure anyone using the capabilities originally from
the agent have to know what they're dealing with, make the
member private and make accessors that spell out explicitly
the important parts.

This is the last step towards addressing the leftover
comment from aosp/1958906.

Bug: 238139913
Test: FrameworksNetTests CtsNetTestCases
Change-Id: I9fc1986c59726212acfc2ad921745c8bbc424035

Chalard Jean   authored and   Paul Hu   commited 2022-08-04 06:45:39 +00:00
39b12d4b8f
Remove filegroup connectivity-module-utils-srcs in connectivity.
Once moving NetworkMonitorUtils to frameworks/libs/net is done, we can
remove the connectivity-module-utils-srcs filegroup from connectivity
module, instead import it from net-utils-device-common lib.

Bug: 238960524
Test: atest ConnectivityCoverageTests
Change-Id: Ic1464a4c32d7c22ca7916e8f298ff1a09b71ce46

Xiao Ma   commited 2022-08-03 18:16:48 +09:00
6014237340
Merge changes Ife5e91de,I46c5dfeb
* changes:
  Change the sanitizeCaps signature in preparation for moving
  Clarify sanitization of caps from NetworkAgent

Paul Hu   authored and   Gerrit Code Review   commited 2022-07-28 12:11:29 +00:00
5760d14c08
Add flag to test BpfNetMaps refactoring
Following CLs will switch previous codepath (JNI) and new codepath
(Java) for bpf map operations based on this flag.

Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: I74f10d5c97390993acea110f6528ef8980bb2aa4

Motomu Utsumi   commited 2022-07-28 02:32:41 +00:00
f688eeb10a
Change the sanitizeCaps signature in preparation for moving
This will move to NetworkAgentInfo. The caps argument is always
the same and can be removed, while the nai argument will become
'this'. The authenticator will need to be passed.

This is a second step towards addressing the leftover
comment from aosp/1958906.

Bug: 238139913
Test: FrameworksNetTests CtsNetTestCases
Change-Id: Ife5e91de15d0571f1251d2cd6f1b3ecc256572c6

Chalard Jean   authored and   Paul Hu   commited 2022-07-27 10:45:26 +00:00
2f9a2b7453
Clarify sanitization of caps from NetworkAgent
This is a first step towards addressing the leftover
comment from aosp/1958906.

Bug: 238139913
Test: FrameworksNetTests CtsNetTestCases
Change-Id: I46c5dfebfc12c4db71f7c9c6624b8d6cdf0bf3b5

Chalard Jean   authored and   Paul Hu   commited 2022-07-27 10:31:30 +00:00
da7fe5732c
Use java BpfMap in BpfNetMaps#replaceUidChain
Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Ib2a2c2646834110a3eeeb786a4ea7a3f85718be8

Motomu Utsumi   commited 2022-07-27 06:01:47 +00:00
9be2ea0080
Merge "Correct javadoc usage"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-07-15 07:41:33 +00:00
b7f81e4a6d
Correct javadoc usage
"{@see" aren't rendered properly. Replace them with "See {@link"
or @see depending on the usage.

Bug: 238753273
Test: make doc-comment-check-docs ; Check the doc result
Change-Id: I70cb2f36e7c5fa8102b5949054df5184d755202c

chiachangwang   commited 2022-07-15 03:44:46 +00:00
9473c59980
Merge "Use common methods to check/enforece mutiple permissions"
Paul Hu   authored and   Gerrit Code Review   commited 2022-07-14 06:19:54 +00:00
6d74747445
Merge "Reword comment for language quality"
Paul Hu   authored and   Gerrit Code Review   commited 2022-07-06 01:52:06 +00:00
e79157578b
Reword comment for language quality
This addresses a leftover comment to aosp/1919251

Bug: 238139913
Test: comment-only
Change-Id: Icfd054a1f9a4b928b222fb1a74af066c36c886b0

Chalard Jean   authored and   Paul Hu   commited 2022-07-06 01:51:35 +00:00
2ddcf603e2
Use common methods to check/enforece mutiple permissions
Use PermissionUtils methods to check/enforece mutiple permissions
to avoid inconsistent behavior and duplicated code.

Bug: 177187957
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I0850a2c8b15e0dfc6d21298c5599ad36bb2056dc

paulhu   authored and   Paul Hu   commited 2022-07-04 10:42:06 +00:00
3ffffe71c7
Log BPF programs & maps in bugreport
Currently (T+), BPF program and map status are only dumped on demand.
$ adb shell dumpsys connectivity trafficcontroller

The information can be useful for issue debugging, especially on Data
Usage and NetworkPolicyManagerService. It should be logged in bugreport
dumpsys connectivity section as Android S (which is handled by netd).

Bug: 237954856
Test: adb bugreport
Change-Id: Ic02a58ff2ebdbf375d9df0917e8218ab8faa96da

Ken Chen   commited 2022-07-04 11:32:44 +08:00
daf5cb64cc
Refactor BpfNetMaps and getChainEnabled
Address comments from aosp/2117045 and aosp/2131752
Rename USE_NETD to PRE_T
Rename getChainEnabled to isChainEnabled
Remove unnecessary parentheses
Fix comment

Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Iaff8c9fc5f74de3fe41a7fb010355b1742fbce90

Motomu Utsumi   commited 2022-06-27 14:33:28 +00:00
25cf86fc95
Add API to get current firewall chain status
This commit adds ConnectivityManager#getFirewallChainEnabled to read the
current firewall chain status

Bug: 208371987
Test: m
Change-Id: I1eadb69f953af5d031cd8dabde3e1f098cf0f4df

Motomu Utsumi   commited 2022-06-24 09:11:53 +00:00
be3ff1e923
Refactor code and improve tests for VPN filtering
Bug: 206482423
Test: atest ConnectivityServiceTest PermissionMonitorTest

Change-Id: Ic6ff7a3d7695ad6ce96764a9bab2c0a641ba2ba6

Motomu Utsumi   commited 2022-06-10 03:18:32 +00:00
f8bd82cd67
Add 3rd deny firewall chain for OEM
Bug: 208371987
Test: atest
CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking
ConnectivityServiceTest

Change-Id: Ib521fa02f6a19270cb88a3d85321bda822516c78

Motomu Utsumi   commited 2022-06-06 07:47:35 +00:00
1d9054ba5f
Add deny firewall chain for OEM
Bug: 207773349
Bug: 208371987
Test: atest
CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking
--iterations 50 && atest ConnectivityServiceTest --iterations 10

Change-Id: I60d5540821abcced03356f366775f16ee369d7f9

Motomu Utsumi   commited 2022-06-03 09:10:57 +00:00
d980149817
Merge "Remove logic from NetworkMonitorManager wrapper"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-06-01 01:20:03 +00:00
de9818fb81
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
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
Merge "Clat dump information improvement"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-19 06:35:16 +00:00
2438b2f5c6
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
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 "Limit data usage request per uid"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-05-13 09:06:41 +00:00
fc938cf026
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
Fallback should be evaluated for each preference
1) alowFallback flag was incorrectly not reset while setting profile
   preference. Corrected it.

2) Threw exception if default preference and enterprise preference are
set together

3) renamed clearUser to withoutUser

Bug: 231670730
Test: ConnectivityServiceTest

Change-Id: Iaf49237bdc791c7e1dd884d069eff64e74757477

Sooraj Sasindran   commited 2022-05-10 22:11:55 -07:00
b0e283c900
Merge changes I5eaeb415,I236f1550
* changes:
  Check carrier privilege for CBS network requests synchronously
  Allow 3p apps to request restricted networks

Paul Hu   authored and   Gerrit Code Review   commited 2022-05-10 14:38:30 +00:00
7d180e679a
Check carrier privilege for CBS network requests synchronously
Normally if an app calls requestNetwork with capabilities that it
does not have permission to request, it gets a SecurityException,
except if it requests NET_CAPABILITY_CBS, in which case the request
will not throw but the app will get an onUnavailable callback.

Make this codepath throw as well. This simplifies the code and makes
the app-visible behaviour more consistent (and consistent with what
happens in S and below). The reason the code was written this way is because the carrier privilege app should receive a callback if it
loses permission. But onUnavailable is also not the best callback to
send, since it is used very rarely and also releases the app's
request. It seems better to leave the request registered and send
onLost.

Test: atest FrameworksNetTests
Bug: 194332512
Change-Id: I5eaeb415a6654851246e38599a996fbd9366fde0

junyulai   authored and   Paul Hu   commited 2022-05-10 10:26:54 +00:00
96bd9fe4de
Allow 3p apps to request restricted networks
Since 3p apps are allowed to use restricted networks in S, they
should be allowed to request a restricted network reasonably.
Otherwise, the functionalities of 3p apps will break if they rely
on restricted networks. Thus, CS needs to allow 3p apps to
request restricted networks if 3p apps are in the allowed list.

Bug: 230509118
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I236f1550095ee2be29adbc3b28d3ac2561a8b072

Paul Hu   commited 2022-05-10 18:10:19 +08:00
8fc2a55a16
Do not remove profile network preference for different uids
Multiple enterprise slice can be setup within single user profile based
on different uids. So do not remove profile network preference with same
user profile but with different uids

Bug: 229644102
Test: manual system test and ConnectivityServciceTest
Change-Id: I897b643e01240958fff575de9e15182069efc698

Sooraj Sasindran   commited 2022-05-06 00:58:33 -07:00
9cc129f37d
Merge "Update VPN isolation code for excluded routes"
Prerana Patil   authored and   Gerrit Code Review   commited 2022-05-03 17:40:12 +00:00
a1c6dbbd53
Merge "Allow device owner to configure profile network preference"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-05-02 07:13:21 +00:00
07a20408db
Allow device owner to configure profile network preference
isMangedProfile returns true for managed profiles.
But enterprise device can be fully managed like device owner.
Hence check specifically if request is coming on fully managed
device.

Bug: 226966328
Bug: 231071836

Test: ran DevicePolicyManager CTS and ConnectivityServiceTest
Change-Id: I7827466bd61e24ba9c36c3a2e25043257e2ed602

Sooraj Sasindran   commited 2022-05-01 21:20:36 -07:00
bb65aa8fc2
Update VPN isolation code for excluded routes
Bug: 230058738
Test: atest LinkPropertiesTest

Result: https://paste.googleplex.com/4706859672928256

Change-Id: I970fca6b0e2cd358e9bd77152563d13367867c74

Prerana   authored and   Prerana Patil   commited 2022-04-29 22:23:02 +00:00
2b97bbebf4
Merge "ClatCoordinator: dump BPF forwarding rules"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-04-27 14:54:16 +00:00
722346dce4