Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Merge "Revert "Use bpf map based isUidNetworkingBlocked on V+"" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2024-04-11 19:37:46 +00:00
c6678bbd71
Revert "Use bpf map based isUidNetworkingBlocked on V+"
This reverts commit 9b272fa53a.

Reason for revert: possible root cause of b/333340911.

Change-Id: Ic4923fd19db7e4704a3ef02d79644b47c271e18e

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-04-11 16:54:04 +00:00
a658220234
Merge "Add a flag to disable the background firewall chain" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-04-02 05:47:56 +00:00
aeacff5033
Add a flag to disable the background firewall chain
The BACKGROUND firewall chain has been recently added. We want to
be able to turn it off in case of contingencies with a device-config
flag flip.

The flag is assumed to be boot-stable and its value is read at boot.
When the flag is off, we ignore any operation on this firewall chain.

Additionally, this chain is always considered disabled on versions
upto UPSIDE_DOWN_CAKE.

Note: All firewall chains are in disabled state at boot by default.

Test: atest FrameworksNetTests
Test: Manually, using adb shell device_config commands.

Bug: 331484830
Change-Id: I9ccc483e02e27a584da6714931466a9f2ec95ca9

Suprabh Shukla   commited 2024-04-01 16:37:32 -07:00
724d8972e4
Use bpf map based isUidNetworkingBlocked on V+
NetworkPolicyManager#isUidNetworkingBlocked does not know about some
firewall chains status(e.g. FIREWALL_CHAIN_OEM_DENY_1)
So BpfNetMaps#isUidNetworkingBlocked is more correct but there could be
some behavior difference.
To avoid breaking devices and have longer verification time, this CL
updates to use BpfNetMaps#isUidNetworkingBlocked only on V+ devices.

Bug: 328732146
Test: TH
Change-Id: I60f84a5fff90386103692841dead465652249446

Motomu Utsumi   commited 2024-03-26 19:16:57 +09:00
9b272fa53a
Merge "Use connectivityHandler in CarrierPrivilegeAuthenticator" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-03-21 07:22:41 +00:00
98eb360c0d
Use connectivityHandler in CarrierPrivilegeAuthenticator
When request_restricted_wifi is enabled CarrierPrivilegeAuthenticator
calls CarrierPrivilegesLost callback passed from ConnectivityService.
But CarrierPrivilegeAuthenticator was using its own handler thread to
receive broadcast and callbacks so CarrierPrivilegesLost callback needed
to post a message to the CS handler.
This CL updates CarrierPrivilegeAuthenticator to use CS handler if
request_restricted_wifi is enabled, and remove the message post in
ConnectivityService.

Test: TH
Change-Id: Ib41304a30e3dd366b0f6f1d7df81145f0e05ece1

Motomu Utsumi   commited 2024-03-18 22:16:53 +09:00
4fcaa4e803
Drop packets to VPN address ingressing via non-VPN interface
When there are addresses that are used by a single VPN interface,
ConnectivityService sets ingress discard rules to drop packets to this
address from the non-Vpn interfaces

Test: FrameworksNetTests
Bug: 295800201
Change-Id: I089d01a38eff3f37a851627fa9e4acefb8d9ad5e

Motomu Utsumi   commited 2024-03-15 15:23:50 +09:00
b4772b1e5d
Merge "Make the subscriptionIds and allowedUids public" into main
Ying Xu   authored and   Gerrit Code Review   commited 2024-03-14 14:33:38 +00:00
a37386a6b6
Merge "Ignore no permission calls for CaptivePortal.appRequest" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-03-14 06:48:06 +00:00
4cd5b9e2d2
Ignore no permission calls for CaptivePortal.appRequest
This enforceNetworkStackPermission() should be adopted to check
the required permission but this may be break OEM captive portal
apps. Simply ignore the request if the caller does not have
permission.

This commit also fixes the format issues that is auto-fixed by
ktlint.

Fix: 329385091
Test: ates FrameworksNetTests
Change-Id: Ia973a1078eda3134fc8ff261d3954cd050767880

Chiachang Wang   commited 2024-03-14 04:32:11 +00:00
73be9a0933
Merge "Add CompatChange for local network matching" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-03-13 02:34:57 +00:00
d2c103ea14
Fix wrong request_count in connectivityStateSample and add tests
This CL updates CSTest to use mocked appOpsManager to bypass
checkPackage enforcement so that test can file network request as
SYSTEM_UID

