Commit Graph

1235 Commits

Author SHA1 Message Date
Motomu Utsumi
bd4a2d0cee Merge "Move uidPermissionMap dump to BpfNetMaps" 2022-10-05 04:07:46 +00:00
Patrick Rohr
e376f2fc72 Merge changes Ic3d0a22e,I6d295bce,I40c38a1f,Ib27b18a1,I5e23fc17, ...
* changes:
  ethernet: further cleanup updateConfiguration tests
  ethernet: add test for updateConfiguration on untracked interface
  ethernet: fix updateConfiguration expectations
  ethernet: add LinkPropertiesChanged coverage in EthernetManagerTest
  ethernet: remove unit test cases that have end-to-end coverage
  ethernet: temporary mitigation for test that uses TUNSETCARRIER
2022-10-04 15:44:20 +00:00
Motomu Utsumi
310850f210 Move uidPermissionMap dump to BpfNetMaps
Also remove the dump of mPrivilegedUser because this is not used now and
the information is duplicated with uidPermissionMap dump.

Before this CL
....
mUidPermissionMap:
10049 PERMISSION_NONE
10027  BPF_PERMISSION_INTERNET BPF_PERMISSION_UPDATE_DEVICE_STATS
1041  BPF_PERMISSION_UPDATE_DEVICE_STATS
....

After this CL
....
sUidPermissionMap:
  10049 PERMISSION_NONE
  10027 PERMISSION_INTERNET PERMISSION_UPDATE_DEVICE_STATS
  1041 PERMISSION_UPDATE_DEVICE_STATS
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I416501d5a28a5443f954f9c8c58ea255e5cdc897
2022-10-04 15:00:34 +09:00
Patrick Rohr
6d49728122 ethernet: add LinkPropertiesChanged coverage in EthernetManagerTest
This replaces testNetworkRequest_linkPropertiesUpdate in
EthernetNetworkFactoryTest.

Test: atest EthernetManagerTest
Change-Id: Ib27b18a153a1866765378753baa9046aff9636f3
2022-10-03 15:31:09 -07:00
Chalard Jean
5f69156e6f Syntactic improvement for NetworkRankerTest
Test: NetworkRankerTest
Change-Id: Iedd944c900a9b59fb662efb9de887a448912b508
2022-10-03 17:42:32 +09:00
Chalard Jean
e0fdea3c5e Add a device config for actively preferring bad wifi
Test: FrameworksNetTests
      adb shell device_config put connectivity actively_prefer_bad_wifi
       + check that dumpsys updates
Test: at this patchset tests fail with :
      Permission denial: reading from settings requires:android.permission.READ_DEVICE_CONFIG

Change-Id: Icfe1e64b8313921ff1dc8e4cbd45f967692e1c4a
2022-10-03 11:53:58 +09:00
Patrick Rohr
6d79595c5d ethernet: remove unit test cases that have end-to-end coverage
The removed test cases already have coverage in EthernetManagerTest and
are therefore removed. The removed tests should all be covered by
testNetworkRequest_withSingleExistingInterface.

Test: atest EthernetManagerTest
Change-Id: I5e23fc17ab10429dfb10477ff9ba546db37727ea
2022-09-30 01:07:40 -07:00
Chalard Jean
8c0f6ba5dd Use resources directly instead of through reflection
Test: FrameworksNetTests CtsNetTestCases
Change-Id: I091c234a53c8d127402ac215d80626d5b508fa5b
2022-09-28 11:50:28 +09:00
Chalard Jean
43aae65caf Move MultinetworkPolicyTracker to services, where it belongs.
This is necessary so that MultinetworkPolicyTracker can see
DeviceConfig. It will also allow removing reflection from
this file to address a long-standing TODO.

Test: build
Change-Id: I968bf67e0e0189b01515242371599c02bc9e2ca2
2022-09-27 14:10:41 +09:00
Patrick Rohr
88a8565697 Merge "ethernet: delete testListenEthernetStateChange" 2022-09-27 03:55:44 +00:00
Lucas Lin
4904cde167 Merge "Clean up VpnTest" 2022-09-26 13:51:19 +00:00
Hungming Chen
0090e969af ClatCoordinator: only dump information when clat is started
ClatCoordinator should not rely on the caller Nat464Xlat to
avoid dumping when clat is not started. It is safer to dump
information after ClatCoordinator has checked its status.
Only dumping ClatCoordinator with clatd started reduces the null
pointer check of dumped elements as well.

