Commit Graph

898 Commits

Author SHA1 Message Date
Motomu Utsumi
ffa6d6152b Remove unnecessary check for skDestroyListener
skDestroyListener is always running with Java code so removed the
unnecessary check.

Bug: 217624062
Test: TH

Change-Id: Ie1a36c3c736005ec4821c5e9c9983998f7042afa
2023-11-07 20:25:28 +09:00
Ryan Zuklie
ac871ada08 Merge "Report sparse per-iface stats using atrace." into main 2023-11-02 20:40:00 +00:00
Ryan Zuklie
f5fc2e3403 Report sparse per-iface stats using atrace.
This reports the total bytes sent and received per interface using
atrace. The totals are taken from the interface counters, rather than
the ringbuffer, since the ring buffer can run out of space.

Interfaces are only reported for interfaces which have packets
sent on them as identified by Nettrace. This helps reduce the cost
significantly for idle periods and on devices with a large number of
interfaces accumulated in the iface stats maps.

Test: TreeHugger
Change-Id: I0e6a3b11de0d1e153b9f8ebb97c338f425381a9c
2023-11-02 10:24:05 -07:00
Junyu Lai
2deeef4f5e Merge "Fix NetworkStatsObersers thread leak in the NetworkStatsServiceTest" into main 2023-11-01 10:18:50 +00:00
Junyu Lai
8b5ebfc342 Fix NetworkStatsObersers thread leak in the NetworkStatsServiceTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
     (with debug code that dump all threads at the end of tests)
Fix: 308544001
Change-Id: I597054633bbb008ffd0edebe34dcf6935958aa5d
2023-11-01 17:11:17 +08:00
Paul Hu
a6307ea9f1 Merge "Remove DefaultState in NsdService" into main 2023-11-01 03:40:37 +00:00
Yuyang Huang
81877c4153 Code cleanup in MdnsInterfaceAdvertiser, MdnsReplySender, MdnsUtils
* Update getRawOffloadPayload() with @NonNull annotation.
* Log the error object directly instead of logging the error message.
* Use Arrays.copyOfRange() instead of System.arraycopy().
* Remove the unnecessary escape of mPacketCreationBuffer member variable in MdnsReplySender.

Bug: 308079421
Test: TH
Change-Id: I8c805bfe1fc1ae1d9a8abfab498059bda05710ff
2023-10-31 13:02:39 +09:00
Paul Hu
77c1118e1c Remove DefaultState in NsdService
The code handling service registration, discovery, and resolution
in DefaultState is never executed because these messages are
always handled in EnabledState. Therefore, the active code in
DefaultState should be moved to EnabledState and DefaultState
should be removed.

Bug: 307209858
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I38a255ddf72148c7ae13d3079dbd3c03f800b9c2
2023-10-27 17:14:05 +08:00
Junyu Lai
41b37349f3 Support NetworkStatsEventLogger
The performPoll method in the NetworkStatsService can be called
for many reasons, such as RAT changed events, LinkProperties
changed events, open session method calls, forceUpdate method
calls, etc.
However, the current logging is not sufficient to trace down
the caller of performPoll. This makes it difficult to debug
frequent poll issues or performance problems.

Adding debug log to logcat is not an option, given that
performPoll might run several times per second by system server
callers.

This change adds a reason code to the performPoll method and
a helper class to log performPoll events. This will allow us
to track down the caller of performPoll and better understand
why it is being called frequently or causing performance
problems.

This change also introduces a PollEvent object, which can be
used to put related information in subsequent changes when
logging.

Sample output:
Poll counts per reason:
  DUMPSYS: 0
  FORCE_UPDATE: 6
  GLOBAL_ALERT: 0
  NETWORK_STATUS_CHANGED: 3
  OPEN_SESSION: 0
  PERIODIC: 1
  RAT_CHANGED: 1
  REG_CALLBACK: 3
  REMOVE_UIDS: 0
  UPSTREAM_CHANGED: 1

Recent poll events:
  2023-10-04T02:47:12.937370 - Poll(flags=3, PollEvent{reason=REG_CALLBACK})
  2023-10-04T02:47:13.178559 - Poll(flags=3, PollEvent{reason=FORCE_UPDATE})