Bug: 314627716
Test: atest ConnectivitySampleMetricsTest
Change-Id: I0a5f3b1bf2c343644e6f5e2a4ec1b0460e2645c4

Motomu Utsumi   commited 2024-03-12 19:07:08 +09:00
e08de4d322
Revert "Log bpf rc file if it differs from the template files."
This reverts commit 41557553f6.

(this is no longer needed, as it rolled out with January module,
while the May module this is targetting already includes an rc,
thus eliminating the need for this warning)

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

Maciej Å»enczykowski   commited 2024-03-05 19:49:20 -08:00
cf3d20011c
Make the subscriptionIds and allowedUids public
This CL allows everyone to see the subscriptionIds and the network owner
to see the allowedUids from the NetworkCapabilities.

Bug: 324357121
Test: atest ConnectivityManagerTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I91e360827d2a9a64625f1d6ae0f808aa327c7d22

Ying Xu   commited 2024-03-04 14:51:20 -08:00
611b80456a
Add CompatChange for local network matching
Apps that target an SDK before V will not see networks with
NET_CAPABILITY_LOCAL_NETWORK unless they explicitly set this capability
in their network requests.

Bug: 319212206
Test: CSLocalAgentTests
Change-Id: I414b03dfea9a8aac83304c6be501f03d637739b4

Motomu Utsumi   commited 2024-03-04 17:50:27 +09:00
ad480e0c58
Correct the method used for permission check
The hasNetworkStackPermission() method does not enfore the
permission check. It should be replaced with
enforceNetworkStackPermission().

Bug: 325984919
Test: atest FrameworksNetTests
Change-Id: I9ad0b47190dbc9afd2ee6f5dfc21a4935036733a

Chiachang Wang   commited 2024-02-26 03:08:22 +00:00
ac162f2272
Store the SubscriptionId together with the Carrier UID
Always store the corresponding SubscriptionId together with the Carrier
uid so that when the carrier loses the Privilege, both the uid and
SubscriptionID will be used in the onCarrierPrivilegesLost callback

Bug: 324357121
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.CarrierPrivilegeAuthenticatorTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I28e51c583261a67d4441c6f825ade6781b862ee4

Ying Xu   commited 2024-02-20 08:58:31 -08:00
0d06b9460a
Merge "Enable CloseFrozenAppSockets feature on V+" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-02-13 07:37:10 +00:00
8960842e6a
Enable CloseFrozenAppSockets feature on V+
On V, this feature is enabled on all devices.
On U, this feature is enabled if the flag is enabled.

Test: TH
Change-Id: I025b9a8098a0896be51cf06c5b8262243ba439b7

Motomu Utsumi   commited 2024-02-13 12:46:59 +09:00
701efffe23
Shell commands to tweak uid rules on FIREWALL_CHAIN_BACKGROUND
These can be used by manual or automated tests.

Test: Manual by using the `cmd connectivity` shell commands
Test: atest CtsNetTestCases:ConnectivityManagerTest
Test: atest netd_integration_test

Bug: 322562125
Change-Id: I1de55e430141f566e510b37554a9416c4444213b

Suprabh Shukla   commited 2024-02-09 16:35:59 -08:00
22ea166bbc
Support Satellite Network Preferred uid's multi layer request
- Implement handleSetSatelliteNetworkPreference() at ConnectivityService
  to create multi layer request with preference order
  PREFERENCE_ORDER_SATELLITE_FALLBACK.
- unit test coverage

Bug: 320514105
Test: m and atest FrameworksNetTests
Change-Id: I3f71104f8c3c998599eaab71ae4076985f4bed77

Nagendra Prasad Nagarle Basavaraju   commited 2024-02-07 16:16:42 +00:00
804aa2326d
Support bringing up restricted wifi
This CL allows the Carrier Config app to request restricted WiFi nework
by setting the correspoding subscription ID in the network request.

Bug: 315835605
Test: atest android.net.cts.NetworkRequestTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.CarrierPrivilegeAuthenticatorTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest

Change-Id: I237e692d092ff5f969ce4b7962f6d58099a6f3a9

Ying Xu   commited 2024-02-07 04:24:38 -08:00
7cabd32bc5
Rename check*Permission* to has*Permission
The check*Permission methods are a bit error-prone because people
can forget to check the return value and expect that they behave
like the enforce* methods. This was pointed out before in some bugs.

