[PATCH 1/2] ieee802154: register a device type for the wpan netdev

Subsystems: ieee 802.15.4 subsystem, networking [general], the rest

COOLING8d

6 messages, 3 authors, 8d ago · open the first message on its own page

[PATCH 1/2] ieee802154: register a device type for the wpan netdev

From: Adriano Cordova <hidden>
Date: 2026-09-05 21:20:15

The cfg802154 netdev notifier never sets a device type, so wpan
interfaces lack a sysfs "type". Mirror cfg80211 by calling
SET_NETDEV_DEVTYPE() in a NETDEV_POST_INIT case with a new
wpan_dev_type.

Signed-off-by: Adriano Cordova <redacted>
---
 net/ieee802154/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index c0b8712018a1..c6213412d291 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -272,6 +272,10 @@ void cfg802154_dev_free(struct cfg802154_registered_device *rdev)
 	kfree(rdev);
 }
 
+static const struct device_type wpan_dev_type = {
+	.name	= "wpan",
+};
+
 static void
 cfg802154_update_iface_num(struct cfg802154_registered_device *rdev,
 			   int iftype, int num)
@@ -296,7 +300,9 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
 	/* TODO WARN_ON unspec type */
 
 	switch (state) {
-		/* TODO NETDEV_DEVTYPE */
+	case NETDEV_POST_INIT:
+		SET_NETDEV_DEVTYPE(dev, &wpan_dev_type);
+		break;
 	case NETDEV_REGISTER:
 		dev->netns_immutable = true;
 		wpan_dev->identifier = ++rdev->wpan_dev_id;
-- 
2.51.0

[PATCH 2/2] ieee802154: warn on unspecific wpan interface type

From: Adriano Cordova <hidden>
Date: 2026-09-05 21:20:19

Add the unspec-iftype WARN_ON that cfg80211 has. The iftype is set to a
real value in ieee802154_setup_sdata(), so hitting the warning is a bug.

Signed-off-by: Adriano Cordova <redacted>
---
 net/ieee802154/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index c6213412d291..ec5bfdf6bd31 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -297,7 +297,7 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
 
 	rdev = wpan_phy_to_rdev(wpan_dev->wpan_phy);
 
-	/* TODO WARN_ON unspec type */
+	WARN_ON(wpan_dev->iftype == NL802154_IFTYPE_UNSPEC);
 
 	switch (state) {
 	case NETDEV_POST_INIT:
-- 
2.51.0

Re: [PATCH 1/2] ieee802154: register a device type for the wpan netdev

From: Miquel Raynal <miquel.raynal@bootlin.com>
Date: 2026-09-07 06:29:50

On 05/09/2026 at 17:20:05 -04, Adriano Cordova [off-list ref] wrote:
The cfg802154 netdev notifier never sets a device type, so wpan
interfaces lack a sysfs "type". Mirror cfg80211 by calling
SET_NETDEV_DEVTYPE() in a NETDEV_POST_INIT case with a new
wpan_dev_type.

Signed-off-by: Adriano Cordova <redacted>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Re: [PATCH 2/2] ieee802154: warn on unspecific wpan interface type

From: Miquel Raynal <miquel.raynal@bootlin.com>
Date: 2026-09-07 06:30:01

On 05/09/2026 at 17:20:06 -04, Adriano Cordova [off-list ref] wrote:
Add the unspec-iftype WARN_ON that cfg80211 has. The iftype is set to a
real value in ieee802154_setup_sdata(), so hitting the warning is a bug.

Signed-off-by: Adriano Cordova <redacted>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Re: [PATCH 1/2] ieee802154: register a device type for the wpan netdev

From: netdev-bot+sashiko@kernel.org
Date: 2026-09-08 18:20:38

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 0

- [Medium] Commit message mischaracterizes both the pre-patch state and
  the effect of the change in net/ieee802154/core.c.

--

ieee802154: register a device type for the wpan netdev

This adds a wpan_dev_type with only a .name field and assigns it from a
new NETDEV_POST_INIT case in cfg802154_netdev_notifier_call(), replacing
the "TODO NETDEV_DEVTYPE" comment.  It mirrors what cfg80211 does with
wiphy_type in cfg80211_netdev_notifier_call().
ieee802154: register a device type for the wpan netdev

    The cfg802154 netdev notifier never sets a device type, so wpan
    interfaces lack a sysfs "type". Mirror cfg80211 by calling
    SET_NETDEV_DEVTYPE() in a NETDEV_POST_INIT case with a new
    wpan_dev_type.
[Severity: Medium]
Is the statement "wpan interfaces lack a sysfs 'type'" accurate?  Every
netdev already gets a type file unconditionally from net/core/net-sysfs.c:

    NETDEVICE_SHOW_RO(type, fmt_dec);
    ...
    static struct attribute *net_class_attrs[] __ro_after_init = {
            ...
            &dev_attr_type.attr,

That attribute shows struct net_device::type, which for wpan interfaces is
already 804 (ARPHRD_IEEE802154), so /sys/class/net/<if>/type exists before
this patch.

The macro used here touches a different field:

    #define SET_NETDEV_DEVTYPE(net, devtype)        ((net)->dev.type = (devtype))

and a struct device_type carrying only .name creates no sysfs attribute
file at all.  The one observable effect is in dev_uevent() in
drivers/base/core.c:

    if (dev->type && dev->type->name)
            add_uevent_var(env, "DEVTYPE=%s", dev->type->name);

So the change adds a DEVTYPE=wpan key to the netdev uevent environment
(also visible in /sys/class/net/<if>/uevent), which is what the cfg80211
precedent does with .name = "wlan".

Could the changelog be reworded to describe that effect instead, and also
mention that this is a new userspace-visible uevent key?  udev and
systemd-networkd rules that match on Type= will now see wpan for
interfaces that previously exported no DEVTYPE.

The code change itself looks fine and consistent with
cfg80211_netdev_notifier_call().
quoted hunk
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index c0b8712018a16..c6213412d2914 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -272,6 +272,10 @@ void cfg802154_dev_free(struct cfg802154_registered_device *rdev)
 	kfree(rdev);
 }
 
+static const struct device_type wpan_dev_type = {
+	.name	= "wpan",
+};
+
 static void
 cfg802154_update_iface_num(struct cfg802154_registered_device *rdev,
 			   int iftype, int num)
@@ -296,7 +300,9 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
 	/* TODO WARN_ON unspec type */
 
 	switch (state) {
-		/* TODO NETDEV_DEVTYPE */
+	case NETDEV_POST_INIT:
+		SET_NETDEV_DEVTYPE(dev, &wpan_dev_type);
+		break;
[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260905212007.304875-1-adrianox%40gmail.com

Re: [PATCH 2/2] ieee802154: warn on unspecific wpan interface type

From: netdev-bot+sashiko@kernel.org
Date: 2026-09-08 18:20:39

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 0

- [Medium] The added WARN_ON fails to detect uninitialized iftypes
  because wpan_dev->iftype zero-initializes to NL802154_IFTYPE_NODE (0),…

--
quoted hunk
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -297,7 +297,7 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
 
 	rdev = wpan_phy_to_rdev(wpan_dev->wpan_phy);
 
-	/* TODO WARN_ON unspec type */
+	WARN_ON(wpan_dev->iftype == NL802154_IFTYPE_UNSPEC);
 
 	switch (state) {
 	case NETDEV_POST_INIT:
[Severity: Medium]
This check cannot fire for the case the commit message says it is
meant to catch. In enum nl802154_iftype (include/uapi/linux/nl802154.h)
NL802154_IFTYPE_UNSPEC is ~(__u32)0 while NL802154_IFTYPE_NODE is 0, so
a wpan_dev whose iftype was never assigned - the struct lives in the
zeroed netdev private area handed out by alloc_netdev(), and
ieee802154_setup_sdata() is the only place that writes it - reads back
as NL802154_IFTYPE_NODE, not UNSPEC. The WARN_ON in
cfg802154_netdev_notifier_call() therefore only triggers if some caller
explicitly stores UNSPEC (or -1, given wpan_dev->iftype is a plain int
and the comparison promotes it to unsigned), which no in-tree code does.
As written this is dead code rather than the assertion described.

Note this is unlike cfg80211, where NL80211_IFTYPE_UNSPECIFIED is 0 and
the same test does catch a zeroed field, so the pattern does not carry
over directly.

How do you want to handle this? Either the sanity check needs to be
expressed in terms of a value that an uninitialized wpan_dev actually
holds, or ieee802154_setup_sdata() and the other wpan_dev producers
need to start out at NL802154_IFTYPE_UNSPEC so the warning has
something to detect. Please also say whether you actually observed the
condition, or whether this is intended purely as a future-proofing
assertion.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260905212007.304875-1-adrianox%40gmail.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help