Skip to content

Conversation

@Cristib05
Copy link
Contributor

Main goal of this PR is to handle a WI-Fi connect/disconnect or link lost and link re-established scenario.
OpenThread's platform code has been enhanced to handle those events.
Border Router application code has been updated to de-initialize platform modules and remove its multicast routes.
TREL code has been updated to accommodate user enable/disable interaction from CLI.

Comment on lines 55 to 60
if (!net_mgmt(NET_REQUEST_WIFI_IFACE_STATUS, ail_iface_ptr,
&status, sizeof(status))) {
if (status.state == WIFI_STATE_COMPLETED) {
(void)trel_plat_init(ot_instance_ptr, ail_iface_ptr);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this make a hardcoded assumption that the backbone link is Wi-Fi? Please correct me if I'm wrong, but I think this module should also work with other interface types like Ethernet?

A generic way to check if the interface is ready to transmit data would be to check net_if_is_up() - for Wi-Fi interfaces, this should only return true if the interface is connected to a Wi-Fi network.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OTBR is planned to support both interfaces, Wi-FI or Ethernet, you are right. It would be a better idea to stick with your approach.

OpenThread interface is initialized beform Wi-Fi interface.
`otPlatTrelEnable` is called by OpenThread stack when it's interface is
being initialized. Given this scenario, socket operation, like `bind`,
will fail. There is also no mean to get a valid pointer to backbone
interface. This is why, `trel_plat_init` was declared and called when
backbone interface reported connectivity.

This commit handles the `ot trel disable/ot trel enable` scenario that
can be initialized from CLI. `otPlatTrelEnable` will be called, but
`trel_plat_init` will not be called anymore, leaving trel socket without
any options set, and `net_socket_service_register` is not called
anymore, to handle incoming traffic.
Now, when `otPlatTrelEnable` is called, it will verify if Wi-Fi
interface is connected and will call `trel_plat_init` if needed.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
@Cristib05 Cristib05 force-pushed the openthread_border_router_fix_socket_close branch from 2523147 to 7311d26 Compare November 17, 2025 11:29
@Cristib05 Cristib05 requested a review from rlubos November 17, 2025 11:34
In this commit, `net_socket_service_register` is called when a platform
module that has sockets is deinitialized, and it's socket/sockets are
closed.
This commit also handles a case when a module tries to join a multicast
group and a subscription, from another module, is already present.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
This commit deinitializes platform modules when external network
interface is brought down. It also delets the multicast routes that are
added for OpenThread interface.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
@Cristib05 Cristib05 force-pushed the openthread_border_router_fix_socket_close branch from 7311d26 to 6de7a35 Compare November 17, 2025 11:55
@sonarqubecloud
Copy link

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.

4 participants