Test: atest ClatCoordinatorTest
Change-Id: Ia0be9a593cd75fd34f647230d642b0dcf84aaf3b
2022-09-26 10:32:42 +00:00
Treehugger Robot
23196b6ccb Merge "Cleanup test (fix comment + make a helper easier to use)" 2022-09-26 08:50:11 +00:00
Chalard Jean
565d679dc0 Cleanup test (fix comment + make a helper easier to use)
Test: ConnectivityServiceTest
Change-Id: Ia3e30d863cf860ee44fa5ea961b5aa0d0b8e44bb
2022-09-26 02:57:30 +00:00
Patrick Rohr
10b848d95b ethernet: delete testListenEthernetStateChange
This test has been broken for a while. It tested:
- adding a listener triggers an interface state changed callback and an
  ethernet state changed callback.
- setEthernetEnabled calls back the correct listeners and removes / adds
  the interface.

Interface state listeners are already well covered in
EthernetManagerTest. I am currently working on adding tests for
setEthernetEnabled (there is partial coverage in setUp and tearDown of
EthernetManagerTest).

Bug: 242671512
Test: atest EthernetTrackerTest
Change-Id: Id1325a9056384444affb5c096cbc19d200ae0c4e
2022-09-25 17:04:33 -07:00
Chalard Jean
4203229ac9 Add unit tests for preferring bad wifi
This tests both the behavior of preferring bad wifi and
the notification.

Test: this
Change-Id: I5b93af756e898998f769015004c3286cd2ac5222
2022-09-24 11:35:15 +09:00
Chalard Jean
1325a631cc Clear notif upon bad wifi off + tests for bad wifi notif
If a notification is up and the avoid bad wifi setting
is turned off, the notification should disappear.

This patch also adds some general tests for the bad wifi
notifications.

Test: new tests in this patch
Change-Id: I5bc42afbe0efd93cfb59a759bf0aaba49a4bfc9f
2022-09-24 11:11:51 +09:00
Chalard Jean
8a9061f0b5 Detect captive portals as they are tested, not upon notifying
In the previous code, ConnectivityService would mark a network
a captive portal when NetworkMonitor sends it a message to notify
the user for it. Theoretically, this is incorrect ; instead, the
marking should be done upon receiving the message that the network
was tested to be a captive portal.

In practice this hasn't been a problem so far. The captive portal
capability is observable in the app-received callbacks, but for
these purposes the old code and the new code behave the same, in
that in the callbacks, the network used to not have the portal
capability, then later it acquires it.

However, this is only not a problem as long as the captive portal
bit isn't used by network selection, which an upcoming change has
to implement for the "prefer bad wifi" feature. When that is the
case, network selection prefers the wrong result between the time
the network is marked as having been evaluated and the time the
network has been marked a captive portal. It should be marked as
both at the same time to avoid this discrepancy. This is what
this patch is accomplishing.

To do this correctly, this patch also has to disconnect the network
immediately upon it being tested as a captive portal if the old
CAPTIVE_PORTAL_MODE setting is set to CAPTIVE_PORTAL_MODE_AVOID,
instead of keeping it until NM sends the message to notify about
it.

Unfortunately because of the relative timing of the events this
patch has observable impact on what callbacks are sent because of
b/245893397 (the DoubleValidated bug). Before this patch, there
would be an extra useless callback when a captive portal validates
where the capabilities contain both VALIDATED and CAPTIVE_PORTAL,
then a second callback removing CAPTIVE_PORTAL. This patch fixes
this, but unfortunately introduces a symmetrical extra useless
callback when a captive portal network starts matching a callback,
where onCapabilitiesChanged is fired a second time after the
onAvailable sequence with the same capabilities. Fixing this is
very complex ; the best (and simplest) solution is really to
address b/245893397 decisively.

In the mean time, the behavior implemented by this patch is better
than the old one, because there no longer is an observable state
where the network is supposed to be a closed captive portal AND
validated, but instead there is a useless, but correct, caps
callback that mirrors exactly the one from b/245893397. When
b/245893397 is addressed this behavior goes away at the same time,
so this is probably the better behavior.

Test: FrameworksNetTests CtsNetTestCases
Change-Id: I6694db498507860e1d711e2aa0c591dfbfa90be2
2022-09-24 11:11:49 +09:00
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