Commit graph android_packages_modules_Co.../staticlibs/tests
Message SHA1
Use helper function getIndexForValue in MulticastRoutingCoordinator.
The SparseArray.indexOfValue() uses == to compare values,
MulticastRoutingCoordinator uses SparseArray with String type values,
and the indexOfValue function would sometimes return -1 when looking for
a value in the SparseArray.

Added a helper function getIndexForValue in CollectionUtils to get index
by comparing values with equals, and used this function in MulticastRoutingCoordinator.

Updated
MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc
test case to use copies of interface names when updating the multicast
configs, so the test would fail without this fix.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.CollectionUtilsTest#testGetIndexForValue
atest android.net.connectivity.com.android.server.connectivity.MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc

Change-Id: I862242d6be01b8552cdd6af6c9691948a9f0bfe0

Yang Sun   commited 2024-04-23 17:22:15 +08:00
4e7baadc71
Improve the nduser option log readability.
Before:
Nduseroptmsg(10, 40, 48, 134, 0, fe80::2a00:79e1🔤f605%wlan0)

after:
Nduseroptmsg(family:10, opts_len:40, ifindex:48, icmp_type:134, icmp_code:0, srcaddr: fe80::2a00:79e1🔤f605%wlan1, NdOptRdnss(type: 25, length: 5, reserved: 0, lifetime: 1209600,servers:[2001:4860:4860::6464,2001:4860:4860::64]))

Bug: 315069348
Test: TH
Change-Id: I3abfbecd53a8cc00eaed9cbac1d9fe187d265847

Xiao Ma   commited 2024-04-05 18:25:54 +09:00
6fc458350a
Merge changes Ie882a5c7,Id94b6538,I58eda41f into main
* changes:
  Support prefix information option parsing in nduser netlink message.
  Add PrefixInformation option struct to parse nduser option.
  Create IpPrefix in PrefixInformationOption constructor

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-04-01 18:41:53 +00:00
da9dfa2207
Add PrefixInformation option struct to parse nduser option.
This is helpful for user space to get the PIO option via netlink message
and check whether the P flag is set or not, this bit flag determines if
we should start DHCPv6 PD process for IPv6 provisioning.

Bug: 315069348
Test: atest NetworkStaticLibTests
Change-Id: Id94b6538c5d88fe43c262ab23c30ccd53c766a62

Xiao Ma   commited 2024-04-01 16:05:59 +09:00
e20dc5ae89
Add isFeatureEnabled API for CaptivePortalLogin experiment namespace.
Bug: 329361366
Test: atest NetworkStaticLibTests
Change-Id: I3421f04bdace03221a3d6bde27da1d2ffd61e789

Xiao Ma   commited 2024-03-28 08:35:08 +00:00
12f7fd26af
Separate Struct.java into its own lib.
* Struct.java is removed from net-utils-device-common-bpf and
  net-utils-device-common-struct's source list
* Created a lib net-utils-device-common-struct-base for Struct.java
* Updated libs that require Struct.java to include
  net-utils-device-common-struct-base.
* Replaced net-utils-multicast-forwarding-structs with
  net-utils-device-common-struct in service-connectivity

Bug: 323503345

Test: build tethering module.
Change-Id: I3f60715c3d8043b7569db7612dee9d4fa1ccba59

Yang Sun   commited 2024-03-27 20:15:17 +08:00
3aa62e6773
Add IPv6 FragmentHeader struct support
Bug: 285124667
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.structs.FragmentHeaderTest
Change-Id: I90c8a52daa35589977333494355ac239ea057204

KH Shi   commited 2024-03-06 05:05:13 +00:00
f8c7d15850
Merge "Revert "Add method to read trunk stable flag"" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-02-08 10:37:09 +00:00
6de59fa208
Revert "Add method to read trunk stable flag"
This reverts commit b0f489021b.

Reason for revert: Currently reading trunk stable flag from mainline module is not supported. So reverting the CL to avoid confusion.

Change-Id: I0db04f28f378399aa299b325312a6af7f45d4f67

Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-02-08 03:06:34 +00:00
4919dcce94
Prepare for @RequiresApi class retention
The android framework has android.annotation.RequiresApi, which is a
copy of androidx.annotation.RequiresApi. However it was added with
source retention instead of class retention like androidx's version
has. This causes it to be missed if you compiled a library and then
used that library to compile something else, that library's public
methods won't have @RequiresApi on them when using that library's
compiled jar file.

To make @RequiresApi have class retention, we need to baseline the
NewApi issues that it would cause. These baselines also require
us to disable strict_updatability_linting in some places.

Bug: 323366771
Test: m lint-check
Change-Id: I0c984e3ba39e357ce102be442568f2d77a4f9034