Test: manual
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsEventLoggerTest
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: 301141955
Change-Id: Ic6d0543ccdef12493385f45200199854b841a26b
2023-10-25 19:23:35 +08:00
Junyu Lai
8f6df28f50 Merge "Add synchronized block when accessing global variables" into main 2023-10-20 06:06:37 +00:00
Paul Hu
f3fe3333d3 Add expired services removal flag
The TTL check and removal of expired services is currently only
performed when a mDNS query is sent. This can result in expired
services remaining in the cache if no queries are sent. To
address this, the remaining TTL will be checked when retrieving
services from the MdnsServiceCache. Add a new flag to enable
the expired services removal feature. This feature will be
implemented in subsequent changes.

Bug: 265787401
Bug: 304649384
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I30f0eea568ee45d363cc02821de0921d6040f981
2023-10-18 17:48:46 +08:00
Junyu Lai
6d0bdd197a Add synchronized block when accessing global variables
This is catched by errorprone where global variables accessing
is not protected by the declared lock, which could lead to a
potiential race problem where these variables are changed but
cannot be seen for the invocation.

This is also safe since:
  1. The method called inside mDefaultNetworks is already holding
     the same lock.
  2. Multiple global variables are protected by this synchronized
     block.

Test: TH
Fix: 181642673
Change-Id: I58e7f124de1f0291e9323ab0b9cf8f52cec32818
2023-10-17 15:03:17 +08:00
Paul Hu
4479bd9f27 Merge "Include A/AAAA records in probing packet" into main 2023-10-17 02:24:10 +00:00
Paul Hu
1eeeb15f2e Merge "Add ServiceExpiredCallback" into main 2023-10-16 01:41:49 +00:00
Paul Hu
d4dcb4bee8 Add ServiceExpiredCallback
This is a no-op change and refactors the design for subsequent
TTL expiration check changes.
- Add a ServiceExpiredCallback to notify expired services.
- To simplify the design, pass the CacheKey to MdnsServiceCache
  methods instead.

Bug: 265787401
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I930a4f7baf9b8d3d0037dc6aefd717dbdd486520
2023-10-13 16:45:31 +08:00
Patrick Rohr
9b2a0d1962 Merge "Include both eth%d and usb%d ethernet interfaces on U+" into main 2023-10-12 17:28:34 +00:00
Patrick Rohr
11eac8e12b Include both eth%d and usb%d ethernet interfaces on U+
Ethernet interface naming is not consistent on Linux. While some USB
ethernet dongles show up as eth0, others might show up as usb0.

This CL changes config_ethernet_iface_regex to "*" which stands for "use
Android version specific default". The default will include both usb\d+
and eth%d named interfaces on Android U+. Android T will continue to
only include eth%d interfaces (note that the "+" is a new addition which
is highly unlikely to have any actual effect, but is more technically
correct).

Bug: 304335605
Test: TH
Change-Id: I823be8ee390cb2b6dd41b537c72ed76f5aa9e0ea
2023-10-12 10:26:47 -07:00
Kangping Dong
4a8977c452 Merge "[mdns] exclude mDNS advertiser code from standalone build test" into main 2023-10-08 12:21:24 +00:00
Kangping Dong
1a1beee654 [mdns] exclude mDNS advertiser code from standalone build test
service-connectivity-mdns-standalone-build-test builds the mDNS
discovery and advertisement implementation against API level 21.
This stops the advertisement code from calling new NsdServiceInfo
public or private APIs which are required by Thread.

This commit removes the mDNS advertisement code from the standalone
build to loose the check given this will never be used by GMS Core.

Bug: 265095929
Test: verified that it can build with aosp/2608627
Change-Id: I32cfce7b994d51a4b4ec468e9f79ffc2be6635ff
2023-10-08 17:22:14 +08:00
Paul Hu
87d128f43d Merge "Store transaction id in MdnsPacket" into main 2023-10-06 05:51:33 +00:00
Xin Li
5a3517e5cd Merge "Merge Android 14" into main 2023-10-06 05:34:16 +00:00
Paul Hu
f286ed5be1 Include A/AAAA records in probing packet
Per RFC6762#8.1, a host can simultaneously probe for uniqueness
of its "A" record and all its SRV records [RFC6763] in the same
query message. Add a flag to include the A/AAAA records in the
probing packet if necessary.

Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I365a938a6c481df755a0598b175069b94905fa3b
2023-10-05 14:14:56 +08:00
Spandan Das
551bb1ea71 Drop path property from cpp filegroup modules
The value of `path` here should be a no-op in Soong's cpp compile
action. Dropping this property helps bazel migration since Bazel's
filegroup rule does not have a path property.

Test: m libnetworkstatsfactorytestjni libservice-connectivity
Bug: 297405814

Change-Id: I7879224bf6deb12417d92e9a3fa52f58fccac999
2023-10-04 23:18:46 +00:00
Treehugger Robot
abb723ab5e Merge "Remove debug only restrictions to network tracing" into main am: 06c8691fe0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2768925

