devlink: Constify struct devlink_dpipe_table_ops
Subsystems (5)
cover devlink: Constify struct devlink_dpipe_table_ops
Patch 1 updates devl_dpipe_table_register() and struct devlink_dpipe_table to accept "const struct devlink_dpipe_table_ops".
Then patch 2 updates the only user of this function.
This is compile tested only.
Christophe JAILLET (2):
devlink: Constify the 'table_ops' parameter of
devl_dpipe_table_register()
mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 8 ++++---- include/net/devlink.h | 4 ++-- net/devlink/dpipe.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.45.1
PATCH 1/2 devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
"struct devlink_dpipe_table_ops" only contains some function pointers.
Update "struct devlink_dpipe_table" and the 'table_ops' parameter of devl_dpipe_table_register() so that structures in drivers can be constified.
Constifying these structures will move some data to a read-only section, so increase overall security.
--- include/net/devlink.h | 4 ++-- net/devlink/dpipe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/devlink.h +2 -2
@@ -352,7 +352,7 @@ struct devlink_dpipe_table {bool resource_valid;u64 resource_id;u64 resource_units; -struct devlink_dpipe_table_ops *table_ops; +const struct devlink_dpipe_table_ops *table_ops;struct rcu_head rcu; };
@@ -1751,7 +1751,7 @@ void devl_sb_unregister(struct devlink *devlink, unsigned int sb_index);void devlink_sb_unregister (struct devlink *devlink,unsigned int sb_index);int devl_dpipe_table_register (struct devlink *devlink,const char *table_name, -struct devlink_dpipe_table_ops *table_ops, +const struct devlink_dpipe_table_ops *table_ops,void *priv,bool counter_control_extern);void devl_dpipe_table_unregister (struct devlink *devlink,const char *table_name);
net/devlink/dpipe.c +1 -1
@@ -839,7 +839,7 @@ EXPORT_SYMBOL_GPL(devlink_dpipe_table_counter_enabled);*/ int devl_dpipe_table_register (struct devlink *devlink,const char *table_name, -struct devlink_dpipe_table_ops *table_ops, +const struct devlink_dpipe_table_ops *table_ops,void *priv,bool counter_control_extern) {struct devlink_dpipe_table *table;
Signature · 1 line
2.45.1
Re: [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
Quoted 11 lines · Christophe JAILLET
"struct
devlink_dpipe_table_ops" only contains some function pointers.Update "struct
devlink_dpipe_table" and the 'table_ops' parameter ofdevl_dpipe_table_register()so that structures in drivers can be constified.Constifying these structures will move some data to a read-only section, so increase overall security.
Signed-off-by Christophe JAILLET <[email protected]>---
Quoted 39 lines
include/net/devlink.h | 4 ++-- net/devlink/dpipe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)include/net/devlink.h +2
-2@@ -352,7 +352,7 @@ struct devlink_dpipe_table {bool resource_valid;u64 resource_id;u64 resource_units; -struct devlink_dpipe_table_ops *table_ops; +const struct devlink_dpipe_table_ops *table_ops;struct rcu_head rcu; };@@ -1751,7 +1751,7 @@ void devl_sb_unregister(struct devlink *devlink, unsigned int sb_index);void devlink_sb_unregister (struct devlink *devlink,unsigned int sb_index);int devl_dpipe_table_register (struct devlink *devlink,const char *table_name, -struct devlink_dpipe_table_ops *table_ops, +const struct devlink_dpipe_table_ops *table_ops,void *priv,bool counter_control_extern);void devl_dpipe_table_unregister (struct devlink *devlink,const char *table_name);net/devlink/dpipe.c +1
-1@@ -839,7 +839,7 @@ EXPORT_SYMBOL_GPL(devlink_dpipe_table_counter_enabled);*/ int devl_dpipe_table_register (struct devlink *devlink,const char *table_name, -struct devlink_dpipe_table_ops *table_ops, +const struct devlink_dpipe_table_ops *table_ops,void *priv,bool counter_control_extern) {struct devlink_dpipe_table *table;
Re: [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
In reply to Christophe JAILLETQuoted 10 lines · Christophe JAILLET
"struct
devlink_dpipe_table_ops" only contains some function pointers.Update "struct
devlink_dpipe_table" and the 'table_ops' parameter ofdevl_dpipe_table_register()so that structures in drivers can be constified.Constifying these structures will move some data to a read-only section, so increase overall security.
Signed-off-by Christophe JAILLET <[email protected]>
PATCH 2/2 mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
In reply to Christophe JAILLET'struct devlink_dpipe_table_ops' are not modified in this driver.
Constifying these structures moves some data to a read-only section, so increase overall security.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
15557 712 0 16269 3f8d drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.o
After:
=====
text data bss dec hex filename
15789 488 0 16277 3f95 drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.o
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +4 -4
@@ -283,7 +283,7 @@ static u64 mlxsw_sp_dpipe_table_erif_size_get(void *priv)return MLXSW_CORE_RES_GET (mlxsw_sp->core,MAX_RIFS ); } -static struct devlink_dpipe_table_ops mlxsw_sp_erif_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_erif_ops = { .matches_dump = mlxsw_sp_dpipe_table_erif_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_erif_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_erif_entries_dump,
@@ -734,7 +734,7 @@ static u64 mlxsw_sp_dpipe_table_host4_size_get(void *priv)return mlxsw_sp_dpipe_table_host_size_get (mlxsw_sp,AF_INET ); } -static struct devlink_dpipe_table_ops mlxsw_sp_host4_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_host4_ops = { .matches_dump = mlxsw_sp_dpipe_table_host4_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_host_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_host4_entries_dump,
@@ -811,7 +811,7 @@ static u64 mlxsw_sp_dpipe_table_host6_size_get(void *priv)return mlxsw_sp_dpipe_table_host_size_get (mlxsw_sp,AF_INET6 ); } -static struct devlink_dpipe_table_ops mlxsw_sp_host6_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_host6_ops = { .matches_dump = mlxsw_sp_dpipe_table_host6_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_host_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_host6_entries_dump,
@@ -1230,7 +1230,7 @@ mlxsw_sp_dpipe_table_adj_size_get(void *priv)return size; } -static struct devlink_dpipe_table_ops mlxsw_sp_dpipe_table_adj_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_dpipe_table_adj_ops = { .matches_dump = mlxsw_sp_dpipe_table_adj_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_adj_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_adj_entries_dump,
Signature · 1 line
2.45.1
Re: [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
Quoted 11 lines · Christophe JAILLET
'struct
devlink_dpipe_table_ops' are not modified in this driver.Constifying these structures moves some data to a read-only section, so increase overall security.
On a
x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
15557 712 0 16269 3f8ddrivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.o
Quoted 7 lines
After:
=====
text data bss dec hex filename
15789 488 0 16277 3f95drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.oSigned-off-by Christophe JAILLET <[email protected]>---
Quoted 43 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +4
-4@@ -283,7 +283,7 @@ static u64 mlxsw_sp_dpipe_table_erif_size_get(void *priv)return MLXSW_CORE_RES_GET (mlxsw_sp->core,MAX_RIFS ); } -static struct devlink_dpipe_table_ops mlxsw_sp_erif_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_erif_ops = { .matches_dump = mlxsw_sp_dpipe_table_erif_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_erif_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_erif_entries_dump,@@ -734,7 +734,7 @@ static u64 mlxsw_sp_dpipe_table_host4_size_get(void *priv)return mlxsw_sp_dpipe_table_host_size_get (mlxsw_sp,AF_INET ); } -static struct devlink_dpipe_table_ops mlxsw_sp_host4_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_host4_ops = { .matches_dump = mlxsw_sp_dpipe_table_host4_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_host_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_host4_entries_dump,@@ -811,7 +811,7 @@ static u64 mlxsw_sp_dpipe_table_host6_size_get(void *priv)return mlxsw_sp_dpipe_table_host_size_get (mlxsw_sp,AF_INET6 ); } -static struct devlink_dpipe_table_ops mlxsw_sp_host6_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_host6_ops = { .matches_dump = mlxsw_sp_dpipe_table_host6_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_host_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_host6_entries_dump,@@ -1230,7 +1230,7 @@ mlxsw_sp_dpipe_table_adj_size_get(void *priv)return size; } -static struct devlink_dpipe_table_ops mlxsw_sp_dpipe_table_adj_ops = { +static const struct devlink_dpipe_table_ops mlxsw_sp_dpipe_table_adj_ops = { .matches_dump = mlxsw_sp_dpipe_table_adj_matches_dump, .actions_dump = mlxsw_sp_dpipe_table_adj_actions_dump, .entries_dump = mlxsw_sp_dpipe_table_adj_entries_dump,
Re: [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
In reply to Christophe JAILLETQuoted 11 lines · Christophe JAILLET
'struct
devlink_dpipe_table_ops' are not modified in this driver.Constifying these structures moves some data to a read-only section, so increase overall security.
On a
x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
15557 712 0 16269 3f8ddrivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.o
Quoted 6 lines
After:
=====
text data bss dec hex filename
15789 488 0 16277 3f95drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.oSigned-off-by Christophe JAILLET <[email protected]>
Quoted 11 lines · Sun, Jun 02, 2024 at 04:18:51PM CEST, [email protected] wrote:
Patch 1 updates
devl_dpipe_table_register()and structdevlink_dpipe_tableto accept "const structdevlink_dpipe_table_ops".Then patch 2 updates the only user of this function.
This is compile tested only.
Christophe JAILLET (2):
devlink: Constify the 'table_ops' parameter of
devl_dpipe_table_register()
mlxsw:spectrum_router: Constify structdevlink_dpipe_table_ops
set-
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 8 lines · On Sun, 2 Jun 2024 16:18:51 +0200 you wrote:
Patch 1 updates
devl_dpipe_table_register()and structdevlink_dpipe_tableto accept "const structdevlink_dpipe_table_ops".Then patch 2 updates the only user of this function.
This is compile tested only.
[...]
Here is the summary with links:
- [1/2,net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
https://git.kernel.org/netdev/net-next/c/82dc29b9737e - [2/2,net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops https://git.kernel.org/netdev/net-next/c/b072aa789918
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html