Commit Graph

1077 Commits

Author SHA1 Message Date
Yan Yan
18ddc7daab Merge "Fix policy leak by deleting forwarding security policies" 2022-11-02 00:47:09 +00:00
lucaslin
afe76f3b77 Test dynamically calculated VPN MTUs
This change adds testing for VPN MTU calculations, and in particular
cases where IPv6 is not supported due to MTUs being too small.

Bug: 245612827
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ib064e6670244cf3b53b5d03bd62c86b2139ff32a
2022-11-01 08:09:37 +00:00
Yan Yan
f4eceba0a9 Fix policy leak by deleting forwarding security policies
Fix the policy leak by deleting forwarding policies when deleting
the IPsec tunnel interface.

Bug: 254566085
Test: atest IpSecServiceParameterizedTest (new tests added)
Change-Id: I29dd4810abb978fe886776b2fbacdfc74325436d
2022-10-31 22:51:08 +00:00
Treehugger Robot
9a726855f2 Merge "[Feature sync] Fix flaky test in MdnsSocketClientTests" 2022-10-28 08:25:08 +00:00
Paul Hu
cd04d83e68 [Feature sync] Fix flaky test in MdnsSocketClientTests
The interface index is only propagated if there is an A/AAAA
record in the response. Since the responses here are not entirely
controlled in the test, we just want to verify that we get a
response with the target we expect.

Verified by running the test 1400 times via --runs_per_test flag.

Bug: 254155029
Fix: 255922416
Test: atest MdnsSocketClientTests#startDiscovery_andPropagate\
      InterfaceIndex_includesInterfaceIndex --iteration 100
Change-Id: Icb0fe7a58a1e626b7f781ff24c2389a3095d4dc6
2022-10-28 10:26:15 +08:00
Nucca Chen
f76b8d67f8 ClatCoordinatorTest: override test generateIpv6Address correctly
aosp/2267683 adds the new param "mark" in generateIpv6Address and
TestDependencies#generateIpv6Address needs to override for this change
correctly.

Change-Id: Ia526bcdf80a428948d55a28bd5adec405530a634
Test: TH
2022-10-27 10:11:28 +00:00
Junyu Lai
0f4cb380f0 Merge "Notify NetworkStats only when interfaces changed in updateLinkProperties" 2022-10-27 06:49:33 +00:00
Chiachang Wang
c39c3759ca Merge "Test session reset on VPN data stall" 2022-10-27 05:13:45 +00:00
chiachangwang
f60356f273 Test session reset on VPN data stall
Add tests to verify ike session being triggered when data stall.

Bug: 238692379
Test: atest FrameworksNetTests
Change-Id: I656ea0973072b0bbdd54863eccbe105adb02d6ad
2022-10-26 03:05:59 +00:00
Paul Hu
e3aa5c0e06 Merge "[Feature sync] Propagate network interface index to MdnsServiceInfo" 2022-10-26 01:17:10 +00:00
Paul Hu
df7335f3cd Merge "[Feature sync] fix handling arbitrary bytes in TXT value" 2022-10-26 01:05:55 +00:00
Patrick Rohr
6150134515 ethernet: consolidate interface enabling functions in EthernetTracker
I want to add some logic to setInterfaceEnabled in a follow up, so
consolidating the functions prevents redundancy.

Test: atest EthernetManagerTest
Change-Id: I5756a09be392a970bc545612220595c6984f2b54
2022-10-25 19:15:17 +00:00
Maciej Żenczykowski
9592fa89b3 Merge "Bypass VPN lockdown for clat initialization" 2022-10-25 07:43:12 +00:00
Junyu Lai
2ed7d4182a Notify NetworkStats only when interfaces changed in updateLinkProperties
In ConnectivityService, updateLinkProperties calls NetworkStats
even though the ip address or interface name has not changed and
only the tcp buffer size has changed. This is noisy and could
be problematic when RAT change occurs frequently, since when
RAT changes tcp buffer size configuration also changes.

