Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
Merge "Implement offload priority" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-01-25 06:09:19 +00:00
0b29cbf114
Merge "Support mDns Multipacket Known-Answer Suppression" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-25 03:00:45 +00:00
eeb79c6937
Merge "Add test for SkDestroyListener::dump()" into main
Ken Chen   authored and   Gerrit Code Review   commited 2024-01-24 11:37:48 +00:00
c930f3e8e5
Support mDns Multipacket Known-Answer Suppression
When a query packet is truncated, the responder should defer
the generation of a response until all packets have been received
and processed. If an answer present in the query packet's answer
section also appears in the responder's response, and the
known-answer's TTL exceeds half of the original TTL, suppress
the corresponding response.

Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
      Passed DISTRIBUTED DUPLICATE SUPPRESSION and \
      MULTIPLE QUESTIONS - DISTRIBUTED DUPLICATE SUPPRESSION \
      test cases of BCT
Change-Id: I781cd813d46f7d0db267f3fe23a15a81ae319e51

Paul Hu   commited 2024-01-24 08:54:58 +00:00
3aaa285293
Add test for SkDestroyListener::dump()
A simple unit test for the SkDestroyListener::dump().
(The follow-up of aosp/2916465)

Bug: 306919485
Bug: 319348954
Test: atest FrameworksNetTests:android.net.connectivity.com.android.serv
er.net.SkDestroyListenerTest

Change-Id: Ica70b2b344ffb2df8047cd936e8edc583e636ceb

Ken Chen   commited 2024-01-24 13:26:50 +08:00
8b33caa55e
Merge "Do not check active socket from other callbacks" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-24 03:15:16 +00:00
95d380fefd
Do not check active socket from other callbacks
Not all SocketTypeClients are cleaned up when their corresponding
sockets are closed. This occurs because the active socket check
for each callback examines the socket from all callbacks, even
those scheduled for removal in later notifications. To fix this,
check the active socket from the current callback only.

Fix: 317461509
Test: atest FrameworksNetTests NsdManagerTest
      Manually test with multiple discovery requests and
      Wifi on/off.
Change-Id: I2f81bb8e75f2c038d5e9dc025b208dcc6b441112

Paul Hu   commited 2024-01-23 10:31:08 +00:00
01d2f643be
Implement offload priority
Implement the TODO to assign priority to services based on an
overlayable configuration.

This changes the default priority from 0 to MAX_VALUE, as higher
priority values are less prioritized, so services not in the priority
list should have a high value. There is currently no user of the API
depending on the priority, so the change should not affect clients.

Test: atest
Change-Id: I3aae9b5fa7756de64c63974c192e4c96b632ce4e

Remi NGUYEN VAN   commited 2024-01-23 19:03:55 +09:00
5c9d6cbf16
Merge "Add SkDestroyListener log in dumpsys netstats" into main
Ken Chen   authored and   Gerrit Code Review   commited 2024-01-22 10:25:50 +00:00
65b4c3f0f1
Add SkDestroyListener log in dumpsys netstats
When sockets are destroyed, the SkDestroyListener receives a
NETLINK_INET_DIAG message informing it to delete the socket cookie from
the BPF CookieTagMap. However, under unknown conditions, all 10,000
spaces on the map were still observed to be filled. SkDestroyListener
and its parent classes, NetlinkMonitor, and FdEventsReader will log
errors. But due to the time required to fill the 10,000 fields is long,
traces in the device log are likely to have been overwritten and cannot
be observed.
This commit enables dumpsys netstats to print the last 20 traces of the
SkDestroyListener. If the issue is caused by the SkDestroyListener,
this will help in obtaining further clues when the issue is reported
again.

Bug: 306919485
Bug: 319348954
Test: atest FrameworksNetTests:android.net.connectivity.com.android.serv
      er.net.NetworkStatsServiceTest#testDumpSkDestroyListenerLogs
Test: manually add mLog.e(...) in
      SkDestroyListener#processNetlinkMessage and check dumpsys netstats
