netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] netlink: make range pointers in policies const
@ 2023-10-25 16:22 Jakub Kicinski
  2023-10-25 16:23 ` Johannes Berg
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jakub Kicinski @ 2023-10-25 16:22 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, Jakub Kicinski, j.vosburgh, andy,
	dsahern, jhs, xiyou.wangcong, jiri, vinicius.gomes, johannes,
	razor, idosch, linux-wireless

struct nla_policy is usually constant itself, but unless
we make the ranges inside constant we won't be able to
make range structs const. The ranges are not modified
by the core.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: j.vosburgh@gmail.com
CC: andy@greyhouse.net
CC: dsahern@kernel.org
CC: jhs@mojatatu.com
CC: xiyou.wangcong@gmail.com
CC: jiri@resnulli.us
CC: vinicius.gomes@intel.com
CC: johannes@sipsolutions.net
CC: razor@blackwall.org
CC: idosch@nvidia.com
CC: linux-wireless@vger.kernel.org
---
 drivers/net/bonding/bond_netlink.c | 2 +-
 drivers/net/vxlan/vxlan_mdb.c      | 2 +-
 include/net/netlink.h              | 4 ++--
 net/ipv6/ioam6_iptunnel.c          | 2 +-
 net/sched/sch_fq.c                 | 2 +-
 net/sched/sch_fq_pie.c             | 2 +-
 net/sched/sch_qfq.c                | 2 +-
 net/sched/sch_taprio.c             | 2 +-
 net/wireless/nl80211.c             | 2 +-
 tools/net/ynl/ynl-gen-c.py         | 2 +-
 10 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 27cbe148f0db..cfa74cf8bb1a 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -85,7 +85,7 @@ static int bond_fill_slave_info(struct sk_buff *skb,
 }
 
 /* Limit the max delay range to 300s */
-static struct netlink_range_validation delay_range = {
+static const struct netlink_range_validation delay_range = {
 	.max = 300000,
 };
 
diff --git a/drivers/net/vxlan/vxlan_mdb.c b/drivers/net/vxlan/vxlan_mdb.c
index 5e041622261a..3a21389658ce 100644
--- a/drivers/net/vxlan/vxlan_mdb.c
+++ b/drivers/net/vxlan/vxlan_mdb.c
@@ -311,7 +311,7 @@ vxlan_mdbe_src_list_pol[MDBE_SRC_LIST_MAX + 1] = {
 	[MDBE_SRC_LIST_ENTRY] = NLA_POLICY_NESTED(vxlan_mdbe_src_list_entry_pol),
 };
 
-static struct netlink_range_validation vni_range = {
+static const struct netlink_range_validation vni_range = {
 	.max = VXLAN_N_VID - 1,
 };
 
diff --git a/include/net/netlink.h b/include/net/netlink.h
index aba2b162a226..83bdf787aeee 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -360,8 +360,8 @@ struct nla_policy {
 		const u32 mask;
 		const char *reject_message;
 		const struct nla_policy *nested_policy;
-		struct netlink_range_validation *range;
-		struct netlink_range_validation_signed *range_signed;
+		const struct netlink_range_validation *range;
+		const struct netlink_range_validation_signed *range_signed;
 		struct {
 			s16 min, max;
 		};
diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
index f6f5b83dd954..7563f8c6aa87 100644
--- a/net/ipv6/ioam6_iptunnel.c
+++ b/net/ipv6/ioam6_iptunnel.c
@@ -46,7 +46,7 @@ struct ioam6_lwt {
 	struct ioam6_lwt_encap	tuninfo;
 };
 
-static struct netlink_range_validation freq_range = {
+static const struct netlink_range_validation freq_range = {
 	.min = IOAM6_IPTUNNEL_FREQ_MIN,
 	.max = IOAM6_IPTUNNEL_FREQ_MAX,
 };
diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index bf9d00518a60..0fd18c344ab5 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -897,7 +897,7 @@ static int fq_resize(struct Qdisc *sch, u32 log)
 	return 0;
 }
 
-static struct netlink_range_validation iq_range = {
+static const struct netlink_range_validation iq_range = {
 	.max = INT_MAX,
 };
 
diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
index 68e6acd0f130..5b595773e59b 100644
--- a/net/sched/sch_fq_pie.c
+++ b/net/sched/sch_fq_pie.c
@@ -202,7 +202,7 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	return NET_XMIT_CN;
 }
 
-static struct netlink_range_validation fq_pie_q_range = {
+static const struct netlink_range_validation fq_pie_q_range = {
 	.min = 1,
 	.max = 1 << 20,
 };
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index 5598f8be18ae..28315166fe8e 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -213,7 +213,7 @@ static struct qfq_class *qfq_find_class(struct Qdisc *sch, u32 classid)
 	return container_of(clc, struct qfq_class, common);
 }
 
-static struct netlink_range_validation lmax_range = {
+static const struct netlink_range_validation lmax_range = {
 	.min = QFQ_MIN_LMAX,
 	.max = QFQ_MAX_LMAX,
 };
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 1cb5e41c0ec7..2e1949de4171 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1015,7 +1015,7 @@ static const struct nla_policy taprio_tc_policy[TCA_TAPRIO_TC_ENTRY_MAX + 1] = {
 							      TC_FP_PREEMPTIBLE),
 };
 
-static struct netlink_range_validation_signed taprio_cycle_time_range = {
+static const struct netlink_range_validation_signed taprio_cycle_time_range = {
 	.min = 0,
 	.max = INT_MAX,
 };
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 2650543dcebe..2f8353bf603c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -463,7 +463,7 @@ nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] = {
 	[NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 },
 };
 
-static struct netlink_range_validation nl80211_punct_bitmap_range = {
+static const struct netlink_range_validation nl80211_punct_bitmap_range = {
 	.min = 0,
 	.max = 0xffff,
 };
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 0fee68863db4..31fd96f14fc0 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -2038,7 +2038,7 @@ _C_KW = {
                 first = False
 
             sign = '' if attr.type[0] == 'u' else '_signed'
-            cw.block_start(line=f'struct netlink_range_validation{sign} {c_lower(attr.enum_name)}_range =')
+            cw.block_start(line=f'static const struct netlink_range_validation{sign} {c_lower(attr.enum_name)}_range =')
             members = []
             if 'min' in attr.checks:
                 members.append(('min', attr.get_limit('min')))
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] netlink: make range pointers in policies const
  2023-10-25 16:22 [PATCH net-next] netlink: make range pointers in policies const Jakub Kicinski
@ 2023-10-25 16:23 ` Johannes Berg
  2023-10-25 18:41 ` David Ahern
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2023-10-25 16:23 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, edumazet, pabeni, j.vosburgh, andy, dsahern, jhs,
	xiyou.wangcong, jiri, vinicius.gomes, razor, idosch,
	linux-wireless

On Wed, 2023-10-25 at 09:22 -0700, Jakub Kicinski wrote:
> struct nla_policy is usually constant itself, but unless
> we make the ranges inside constant we won't be able to
> make range structs const. The ranges are not modified
> by the core.

Makes sense, wonder why I didn't do that from the beginning ...

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>

johannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] netlink: make range pointers in policies const
  2023-10-25 16:22 [PATCH net-next] netlink: make range pointers in policies const Jakub Kicinski
  2023-10-25 16:23 ` Johannes Berg
