Commit ea23fbd2 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

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: default avatarJohannes Berg <johannes@sipsolutions.net>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Reviewed-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20231025162204.132528-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5af8d8ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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,
};

+1 −1
Original line number Diff line number Diff line
@@ -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,
};

+2 −2
Original line number Diff line number Diff line
@@ -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;
		};
+1 −1
Original line number Diff line number Diff line
@@ -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,
};
+1 −1
Original line number Diff line number Diff line
@@ -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,
};

Loading