Commit Graph

1269 Commits

Author SHA1 Message Date
Chalard Jean
9708f7239c Implement the "actively prefer bad wifi" feature
Test: in progress
Change-Id: Ib7aba464a2f32642d434418842306dfcf90b8319
2022-09-22 16:59:30 +09:00
Chalard Jean
020b93ac63 Introduce an overlay for actively preferring bad wifi.
This correctly updates when the mcc/mnc change.

Test: MultinetworkPolicyTrackerTest
Change-Id: I11c7ea7074a15975fb68d39eb3c728778d84a516
2022-09-22 16:58:49 +09:00
Patrick Rohr
0a822f8f41 Merge changes I0b88bc8b,I60d884db,I436858e7,Iaaace0e6,Ie7ee84c3, ...
* changes:
  ethernet: cleanup updateConfiguration tests
  ethernet: fix callbacks for running interfaces
  ethernet: test callbacks when adding running interface
  ethernet: ensure EthernetOutcomeReceiver receives only one result
  ethernet: fix enable/disableInterface result
  ethernet: remove enable/disable interface unit test
2022-09-21 19:08:02 +00:00
Patrick Rohr
faebf303a6 ethernet: remove enable/disable interface unit test
This unit test is not particularly useful and there is already coverage
in EthernetManagerTest.

Test: test only change.
Change-Id: I6f9d19d9603229553f44d562ff0276567cb0e26d
2022-09-21 12:03:11 -07:00
Chiachang Wang
90798f9a5a Merge "Update VpnTest to handle teardown-on-network-lost" 2022-09-21 14:22:33 +00:00
Treehugger Robot
dd2dd2baa2 Merge "Start listening to telephony changes in #start()" 2022-09-21 12:24:28 +00:00
lucaslin
4b842678b1 Update VpnTest to handle teardown-on-network-lost
- Fix the wrong MOBIKE value set in
  testStartPlatformVpnHandlesNetworkLoss_mobikeEnabled.
- Verify the networkAgent is unregistered when the default
  network is lost

Bug: 231749077
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idc6ebd42090eff1135dc5f96af4bc2fb268dd340
2022-09-21 11:30:49 +00:00
Chalard Jean
f11ed8c699 Start listening to telephony changes in #start()
Starting to listen on the handler races with the rest of
the constructor. The class already has a #start() method
meant to start listening, so implement better practices
by leveraging this method.

Test: CtsNetTestCases
      FrameworksNetIntegrationTests
      FrameworksNetTests
Change-Id: I772f761d3ca5f9711b9d988e6330b0878814f491
2022-09-21 18:07:13 +09:00
chiachangwang
8dae9343bb Update test on calling getAppExclusionList with restricted user
Bug: 247344442
Test: atest VpnTest
Change-Id: I3b847f13162f8702013b23cabefce8d98b62f5c6
2022-09-20 08:58:50 +00:00
Lorenzo Colitti
605c4e3ecc Merge "Verify converting to Vpnprofile with IkeTunnelConnectionParams set" 2022-09-20 02:32:55 +00:00
Treehugger Robot
b624b0f539 Merge "BpfNetMaps.java - array index U32 -> S32" 2022-09-19 17:27:56 +00:00
Treehugger Robot
714fd251a1 Merge "BpfNetMaps.java - uid U32 -> S32" 2022-09-19 17:27:17 +00:00
Jean Chalard
ecb0b3cab3 Merge "Rework unvalidated prompt into first eval timeout" 2022-09-17 12:52:52 +00:00
Maciej Żenczykowski
dc88622eb8 BpfNetMaps.java - array index U32 -> S32
This converts the key, which is an index in an array, of sConfigurationMap from U32 to S32.

Since the array has exactly 2 elements, there's no real difference.
In addition while the kernel does indeed index arrays with U32s,
it doesn't matter, because you'd need to have over 2 billion
elements in the bpf map (at which point you'd need GBs of ram for
the bpf map itself)...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If17efc25d910af642e519f9ecb6d0e8695c38d42
2022-09-17 06:16:34 +00:00
Maciej Żenczykowski
785793fe19 BpfNetMaps.java - uid U32 -> S32
This converts the key, which is a uid, of sUidOwnerMap & sUidPermissionMap from U32 to S32.