This CL also fixes a wrong nullability annotation where the oldLp
of updateLinkProperties could be null when updateNetworkInfo
is called.

Test: atest ConnectivityServiceTest#testStatsIfacesChanged
Fix: 232048480
Change-Id: Ic226eb4a8aa1f38cba293510813f1cb55f0ea658
2022-10-25 15:27:53 +08:00
Treehugger Robot
a40faea28d Merge changes I0789d9bd,Idf4cf74a
* changes:
  Disable ignoring validation on roam just after boot.
  Minor cleanups for ignore validation failures after roam tests.
2022-10-25 02:15:29 +00:00
t-m-w
130e75b0ab Bypass VPN lockdown for clat initialization
This allows clat to initialize properly when VPNs are configured
with "Block connections without VPN", rather than to error out with
"no IPv6 addresses were available for clat".

This issue primarily affects particular mobile networks configured
with NAT64 (without direct IPv4 connectivity).

Bug: 255040839
Change-Id: I4a8ee0295e0f5d1e330f7529856347b8bd10360c
2022-10-25 01:54:51 +00:00
Lorenzo Colitti
5edd296baa Merge "Improve tests for notifyIfacesChangedForNetworkStats." 2022-10-24 23:35:35 +00:00
Lorenzo Colitti
580d0d53be Disable ignoring validation on roam just after boot.
shouldIgnoreValidationFailureAfterRoam will incorrectly return
true in the first few seconds after boot even if the network
never roamed. This is extremely unlikely to happen, but add a
check for that just in case.

Fix: 230450214
Test: new unit test
Change-Id: I0789d9bdaa0bd9e78673e8f4248a2ca610052f1e
2022-10-24 23:28:56 +09:00
Lorenzo Colitti
6bf9bb3e58 Minor cleanups for ignore validation failures after roam tests.
- Confirm that the default network switches to cell for the right
  reason.
- Test the behaviour on T as well (always disabled).
- Minor code cleanups.

Bug: 216567577
Test: test-only change
Change-Id: Idf4cf74aec3d40246f67519d211dbd45e739a6dc
2022-10-24 23:28:54 +09:00
Paul Hu
e62d151d1e [Feature sync] Fix issue where multiple SRV records with same host are not fully resolved
For Matter, a device may have a single host with multiple A/AAAA
records, but multiple PTR/SRV pairs that represent different
operational identities for the same device.

Currently, MdnsResponseDecoder looks for only a single matching
MdnsResponse by hostname when looping through the A/AAAA records
(which will leave the second response incomplete). Updated with a
flag that will allow returning all MdnsResponses which match the
given hostname and update the Inet records for all responses.

Bug: 254155029
Test: atest FrameworksNetTests
      Verified with a Matter device with two identities that the
      second response is incomplete without this change.
      Additionally, added unit tests to verify the before and
      after behavior with a real packet capture from the device.
Change-Id: Ic4a101b305c039f6cd7fd557246a2bfdaf0c781a
2022-10-24 07:29:44 +00:00
Paul Hu
6540583f08 [Feature sync] Propagate network interface index to MdnsServiceInfo
For Matter, in addition to the InetAddress and port, we also need
to know the associated NetworkInterface index. With this change,
the interface index is propagated from the MdnsSocketTypeClient
through to MdnsServiceInfo based on a flag (defaulting to -1 for
unspecified, if the flag is disabled).

Validated end-to-end against a commissioned Matter device,
enabling the flags, verifying the returned network index against
an adb shell 'ip link show' output.

Bug: 254155029
Test: atest FrameworksNetTests
Change-Id: I96e804b32cdeeff3ed22da35a030df4d5dbb179a
2022-10-24 06:41:50 +00:00
Paul Hu
e231650e34 [Feature sync] fix handling arbitrary bytes in TXT value
RFC 6763 defines that TXT value can accept both utf-8 string and
binary data. Current implementation will always cast the TXT
value to a utf-8 string and will cause data lose when there are
non-utf-8 chars in the TXT value. This commit fixes this by
having the browser passing the TXT values back as byte[].