Change-Id: I5bbfe07e05cf959f809f28a7633ee5f99e29f641

Ken Chen   commited 2024-01-22 13:48:34 +08:00
375d780c8e
Merge "Apply multicast routing configs" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-22 00:57:42 +00:00
cc23753288
Merge "Support multicast routing" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-22 00:55:10 +00:00
bcc245d5bf
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
Support multicast routing
Added support to apply multicast routing config between network
interfaces in MulticastRoutingCoordinatorService.

Bug: 281217735

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.connectivity.MulticastRoutingCoordinatorServiceTest

Change-Id: If608b79d4e62a20d2e01755a83a901f6e274d9a2

Yang Sun   commited 2024-01-20 21:32:11 +08:00
baa50fa478
Merge "Remove the UID range check for TCP sockets" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-01-19 02:53:29 +00:00
26aab9b0d9
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
Fix NetworkRequestReceivedRemoved test
Test: atest FrameworksNetTests
Bug: 320588833
Change-Id: I8f80dee7b90a499bf761fdcccbc33182df259332

Danuta Brotikovskaya   commited 2024-01-18 09:32:32 +00:00
065ccfab8c
Merge "Implement NetworkRequestsState atom" into main
Danuta Brotikovskaya   authored and   Gerrit Code Review   commited 2024-01-17 01:33:06 +00:00
d6aae95da7
Implement NetworkRequestsState atom
Bug: 278833398
Test: atest FrameworksNetTests
Change-Id: I95a8c8dddd2d8f6863fe64cd4a65ef48dfb5153a

Danuta Brotikovskaya   commited 2024-01-16 21:50:12 +00:00
878fd25d84
Merge "Use MonitorThreadLeak in CSTest related tests" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-16 08:36:36 +00:00
d54613fd4e
Use MonitorThreadLeak in CSTest related tests
Fix current leaks in CSTest related tests, which leaked the
ConnectivityService and AlarmManager handler threads, and enable
the checks.

Using @DevSdkIgnoreRunner.MonitorThreadLeak ensures that tests properly
cleanup threads (in particular handler threads), as many leaked threads
could affect other tests.

Fix: 308520131
Test: atest ConnectivityCoverageTests
Change-Id: Ia6fb2c97f7a1740bafc0ab549440fdbeb1d5fad6

Paul Hu   commited 2024-01-16 06:56:34 +00:00
8792a72e8e
Fix replying to queries via unicast
Instead of (wrongly) looking at the DNS message flags for the Query
Unicast bit, look at the flag in the question record.

The previous bug means that all queries would be replied multicast
instead of sometimes unicast. The fix is flagged off as this is a
behavior change that may affect performance and latency.

Bug: 289482497
Test: atest
Change-Id: I08e30c4ffa747c9073d631e8addca1278ea40648

Remi NGUYEN VAN   commited 2024-01-15 20:26:28 +09:00
0ca094b577
Only use source addresses in handlePacket
MulticastPacketReader uses an InetSocketAddress as a buffer that gets
filled for each incoming packet for the source address. Similarly to the
receive buffer, it should not be used outside of the handlePacket
method, as it will be modified on the handler thread when further
packets are received.

Fix the current usage in MdnsInterfaceAdvertiser/MdnsRecordRepository.
Fortunately due to a bug packets are never replied unicast, so today the
MdnsRecordRepository code using the source address never triggers, even
though it may be circulating an incorrect source address instance that
changes over time.

Test: atest
Change-Id: I4cadfa6e54d1b37d9a6b0f8ca0269193a229bc51

Remi NGUYEN VAN   commited 2024-01-12 19:11:44 +09:00
7078ac59b9
Merge "Use MonitorThreadLeak in ConnectivityService tests" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-12 06:48:51 +00:00
c45efc312e
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 "Fix leak of NetworkAgentWrapper HandlerThread" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-01-11 10:33:21 +00:00
64a8ead5d1
Use MonitorThreadLeak in ConnectivityService tests
Fix current leaks in ConnectivityServiceIntegrationTest, which leaked
the ConnectivityService and CarrierPrivilegeAuthenticator handler
threads, and enable the checks.