Cole Faust   commited 2024-02-02 12:04:05 -08:00
53da9ac34c
Merge "Rename check*Permission* to has*Permission" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-02-02 07:07:31 +00:00
ef58a8a33a
Rename check*Permission* to has*Permission
The check*Permission methods are a bit error-prone because people
can forget to check the return value and expect that they behave
like the enforce* methods. This was pointed out before in some bugs.

This change adds @CheckResult annotation to enforce linter warning
and rename methods accordingly.

Test: TH
Fix: 279691948
Change-Id: Ibb0df6540fe0ed40289bb190b790130daaa2f763

Junyu Lai   commited 2024-02-01 15:24:35 +08:00
71b5153898
Add netlinkSocketForProto() without buffersize.
Test: atest NetworkStaticLibTests
atest FrameworksNetTests

Change-Id: I34a0a29eb7e78490701872229585e61f7a0c1dd3

Yang Sun   commited 2024-02-01 09:50:52 +08:00
1d8b7cc422
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
Merge "Pass buffer size to NetlinkUtils.netlinkSocketForProto" into main
Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2024-01-31 01:42:49 +00:00
2cb28ea360
Pass buffer size to NetlinkUtils.netlinkSocketForProto
Pass buffer size to netlinkSocketForProto to allow callers to specify
buffer size. The buffer size is not set if 0 is passed in.

Following callers of netlinkSocketForProto passes SOCKET_RECV_BUFFERSIZE
to keep same behavior as before:
 * OffloadHardwareInterface.createConntrackSocket()
 * NetlinkUtils.sendOneShotKernelMessage()
 * IpSecXfrmController.Dependencies.newNetlinkSocket()
 * InetDiagMessage.getConnectionOwnerUid()
Following callers pass 0 to not update the buffer size:
 * TunInterfaceController - it uses the socket only for writing
 * NetlinkUtils.createNetLinkInetDiagSocket() same behavior as before
Added a SOCKET_DUMP_RECV_BUFFERSIZE of 128k to be used by socket
requesting dump information from kernel:
 * NetlinkUtils.getAndProcessNetlinkDumpMessages() - sends dump request
   and expecting multiple reply messages.

Bug: 320420453

Test: atest NetworkStaticLibTests
atest FrameworksNetTests

Change-Id: I3dcb76963cf2646eb311602b50ab4e44b8ad3e8f

Yang Sun   commited 2024-01-30 21:54:48 +08:00
7934241c8f
Support adding an IPv4 address via RTM_NEWADDR netlink message.
Usually we can call InterfaceController.setIPv4Address API to add an
IPv4 address on the interface, in fact it ends up calling the native
Netd API which doesn't support setting deprecation/expiration time. In
user space we already have the netlink infra to send RTM_NEWADDR for
IPv6 address, extend the function to support IPv4 as well, then we can
deprecate the Netd API in IpClient.

Bug: 129660498
Test: atest NetworkStaticLibTests
Change-Id: I9fc7ba8d7035e0ed1df8c1f2baef9ec7e1806be3

Xiao Ma   commited 2024-01-26 05:40:34 +00:00
a3d165e814
Merge "Parse destination and source mac address of ARP packet." into main
Xiao Ma   authored and   Gerrit Code Review   commited 2024-01-22 06:22:46 +00:00
94192b136b
Add helper method to enfore a package name belongs to an uid
This is no-op refactor to move utility methods from
ConnectivityService to a common place.

Test: atest NetworkStaticLibTests#com.android.net.moduletests.util.PermissionUtilsTest#testEnforcePackageNameMatchesUid
Bug: N/A
Change-Id: I5802dedcc91fa6e130a5c534bba5080ca37dbeec

Junyu Lai   commited 2024-01-18 11:26:55 +08:00
8fdc4318c7
Parse destination and source mac address of ARP packet.
This can be used in the integration test to assert if an ARP packet
captured on the tap interface is broadcast or unicast request.

Bug: 315076572
Test: atest NetworkStaticLibTests
Change-Id: I52c0b18bf3fd2b64727912e54c045a8e8405d2f6

Xiao Ma   commited 2024-01-17 23:43:11 +09:00
0f7f901c87
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
Merge changes I71545bee,Ic26cddab,I57b36e66,I71367761,I07e7aa8c into main
* changes:
  Use NetlinkUtil to process dump messages in InetDiagMessage.
  Add mif6ctl struct definition.
  Add mf6cctl struct definition.
  Add Mrt6Msg struct for multicast routing support.
  Add support to dump all multicast routes in NetlinkUtils

