Skip to contentSkip to conversation

net: make kobj_type structures constant

PATCH Applied Thomas Weißschuh 3 participants 5 messages Feb 14, 2023 – Feb 15, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover net: make kobj_type structures constant

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent modification at runtime.

---
Changes in v2:
- drop sunrpc patch from series
- use "net-next" patch prefix
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Thomas Weißschuh (2):
net: bridge: make kobj_type structure constant
net-sysfs: make kobj_type structures constant

 net/bridge/br_if.c   | 2 +-
 net/core/net-sysfs.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

---
base-commit: f6feea56f66d34259c4222fa02e8171c4f2673d1
change-id: 20230211-kobj_type-net-99f71346aed2

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#1 lore raw

PATCH v2 1/2 net: bridge: make kobj_type structure constant

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definition to prevent modification at runtime.

---
 net/bridge/br_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_if.c +1 -1
index ad13b48e3e08..24f01ff113f0 100644
@@ -269,7 +269,7 @@ static void brport_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t
 	net_ns_get_ownership(dev_net(p->dev), uid, gid);
 }
 
-static struct kobj_type brport_ktype = {
+static const struct kobj_type brport_ktype = {
 #ifdef CONFIG_SYSFS
 	.sysfs_ops = &brport_sysfs_ops,
 #endif
Signature · 1 line
2.39.1
maintainer Acked-by on v2 1/2
#2 lore raw

Re: [PATCH net-next v2 1/2] net: bridge: make kobj_type structure constant

Quoted 17 lines · Thomas Weißschuh

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definition to prevent modification at runtime.

---
 net/bridge/br_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_if.c +0 -0
index ad13b48e3e08..24f01ff113f0 100644

net/bridge/br_if.c static void brport_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t · line 275

Quoted 8 lines
net/bridge/br_if.c +1 -1
@@ -269,7 +269,7 @@ static void brport_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t
 	net_ns_get_ownership(dev_net(p->dev), uid, gid);
 }
 
-static struct kobj_type brport_ktype = {
+static const struct kobj_type brport_ktype = {
 #ifdef CONFIG_SYSFS
 	.sysfs_ops = &brport_sysfs_ops,
 #endif
#3 lore raw

PATCH v2 2/2 net-sysfs: make kobj_type structures constant

In reply to Thomas Weißschuh

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent modification at runtime.

---
 net/core/net-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/net-sysfs.c +2 -2
index ca55dd747d6c..a3771bba841a 100644
@@ -1040,7 +1040,7 @@ static void rx_queue_get_ownership(const struct kobject *kobj,
 	net_ns_get_ownership(net, uid, gid);
 }
 
-static struct kobj_type rx_queue_ktype __ro_after_init = {
+static const struct kobj_type rx_queue_ktype = {
 	.sysfs_ops = &rx_queue_sysfs_ops,
 	.release = rx_queue_release,
 	.default_groups = rx_queue_default_groups,
@@ -1643,7 +1643,7 @@ static void netdev_queue_get_ownership(const struct kobject *kobj,
 	net_ns_get_ownership(net, uid, gid);
 }
 
-static struct kobj_type netdev_queue_ktype __ro_after_init = {
+static const struct kobj_type netdev_queue_ktype = {
 	.sysfs_ops = &netdev_queue_sysfs_ops,
 	.release = netdev_queue_release,
 	.default_groups = netdev_queue_default_groups,
Signature · 1 line
2.39.1
#4 lore raw
In reply to Thomas Weißschuh
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 14 Feb 2023 04:23:10 +0000 you wrote:

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent modification at runtime.

[...]

Here is the summary with links:
- [net-next,v2,1/2] net: bridge: make kobj_type structure constant

    https://git.kernel.org/netdev/net-next/c/e8c6cbd7656e
  - [net-next,v2,2/2] net-sysfs: make kobj_type structures constant
    https://git.kernel.org/netdev/net-next/c/b2793517052d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html