@ 2023-10-25 18:41 ` David Ahern
  2023-10-25 19:12 ` Nikolay Aleksandrov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2023-10-25 18:41 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, edumazet, pabeni, j.vosburgh, andy, jhs, xiyou.wangcong,
	jiri, vinicius.gomes, johannes, razor, idosch, linux-wireless

On 10/25/23 10:22 AM, Jakub Kicinski wrote:
> struct nla_policy is usually constant itself, but unless
> we make the ranges inside constant we won't be able to
> make range structs const. The ranges are not modified
> by the core.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: j.vosburgh@gmail.com
> CC: andy@greyhouse.net
> CC: dsahern@kernel.org
> CC: jhs@mojatatu.com
> CC: xiyou.wangcong@gmail.com
> CC: jiri@resnulli.us
> CC: vinicius.gomes@intel.com
> CC: johannes@sipsolutions.net
> CC: razor@blackwall.org
> CC: idosch@nvidia.com
> CC: linux-wireless@vger.kernel.org
> ---
>  drivers/net/bonding/bond_netlink.c | 2 +-
>  drivers/net/vxlan/vxlan_mdb.c      | 2 +-
>  include/net/netlink.h              | 4 ++--
>  net/ipv6/ioam6_iptunnel.c          | 2 +-
>  net/sched/sch_fq.c                 | 2 +-
>  net/sched/sch_fq_pie.c             | 2 +-
>  net/sched/sch_qfq.c                | 2 +-
>  net/sched/sch_taprio.c             | 2 +-
>  net/wireless/nl80211.c             | 2 +-
>  tools/net/ynl/ynl-gen-c.py         | 2 +-
>  10 files changed, 11 insertions(+), 11 deletions(-)
> 


