Skip to contentSkip to conversation

net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)

PATCH Superseded Yajun Deng 3 participants 5 messages May 21, 2025 – Jun 12, 2025

Subsystems (2)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH v2 1/1 net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)

phys_port_id_show, phys_port_name_show and phys_switch_id_show would return -EOPNOTSUPP if the netdev didn't implement the corresponding method.

There is no point in creating these files if they are unsupported.

Put these attributes in netdev_phys_group and implement the is_visible method. make phys_(port_id, port_name, switch_id) invisible if the netdev dosen't implement the corresponding method.

---
v2: Remove worthless comments
v1: https://lore.kernel.org/all/[email protected]/

---
 include/linux/netdevice.h |  2 +-
 net/core/net-sysfs.c      | 68 +++++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 28 deletions(-)
include/linux/netdevice.h +1 -1
index 32a1e41636a9..efbcc4836498 100644
@@ -2384,7 +2384,7 @@ struct net_device {
 	struct dm_hw_stat_delta __rcu *dm_private;
 #endif
 	struct device		dev;
-	const struct attribute_group *sysfs_groups[4];
+	const struct attribute_group *sysfs_groups[5];
 	const struct attribute_group *sysfs_rx_queue_group;
 
 	const struct rtnl_link_ops *rtnl_link_ops;
net/core/net-sysfs.c +41 -27

116 lines not on this page · raw message

Signature · 1 line
2.25.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Yajun Deng

phys_port_id_show, phys_port_name_show and phys_switch_id_show would return -EOPNOTSUPP if the netdev didn't implement the corresponding method.

There is no point in creating these files if they are unsupported.

Quoted 8 lines

Put these attributes in netdev_phys_group and implement the is_visible method. make phys_(port_id, port_name, switch_id) invisible if the netdev dosen't implement the corresponding method.

---
v2: Remove worthless comments
v1: https://lore.kernel.org/all/[email protected]/

FWIIW, I had the same thought that Jakub related in his review of v1.

"I'm slightly worried some user space depends on the files existing,
but maybe ENOENT vs EOPNOTSUPP doesn't make a big difference.|

...

maintainer
#2 lore raw
In reply to Yajun Deng
Quoted 11 lines · Yajun Deng

phys_port_id_show, phys_port_name_show and phys_switch_id_show would return -EOPNOTSUPP if the netdev didn't implement the corresponding method.

There is no point in creating these files if they are unsupported.

Put these attributes in netdev_phys_group and implement the is_visible method. make phys_(port_id, port_name, switch_id) invisible if the netdev dosen't implement the corresponding method.

I fear that some orchestration infra depends on the files existence - i.e. scripts don't tolerate the files absence, deal only with I/O errors after open.

It feel a bit too dangerous to merge a change that could break user-space this late. Let's defer it to the beginning of the next cycle.

Paolo

author
#3 lore raw
Quoted 29 lines · Paolo Abeni
Quoted 15 lines · Yajun Deng

phys_port_id_show, phys_port_name_show and phys_switch_id_show would

return -EOPNOTSUPP if the netdev didn't implement the corresponding

method.

There is no point in creating these files if they are unsupported.

Put these attributes in netdev_phys_group and implement the is_visible

Quoted 8 lines

method. make phys_(port_id, port_name, switch_id) invisible if the netdev

dosen't implement the corresponding method.

I fear that some orchestration infra depends on the files existence -

Quoted 8 lines

i.e. scripts don't tolerate the files absence, deal only with I/O errors

after open.

It feel a bit too dangerous to merge a change that could break

user-space this late. Let's defer it to the beginning of the next cycle.

Ping.

Quoted 2 lines

Paolo

maintainer
#4 lore raw
Quoted 29 lines · Yajun Deng
Quoted 28 lines · Paolo Abeni
Quoted 14 lines · Yajun Deng

phys_port_id_show, phys_port_name_show and phys_switch_id_show would

return -EOPNOTSUPP if the netdev didn't implement the corresponding

method.

There is no point in creating these files if they are unsupported.

Put these attributes in netdev_phys_group and implement the is_visible

Quoted 8 lines

method. make phys_(port_id, port_name, switch_id) invisible if the netdev

dosen't implement the corresponding method.

I fear that some orchestration infra depends on the files existence -

i.e. scripts don't tolerate the files absence, deal only with I/O errors

Quoted 8 lines
Quoted 6 lines

after open.

It feel a bit too dangerous to merge a change that could break

user-space this late. Let's defer it to the beginning of the next cycle.

Ping.

I was likely not clear. The above means you should re-submit the patch now.

/P