Yang Sun   authored and   Gerrit Code Review   commited 2023-12-25 03:19:12 +00:00
907c6e377b
Merge "Add netlink attributes field into the InetDiagMessage" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-12-25 03:09:42 +00:00
504f6d6c90
Add netlink attributes field into the InetDiagMessage
Add nlAttrs parameter to store the remaining attributes data.

As a part of follow-up work from aosp/2354202, the TCP socket
parsing can be done by using existing InetDiagMessage class.
The missing piece in the InetDiagMessage class is the possible
netlink attributes fields that may be appended after an
InetDiagMessage.

Bug: 311119352
Bug: 265877161
Test: atest NetworkStaticLibTests
Change-Id: I9c34166124fd4efba2ab211bfb537ccce5e774a4

Chiachang Wang   commited 2023-12-25 01:40:13 +00:00
4fc3f4fa15
Add mif6ctl struct definition.
This is used to configure interfaces for multicast routing.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.structs.StructMif6ctlTest
Change-Id: Ic26cddab2d5a9f90f63b0828c3e133d830aa0db4

Yang Sun   commited 2023-12-22 18:51:27 +08:00
03e3ceaab1
Add mf6cctl struct definition.
This is used to configure multicast routes.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.structs.StructMf6cctlTest
Change-Id: I57b36e6678262f48781b70ab77d49b920c7ddca2

Yang Sun   commited 2023-12-22 18:51:15 +08:00
15d4e023f7
Add Mrt6Msg struct for multicast routing support.
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.structs.StructMrt6MsgTest
Change-Id: I71367761662117aa6c0af3153039e50266d79259

Yang Sun   commited 2023-12-22 18:05:40 +08:00
50b4fd79fa
Add support to dump all multicast routes in NetlinkUtils
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.NetlinkUtilsTest
Change-Id: I07e7aa8ce677dafb94891c8075f8822dadcfd6d1

Yang Sun   commited 2023-12-21 10:06:33 +08:00
3ee59057b7
Add getRtmFamily for RtNetlinkRouteMessage
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.RtNetlinkRouteMessageTest
Change-Id: Ifdf5afc4f58ff55bd20cc60e23b17c3138754392

Yang Sun   commited 2023-12-17 17:34:39 +08:00
6000558538
Add support for multicast route in RtNetlinkRouteMessage
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.RtNetlinkRouteMessageTest
Change-Id: I2f3d69a5bda81de65e4a36e0db61d98dcf082b2d

Yang Sun   commited 2023-12-17 17:31:00 +08:00
08622b8ecb
Add support for long values in StructNlAttr
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.StructNlAttrTest
Change-Id: Iaaa7f63a2b550f017a8c75f84b9d69bf9e829a8c

Yang Sun   commited 2023-12-16 21:58:15 +08:00
d4195824ab
Add support for processing netlink dump messages
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.NetlinkUtilsTest
Change-Id: I15e208dca5ed6a723585f79cf09276017bc8a885

Yang Sun   commited 2023-12-16 21:58:07 +08:00
0b2d75c09a
Merge changes I395560fb,If6abc33c into main
* changes:
  Add support for NLM_F_DUMP request in StructNLMsgHdr
  Mark NetworkStaticLibTestsLib as test for lint

Yang Sun   authored and   Gerrit Code Review   commited 2023-12-12 12:46:55 +00:00
336f3c1084
Add support for NLM_F_DUMP request in StructNLMsgHdr
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink.StructNlMsgHdrTest
Change-Id: I395560fb1edfb1c806b2ed4c74a7a3081c7b2515

Yang Sun   commited 2023-12-09 20:03:43 +08:00
9ea3be13fc
Mark NetworkStaticLibTestsLib as test for lint
This can avoid VisibleForTesting warnings in tests.

Test: atest NetworkStaticLibTests
Change-Id: If6abc33cf266246aeac22ff4b53cfba386c8979f

Yang Sun   commited 2023-12-06 19:57:29 +08:00
d5c0276b34
[XFRM_MSG_NEWSA] Support xfrm_replay_state_esn and XFRM_MSG_NEWSA
Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: I4c21a64c634b1814d52ce81a48abe2550876b755

Yan Yan   commited 2023-12-05 10:49:16 -08:00
0a892e6ec2
[XFRM_MSG_NEWSA] Support xfrm_stats and xfrm_usersa_info
Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: I8641cf36a790d7b15fbe41b4da328c1d91fcec1e

Yan Yan   commited 2023-12-05 10:36:09 -08:00
c9a194c44b
Merge "Update registerOffloadEngine() permission check" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-11-30 05:57:02 +00:00
4c969a65ae
Update registerOffloadEngine() permission check
Update registerOffloadEngine() permission check to check the
DEVICE_POWER permission in U. This change is required to allow the
android TV device to access the API in U because the
REGISTER_NSD_OFFLOAD_ENGINE permission can not be backported.

