Skip to content

Commit f1e9dd2

Browse files
Florian Grandelcarlescufi
authored andcommitted
drivers: ieee802154: properly announce promisc mode
Most IEEE 802.15.4 drivers do not support promiscuous mode, some do. There is a dedicated L2 flag to signal this capability to clients. Unfortunately the IEEE 802.15.4 L2 stack does not announce this flag even for drivers that correctly expose it in their HW capabilities. Some clients (notably the OpenThread L2) even uses promiscuous mode without checking whether the driver actually supports it. This change lets the vanilla IEEE 802.15.4 L2 check the driver's HW capabilities to announce promiscuous mode on its 'get_flags()' interface if supported. The OpenThread L2 uses a constant (potentially incorrect) response to 'get_flags()'. Fixing the OpenThread L2 is out of scope of this change. This change just introduces TODO messages to the OpenThread code so that the OpenThread team may fix the issue (or delete the TODO if they deem it irrelevant). Fixes: #51263 Signed-off-by: Florian Grandel <[email protected]>
1 parent 62ed153 commit f1e9dd2

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

modules/openthread/platform/radio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,10 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
808808
LOG_DBG("PromiscuousMode=%d", aEnable ? 1 : 0);
809809

810810
promiscuous = aEnable;
811+
/* TODO: Should check whether the radio driver actually supports
812+
* promiscuous mode, see net_if_l2(iface)->get_flags() and
813+
* ieee802154_get_hw_capabilities(iface).
814+
*/
811815
radio_api->configure(radio_dev, IEEE802154_CONFIG_PROMISCUOUS, &config);
812816
}
813817

subsys/net/l2/ieee802154/ieee802154.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ void ieee802154_init(struct net_if *iface)
431431
*/
432432
ctx->channel = IEEE802154_NO_CHANNEL;
433433
ctx->flags = NET_L2_MULTICAST;
434+
if (ieee802154_get_hw_capabilities(iface) & IEEE802154_HW_PROMISC) {
435+
ctx->flags |= NET_L2_PROMISC_MODE;
436+
}
434437

435438
ctx->short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED;
436439
sys_memcpy_swap(ctx->ext_addr, eui64_be, IEEE802154_EXT_ADDR_LENGTH);

subsys/net/l2/openthread/openthread.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ void ieee802154_init(struct net_if *iface)
540540

541541
static enum net_l2_flags openthread_flags(struct net_if *iface)
542542
{
543+
/* TODO: Should report NET_L2_PROMISC_MODE if the radio driver
544+
* reports the IEEE802154_HW_PROMISC capability.
545+
*/
543546
return NET_L2_MULTICAST | NET_L2_MULTICAST_SKIP_JOIN_SOLICIT_NODE;
544547
}
545548

0 commit comments

Comments
 (0)