Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netlink: make range pointers in policies const

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.

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20231025162204.132528-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+11 -11
+1 -1
drivers/net/bonding/bond_netlink.c
··· 85 85 } 86 86 87 87 /* Limit the max delay range to 300s */ 88 - static struct netlink_range_validation delay_range = { 88 + static const struct netlink_range_validation delay_range = { 89 89 .max = 300000, 90 90 }; 91 91
+1 -1
drivers/net/vxlan/vxlan_mdb.c
··· 311 311 [MDBE_SRC_LIST_ENTRY] = NLA_POLICY_NESTED(vxlan_mdbe_src_list_entry_pol), 312 312 }; 313 313 314 - static struct netlink_range_validation vni_range = { 314 + static const struct netlink_range_validation vni_range = { 315 315 .max = VXLAN_N_VID - 1, 316 316 }; 317 317
+2 -2
include/net/netlink.h
··· 360 360 const u32 mask; 361 361 const char *reject_message; 362 362 const struct nla_policy *nested_policy; 363 - struct netlink_range_validation *range; 364 - struct netlink_range_validation_signed *range_signed; 363 + const struct netlink_range_validation *range; 364 + const struct netlink_range_validation_signed *range_signed; 365 365 struct { 366 366 s16 min, max; 367 367 };
+1 -1
net/ipv6/ioam6_iptunnel.c
··· 46 46 struct ioam6_lwt_encap tuninfo; 47 47 }; 48 48 49 - static struct netlink_range_validation freq_range = { 49 + static const struct netlink_range_validation freq_range = { 50 50 .min = IOAM6_IPTUNNEL_FREQ_MIN, 51 51 .max = IOAM6_IPTUNNEL_FREQ_MAX, 52 52 };
+1 -1
net/sched/sch_fq.c
··· 897 897 return 0; 898 898 } 899 899 900 - static struct netlink_range_validation iq_range = { 900 + static const struct netlink_range_validation iq_range = { 901 901 .max = INT_MAX, 902 902 }; 903 903
+1 -1
net/sched/sch_fq_pie.c
··· 202 202 return NET_XMIT_CN; 203 203 } 204 204 205 - static struct netlink_range_validation fq_pie_q_range = { 205 + static const struct netlink_range_validation fq_pie_q_range = { 206 206 .min = 1, 207 207 .max = 1 << 20, 208 208 };
+1 -1
net/sched/sch_qfq.c
··· 213 213 return container_of(clc, struct qfq_class, common); 214 214 } 215 215 216 - static struct netlink_range_validation lmax_range = { 216 + static const struct netlink_range_validation lmax_range = { 217 217 .min = QFQ_MIN_LMAX, 218 218 .max = QFQ_MAX_LMAX, 219 219 };
+1 -1
net/sched/sch_taprio.c
··· 1015 1015 TC_FP_PREEMPTIBLE), 1016 1016 }; 1017 1017 1018 - static struct netlink_range_validation_signed taprio_cycle_time_range = { 1018 + static const struct netlink_range_validation_signed taprio_cycle_time_range = { 1019 1019 .min = 0, 1020 1020 .max = INT_MAX, 1021 1021 };
+1 -1
net/wireless/nl80211.c
··· 463 463 [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, 464 464 }; 465 465 466 - static struct netlink_range_validation nl80211_punct_bitmap_range = { 466 + static const struct netlink_range_validation nl80211_punct_bitmap_range = { 467 467 .min = 0, 468 468 .max = 0xffff, 469 469 };
+1 -1
tools/net/ynl/ynl-gen-c.py
··· 2038 2038 first = False 2039 2039 2040 2040 sign = '' if attr.type[0] == 'u' else '_signed' 2041 - cw.block_start(line=f'struct netlink_range_validation{sign} {c_lower(attr.enum_name)}_range =') 2041 + cw.block_start(line=f'static const struct netlink_range_validation{sign} {c_lower(attr.enum_name)}_range =') 2042 2042 members = [] 2043 2043 if 'min' in attr.checks: 2044 2044 members.append(('min', attr.get_limit('min')))