Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Mesh: Adding Mesh 1.1 Subnet Bridge #78400

Merged
merged 25 commits into from
Sep 17, 2024

Conversation

Balaklaka
Copy link
Collaborator

Adding the Mesh Protocol v1.1 functionality for the Subnet Bridge functionality.
This PR contain:

  • Bridge Configuration Client and Server with API descriptions, implementation and documentation.
  • Subnet bridge documentation
  • There is both unit tests and bsim test added for the Bridge Configuration Client and Server.
  • There is added mesh_shell commands for the Bridge Configuration Client.
  • There is added PTS support for the Subnet bridge, Bridge Configuration Client and Server to the tester, and the PTS tests are passing.

Signed-off-by: Ingar Kulbrandstad ingar.kulbrandstad@nordicsemi.no
Fixes #74961

Balaklaka and others added 24 commits September 13, 2024 14:40
Adding documentation and function calles for the API's
in Bridge Configuration Client model and Bridge
Configuration Server model.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
The `brg_cfg` module implements the states needed for subnet bridge
feature. It provides two states - enable state, and bridging table
state. APIs are provided to access and modify the states. The module
handles responsibility of persistence of the states.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Changes status type to be status codes defined in Mesh Protocol 4.3.14
as defined for the `BRIDGING_TABLE_STATUS` message.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Change the parameters of the bridge table add function to take an
entry struct rather than the fields of an entry.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Implements the Bridge Configuration Client model.
Adds opcodes for all Bridge messages to `foundation.h`. Adds client-side
support for these messages.
Adds a new Kconfig option for the Bridge Configuration Client model to
configure the waiting time for respones for acked messages.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Adds the Bridge Configuration Client commands to Mesh shell.

Unifies documentation for shell Kconfig options.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Adds implementation for the Bridge Configuration Server model.

Updates `brg_cfg` module to add sanity check for
bt_mesh_brg_cfg_tbl_remove() API. Also, updates the unit test
accordingly.

Adds documentation for the Bridge Configuration Server model

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Adds subnet bridging functionality to the network layer.
Also fixes brg_cfg_srv for minor issues to get it working.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Added support for the Bridge Configuration client and server
to the tester application.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Fixed bugs found while running PTS test.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Added high-level documentation for Subnet Bridge,
connecting models together and explaining usage.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
We store only filled up entries, but want to restore the entire table.
`bt_mesh_setting_set` fails if the restored length didn't match the
provided length.

This commit fixes the restoring of the bridging table by allowing to
restore any size as long as the stored size is less than the allocated
one and it is a multiple of the size of a single entry.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Though nvs backend checks whether the data passed to it is identical to
the stored one, this isn't guaranteed by other the settings api. We can
also avoid going into the settings subsystem since we know what was
actually changed.

This commit adds 2 flags that allow to control whether Subnet Bridge
or Bridging Table states were changed and skips storing if the certain
state was not changed.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The initial implementation of RPL check for Subnet Bridge wasn't fully
correct. It decides whether to relay or not a PDU based on RPL of only
received messages. However, the spec section 3.9.8 says:

```
In addition, a Subnet Bridge node shall implement replay protection for
all Access and Transport Control messages that are sent to bridged
subnets.

A Subnet Bridge node shall maintain the most recent IVISeq value for
each source address authorized to send messages to bridged subnets.
Messages received by the Subnet Bridge node with the IVISeq value less
than or equal to the last stored value from that source address shall
be discarded immediately upon reception. When a message is retransmitted
to a bridged subnet, the stored IVISeq value shall be updated. In this
way, bridged subnets are protected against replay attacks from other
subnets.
```

This was noticed with MESH/NODE/SBR/NET/BV-02-C test. It passes when
PTS misses the message at step 3 and 4, and fails when PTS manages to
receive the message.

This commit fixes the wrong behavior by removing argument for
`bt_mesh_rpl_check` function making store a new message and bypassing
`local_match` check in case of Subnet Bridge node.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Add constants for directions so that they can be used in the
subnet bridge client api.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When relaying a Network PDU to another subnet, we need to update sub
field of rx structure so that correct credentials are used. We also need
to update NID field of the Network PDU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The Subnet Bridge node must bridge traffic regardless of the Relay
state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When a synchronous API is used, the content of `buf` will not be
valid by the time the thread that called the synchronous API is woken up
again.