The kernel is actually not consistent in whether uids & gids
are signed or unsigned, and neither is our Java code, which
also commonly uses just 'int' for uid.  In practice values
greater or equal to 2**31 often don't quite work right.
For example icmp sockets are enabled via a sysctl that
takes a minimum and maximum gid - and these are signed int32s.

It's worth pointing out that these functions already accept int's
as arguments, so when converting them to U32 (and thus long) they
technically previously did the wrong thing (though it's unlikely
it ever mattered).

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7b389a1cf822c56134b20df5ded269963f5bf69f
2022-09-17 06:06:23 +00:00
Maciej Żenczykowski
2b0a6dce97 mUidCounterSetMap - key, which is uid, U32 -> S32
The kernel is actually not consistent in whether uids & gids
are signed or unsigned, and neither is our Java code, which
also commonly uses just 'int' for uid.  In practice values
greater or equal to 2**31 often don't quite work right.
For example icmp sockets are enabled via a sysctl that
takes a minimum and maximum gid - and these are signed int32s.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia309eb99f71765e30510d6a253c1329c20719f21
2022-09-17 01:54:19 +00:00
Maciej Żenczykowski
6c1c6bb582 UidOwnerValue.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6e1da81c03bd36d8c6e7bd2b33f535d1fabfad0a
2022-09-16 18:34:39 +00:00
Maciej Żenczykowski
b3f6876ddc Merge "Migrate BpfInterfaceMapUpdater from U32 to S32" 2022-09-16 17:58:48 +00:00
Chalard Jean
5fb43c7d38 Rework unvalidated prompt into first eval timeout
This patch removes the 8-second unvalidated prompt timer
and replaces it with a 20-second timer that does the
same thing in addition to signalling the stack that the
concerned network has now undergone evaluation once.

Test: FrameworksNetTests
Change-Id: I806f2bdfbf35243fa7cdb1cd1f0a5d549cfcd9c8
2022-09-16 16:53:32 +09:00
Jean Chalard
1df85dfdff Merge "Add tests for captive/partial after roam and ignore roam failures" 2022-09-16 07:49:24 +00:00
Jean Chalard
4a4c752572 Merge "Factorize ignoreValidationAfterRoam tests" 2022-09-16 07:48:57 +00:00
Maciej Żenczykowski
66b98ba2b1 Migrate BpfInterfaceMapUpdater from U32 to S32
continuation of
  https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2184446/

replace U32 ifindex with S32

These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I48df3bf86f0590fbd0e21b7cf9f19d1a6bbacd31
2022-09-16 04:46:10 +00:00
Lucas Lin
e490cffb0a Merge "Replace requestNetwork with registerSystemDefaultNetworkCallback" 2022-09-15 09:00:39 +00:00
Jean Chalard
be0e453159 Merge "Add a field and score flag for first evaluation" 2022-09-15 08:56:26 +00:00
Chalard Jean
c18ae65f6b Add tests for captive/partial after roam and ignore roam failures
Test: This
Change-Id: Idc547d6e8b54f62b791552cf9e93ddab96991f5d
2022-09-15 17:07:18 +09:00
Chalard Jean
3bad973354 Factorize ignoreValidationAfterRoam tests
Test: ConnectivityServiceTest
Change-Id: Ied3704459a77fcef9eb34e08ab5a45ea85d4ce77
2022-09-15 16:57:50 +09:00
Chiachang Wang
fc54e71b02 Merge "Remove usage for deprecated ro.radio.noril" 2022-09-15 06:21:49 +00:00
Jean Chalard
76fdaf89c6 Merge "Test no Internet and partial connectivity notifications." 2022-09-15 03:56:13 +00:00
chiachangwang
4e8b49bee4 Remove usage for deprecated ro.radio.noril
The ro.radio.noril system properties is not used anymore. Tests
that require to check if device supports wifi but not telephony
should verify it via PackageManager.hasSystemFeature(). Also
remove the systemProperties mocking since the only need for the
mocking is removed.

Bug: 242647857
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ie34e87394458e64a9363678a863d6d977834958f
2022-09-14 14:08:24 +08:00
chiachangwang
4e953f63dd Verify converting to Vpnprofile with IkeTunnelConnectionParams set
Add test to verify converting Ikev2VpnProfile to Vpnprofile with
IkeTunnelConnectionParams set. Some fields like server should
not be set since the information should contain in the assigned
IkeTunnelConnectionParams.