This change adds @CheckResult annotation to enforce linter warning
and rename methods accordingly.

Test: TH
Fix: 279691948
Change-Id: Ibb0df6540fe0ed40289bb190b790130daaa2f763

Junyu Lai   commited 2024-02-01 15:24:35 +08:00
71b5153898
Add Multicast routing status to dump
Bug: 281217735

Test: adb shell dumpsys connectivity
Change-Id: I0816f8cd1b9bcbcbac3f78f98c499874976cef6d

Yang Sun   commited 2024-01-22 13:37:25 +08:00
ca537d5e25
Merge "Apply multicast routing configs" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-22 00:57:42 +00:00
cc23753288
Apply multicast routing configs
Applies multicast routing configs when they are updated in
LocalNetworkConfig, or when local network/upstream network
status changes.

Bug: 281217735

Test: atest CSLocalAgentTests
Change-Id: Ib1c43c645a367d0f91e5cf0a0d9f8e5883be2c40

Yang Sun   commited 2024-01-20 21:32:20 +08:00
29037f6046
Remove the UID range check for TCP sockets
The original patch (aosp/2891011) incorrectly counted TCP
sockets with keepalive enabled for VPNs. This issue was
caused by the UID range verification. On bypassable VPNs,
the socket mark is always correct. It's possible for an
app that is not in the UID ranges to establish a socket
on the VPN. But that socket should be counted for the
purposes of keepalive. The old code would correctly count
it and the new code will incorrectly not count it. Also,
the UID range verification does not help on non-bypassable
VPNs since the socket mark is always the mark of default
network, not the socket mark of the VPN.

Instead of reverting the entire patch, this commit
removes the UID range mechanism. The code refactoring from
the original commit (which used structured classes to read
socket information) has been kept as it is a valuable
improvement.

Bug: 320842519
Test: atest FrameworksNetTests
Change-Id: I00731796144c982b9fd4d9771f3d0db1f1529a89

Chiachang Wang   commited 2024-01-19 02:50:35 +00:00
ac2e8f354d
Merge changes Ifafafcd6,I5802dedc into main
* changes:
  Fix incorrect nullability annotations
  Add helper method to enfore a package name belongs to an uid

Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-18 07:35:38 +00:00
fbc97d95bb
Add helper method to enfore a package name belongs to an uid
This is no-op refactor to move utility methods from
ConnectivityService to a common place.

Test: atest NetworkStaticLibTests#com.android.net.moduletests.util.PermissionUtilsTest#testEnforcePackageNameMatchesUid
Bug: N/A
Change-Id: I5802dedcc91fa6e130a5c534bba5080ca37dbeec

Junyu Lai   commited 2024-01-18 11:26:55 +08:00
8fdc4318c7
Implement NetworkRequestsState atom
Bug: 278833398
Test: atest FrameworksNetTests
Change-Id: I95a8c8dddd2d8f6863fe64cd4a65ef48dfb5153a

Danuta Brotikovskaya   commited 2024-01-16 21:50:12 +00:00
878fd25d84
Merge "Revert "Implement NetworkRequestsState atom"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-12 05:18:49 +00:00
a8062d9ed0
Merge "Migrate Tethering#dump to use runWithScissorsForDump" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-01-10 09:46:12 +00:00
7b4ebdf2ef
Migrate Tethering#dump to use runWithScissorsForDump
This change includes:
  1. Refactor the logic in Tethering#dump into utils class.
  2. Move the utils class to a common place which could be referenced
     from other sub-modules.
  3. Add @MonitorThreadLeak annotation to enforce
     there is no thread leak problem.

Test: atest FrameworksNetTests NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.networkstack.tethering.TetheringTest#testDumpTetheringLog
Test: adb shell dumpsys tethering (with hardcoded exception)
Fix: 312669345

Change-Id: Ia6fdfeeec2110afa0ec9e056e9db3843748845c3

Junyu Lai   commited 2024-01-10 13:56:55 +08:00
2ff42d264b
Revert "Implement NetworkRequestsState atom"
This reverts commit e3245081b1.

Reason for revert: The change is unsafe as it introduces code with writings to a separate thread whose message queue size is unlimited.
Test: atest FrameworksNetTests

Change-Id: I392a30f77cfbcd17f420e29f0944604fd789b10a

