Also simplify DnsManagerTest by using the autogenerated equals()
method in ResolverParamsParcel instead of a hand-rolled
comparison method.
Test: covered by existing tests
Change-Id: Ie1b1bd011a440be0175420f903f39a4153d2245e
Lorenzo Colitticommited 2024-04-17 23:05:14 +09:00
If the query with known answer feature is enabled and the
MdnsPacket is too large for a single DatagramPacket, it
will be split into multiple DatagramPackets.
Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I831fb6035cc0ad03078fbd3b9c550b56ddca07fb
CSTest SetUp sets flag values based on annotations before
constructing ConnectivityService.
For flags that are loaded at ConnectivityService constructor, tests can
use this annotation to set flag values.
Test: TH
Change-Id: I5a995a3de4e433ac39e6ccc116b9d89da468b04b
This method can generate query packets from an oversized
MdnsPacket.
Bug: 312657709
Test: atest FrameworksNetTests
Change-Id: I21c1e082e01e0a6421920692115b0afdca0c9f9c
Similar to aosp/2988171, this CL restarts the announcement of services
when the services' host gets new addresses.
Bug: 327304356
Bug: 323712889
Change-Id: I1d9706d4721c216dacda203bf0445f557b008ebf
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
Update isUidNetworkingBlocked to return false for system uids regardless
of firewall chain status since this is an actual behavior
Bug: 328732146
Test: TH
Change-Id: Ic4760b927f51a1229e9af09c79b5261f85fe89d1
When some of a custom host's addresses are removed, the services which
are using the custom host should be updated accordingly:
- For the services being probed, the probing should be restarted with
the updated address records.
- For the services which already finished probing, they should be
re-announced with the updated address records.
For example, here is a scenario where the fix is necessary:
1. Register a host (host1) with addresses (addresses1)
2. Register a service (service1) using the host1.
3. Unregister the host1.
4. Re-register the host1 with different addresses (addresses2).
Then the probing messages of the second registration of host1 may
conflict with the announcements of service1 (which containing addresses
records of the addresses1). This is an undesired conflict. Restarting
the announcement of service1 when updating the addresses of host1
can get rid of this conflict.
Bug: 327304356
Change-Id: Ie97b72f1482c69fb5f24eab3ce9ed8f7cea957ec
BpfNetMapsReader is loaded to bootclasspath. So this class should not
contain unnecessary codes.
To make this clear, this CL renames to NetowrkStackBpfNetMaps and add
comments
Bug: 328732146
Test: TH
Change-Id: I557627c9fae087eb6119c2ae31d46526fa9e5d7e
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
The last dependency in the vpn-jarjar-rules can be removed
after refactoring the test as the test does not really
rely on the content of VpnProfileStore.
Test: atest FrameworksNetTests
Change-Id: Ib665dd7c05cca1eae77bf4100c43911686aac0ea
To support known-answer suppression, the querier should include
its known answers within each query packet. This allows the
service to determine whether a response is necessary based on
the querier's existing knowledge.
Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I2fb421aff1ae150b310e1a44f50f098a3edb9992
This no-op change uses MdnsUtils#createRawDnsPacket to construct
query packets instead of MdnsPacketWriter. This refactoring sets
the stage for future support of constructing multiple query
packets.
Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I404ec52e97635eed9d965d7c7ceaf6e726386d64
Use getAndClearLastScheduledRunnable() to run the query task
instead of getAndClearSubmittedRunnable(). Additionally,
remove running the query task twice incorrectly.
Test: atest MdnsServiceTypeClientTests
Change-Id: If8ee1b4d08fe716eaae97d66e6c10ec2af89c024
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
KeepaliveStatsTracker calls addOnSubscriptionsChangedListener from the
constructor.
And KeepaliveStatsTracker is instantiated from ConnectivityService
constructor.
So using actual SubscriptionManager leaked listener and tests started
failing.
Bug: 329365833
Test: atest ConnectivityCoverageTests
Change-Id: I65ac34e4bc6b5fd86a290706be844914d09918a5
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
Instead of creating one NetworkInterfaceProvider for each MdnsSocket,
create one in MdnsSocketClient and use it for each MdnsSocket.
MdnsSocket only calls getMulticastNetworkInterfaces and
getAvailableNetwork on MulticastNetworkInterfaceProvider, which are
thread-safe (the first one is synchronized). There is no need to have
multiple MulticastNetworkInterfaceProvider tracking the same state.
This allows reducing the number of callbacks filed to
ConnectivityManager, which is a resource usage improvement and can be
beneficial for huge apps that have many components which may
collectively reach the MAX_NETWORK_REQUESTS_PER_UID limit in
ConnectivityService (100).
MdnsSocketClient is unused in AOSP so this is a no-op in the platform.
It is only used by users of the unbundled mdns library.
Bug: 322049918
Test: atest
Change-Id: I515459beaee6aacc99c7c0c2a05c3c9c41473b62
This change also implement a getOrCompute method, if the entry
is not found in the cache or has expired, computes it using the
provided supplier and stores the result in the cache.
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.TrafficStatsRateLimitCacheTest
Bug: N/A
Change-Id: I60f07e84b7d2c754548b7cd431bd079b0d808c0a
There is a race condition in MdnsAdvertiser when removing the last
service:
1. When the last service is removed, it will call the destroyNow()
to tear down the interface advertiser and schedule a onDestroyed()
callback for MdnsAdvetiser to do further cleanup
2. If another serivce is registered after removing the last service but
before onDestroyed() is invoked, then onAdvertiserDestroyed() will
return false and the InterfaceAdvertiserRequest is kept in the map in
MdnsAdvertiser. This is because the newly registered service is in
the mPendingRestionstrations.
3. The problem is that InterfaceAdvertiserRequest now have no
InterfaceAdvertiser (because the only advertiser has already
destroyed) and cause the newly registered service can't be
advertised.
It needs to schedule onDestroyed() on the handler thread because we
can't do modify-during-iteration, but this introduces the race condition
here.
The fix in this commit changes to not destroy the InterfaceAdvertiser
immediately when the last service is removed but destroy when there are
no pending registrations in the InterfaceAdvertiserRequest.
Test: atest --iterations 100 CtsNetTestCases:android.net.cts.NsdManagerTest#testRegisterService_registerImmediatelyAfterUnregister_serviceFound
Change-Id: I6b6f01e6ddf103d16a8b0296af000dc8262ea65b
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
This change includes:
1. Use service handler looper when initializing the observers
to simplify the structure.
2. Make the handler variable final in the observers class.
3. Remove misleading comments, where the callback events
are actually dispatched on the oneway binder thread,
which does not block handler thread.
4. Update tests accordingly.
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Test: atest FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Test: atest CtsNetTestCases:NetworkStatsManagerTest
Bug: N/A
Change-Id: I5be92853b5bbc795a36bf774956bdac33d79099b