Change-Id: I3a5de68794272cd076d8ab7f90b7c8659c2d2ab9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-30 05:10:03 +00:00
Ryan Zuklie
9fb8f18c1b Remove debug only restrictions to network tracing
Network tracing was only available on userdebug and eng builds. This
change makes it available on all build types behind a flag.

Bug: 298197881
Test: flash & trace, toggle flag on/off
Change-Id: I75d854aee74adf7e23f7a970b20233790f9b0354
2023-09-29 16:52:11 -07:00
Maciej Żenczykowski
e758463ffe Merge "reverse BpfMap & BpfMapRO inheritence to make sense" into main am: d58042e0d4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2767825

Change-Id: Ibb59b151e9f6c69b940920203bc3de4a50d6855d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-29 03:59:04 +00:00
Motomu Utsumi
ac3f145c63 Merge "Update the logic of isFeatureEnabled and isFeatureNotChickenedOut" into main am: 241e110c6c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2749983

Change-Id: I62002804d1627b4ccae6a5fafe17e78efe45c7db
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-29 03:58:47 +00:00
Maciej Żenczykowski
d58042e0d4 Merge "reverse BpfMap & BpfMapRO inheritence to make sense" into main 2023-09-29 03:24:37 +00:00
Maciej Żenczykowski
7e2f53e762 reverse BpfMap & BpfMapRO inheritence to make sense
Bug: 235590615
Bug: 235907076
Bug: 286003437
Test: TreeHugger, m droid gpuservice_unittest libtimeinstate_test bpf_benchmark bpf_module_test libbpf_load_test && mma
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I020a898fe8b257040a100f146654d4a04b19f843
2023-09-29 00:44:33 +00:00
Paul Hu
6df06daaec Store transaction id in MdnsPacket
The transaction id is a number that is used to identify a
specific query packet. But it's not necessary for probing
or announcing services, so the transaction id is not
currently used on advertising when creating a MdnsPacket or
decoding the response to a MdnsPacket. This means that it is not
possible to track which query packets have received
responses. Therefore, store the transaction id so that
it can be used for subsequent query packet changes.

Bug: 302269599
Test: atest FrameworksNetTests
Change-Id: I6734752b32b91678afb7df06e1fa51237cf70894
2023-09-27 18:20:28 +08:00
Motomu Utsumi
ed4e7ec954 Update the logic of isFeatureEnabled and isFeatureNotChickenedOut
If the flag value is unset or 0, isFeatureEnabled return false and
isFeatureNotChickenedOut return true.
If the flag value is -1 (force disable), both return false.
If the flag value is other values, both query the package version and
return `flagValue <= packageVersion`

Now the only difference is a default behavior when the flag is not set
or 0.
So isFeatureEnabled and isFeatureNotChickenedOut can use the same flag.

This CL also fixes the issue in rollback.
Before this CL, isFeatureNotChickenedOut did not check the module
version and could have a issue if there is a rollback.

Test: NetworkStaticLibsTests
Bug: 279108992
Change-Id: I12d6ebadff3aee7b7c614aca4eb0a34ef0db9857
2023-09-27 17:30:01 +09:00
Igor Zaslavsky
2d8debe62c Merge "Park RemoteAuth Manager and Service" into main am: f0afc53836
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2759205

Change-Id: I6e3f1ddf1d6c7f8e645a327f59e666851ccb4918
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-26 18:20:50 +00:00
Igor Zaslavsky
f0afc53836 Merge "Park RemoteAuth Manager and Service" into main 2023-09-26 17:17:29 +00:00
Ryan Zuklie
31f7fd8546 Merge changes Ic69fc75e,I6373d251 into main am: 8a88d85145
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2749654

Change-Id: I647baa696ac6e0f99aacb5de35148ad74f5a5498
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-22 20:50:11 +00:00
Igor Zaslavsky
e336586353 Park RemoteAuth Manager and Service
Limit the amount of parked code built into Connectivity module

Test: built successfully.
Bug: 300522527
Change-Id: I87d7516011c469aa89fc7e67cf03c4ee8aa1bb9b
2023-09-22 04:09:02 +00:00
Ryan Zuklie
e72b48416c Add ICMP type/code and udplite/sctp in Nettrace.
This adds support for additional protocols and also provides more clear
semantics of protocol specific fields, such as only including tcpFlags
when the protocol is IPPROTO_TCP.