Using @DevSdkIgnoreRunner.MonitorThreadLeak ensures that tests properly
cleanup threads (in particular handler threads), as many leaked threads
could affect other tests.

Bug: 310659032
Test: atest --rerun-until-failure 20
Change-Id: Ia62d33d86217fef1d03532bb51c890a90430a70e

Remi NGUYEN VAN   commited 2024-01-11 19:19:13 +09:00
de0b07b46e
Fix leak of NetworkAgentWrapper HandlerThread
ConnectivityServiceTest creates hundreds of NetworkAgentWrapper, without
stopping their HandlerThread. This leaks a lot of threads while tests
are running.

Ensure the threads are stopped in ConnectivityServiceTest, and
integration tests that also use NetworkAgentWrapper.

Test: atest, watch adb shell ps -T [test package pid]
Bug: 310659032
Change-Id: I34f367b2efe3d05e1db5eab4c9fd93ee79c1b683

Remi NGUYEN VAN   commited 2024-01-11 17:59:29 +09:00
2491624106
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 "Change throw to Log.wtf" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-12-28 01:40:10 +00:00
ab2fd4cac9
Stop registering native mdns service
NsdService switched from Netd native solution to Java solution on
Android U. MDNS service provided by Netd will be removed from Android V.

1. Stop registering native mdns service from V.
2. Stop startDaemon() in NsdManager from V.
3. As a double safety, return early in NsdService methods that call the
   native mdns service when platform version is V+.
4. Modify NsdManagerTest to cover V+ behavior.

Bug: 298594687
Test: Build. Presubmit.
Change-Id: Ifdac8f7a44aa57d93d453ba482ec473a2b531452

Ken Chen   commited 2023-12-27 13:54:50 +00:00
80c9f6f35f
Merge changes from topic "fix-mdns" into main
* changes:
  [mdns] add tests for verifying address of mDNS reply
  [mdns] fix wrong NSEC answer for unique RRs
  [mdns] fix duplicated records for multiple questions

Kangping Dong   authored and   Gerrit Code Review   commited 2023-12-27 13:15:30 +00:00
81e6439298
Change throw to Log.wtf
Log.wtf should avoid crashes, while making sure that one can still
notice if there is a problem.

In particular, it may be possible that calling ensureIpServerStopped
and ensureIpServerStarted could start forwarding before the previous
IpServer has stopped it.

Bug: 314260975
Change-Id: I047a673d2fe6f218192d3144fa0bd60ce8739a15
Test: TH

Remi NGUYEN VAN   commited 2023-12-27 19:31:54 +09:00
ca3c524b49
[mdns] add tests for verifying address of mDNS reply
Bug: 265095929
Test: atest FrameworksNetTests
Change-Id: I3499fb9dfc24fec9648f9c97d6028c3fca4f925a

Kangping Dong   commited 2023-12-27 16:54:18 +08:00
b83b90e779
[mdns] fix wrong NSEC answer for unique RRs
Existing MdnsRecordRepositiry#getReply will send a NSEC RR in the reply
when 1) a query for a unique RR is not found or 2) any unique name which is
included in the answer sections. The second one is not aligned with the
spec:

```
On receipt of a question for a particular name, rrtype, and rrclass,
for which a responder does have one or more unique answers, the
responder MAY also include an NSEC record in the Additional Record
Section indicating the nonexistence of other rrtypes for that name
and rrclass.
```

This commit fixes the issue in 2) by checking that all unique records of
the name are included in the answers before adding a NSEC record.

Bug: 265095929
Test: atest FrameworksNetTests
Change-Id: I0531fbccf98e69a50bb8a45e529caaed3ad80b59