Danuta Brotikovskaya   commited 2023-12-28 18:19:20 +00:00
2971ffc776
Merge "Revert "Rename checkSystemBarServicePermission"" into main
Karl Shaffer   authored and   Gerrit Code Review   commited 2023-12-27 17:22:36 +00:00
ac6a617415
Revert "Rename checkSystemBarServicePermission"
This reverts commit c0baea5406.

Reason for revert: Checking if culprit of b/317506400

Change-Id: Icbe9d993c6d4bfdf305f2a4c7b8422095c8846a6
Bug: 317506400

Chris Göllner   commited 2023-12-26 16:13:51 +00:00
cc9620267e
Merge "Implement NetworkRequestsState atom" into main
Danuta Brotikovskaya   authored and   Gerrit Code Review   commited 2023-12-21 18:02:50 +00:00
0d8a980059
Implement NetworkRequestsState atom
Bug: 278833398
Test: atest FrameworksNetTests
Change-Id: Ie83bf49693411e4c3f629c07d98071505f48c08f

Danuta Brotikovskaya   commited 2023-12-21 15:56:03 +00:00
e3245081b1
Merge "Rename checkSystemBarServicePermission" into main
Quang Luong   authored and   Gerrit Code Review   commited 2023-12-21 04:43:03 +00:00
b8eedd186d
Rename checkSystemBarServicePermission
Rename checkSystemBarServicePermission to checkStatusBarServicePermission to be consistent with the actual permission name.

Bug: 307161342
Change-Id: Ib0d353d33f1fc64d298919c107d3bc6691dc0bfe
Test: build

Quang Luong   commited 2023-12-18 07:31:17 +00:00
c0baea5406
Merge "[BR14] Tracker Data Saver status in ConnectivityService" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-12-11 10:09:57 +00:00
5ad399d8c3
[BR14] Tracker Data Saver status in ConnectivityService
BYPASS_INCLUSIVE_LANGUAGE_REASON=Using public API
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSBpfNetMapsTest
      (on U and V devices respectively)
Bug: 297836825
Fix: 314858283

Change-Id: Ibeac8cd3a33468c6539234255328affc6b3f8ffe

Junyu Lai   commited 2023-12-08 13:54:29 +08:00
38c7503ab5
Merge "Support network slicing permission check in multi-user environment" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-12-07 12:32:18 +00:00
38f871c8e0
Revert canSeeAllowedUids for ownerUid
aosp/2405720 allowed network owner uid to see allowed uids
But this breaked old cts.
This CL reverts the behavior for network owner uid.

Bug: 312093253
Bug: 313025186
Bug: 312196228
Test: TH
Change-Id: Iaa732d22f67ecce7678e68bb8b20cec526116dc9

Motomu Utsumi   commited 2023-12-01 00:45:14 +09:00
eb4a1968ef
Merge "Log bpf rc file if it differs from the template files." into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-11-30 03:32:56 +00:00
8670809d7f
Log bpf rc file if it differs from the template files.
Check if the bpf loader rc file is differs from the template files when
ConnectivityService starts. Use Log.wtf() to log the file if there is a
diff.

Bug: 312638861
Test: TH
Change-Id: I0b9ed9962ad0954a051a17b01357d04a0e655ff4

Yuyang Huang   commited 2023-11-29 19:58:15 +09:00
41557553f6
Support network slicing permission check in multi-user environment
In multi-user environment, the App might not be installed by system user.
As a result, the ConnectivityService should use the packageManager from
the user's context to be able to read the property correctly.

Bug: 300274339
Test: TH
Change-Id: I5398c95562bcaf5752270b52f38cca1f02698ba1

Yuyang Huang   commited 2023-11-28 16:54:49 +09:00
4c7deee859
Replace useTls with mode in PrivateDnsConfig
In PrivateDnsConfig class, `useTls` is replaced with `mode`.
This CL a corresponding change.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: I60c53e52f287fc7fa05543603a62632d934bb2e6

Mike Yu   commited 2023-11-28 07:49:58 +00:00
9738b47758
Merge changes I30f8814c,Ifdf67318,If312b8f8 into main
* changes:
  Rename hasCarrierPrivilege... to isCarrierServiceUid...
  Detect discrepancies in subIds
  Allow carrier service UIDs to access their own WiFi networks.

Jean Chalard   authored and   Gerrit Code Review   commited 2023-11-20 06:55:04 +00:00
4a013c47c2