Also fixed the TXT key&value parsing issues per RFC 6763
section 6.5: accept cases of no '=' and reject empty key.

Bug: 254155029
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I4b755e60ad6e59db19faa41556dd214993d73896
2022-10-24 06:03:50 +00:00
Chalard Jean
90143e475f [CC05] Replace expectCallback* with expect
See CC03 (aosp/2255619) for details

Test: CtsNetTestCases
      FrameworksNetIntegrationTests
      FrameworksNetTests
Bug: 157405399
Change-Id: I0fd99561757bd76c073a050d511c668270ccb2b7
2022-10-21 11:46:27 +09:00
Jean Chalard
d6317fbe77 Merge "[CC02] Expect losing explicitly" 2022-10-19 00:22:48 +00:00
Chalard Jean
cea002351d [CC02] Expect losing explicitly
Before this patch, ConnectivityServiceTest#TestNetworkCallback
relies on TestableNetworkCallback calling this overridden methods
for all expectCallback calls. This is very confusing :
- The code for TestableNetworkCallback might be refactored so it
  no longer calls this, we'd lose the checks and nobody would
  notice.
- Anyone using TestableNetworkCallback instead of
  TestNetworkCallback would get a different behavior but would
  not notice as the interface for these two classes is exactly
  the same

This is also bad for performance because all callback checks will
always look whether it's a check for LOSING, which is rare.
This patch also only generates the error message when the error
actually happens.

Test: ConnectivityServiceTest
Bug: 157405399
Change-Id: Ic9566b815dc4f9b001986ed1376d31a1b97ac8c5
2022-10-18 17:52:56 +09:00
Aaron Huang
151894e282 Merge "Filter ifaces for uid operations value before combine" 2022-10-18 06:58:20 +00:00
Aaron Huang
af1b47c2ce Filter ifaces for uid operations value before combine
Currently, the stats returned by getNetworkStatsUidDetail()
does not filter iface for mUidOperations, it will cause this
API returns the stats that might contain data with unexpected
iface. Thus filter iface for mUidOperations before combining
it into the return stats.

Bug: 235444141
Test: FrameworksNetTests
Change-Id: I81aaacb5682d69022e521a793516373037510742
2022-10-17 15:41:52 +08:00
Jean Chalard
bda6a2d310 Merge "Add logs for changes in capabilities and score" 2022-10-17 05:54:39 +00:00
Motomu Utsumi
403d7d7589 Merge changes Icf3df3aa,I92adad60
* changes:
  Add sEnableJavaBpfMap value to the dump
  Move CookieTag map dump to BpfNetMaps
2022-10-17 04:23:36 +00:00
Chalard Jean
86317d8bb4 Add logs for changes in capabilities and score
This will be useful for diagnosing default network changes.

Logs may look like, for example :
Update capabilities for net 100 : -NET_CAPABILITY_OEM_PAID+NET_CAPABILITY_TRUSTED
Or :
Update score for net 100 : -POLICY_EVER_EVALUATED+POLICY_IS_VPN+POLICY_IS_DESTROYED

Test: FrameworksNetTests
      manual
Change-Id: Ic4788c599573aae9daeca995b8853800aaaba0b8
2022-10-14 14:32:38 +09:00
Lorenzo Colitti
0df40f3eaf Improve tests for notifyIfacesChangedForNetworkStats.
Add code to verify which networks are passed in, and check that
the default interface appears in the LinkProperties of one of the
snapshots.

