Skip to content

[network-diag] introduce RouterNeighborTlv - #12827

Merged
jwhui merged 1 commit into
openthread:mainfrom
abtink:netdiag/neighbor-tlv
Apr 4, 2026
Merged

[network-diag] introduce RouterNeighborTlv#12827
jwhui merged 1 commit into
openthread:mainfrom
abtink:netdiag/neighbor-tlv

Conversation

@abtink

@abtink abtink commented Apr 3, 2026

Copy link
Copy Markdown
Member

This commit updates RouterNeighborTlv to follow the SimpleTlvInfo pattern, separating the TLV value structure from its type/length header.

Specifically, it defines RouterNeighborTlvValue to hold the data fields for a router neighbor's diagnostic information, while RouterNeighborTlv is redefined as a SimpleTlvInfo using the value structure and the kRouterNeighbor type.

This allows the use of generic Tlv::Append<RouterNeighborTlv>() and tlvInfo.Read<RouterNeighborTlv>() methods, which are generally safer and allow value type reuse.

The NetworkDiagnostic and MeshDiag module are updated to utilize these new methods.

This commit updates `RouterNeighborTlv` to follow the `SimpleTlvInfo`
pattern, separating the TLV value structure from its type/length
header.

Specifically, it defines `RouterNeighborTlvValue` to hold the data
fields for a router neighbor's diagnostic information, while
`RouterNeighborTlv` is redefined as a `SimpleTlvInfo` using the value
structure and the `kRouterNeighbor` type.

This allows the use of generic `Tlv::Append<RouterNeighborTlv>()` and
`tlvInfo.Read<RouterNeighborTlv>()` methods,  which are generally
safer and allow value type reuse.

The `NetworkDiagnostic`  and `MeshDiag` module are updated to
utilize these new methods.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the RouterNeighborTlv implementation to adopt the standard SimpleTlvInfo pattern used across the codebase. By decoupling the TLV value structure from the type/length header, the changes improve code safety and maintainability while allowing for more consistent use of generic TLV handling utilities throughout the network diagnostic and mesh diagnostic modules.

Highlights

  • Refactoring RouterNeighborTlv: Updated RouterNeighborTlv to follow the SimpleTlvInfo pattern by separating the TLV value structure from its header.
  • API Improvements: Introduced RouterNeighborTlvValue to hold data fields, enabling the use of generic Tlv::Append and tlvInfo.Read methods for improved safety and reusability.
  • Module Updates: Updated NetworkDiagnostic and MeshDiag modules to utilize the new TLV structure and reading methods.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown

Merging #12827 into main

name branch text data bss total
ot-cli-ftd dab83c9 482784 860 66540 550184
67113d9 482768 860 66540 550168
+/- -16 +0 +0 -16
ot-ncp-ftd dab83c9 448676 764 61776 511216
67113d9 448676 764 61776 511216
+/- +0 +0 +0 +0
ot-cli-mtd dab83c9 374928 764 50972 426664
67113d9 374928 764 50972 426664
+/- +0 +0 +0 +0
ot-ncp-mtd dab83c9 356076 764 46240 403080
67113d9 356076 764 46240 403080
+/- +0 +0 +0 +0
ot-cli-ftd-br dab83c9 599128 864 136612 736604
67113d9 599112 864 136612 736588
+/- -16 +0 +0 -16
ot-rcp dab83c9 63328 568 20804 84700
67113d9 63328 568 20804 84700
+/- +0 +0 +0 +0
Library files
name branch text data bss total
libopenthread-ftd.a dab83c9 250649 95 40319 291063
67113d9 250635 95 40319 291049
+/- -14 +0 +0 -14
libopenthread-cli-ftd.a dab83c9 61750 0 8091 69841
67113d9 61750 0 8091 69841
+/- +0 +0 +0 +0
libopenthread-ncp-ftd.a dab83c9 33583 0 5948 39531
67113d9 33583 0 5948 39531
+/- +0 +0 +0 +0
libopenthread-mtd.a dab83c9 169022 0 24783 193805
67113d9 169022 0 24783 193805
+/- +0 +0 +0 +0
libopenthread-cli-mtd.a dab83c9 41459 0 8059 49518
67113d9 41459 0 8059 49518
+/- +0 +0 +0 +0
libopenthread-ncp-mtd.a dab83c9 25807 0 5948 31755
67113d9 25807 0 5948 31755
+/- +0 +0 +0 +0
libopenthread-ftd-br.a dab83c9 367774 99 110351 478224
67113d9 367760 99 110351 478210
+/- -14 +0 +0 -14
libopenthread-cli-ftd-br.a dab83c9 80957 0 8131 89088
67113d9 80957 0 8131 89088
+/- +0 +0 +0 +0
libopenthread-rcp.a dab83c9 9946 0 5060 15006
67113d9 9946 0 5060 15006
+/- +0 +0 +0 +0
libopenthread-radio.a dab83c9 19725 0 238 19963
67113d9 19725 0 238 19963
+/- +0 +0 +0 +0

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the RouterNeighborTlv implementation by introducing RouterNeighborTlvValue and utilizing the SimpleTlvInfo template. These changes simplify TLV appending and reading operations across the network diagnostic and mesh diagnostic modules. Feedback was provided regarding a potential regression in forward compatibility: the new implementation uses a strict length check when reading the TLV, whereas the previous code allowed for a minimum length, which is safer if the protocol is extended in the future.

Comment thread src/core/utils/mesh_diag.cpp
@codecov

codecov Bot commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.57%. Comparing base (dab83c9) to head (7934981).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/core/thread/network_diagnostic.cpp 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12827      +/-   ##
==========================================
- Coverage   75.56%   74.57%   -1.00%     
==========================================
  Files         694      696       +2     
  Lines       95495    95483      -12     
==========================================
- Hits        72165    71205     -960     
- Misses      23330    24278     +948     
Files with missing lines Coverage Δ
src/core/thread/network_diagnostic_tlvs.cpp 81.75% <100.00%> (-0.27%) ⬇️
src/core/thread/network_diagnostic_tlvs.hpp 97.67% <ø> (ø)
src/core/utils/mesh_diag.cpp 85.22% <100.00%> (-0.06%) ⬇️
src/core/utils/mesh_diag.hpp 50.00% <ø> (ø)
src/core/thread/network_diagnostic.cpp 67.87% <50.00%> (-10.77%) ⬇️

... and 217 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abtink
abtink marked this pull request as ready for review April 3, 2026 19:49
@jwhui
jwhui merged commit 9f28df1 into openthread:main Apr 4, 2026
110 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants