Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
On U+ require config_networkWakeupPacketMark/Mask to be 0x80000000
See system/netd/include/Fwmark.h which reserves the bottom 21 bits
of skb->mark for netid, etc... so out of necessity these have to be
in the top 11 bits.

In practice the only values that really make sense are either:
  mark == mask == 0 (disabled)
or (mark == mask) being one of the top 11 available bits, for example:
  mark == mask == 0x80000000 (enabled, using top-most bit)
(only a single bit makes sense, as this is really just a boolean signal,
 and only the topmost is known to be used on any real devices)

Let's just force the use of 0x80000000 for ecosystem consistency.

Bug: 284334830
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I199e9b00de845b3747940426ea6644426ab72e87

Maciej Żenczykowski   commited 2023-06-05 07:41:00 +00:00
cf41fc877a
Merge changes If830eb53,If03514f1
* changes:
  Update tethered/local only interfaces when no all networks request
  Use wifi p2p interfaces for mDNS

Paul Hu   authored and   Gerrit Code Review   commited 2023-06-02 13:10:51 +00:00
83bd5a5927
Update tethered/local only interfaces when no all networks request
If there is no request for all networks, the tethered/local only
interface changes will be ignored. However, these available
interfaces are not used for mDNS when a user requests a socket
with a null network because the interfaces are lost due to the
previous ignore. Therefore, the interface changes should be
retained and will be used for socket creations afterwards.

Bug: 284939720
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: If830eb53af26f21f497314477b131ce28468a971

Paul Hu   commited 2023-06-02 08:54:41 +00:00
bb69412f5b
Use wifi p2p interfaces for mDNS
mDNS is used by wifi p2p in many places. However,
MdnsSocketProvider does not monitor changes to the wifi p2p
connection to get the names of the available wifi p2p interfaces.
This prevents mDNS from registering or discovering services on
the wifi p2p interfaces. Therefore, listen to the wifi p2p change
intent to know the available interfaces and status changes that
can be used by mDNS.

Bug: 284263838
Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Change-Id: If03514f1286c0507e5862372272234dd07eb084d

Paul Hu   commited 2023-06-02 08:54:41 +00:00
fbba5e8307
Merge changes from topic "refresh-record"
* changes:
  Renew the SRV/TXT records if half of TTL passed
  Turn on removeExpiredService feature

Yuyang Huang   authored and   Gerrit Code Review   commited 2023-06-02 08:10:52 +00:00
c823dc2259
Renew the SRV/TXT records if half of TTL passed
As mentioned in RFC6762 7.1. The records only needed to be renewed if
at least half of the TTL passed. Usually A/AAAA records are included in
the response to the SRV record query, they are not refreshed individually.

Bug: 285261577
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Ifd7140de0d733191256184c5481412e1822d279b

Yuyang Huang   authored and   Remi NGUYEN VAN   commited 2023-06-02 15:36:09 +09:00
f2cc01dc12
Turn on removeExpiredService feature
Turn on removeExpiredService feature by: 1) Remove the unnecessary
allowSearchOptionsToRemoveExpiredService flag. 2) Turn on the
removeExpiredService flag in the MdnsSearchOptions.

Bug: 285260665
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Ib115b40e70b0f81a7877deb73af7d61e2e0c385f

Yuyang Huang   authored and   Remi NGUYEN VAN   commited 2023-06-02 12:33:55 +09:00
ff96322c4f
Merge "Add tests for PAC proxies."
Jean Chalard   authored and   Gerrit Code Review   commited 2023-06-01 05:20:37 +00:00
5e76b40973
Matches all MdnsServiceTypeClient if using MdnsSocketClient
MdnsSocketClient doesn't support requesting specific network. As a
result, when processing the response, all the MdnsServiceTypeClient
should be called.

Bug: 285064577
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Id95f1e78d60063ccee7f5855a21fa6b5a48fbd3e

Yuyang Huang   commited 2023-05-31 15:39:08 +09:00
d72daab448
Merge "Add MdnsDiscoveryManager constructor without looper"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-30 10:24:27 +00:00
ae9b229b7e
Add MdnsDiscoveryManager constructor without looper
In some use cases for the MdnsDiscoveryManager, providing looper as an
argument to the MdnsDiscoveryManager constructor is not feasible. Adding
a constructor without looper can help to match those use cases. If
constructor without looper is used. The shutDown() must be called as a
part of cleanup process.

Bug: 283914408
Test: atest FrameworksNetTests
Change-Id: I0ab04d67bae127628c6d67c4b8c109201612a54b

Yuyang Huang   commited 2023-05-30 17:14:54 +09:00
243d1a5de4
Add tests for PAC proxies.
Test: this is a change that adds a test
Bug: 138810051
Bug: 140610528
Change-Id: I6e7b77320f6baf32ac2f98634fa2e3231d1bf12f