Reviewed-by: David Ahern <dsahern@kernel.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] netlink: make range pointers in policies const
  2023-10-25 16:22 [PATCH net-next] netlink: make range pointers in policies const Jakub Kicinski
  2023-10-25 16:23 ` Johannes Berg
  2023-10-25 18:41 ` David Ahern
@ 2023-10-25 19:12 ` Nikolay Aleksandrov
  2023-10-26  5:44 ` Jiri Pirko
  2023-10-26 23:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Nikolay Aleksandrov @ 2023-10-25 19:12 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, edumazet, pabeni, j.vosburgh, andy, dsahern, jhs,
	xiyou.wangcong, jiri, vinicius.gomes, johannes, idosch,
	linux-wireless

On 10/25/23 19:22, Jakub Kicinski wrote:
> struct nla_policy is usually constant itself, but unless
> we make the ranges inside constant we won't be able to
> make range structs const. The ranges are not modified
> by the core.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: j.vosburgh@gmail.com
> CC: andy@greyhouse.net
> CC: dsahern@kernel.org
> CC: jhs@mojatatu.com
> CC: xiyou.wangcong@gmail.com
> CC: jiri@resnulli.us
> CC: vinicius.gomes@intel.com
> CC: johannes@sipsolutions.net
> CC: razor@blackwall.org
> CC: idosch@nvidia.com
> CC: linux-wireless@vger.kernel.org
> ---
>   drivers/net/bonding/bond_netlink.c | 2 +-
>   drivers/net/vxlan/vxlan_mdb.c      | 2 +-
>   include/net/netlink.h              | 4 ++--
>   net/ipv6/ioam6_iptunnel.c          | 2 +-
>   net/sched/sch_fq.c                 | 2 +-
>   net/sched/sch_fq_pie.c             | 2 +-
>   net/sched/sch_qfq.c                | 2 +-
>   net/sched/sch_taprio.c             | 2 +-
>   net/wireless/nl80211.c             | 2 +-
>   tools/net/ynl/ynl-gen-c.py         | 2 +-
>   10 files changed, 11 insertions(+), 11 deletions(-)
> 

Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] netlink: make range pointers in policies const
  2023-10-25 16:22 [PATCH net-next] netlink: make range pointers in policies const Jakub Kicinski
                   ` (2 preceding siblings ...)
  2023-10-25 19:12 ` Nikolay Aleksandrov
@ 2023-10-26  5:44 ` Jiri Pirko
  2023-10-26 23:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2023-10-26  5:44 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, j.vosburgh, andy, dsahern, jhs,
	xiyou.wangcong, vinicius.gomes, johannes, razor, idosch,
	linux-wireless

Wed, Oct 25, 2023 at 06:22:04PM CEST, kuba@kernel.org wrote:
>struct nla_policy is usually constant itself, but unless
>we make the ranges inside constant we won't be able to
>make range structs const. The ranges are not modified
>by the core.
>
>Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] netlink: make range pointers in policies const
  2023-10-25 16:22 [PATCH net-next] netlink: make range pointers in policies const Jakub Kicinski
                   ` (3 preceding siblings ...)
  2023-10-26  5:44 ` Jiri Pirko
@ 2023-10-26 23:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-26 23:40 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, j.vosburgh, andy, dsahern, jhs,
	xiyou.wangcong, jiri, vinicius.gomes, johannes, razor, idosch,
	linux-wireless

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 25 Oct 2023 09:22:04 -0700 you wrote:
> struct nla_policy is usually constant itself, but unless
> we make the ranges inside constant we won't be able to
> make range structs const. The ranges are not modified
> by the core.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net-next] netlink: make range pointers in policies const
    https://git.kernel.org/netdev/net-next/c/ea23fbd2a8f7

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] 6+ messages in thread

end of thread, other threads:[~2023-10-26 23:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 16:22 [PATCH net-next] netlink: make range pointers in policies const Jakub Kicinski
2023-10-25 16:23 ` Johannes Berg
2023-10-25 18:41 ` David Ahern
2023-10-25 19:12 ` Nikolay Aleksandrov
2023-10-26  5:44 ` Jiri Pirko
2023-10-26 23:40 ` 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).