Test: atest libnetworkstats_test & flash and trace
Change-Id: Ic69fc75e85ebf8734027c942a253af4972ad14d8
2023-09-21 15:14:07 -07:00
Ryan Zuklie
1733d3e6be Make BundleKey a distinct struct from PacketTrace.
This change refactors BundleKey to be a separate struct. This allows
us to do the conversion (e.g. of sport/dport, or icmp fields in the
future) in the constructor and change types (use optionals) where it
is convenient to simplify the code.

This change also fixes a bunch of desigated initializer order warnings
in the test (fields should be declared in same order as defined).

Test: atest libnetworkstats_test
Change-Id: I6373d2512280e93c54395fde38dcff43705b449e
2023-09-21 15:14:07 -07:00
Kangping Dong
e5f1122ec9 Merge "[Thread] initial Thread network service" into main am: 01e6dadd1f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2721333

Change-Id: I5b1dad9c40dcade78c352265164da0992a3fcb0d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-19 11:29:17 +00:00
Kangping Dong
01e6dadd1f Merge "[Thread] initial Thread network service" into main 2023-09-19 11:25:37 +00:00
Yuyang Huang
8992911f24 Merge "Add newApi linter check for mDNS library" into main am: 365cf0a393
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2718538

Change-Id: I6e392853943db3ff509bc25a4055367774e65cae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-13 06:17:54 +00:00
Yuyang Huang
365cf0a393 Merge "Add newApi linter check for mDNS library" into main 2023-09-13 05:55:51 +00:00
Treehugger Robot
ac88cd6df9 Merge "Add test for downstream tethering" into main am: dba0dbc7ec
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2606668

Change-Id: I251696b855e7f971ac740eb70fa86a4158f15c58
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-13 02:09:58 +00:00
Treehugger Robot
dba0dbc7ec Merge "Add test for downstream tethering" into main 2023-09-13 01:01:32 +00:00
Kangping Dong
1cec48f3c0 [Thread] initial Thread network service
This commit sets up the initial Thread network service for the
Android Thread feature which allows an Android device to create
a Thread network and being a Border Router.

See https://www.threadgroup.org/What-is-Thread for background of
Thread.

See b/235016403 for the Android Thread feature request.

Test: lunch aosp_cf_x86_64_tv-userdebug
      m && launch_cvd
      atest CtsThreadNetworkTestCases
Bug: 262683651
Change-Id: Ie1bb23084531f67165ec068ea3ca39592dbc01d1
2023-09-12 21:48:57 +08:00
Yuyang Huang
fc83170c70 Add newApi linter check for mDNS library
The mDNS library need to be backported to some internal library which
support minSdk 21. Therefore, updated the build rules to add the linter
check.

Bug: 296175311
Test: TH
Change-Id: Iae0bffa315dc6de2339a05f595b13480fa7385ae
2023-09-12 19:01:21 +09:00
Yuyang Huang
fca402abed Add test for downstream tethering
Add end-to-end testing for testing NsdManager advertising and
discovering works fine with downstream tethering interfaces.

Bug: 281639507
Test: atest NsdManagerTest
Change-Id: I5a66423f216cfe0c82db5128502c885980ab264b
2023-09-12 17:53:37 +09:00
Paul Hu
f5ee683cbd Merge "Correct isLegacy metric data" into main am: 046b0c1c82
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2745877

Change-Id: Icd79d1af11839f6ddaa914a86843540418b29b92
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-12 08:52:09 +00:00
Paul Hu
508a012b2e Correct isLegacy metric data
The isLegacy field of Nsd metrics should indicate whether the
data was collected from the old backend or not. However, it is
currently only dependent on the ENABLE_PLATFORM_MDNS_BACKEND
compat change value, which is incorrect. This is because the
NsdService always uses the new backend since Android U,
regardless of the compat change value. Therefore, the isLegacy
data should be obtained from each transaction.

Bug: 287546772
Bug: 299880473
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I156abd656b90578d710696a69ccf7dfca97a2c9c
2023-09-12 01:20:00 +00:00
Yuyang Huang
4596ba4bd1 Handle closed socket and NPE properly am: 8f4adaedaf
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2745875

Change-Id: Ie1b5efb699c37314394f85ca04696f748343361f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-11 06:51:52 +00:00
Yuyang Huang
8f4adaedaf Handle closed socket and NPE properly
Don't get interfaceIndex if the socket is closed. Properly catch NPE
instead of letting is propagating.

Test: TH
Change-Id: If962541e67dd6323426e46bc7a1f118786f83b9b
2023-09-11 13:10:05 +09:00