Bug: 243718982
Test: atest FrameworksNetTests
Change-Id: Ie019ea98932a6d079f213e3bff45f21b44d3fa4e
2022-09-14 02:38:26 +00:00
Motomu Utsumi
9e1675d38c Merge changes from topic "dump_map_status"
* changes:
  Move Interface index name map dump to NetworkStatsService
  Move stats map A/B dump to NetworkStatsService
  Add BpfInterfaceMapUpdater#getIfNameByIndex
2022-09-14 01:27:49 +00:00
Chalard Jean
f9f4a8ddfe Add a field and score flag for first evaluation
A wifi network that is still evaluating, i.e. that doesn't know
yet if it's behind a captive portal, should not be preferred
to a network that yields to bad wifi because the stack doesn't
know yet if it's bad.

To rank the networks correctly, the ranker will therefore need
to know whether a network is still being evaluated. This patch
adds the time when this happened first to the NAI (as a
timestamp for debuggability) and the corresponding flag in
FullScore.

This doesn't have new tests because it doesn't yet expose
new behavior. Tests will come with the behavior.

Test: FrameworksNetTests
Change-Id: I737f314760356926fc07e6eef52f3c8abba2248b
2022-09-13 19:33:30 +09:00
Chalard Jean
4c46308265 Test no Internet and partial connectivity notifications.
Test: new unit tests pass
Change-Id: I363fa3ef15476a30e7b8708a80867dd456e5e520
2022-09-13 19:33:26 +09:00
Motomu Utsumi
fdb601603d Move Interface index name map dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
     mIfaceIndexNameMap:
      ifaceIndex=5 ifaceName=ip6_vti0
      ifaceIndex=19 ifaceName=r_rmnet_data3
      ifaceIndex=17 ifaceName=r_rmnet_data1
      ifaceIndex=18 ifaceName=r_rmnet_data2
      ifaceIndex=23 ifaceName=wifi-aware0
....

$ dumpsys netstats
....
  BPF map content:
    ifaceIndex=5 ifaceName=ip6_vti0
    ifaceIndex=19 ifaceName=r_rmnet_data3
    ifaceIndex=17 ifaceName=r_rmnet_data1
    ifaceIndex=18 ifaceName=r_rmnet_data2
    ifaceIndex=8 ifaceName=rmnet_ipa0
....

Bug: 217624062
Test: dumpsys netstats, atest
com.android.server.net.BpfInterfaceMapUpdaterTest

Change-Id: If182bd97f72713b6347028668cf7bd4676b8aea4
2022-09-12 16:53:51 +09:00
Motomu Utsumi
608c32c782 Move stats map A/B dump to NetworkStatsService
Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
      mStatsMapA:
      ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
      20 wlan0 0x0 1051 0 144 2 312 4
      10 rmnet_data0 0x0 0 0 0 0 48 1
      20 wlan0 0x0 0 0 0 0 136 2
      20 wlan0 0xffffff82 1051 0 144 2 312 4

      mStatsMapB:
      ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
....

$ dumpsys netstats
....
  mStatsMapA:
    ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
    20 wlan0 0x0 1051 0 144 2 312 4
    10 rmnet_data0 0x0 0 0 0 0 48 1
    20 wlan0 0x0 0 0 0 0 136 2
    20 wlan0 0xffffff82 1051 0 144 2 312 4
  mStatsMapB:
    ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
....

Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest

Change-Id: Ifbd45f0ad6dd9c519a15a7680cf0ea99fb5f5dcf
2022-09-12 16:53:48 +09:00
Paul Hu
ab32bf8aa1 Merge "Check automotive system feature on Constructor" 2022-09-12 07:36:33 +00:00
Aaron Huang
f4fbf8ed52 Make constants static import
Bug: 238843364
Test: FrameworksNetTests
Change-Id: Id88bcc175db0a599dd3205812b1bce78012e2216
2022-09-12 06:51:57 +00:00
Motomu Utsumi
95e095dd0d Add BpfInterfaceMapUpdater#getIfNameByIndex
Upcoming CL uses this to dump stats bpf map

Bug: 217624062
Test: atest com.android.server.net.InterfaceMapValueTest
com.android.server.net.BpfInterfaceMapUpdaterTest

