* [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops
@ 2024-06-02 14:18 Christophe JAILLET
2024-06-02 14:18 ` [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register() Christophe JAILLET
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Christophe JAILLET @ 2024-06-02 14:18 UTC (permalink / raw)
To: idosch, petrm, davem, edumazet, kuba, pabeni, jiri
Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET
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(-)
--
2.45.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
2024-06-02 14:18 [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops Christophe JAILLET
@ 2024-06-02 14:18 ` Christophe JAILLET
2024-06-03 8:45 ` Wojciech Drewek
2024-06-03 10:52 ` Ido Schimmel
2024-06-02 14:18 ` [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops Christophe JAILLET
` (2 subsequent siblings)
3 siblings, 2 replies; 9+ messages in thread
From: Christophe JAILLET @ 2024-06-02 14:18 UTC (permalink / raw)
To: idosch, petrm, davem, edumazet, kuba, pabeni, jiri
Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET
"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.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
include/net/devlink.h | 4 ++--
net/devlink/dpipe.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 35eb0f884386..db5eff6cb60f 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -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);
diff --git a/net/devlink/dpipe.c b/net/devlink/dpipe.c
index a72a9292efc5..55009b377447 100644
--- a/net/devlink/dpipe.c
+++ b/net/devlink/dpipe.c
@@ -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;
--
2.45.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
2024-06-02 14:18 [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops Christophe JAILLET
2024-06-02 14:18 ` [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register() Christophe JAILLET
@ 2024-06-02 14:18 ` Christophe JAILLET
2024-06-03 8:46 ` Wojciech Drewek
2024-06-03 10:53 ` Ido Schimmel
2024-06-03 12:47 ` [PATCH 0/2 net-next] devlink: " Jiri Pirko
2024-06-05 9:30 ` patchwork-bot+netdevbpf
3 siblings, 2 replies; 9+ messages in thread
From: Christophe JAILLET @ 2024-06-02 14:18 UTC (permalink / raw)
To: idosch, petrm, davem, edumazet, kuba, pabeni, jiri
Cc: netdev, linux-kernel, kernel-janitors, 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
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
index ca80af06465f..fa6eddd27ecf 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
@@ -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,
--
2.45.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
2024-06-02 14:18 ` [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register() Christophe JAILLET
@ 2024-06-03 8:45 ` Wojciech Drewek
2024-06-03 10:52 ` Ido Schimmel
1 sibling, 0 replies; 9+ messages in thread
From: Wojciech Drewek @ 2024-06-03 8:45 UTC (permalink / raw)
To: Christophe JAILLET, idosch, petrm, davem, edumazet, kuba, pabeni,
jiri
Cc: netdev, linux-kernel, kernel-janitors
On 02.06.2024 16:18, Christophe JAILLET wrote:
> "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.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> include/net/devlink.h | 4 ++--
> net/devlink/dpipe.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/devlink.h b/include/net/devlink.h
> index 35eb0f884386..db5eff6cb60f 100644
> --- a/include/net/devlink.h
> +++ b/include/net/devlink.h
> @@ -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);
> diff --git a/net/devlink/dpipe.c b/net/devlink/dpipe.c
> index a72a9292efc5..55009b377447 100644
> --- a/net/devlink/dpipe.c
> +++ b/net/devlink/dpipe.c
> @@ -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;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
2024-06-02 14:18 ` [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops Christophe JAILLET
@ 2024-06-03 8:46 ` Wojciech Drewek
2024-06-03 10:53 ` Ido Schimmel
1 sibling, 0 replies; 9+ messages in thread
From: Wojciech Drewek @ 2024-06-03 8:46 UTC (permalink / raw)
To: Christophe JAILLET, idosch, petrm, davem, edumazet, kuba, pabeni,
jiri
Cc: netdev, linux-kernel, kernel-janitors
On 02.06.2024 16:18, Christophe JAILLET wrote:
> '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
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
> index ca80af06465f..fa6eddd27ecf 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
> @@ -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,
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
2024-06-02 14:18 ` [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register() Christophe JAILLET
2024-06-03 8:45 ` Wojciech Drewek
@ 2024-06-03 10:52 ` Ido Schimmel
1 sibling, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2024-06-03 10:52 UTC (permalink / raw)
To: Christophe JAILLET
Cc: petrm, davem, edumazet, kuba, pabeni, jiri, netdev, linux-kernel,
kernel-janitors
On Sun, Jun 02, 2024 at 04:18:52PM +0200, Christophe JAILLET wrote:
> "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.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops
2024-06-02 14:18 ` [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops Christophe JAILLET
2024-06-03 8:46 ` Wojciech Drewek
@ 2024-06-03 10:53 ` Ido Schimmel
1 sibling, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2024-06-03 10:53 UTC (permalink / raw)
To: Christophe JAILLET
Cc: petrm, davem, edumazet, kuba, pabeni, jiri, netdev, linux-kernel,
kernel-janitors
On Sun, Jun 02, 2024 at 04:18:53PM +0200, Christophe JAILLET wrote:
> '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
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops
2024-06-02 14:18 [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops Christophe JAILLET
2024-06-02 14:18 ` [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register() Christophe JAILLET
2024-06-02 14:18 ` [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops Christophe JAILLET
@ 2024-06-03 12:47 ` Jiri Pirko
2024-06-05 9:30 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 9+ messages in thread
From: Jiri Pirko @ 2024-06-03 12:47 UTC (permalink / raw)
To: Christophe JAILLET
Cc: idosch, petrm, davem, edumazet, kuba, pabeni, netdev,
linux-kernel, kernel-janitors
Sun, Jun 02, 2024 at 04:18:51PM CEST, christophe.jaillet@wanadoo.fr wrote:
>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
set-
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops
2024-06-02 14:18 [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops Christophe JAILLET
` (2 preceding siblings ...)
2024-06-03 12:47 ` [PATCH 0/2 net-next] devlink: " Jiri Pirko
@ 2024-06-05 9:30 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-05 9:30 UTC (permalink / raw)
To: Christophe JAILLET
Cc: idosch, petrm, davem, edumazet, kuba, pabeni, jiri, netdev,
linux-kernel, kernel-janitors
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Sun, 2 Jun 2024 16:18:51 +0200 you wrote:
> 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.
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-06-05 9:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-02 14:18 [PATCH 0/2 net-next] devlink: Constify struct devlink_dpipe_table_ops Christophe JAILLET
2024-06-02 14:18 ` [PATCH 1/2 net-next] devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register() Christophe JAILLET
2024-06-03 8:45 ` Wojciech Drewek
2024-06-03 10:52 ` Ido Schimmel
2024-06-02 14:18 ` [PATCH 2/2 net-next] mlxsw: spectrum_router: Constify struct devlink_dpipe_table_ops Christophe JAILLET
2024-06-03 8:46 ` Wojciech Drewek
2024-06-03 10:53 ` Ido Schimmel
2024-06-03 12:47 ` [PATCH 0/2 net-next] devlink: " Jiri Pirko
2024-06-05 9:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).