Aaron Huang   authored and   Chalard Jean   commited 2023-05-30 15:53:11 +09:00
40b524448c
Merge "Instrument SDK level and change IDs to help testing"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-05-30 02:10:05 +00:00
5cc9676d4c
Instrument SDK level and change IDs to help testing
This patch mocks the SDK level and/or change IDs to help
developing functionality that depends on these without
having to flash a new device every time.

Test: TH
Change-Id: I1011193c99e123a0e5501ed313c9cecbceebdae6

Chalard Jean   commited 2023-05-29 18:42:31 +09:00
df29a85ee7
Merge "Do not process null network packets on all clients"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-05-29 03:56:26 +00:00
f4cf2707e7
Merge "Only send to downstream ifaces for null network"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-05-29 03:56:20 +00:00
5a1c614e42
Merge "Use the ServiceTypeClient network for queries"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-05-29 03:56:12 +00:00
401ab44c36
Do not process null network packets on all clients
Packets received from the "null" networks are packets received from
tethering downstream interfaces. They should not be processed by all
MdnsServiceTypeClients; instead they should be processed by
the MdnsServiceTypeClient for the null network.

Bug: 283708537
Test: atest
Change-Id: Ifef59eca7a24bdfe3650067445d2565869dfa852

Remi NGUYEN VAN   commited 2023-05-24 16:37:13 +09:00
0ba206cbd1
Only send to downstream ifaces for null network
When sendMulticastPacket or sendUnicastPacket is called with the null
network, only send the packets to interfaces indexed with null, instead
of all interfaces.

When using MdnsMultinetworkSocketClient sending packets on the null
network means sending on tethered downstream interfaces. When
MdnsSocketClient is used (not used in the Android tree), sending on the
null network sends on all interfaces as MdnsSocketClient does not
support specific networks. This is clarified by explicitly throwing
when a non-null Network is attempted to be used with MdnsSocketClient
(but MdnsSocketClient is only used for tests in the Android tree).

Bug: 283708537
Test: atest
Change-Id: Ia0186bf8aa2e0fc5878d6071fd23599df8488616

Remi NGUYEN VAN   commited 2023-05-24 14:30:14 +09:00
87c374a37a
Merge "Cleanup VpnTest for unused methods/annotations"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-05-24 01:41:01 +00:00
3fabc1b0e0
Merge "Test for not logging meaningless caps changes"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-05-24 01:40:34 +00:00
b1f3dd9dd1
Cleanup VpnTest for unused methods/annotations
• Remove unused private methods
• Build files have this test in FrameworksNetTests, which
  by TEST_MAPPING is not run on T and below. It is not in
  the targets that do run on T and below like
  ConnectivityCoverageTest.

Test: VpnTest
Change-Id: I198e5b3571e34e41611f71d351501d3f98f78caa

Chalard Jean   commited 2023-05-23 18:30:05 +09:00
74732ba43d
Test for not logging meaningless caps changes
Test: this
Change-Id: Ife6500daae58b7f85a7f4c76cd89ce91def5e78c

Chalard Jean   commited 2023-05-23 18:30:04 +09:00
16e41d130c
Merge "Use "don't actively prefer" timeout when avoiding bad wifi"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-23 06:47:18 +00:00
7be7f06fc4
Use "don't actively prefer" timeout when avoiding bad wifi
Test: ConnectivityServiceTest
Change-Id: I6e99aff77c55805630d878e472f466bd31bba360

Chalard Jean   commited 2023-05-23 13:47:15 +09:00
6f6c353baf
Delete the LinkAddress in cache when RTM_DELADDR is received
The addOrUpdateInterfaceAddress() should be called when RTM_NEWADDR
message is received and the address isPreferred. The
deleteInterfaceAddress() should be called when RTM_DELADDR is called.

Bug: 282592527
Test: atest MdnsSocketProviderTest
Change-Id: I06a5940f53d01552f117309b1cc09256a2a9fae7

Yuyang Huang   commited 2023-05-22 17:17:27 +09:00
9d778c7fe7
Use the ServiceTypeClient network for queries
Instead of the network specified in the MdnsSearchOptions, which is
often null to request searching on all networks, use the
MdnsServiceTypeClient Network to build the queries.

When MdnsSearchOptions.network is null, one MdnsServiceTypeClient is
created for each mDNS-compatible Network. Each MdnsServiceTypeClient
schedules queries with a Network selector. If the Network selector is
null, each MdnsServiceTypeClient will post its queries to all networks.
Instead, it should be the Network of the MdnsServiceTypeClient.