Change-Id: I5454b6abbd9d84cb7e1dccaaa772d66726cfe3d0
2022-09-12 15:03:18 +09:00
Motomu Utsumi
08ccd0d2e1 Merge changes from topic "idiag_sock_id"
* changes:
  Switch SkDestroyListener based on the flag.
  Add startSkDestroyListener flag to native_init
  Add SkDestroyListenerTest
2022-09-10 02:02:11 +00:00
Motomu Utsumi
3dc2fb5378 Merge "register callback to pull NetworkBpfMapInfo atom" 2022-09-09 08:11:37 +00:00
Motomu Utsumi
166f966209 register callback to pull NetworkBpfMapInfo atom
Test: statsd_testdrive 10161, atest BpfNetMaps
Bug: 217624062
Bug: 245228691

Change-Id: I630a86cb5a34aaa1810eb75b374588dba570f0ff
2022-09-09 11:23:10 +09:00
Treehugger Robot
3b2907e449 Merge "Split POLICY_EVER_VALIDATED_NOT_AVOIDED_WHEN_BAD into two" 2022-09-08 15:42:44 +00:00
Chalard Jean
710b2893c2 Split POLICY_EVER_VALIDATED_NOT_AVOIDED_WHEN_BAD into two
This flag conflates these two things, but it's a lot clearer
if they are separate and evaluated at the end.

Moreover, a new policy will make use only of one of them,
so having them separate is also useful going forward.

Test: FrameworksNetTests

Change-Id: Ia47b3974277cf76153a53d7e8a0e969c90ba78f4
2022-09-08 19:41:38 +09:00
Paul Hu
00955f3d46 Check automotive system feature on Constructor
The system feature depends on device, it will not change at runtime
basically. So do the system feature check once on NetworkAgentInfo
constructor.

Test: FrameworksNetTests CtsNetTestCases
Change-Id: I03fb8b87f5fda93286bd68ccbb23210066b0611b
2022-09-08 06:38:20 +00:00
Motomu Utsumi
96c6aad70d Merge "Open CookieTagMap in BpfNetMaps" 2022-09-08 05:38:27 +00:00
Motomu Utsumi
b9548860a9 Open CookieTagMap in BpfNetMaps
Upcoming CL will update BpfNetMaps to pull NetworkBpfMapInfo atom that
contains the cookieTagMap size field.

Test: m, atest BpfNetMaps
Bug: 217624062
Change-Id: I84bb0aa56e3916fc6fc0ca31ba5962f3b9be4b6f
2022-09-06 22:33:44 +09:00
Motomu Utsumi
d95a0dafa8 Switch SkDestroyListener based on the flag.
Switch existing C SkDestroyListener and new Java SkDestroyListener based
on the experiment flag.

Bug: 217624062
Test: atest SkDestroyListenerTest
Change-Id: I7031ba7c155edb43e0e7b77449587058d6ba38fb
2022-09-06 11:23:13 +09:00
Treehugger Robot
26ebf8c97a Merge "Migrate NetworkStatsServiceTest from when().thenReturn() to doReturn().when()" 2022-09-05 12:20:55 +00:00
lucaslin
24e83ac4e1 Clean up VpnTest
- Reset any permissions to PERMISSION_DENIED in tearDown().
- Check there is only one category will be sent when VpnManager
  event is sent.
- Remove SDK check since VpnTest is non-connectivity-module-test
  now, which will not be run on mainline-prod target when running
  TH.
- Have two new methods for verifying ALWAYS_ON_STATE_CHANGED
  event and DEACTIVATED_BY_USER event, the new methods make the
  code clearer and more easy to read.
- Check if the target package of receiving VpnManager event is
  expected or not.
- Import recent ConstantsShim instead of a specific API version.

Bug: 236409954
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ibe5d549f86d11d32e2f0ae63eab1d80ee8800e0d
2022-09-05 18:32:04 +08:00
Junyu Lai
bae070bf80 Migrate NetworkStatsServiceTest from when().thenReturn() to doReturn().when()
This will address flakiness issues arising from the use of
when() in multithread context.

Fix: 243658074
Test: atest com.android.server.net.NetworkStatsServiceTest#testDataMigration_differentFromFallback \
      --rerun-until-failure 1000
Change-Id: I047050ef14cb60658098ff7803c6773907a92919
2022-09-05 16:17:57 +08:00