Test: test-only change
Change-Id: I3c1a483b89564b1c994b8e644ece5b903f549475
2022-10-13 16:06:54 +09:00
Chiachang Wang
98a35775cd Merge "Test MOBIKE trigged while VPN data stall" 2022-10-12 14:04:39 +00:00
Motomu Utsumi
480ddf35f4 Merge "Move Interface stats map dump to NetworkStatsService" 2022-10-07 10:27:04 +00:00
Treehugger Robot
d577c39663 Merge "Partially enforce permission when calling getNetworkInfoForUid" 2022-10-07 04:38:30 +00:00
Junyu Lai
163cb98751 Partially enforce permission when calling getNetworkInfoForUid
Test: atest ConnectivityServiceTest#testGetNetworkInfoForUid
Change-Id: Ie0ac289e77a865cf3cc98a6a2bbd5b25cf402622
2022-10-06 10:40:57 +08:00
Treehugger Robot
bc5a46e564 Merge "Fix the test flake on ConnectivityServiceTest" 2022-10-05 11:23:32 +00:00
Motomu Utsumi
ef546a9bd5 Move CookieTag map dump to BpfNetMaps
Also removes dump tests in TrafficController

Bug: 217624062
Test: atest BpfNetMaps TagSocketTest
Change-Id: I92adad60c55443435d7c7a0bfc84b38162fd51b0
2022-10-05 18:28:13 +09:00
Motomu Utsumi
809a316035 Move Interface stats map dump to NetworkStatsService
Bug: 217624062
Test: dumpsys netstats, atest NetworkStatsServiceTest
Change-Id: Ie0357a79925c0bbb34aa05442f727c776f434f88
2022-10-05 17:33:02 +09:00
Motomu Utsumi
b2832afa9a Merge "Move ownerMatch config dump to BpfNetMaps" 2022-10-05 04:11:43 +00:00
Motomu Utsumi
1e003b4c9a Merge "Move current StatsMap dump to BpfNetMaps" 2022-10-05 04:11:11 +00:00
Motomu Utsumi
2f17ade211 Merge "Move uidOwnerMap dump to BpfNetMaps" 2022-10-05 04:10:13 +00:00
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
Paul Hu
bdd7fe48e4 Fix the test flake on ConnectivityServiceTest
This test need a connected enterprise Network before setting
a profile network preferences. If there is no enterprise network
after setting no fallback preference, it will get lost callback
from cell network because it's not matched current preference.
The test fails sometimes because the enterprise network agent is
not fully connected yet. Thus, make sure the agent is fully
connected before settting a profile network preferences.

Fix: 242833379
Test: atest FrameworksNetTests:com.android.server.Connectivity\
      ServiceTest#testPreferenceForUserNetworkUpDownWithNo\
      FallbackWithAlreadyConnectedWorkAgent \
      --rerun-until-failure 100 on cf target
Change-Id: I040b9f31c29834f90f4ca62c512e392141a3244d
2022-10-04 08:13:15 +00:00
Motomu Utsumi
372c9b45ee Move ownerMatch config dump to BpfNetMaps
Information in the dump does not change
....
current ownerMatch configuration: 516 DOZABLE_MATCH OEM_DENY_1_MATCH
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I5f7b56e4ba03256414f49d0e82d65477fb97f05a
2022-10-04 15:02:43 +09:00
Motomu Utsumi
c675d6fc01 Move current StatsMap dump to BpfNetMaps
Information in the dump does not change
....
current statsMap configuration: 0 SELECT_MAP_A
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I42a844227f258b91ba5b368d8e8abf82a773a801
2022-10-04 15:02:43 +09:00
Motomu Utsumi
956d86ccdf Move uidOwnerMap dump to BpfNetMaps
Before this CL
....
mUidOwnerMap:
10050  IIF_MATCH LOCKDOWN_VPN_MATCH 0
10061  HAPPY_BOX_MATCH
10091  HAPPY_BOX_MATCH IIF_MATCH LOCKDOWN_VPN_MATCH 0
....

After this CL
....
sUidOwnerMap:
  10050 IIF_MATCH LOCKDOWN_VPN_MATCH 0
  10061 HAPPY_BOX_MATCH
  10091 HAPPY_BOX_MATCH IIF_MATCH LOCKDOWN_VPN_MATCH 0
....

Bug: 217624062
Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest
Change-Id: I0e2358e462824273a89fcba6e19e75a233f9fe18
2022-10-04 15:02:41 +09: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