There is one remaining problem when a tethered interface is up: in that
case, there will be one MdnsServiceTypeClient for tethered interfaces
with a null network, which will still broadcast its queries to all
networks. This should be addressed in a follow-up by having
MdnsMultinetworkSocketClient only send queries to interfaces that have a
null network, when the network selector is null (and not all
interfaces).

Bug: 283708537
Test: atest
Change-Id: If571d7a59c5e55d809eeb1f3d1c4b58684612cdd

Remi NGUYEN VAN   commited 2023-05-22 14:49:59 +09:00
404c1bf787
Merge "Revert ConnectivityServiceDependencies access modifier"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-05-18 05:54:32 +00:00
404636629a
Revert ConnectivityServiceDependencies access modifier
Address review comment on aosp/2490881

ConnectivityServiceDependencies was made public in aosp/2490881 to
verify destroyLiveTcpSockets call.
This CL reverts that change and updates tests to use mocked
DestroySocketsWrapper to verify destroy sockets call.

Bug: 270298713
Test: atest FrameworksNetTests
Change-Id: I101016399ea29bc5176b7559edf0447f0f7901ce

Motomu Utsumi   commited 2023-05-18 12:31:44 +09:00
d54120344d
Merge "Fix agents disconnecting in SUSPENDED state."
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-05-17 01:59:18 +00:00
ec4511c8aa
Merge "Check clatd does not stop when suspended network is disconnected"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-05-16 08:50:06 +00:00
d15b397606
Merge changes from topic "MdnsDM_running_on_looper_thread"
* changes:
  Pass NsdService thread looper to MdnsDiscoveryManager
  Ensure MdnsDiscoveryManager calls to ServiceTypeClients on looper thread

Paul Hu   authored and   Gerrit Code Review   commited 2023-05-16 08:46:13 +00:00
d0ebd7023f
Merge "Use case-insensitive matching in discovery/advertising"
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-05-16 07:56:21 +00:00
c61c5788fe
Fix agents disconnecting in SUSPENDED state.
Network state is not changed to disconnected when a networkagent
is disconnected and network state is SUSPENDED.

So the function requiresClat return true. Clat is not stoped.

Bug: 277682237
Test: atest FrameworksNetTests

Change-Id: I5edfcf64aca5d2d34325d722dd29fab41bcf2600

wangshengrjxtjcb   authored and   Motomu Utsumi   commited 2023-05-16 16:35:03 +09:00
fd5d3d90e1
Pass NsdService thread looper to MdnsDiscoveryManager
MdnsDiscoveryManager should use the same thread that create on
NsdService that is used on other mDns components. Thus, pass that
thread loop to MdnsDiscoveryManager.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: Icc23994c3ebc99da6043ed2d93540c44f53a150b

Paul Hu   commited 2023-05-16 14:39:09 +08:00
7f0af78c5e
Ensure MdnsDiscoveryManager calls to ServiceTypeClients on looper thread
ServiceTypeClients will store/access services on MdnsServiceCache
in subsequent changes. And MdnsServiceCache can be accessed from
looper thread only. So ensure MdnsDiscoveryManager calls to
ServiceTypeClients on the looper thread.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I05e73140da58c029b49057bb0ccfdb8ed7818dfc

Paul Hu   commited 2023-05-16 14:38:36 +08:00
bd4140ea91
Check clatd does not stop when suspended network is disconnected
Currently, clatd is not stopped when suspended network is disconnected
and aosp/2583410 fixes this issue.
This CL adds test for current behavior, aosp/2583410 can update
testDisconnectSuspendedNetworkStopClatd to call verifyClatdStop instead
of verifyNeverClatdStop

Test: atest FrameworksNetTests
Bug: 277682237
Change-Id: I345e097ce8e114800d77c5f44d38d7ae4938935c

Motomu Utsumi   commited 2023-05-16 12:32:52 +09:00
4a5b06559f
Use case-insensitive matching in discovery/advertising
mDNS is supposed to be case-insensitive (like DNS). Both advertising and
discovery logic should use case-insensitive matching instead of
case-sensitive matching.

The case sensitive matching can be found by grepping the String.equals()
and Arrays.equals() check across the whole code base. Each occurrence is
analyzed carefully to list up all necessary fixes.

Bug: 272194544
Test: atest FrameworksNetTests
Change-Id: I7c10878129663549c9171c1420b6f399930df2cb

Yuyang Huang   commited 2023-05-16 11:50:07 +09:00
73772f325d
Stop MdnsServiceTypeClient send on socket destroy
MdnsServiceTypeClient should stop sending when it is removed due to its
socket being destroyed.

On null networks (downstream interfaces) that may have multiple sockets,
this should only happen once the last socket used by the (null) network
has been destroyed.

Bug: 278635632
Test: atest
Change-Id: Ie1808840bd68678f2af7b71bdd8f3be377c14424