Therefore, the simplest way to solve this is when a user allocates the
buffer which will be filled up with the content of the buffer passed to
the model callback.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If relay feature doesn't have own adv set, it should use the main adv
set to send messages.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
We must tcheck if buf has enough tailroom to fit another pair of keys or
pair addresses with direction.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If use `IS_ENABLED` macro inside if statements but not as preprocessor
directives, we can always compile the code for settings even if settings
are not used. This allows to reduce amount of firmwares we need to build
in CI to ensure that code compiles.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit adds Bridge Configuration Server to the mesh_shell sample.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit adds the following tests:
- Simple test for bridging table
- Test bridging table state changes
- Test persistence storage of subnet bridge
- Test IV Index update with subnet bridge
- Test network key removal for subnet bridge

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When a message with invalid parameters is received, we must ignore it.

In this commit we check invalid parameters first.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
@zephyrbot zephyrbot added area: Bluetooth Host area: Bluetooth platform: nRF BSIM Nordic Semiconductors, nRF BabbleSim area: Bluetooth Qualification Bluetooth Qualification -related issues and pull requests area: Bluetooth Mesh labels Sep 13, 2024
@Balaklaka
Copy link
Collaborator Author

Unfortunatelly new Qualification Workspace is not able to properly import ICS if file is UNIX line endings.

@Balaklaka Balaklaka force-pushed the develop/collab-mesh-subnet branch 2 times, most recently from e710ab5 to 7a200c9 Compare September 13, 2024 15:05
@Thalley Thalley removed their request for review September 13, 2024 15:18
@PavelVPV PavelVPV changed the title Adding Mesh 1.1 Subnet Bridge Bluetooth: Mesh: Adding Mesh 1.1 Subnet Bridge Sep 13, 2024
PavelVPV
PavelVPV previously approved these changes Sep 13, 2024
@jhedberg
Copy link
Member

How is it possible the build and compliance checks are failing? Weren't those run on the collab branch?

@jhedberg
Copy link
Member

Unfortunatelly new Qualification Workspace is not able to properly import ICS if file is UNIX line endings.

Ah, this thing again. @nashif @carlescufi once other CI issues have been resolved this will again need a merge override due to the CRLF line endings.

@PavelVPV
Copy link
Collaborator

Unfortunatelly new Qualification Workspace is not able to properly import ICS if file is UNIX line endings.

Ah, this thing again. @nashif @carlescufi once other CI issues have been resolved this will again need a merge override due to the CRLF line endings.

We created an issue long time ago: #70360. This is closed now, but the problem still exists.

@alxelax
Copy link
Collaborator

alxelax commented Sep 16, 2024

Hi @Balaklaka, there are a couple of clang-format warnings related to coding style. Could you fix them?

@hermabe hermabe removed their request for review September 16, 2024 07:53
@Balaklaka Balaklaka force-pushed the develop/collab-mesh-subnet branch 2 times, most recently from 77192df to 84c5365 Compare September 16, 2024 12:12
@Balaklaka
Copy link
Collaborator Author

Hi @Balaklaka, there are a couple of clang-format warnings related to coding style. Could you fix them?

Fixed, only "Unfortunatelly new Qualification Workspace is not able to properly import ICS if file is UNIX line endings." left

Removed deprecated native_posix as test platform.
Added unique sim_ids for tests with the psa as a overlay.
Fixed clang-format issues.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
@PavelVPV
Copy link
Collaborator

@carlescufi, I assume this PR won't show up in the mergelist due to failing CI. How it can be merged? It has 2 approvals now and CI is failing because of line endings in pts files.

@nashif nashif merged commit d41e834 into zephyrproject-rtos:main Sep 17, 2024
25 of 26 checks passed
@Balaklaka Balaklaka deleted the develop/collab-mesh-subnet branch September 17, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host area: Bluetooth Mesh area: Bluetooth Qualification Bluetooth Qualification -related issues and pull requests area: Bluetooth platform: nRF BSIM Nordic Semiconductors, nRF BabbleSim
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subnetwork bridge for BLE Mesh
9 participants