Bug: 313546516
Test: TH
Change-Id: I84b80d102a34487ad54719a86eb525b319e2fd8b

Yuyang Huang   commited 2023-11-29 13:38:40 +09:00
d5896e7721
Fix StructXfrmLifetimeCurTest failure when default timezone is not GMT
Previously the calculation of the expected ADD_TIME implicitly depended
on the default timezone of the test device and thus might have
different values and cause test failures. This fix updates the test to
always use "GMT" to generate the ADD_TIME

Bug: 308011229
Test: StructXfrmLifetimeCurTest passing with default timezone being
      GMT, GMT-6, GMT-10
Change-Id: Ib88a253c1ecb09feeb298a04b847c4105651a710

Yan Yan   commited 2023-11-29 00:15:07 +00:00
17b7a74041
Merge changes Ibd38e3c0,I0e9f52aa into main
* changes:
  [XFRM_MSG_NEWSA] Support xfrm_lifetime_cfg and xfrm_lifetime_cur
  [XFRM_MSG_NEWSA] Support xfrm_selector and xfrm_id

Yan Yan   authored and   Gerrit Code Review   commited 2023-11-28 22:51:44 +00:00
7475acf7e2
Update bug component in xfrm folder OWNER file.
Change the component number to 685852 which is used for IpSec. and also
add OWNER file for xfrm unit test folder.

Test: TH
Change-Id: I2359d6d8c6b3916ce36fdbcc1f487896efb0dccb

Xiao Ma   commited 2023-11-28 11:54:41 +09:00
9224b1019a
[XFRM_MSG_NEWSA] Support xfrm_lifetime_cfg and xfrm_lifetime_cur
Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: Ibd38e3c0036c760f6397910162054cfb02e45059

Yan Yan   commited 2023-11-27 12:10:59 -08:00
7a82062499
[XFRM_MSG_NEWSA] Support xfrm_selector and xfrm_id
Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: I0e9f52aad8e9cb72b8bbac1f9ee9f8e53d939e47

Yan Yan   commited 2023-11-27 12:10:52 -08:00
97ea643797
[XFRM_MSG_GETSA] Support XFRM_MSG_GETSA message
Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: I42e423c09ffb733a809636360468c963c7864872

Yan Yan   commited 2023-11-27 12:10:46 -08:00
c5e280590a
[XFRM_MSG_GETSA] Fix the class names and code locations
- Change class names to start with Xfrm or StructXfrm for consistency
  with other messages and structs
- Create xfrm sub-folder for xfrm messages
- Add "finals" to input parameters

Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: Id6d34b4549bbc1890b3f4dd9f1638977f66e3236

Yan Yan   commited 2023-11-21 19:21:32 +00:00
f085fadfdc
[XFRM_MSG_GETSA] Support xfrm_address_t and xfrm_usersa_id
Add xfrm_address_t and xfrm_usersa_id structs

Bug: 308011229
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.netlink
      (new tests added)
Change-Id: I552983d7e768e7fb8ba307ffc55060c8b35e7436

Yan Yan   commited 2023-11-16 21:46:43 +00:00
1c363601a1
Test: A minor fix for testDnsSvcbRecord_svcParamMandatory
As per draft-ietf-dnsop-svcb-https-12.html#name-mandatory, the
values in SvcParamKey "mandatory" can appear in any order

Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: Idc347bcefd7a53323f2b380fba612926b2838e65

Mike Yu   commited 2023-11-13 02:52:23 +00:00
0b1574d863
Add tests for DnsSvcbRecord and DnsSvcbPacket
This change adds the test coverage for DnsSvcbRecord
and DnsSvcbPacket.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: I0b6328337fd61c5ac2e5f6b3737238f7d678245a

Mike Yu   commited 2023-11-09 02:14:29 +00:00
f5032571a8
Add DnsSvcbRecord
This change is an initial implementation of DNS SVCB Record. It
can parse an SVCB Record in wire format.

The RDATA field of a SVCB Record is formatted as follows:
- SvcPriority: 2-byte field
- TargetName: a domain name that follows RFC1035 section 5.1
- SvcParams (optional): a list of SvcParam

This initial implementation focuses on the SvcParams related to DDR,
including alpn, port, ipv4hint, ipv6hint, and dohpath. For the other
SvcParams, such as mandatory and ech, this change doesn't check
whether their value is valid.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Test: No test for DnsSvcbRecord for now. will add some tests in a
      follow-up change
Change-Id: Icfe9b623eda8390c40b106123a718cdd2af3af99

Mike Yu   commited 2023-11-09 02:14:29 +00:00
9b96c83238