Remi NGUYEN VAN   commited 2023-05-16 10:45:36 +09:00
3d66b0432d
Do not send socket destroyed on unregistration
When a SocketCallback is unregistered from MdnsSocketProvider, do not
send socket destroyed callbacks. Callers may not expect getting
callbacks after unregistration, and the current callbacks are also
broken when an unrequested socket is still in use by another requester.

MdnsAdvertiser already does not depend on getting this callback, as it
only unregisters the SocketCallback after it is done using the socket.
This change fixes MdnsMultinetworkSocketClient to destroy the socket by
itself when unrequesting.

Bug: 276177548
Test: atest
Change-Id: If95f833e293f3aab91128aab1c9852ebfd41995d

Remi NGUYEN VAN   commited 2023-05-15 17:52:22 +09:00
5fe9bacc63
Merge "Do not immediately send new queries on cache hit"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-05-12 14:50:09 +00:00
4bcc151bf4
Merge changes I09e780af,I21367c66
* changes:
  Implement proper subtype advertising
  Implement proper discovery with subtypes

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-05-12 13:31:19 +00:00
94a4149a8f
Merge changes from topic "firewall_socket_destroy"
* changes:
  Close sockets from ConnectivityService#setFirewallChainEnabled
  Add test to verify socket close when firewall is enabled

Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-05-12 09:18:40 +00:00
179d18b3ad
Do not immediately send new queries on cache hit
If a listener request is fulfilled immediately from cache, do not
restart queries immediately, but just schedule the next run.

This avoids doubling the number of queries when discovery, then resolve
is requested.

Bug: 281793453
Test: atest
Change-Id: Ibe41ee20427068a1ccdbc1f04525988a89a58899

Remi NGUYEN VAN   commited 2023-05-12 16:23:28 +09:00
58bb0a129a
Implement proper subtype advertising
Implement subtype advertising by advertising an additional PTR record if
subtype advertising was requested.

For an advertiser a subtype is just an additional PTR record, so this
just involves plumbing the subtype down to MdnsRecordRepository, which
includes the additional record in the service registration.

Bug: 266167702
Test: atest
Change-Id: I09e780af25149162f16bd75410ddc50f160a0dab

Remi NGUYEN VAN   commited 2023-05-12 13:34:27 +09:00
ce44beb7aa
Implement proper discovery with subtypes
Apps may want to discover a particular subtype, such as
_color._sub._printer._tcp.local, which may return services like
Printer1._printer._tcp.local. The previous code was trying to discover,
and would return service types named _color._sub._printer._tcp.local,
even though the actual service type is still _printer._tcp.local. This
is a regression compared to S/T.

Fix this by passing the subtype to MdnsDiscoveryManager in its options
instead of the service type, and ensure that MdnsDiscoveryManager only
sends callbacks to callers that have requested the given subtype (a
color that asked for _color._sub._printer._tcp.local should not receive
BlackAndWhite._printer._tcp.local).

Bug: 266167702
Test: atest
Change-Id: I21367c66534078667718a9b54dfc858b12ba7103

Remi NGUYEN VAN   commited 2023-05-12 13:29:20 +09:00
f2d064112c
Ensure service type ends with a dot in discovery
Historical behavior of onServiceFound is to include a dot at the end of
the service type. To avoid inconsistencies between behavior of new and
older backend, which would be hard to predict/handle for apps, ensure
that the same format is used. This means a dot must be added when using
the new backend.

Implement this by creating the callback service types based on
MdnsServiceInfo obtained from MdnsDiscoveryManager, rather than the
service type that was provided by the calling app. This avoids
inconsistencies as the calling app may or may not include dots
originally, and it may use subtypes ("_sub._type._tcp.local" or even
"_type._tcp.local,_sub"), which would result in callbacks giving invalid
service types, or inconsistent with S/T behavior.

Fixes: 281776253
Test: atest
Change-Id: I677ee885d1ee8e6a09773f21e4dd53e96faee748

Remi NGUYEN VAN   commited 2023-05-12 10:35:36 +09:00
2f82fcdd6c
Merge "Remove the ServiceTypeClient after socket destroyed"
Paul Hu   authored and   Gerrit Code Review   commited 2023-05-11 11:50:57 +00:00
6f47b7d501
Remove the ServiceTypeClient after socket destroyed
The ServiceTypeClient should be removed after socket destroyed
because it's no longer used by any request. The requests will be
matched to the newly created ServiceTypeClient.

Bug: 278635632
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ia917b14d3666f3bfe8e874606a34800a4ce65c5a

Paul Hu   commited 2023-05-11 15:17:21 +08:00
f2a51ac5f8
Merge "Immediately create native networks when NetworkAgents register."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2023-05-11 03:35:21 +00:00
18cdec34dd