Kangping Dong   commited 2023-12-27 16:54:15 +08:00
04b61c4a3c
Merge "[AF03] Adopt FastDataInput" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-12-26 09:15:02 +00:00
713fc49cdb
[AF03] Adopt FastDataInput
FastDataInput for reading persistent data is currently disabled
by default. This functionality will be gradually enabled through
A/B experiments to assess its impact.

One-shot boot time increase up to 10 second is one expected
outcome in worst case. Currently, the persistent data was loaded
when the first caller query it, but in this change it will be
done twice in the boot stage due to the needs of doing comparison.

Test: adb shell dumpsys netstats
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Test: manual test against data points under benchmark/assets/dataset
Bug: 313841499

Change-Id: Ia927bd115de5453ca3ee22104f3efbf44a55c2b8

Junyu Lai   commited 2023-12-26 15:42:09 +08:00
da6020a329
Merge "Check target sockets by UID range" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-12-26 06:19:17 +00:00
34afa7b73c
Check target sockets by UID range
This commit optimizes the mechanism to examine the TCP sockets
based on the VPN UID range.

The automaticOnOffKeepalives will be paused/resumed by checking
the TCP sockets status on the VPN network. The existing design
considers all UIDs, not the UID ranges for the specific VPN
network. This may lead to an inaccurate judgement to not to
stop the keepalive even when there is no socket on the VPN
network.

This commit is also a part of follow-up work from aosp/2354202
to use structized class to parse the TCP sockets.

Bug: 311119352
Bug: 265877161
Test: atest FrameworksNetTests
Change-Id: I4a6b751cb904b9c18ed1df420cc880ea38022d6a

Chiachang Wang   commited 2023-12-26 05:22:00 +00:00
d8474bb1cf
Merge "[AF06] Fill file attributes metrics" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-12-26 04:34:05 +00:00
46afd1b4cb
Merge "Add MdnsReplySenderTest" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-12-25 08:25:21 +00:00
1cbb9ab59f
Merge "Correct coding format" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-12-25 07:00:41 +00:00
32350ca201
Add MdnsReplySenderTest
Currently, the MdnsReplySender doesn't have a dedicated test
class to verify its functionality. To address this gap, add the
MdnsReplySenderTest class, which can test all methods within the
MdnsReplySender class.

Bug: 312657709
Test: atest FrameworksNetTests
Change-Id: Ibd948d97d38c012c63092ed4c6877d04b1ff14c1

Paul Hu   commited 2023-12-25 14:23:41 +08:00
0228e63a45
[mdns] fix duplicated records for multiple questions
Existing MdnsRecordRepositiry#getReply will result in duplicated RRs in
answer and additional records sections if multiple PTR questions for the
same service are received in a single query message.

This commit fixes this by using a Set<> for maintaining the RR set and
moving the NSEC construction to outer of the addReplyFromService() after
all answer and additional records have been added.

This commit also refactors the unit tests to cover more cases of
multiple queries other than PTR records

Bug: 265095929
Change-Id: I379dd89703915406c5700ed19aad46ef4035b917

Kangping Dong   commited 2023-12-25 13:59:41 +08:00
0c374445dc
Correct coding format
A clean up commit to correct the coding format.

Test: atest FrameworksNetTests
Change-Id: I7d7ed3765a0be503400ed3c33ea461e9baa3e72d

Chiachang Wang   commited 2023-12-25 05:55:29 +00:00
4823f0fb4d
[AF06] Fill file attributes metrics
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsRecorderTest
Bug: 313841499

Change-Id: I12759e14c29917ad61eedad4cfee21f153a1a6bd

Junyu Lai   commited 2023-12-25 10:39:59 +08:00
ed1097b733
Merge "[AF02.1] Support read by FastDataInput in the NetworkStatsRecorder" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-12-25 01:58:14 +00:00
962515a8a8
Merge "Support mDns Known-Answer Suppression" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-12-22 08:32:29 +00:00
0db97a6f93