Commit ff419afa authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

ethtool: trim policy tables

Since ethtool uses strict attribute validation there's no need
to initialize all attributes in policy tables. 0 is NLA_UNSPEC
which is going to be rejected. Remove the NLA_REJECTs.

Similarly attributes above maxattrs are rejected, so there's
no need to always size the policy tables to ETHTOOL_A_..._MAX.

v2: - new patch
Suggested-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5028588b
...@@ -302,8 +302,7 @@ int ethnl_put_bitset32(struct sk_buff *skb, int attrtype, const u32 *val, ...@@ -302,8 +302,7 @@ int ethnl_put_bitset32(struct sk_buff *skb, int attrtype, const u32 *val,
return -EMSGSIZE; return -EMSGSIZE;
} }
static const struct nla_policy bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = { static const struct nla_policy bitset_policy[] = {
[ETHTOOL_A_BITSET_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_BITSET_NOMASK] = { .type = NLA_FLAG }, [ETHTOOL_A_BITSET_NOMASK] = { .type = NLA_FLAG },
[ETHTOOL_A_BITSET_SIZE] = NLA_POLICY_MAX(NLA_U32, [ETHTOOL_A_BITSET_SIZE] = NLA_POLICY_MAX(NLA_U32,
ETHNL_MAX_BITSET_SIZE), ETHNL_MAX_BITSET_SIZE),
...@@ -312,8 +311,7 @@ static const struct nla_policy bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = { ...@@ -312,8 +311,7 @@ static const struct nla_policy bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = {
[ETHTOOL_A_BITSET_MASK] = { .type = NLA_BINARY }, [ETHTOOL_A_BITSET_MASK] = { .type = NLA_BINARY },
}; };
static const struct nla_policy bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = { static const struct nla_policy bit_policy[] = {
[ETHTOOL_A_BITSET_BIT_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_BITSET_BIT_INDEX] = { .type = NLA_U32 }, [ETHTOOL_A_BITSET_BIT_INDEX] = { .type = NLA_U32 },
[ETHTOOL_A_BITSET_BIT_NAME] = { .type = NLA_NUL_STRING }, [ETHTOOL_A_BITSET_BIT_NAME] = { .type = NLA_NUL_STRING },
[ETHTOOL_A_BITSET_BIT_VALUE] = { .type = NLA_FLAG }, [ETHTOOL_A_BITSET_BIT_VALUE] = { .type = NLA_FLAG },
...@@ -329,10 +327,10 @@ static const struct nla_policy bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = { ...@@ -329,10 +327,10 @@ static const struct nla_policy bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = {
*/ */
int ethnl_bitset_is_compact(const struct nlattr *bitset, bool *compact) int ethnl_bitset_is_compact(const struct nlattr *bitset, bool *compact)
{ {
struct nlattr *tb[ETHTOOL_A_BITSET_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
int ret; int ret;
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_MAX, bitset, ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, bitset,
bitset_policy, NULL); bitset_policy, NULL);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -381,10 +379,10 @@ static int ethnl_parse_bit(unsigned int *index, bool *val, unsigned int nbits, ...@@ -381,10 +379,10 @@ static int ethnl_parse_bit(unsigned int *index, bool *val, unsigned int nbits,
ethnl_string_array_t names, ethnl_string_array_t names,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct nlattr *tb[ETHTOOL_A_BITSET_BIT_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(bit_policy)];
int ret, idx; int ret, idx;
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_BIT_MAX, bit_attr, ret = nla_parse_nested(tb, ARRAY_SIZE(bit_policy) - 1, bit_attr,
bit_policy, extack); bit_policy, extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -555,15 +553,15 @@ int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits, ...@@ -555,15 +553,15 @@ int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits,
const struct nlattr *attr, ethnl_string_array_t names, const struct nlattr *attr, ethnl_string_array_t names,
struct netlink_ext_ack *extack, bool *mod) struct netlink_ext_ack *extack, bool *mod)
{ {
struct nlattr *tb[ETHTOOL_A_BITSET_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
unsigned int change_bits; unsigned int change_bits;
bool no_mask; bool no_mask;
int ret; int ret;
if (!attr) if (!attr)
return 0; return 0;
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_MAX, attr, bitset_policy, ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr,
extack); bitset_policy, extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -608,7 +606,7 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask, ...@@ -608,7 +606,7 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask,
ethnl_string_array_t names, ethnl_string_array_t names,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct nlattr *tb[ETHTOOL_A_BITSET_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
const struct nlattr *bit_attr; const struct nlattr *bit_attr;
bool no_mask; bool no_mask;
int rem; int rem;
...@@ -616,8 +614,8 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask, ...@@ -616,8 +614,8 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask,
if (!attr) if (!attr)
return 0; return 0;
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_MAX, attr, bitset_policy, ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr,
extack); bitset_policy, extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
no_mask = tb[ETHTOOL_A_BITSET_NOMASK]; no_mask = tb[ETHTOOL_A_BITSET_NOMASK];
......
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
*/ */
#define MAX_CABLE_LENGTH_CM (150 * 100) #define MAX_CABLE_LENGTH_CM (150 * 100)
const struct nla_policy const struct nla_policy ethnl_cable_test_act_policy[] = {
ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = {
[ETHTOOL_A_CABLE_TEST_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_CABLE_TEST_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_CABLE_TEST_HEADER] = { .type = NLA_NESTED },
}; };
...@@ -212,17 +210,14 @@ struct cable_test_tdr_req_info { ...@@ -212,17 +210,14 @@ struct cable_test_tdr_req_info {
struct ethnl_req_info base; struct ethnl_req_info base;
}; };
static const struct nla_policy static const struct nla_policy cable_test_tdr_act_cfg_policy[] = {
cable_test_tdr_act_cfg_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX + 1] = {
[ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .type = NLA_U32 }, [ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .type = NLA_U32 },
[ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST] = { .type = NLA_U32 }, [ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST] = { .type = NLA_U32 },
[ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP] = { .type = NLA_U32 }, [ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP] = { .type = NLA_U32 },
[ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR] = { .type = NLA_U8 }, [ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR] = { .type = NLA_U8 },
}; };
const struct nla_policy const struct nla_policy ethnl_cable_test_tdr_act_policy[] = {
ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1] = {
[ETHTOOL_A_CABLE_TEST_TDR_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_CABLE_TEST_TDR_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_CABLE_TEST_TDR_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_CABLE_TEST_TDR_CFG] = { .type = NLA_NESTED }, [ETHTOOL_A_CABLE_TEST_TDR_CFG] = { .type = NLA_NESTED },
}; };
...@@ -232,7 +227,7 @@ static int ethnl_act_cable_test_tdr_cfg(const struct nlattr *nest, ...@@ -232,7 +227,7 @@ static int ethnl_act_cable_test_tdr_cfg(const struct nlattr *nest,
struct genl_info *info, struct genl_info *info,
struct phy_tdr_config *cfg) struct phy_tdr_config *cfg)
{ {
struct nlattr *tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(cable_test_tdr_act_cfg_policy)];
int ret; int ret;
cfg->first = 100; cfg->first = 100;
...@@ -243,8 +238,10 @@ static int ethnl_act_cable_test_tdr_cfg(const struct nlattr *nest, ...@@ -243,8 +238,10 @@ static int ethnl_act_cable_test_tdr_cfg(const struct nlattr *nest,
if (!nest) if (!nest)
return 0; return 0;
ret = nla_parse_nested(tb, ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX, nest, ret = nla_parse_nested(tb,
cable_test_tdr_act_cfg_policy, info->extack); ARRAY_SIZE(cable_test_tdr_act_cfg_policy) - 1,
nest, cable_test_tdr_act_cfg_policy,
info->extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -17,18 +17,8 @@ struct channels_reply_data { ...@@ -17,18 +17,8 @@ struct channels_reply_data {
#define CHANNELS_REPDATA(__reply_base) \ #define CHANNELS_REPDATA(__reply_base) \
container_of(__reply_base, struct channels_reply_data, base) container_of(__reply_base, struct channels_reply_data, base)
const struct nla_policy const struct nla_policy ethnl_channels_get_policy[] = {
ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_MAX + 1] = {
[ETHTOOL_A_CHANNELS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_CHANNELS_RX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_TX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_OTHER_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_COMBINED_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_RX_COUNT] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_TX_COUNT] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_COMBINED_COUNT] = { .type = NLA_REJECT },
}; };
static int channels_prepare_data(const struct ethnl_req_info *req_base, static int channels_prepare_data(const struct ethnl_req_info *req_base,
...@@ -109,14 +99,8 @@ const struct ethnl_request_ops ethnl_channels_request_ops = { ...@@ -109,14 +99,8 @@ const struct ethnl_request_ops ethnl_channels_request_ops = {
/* CHANNELS_SET */ /* CHANNELS_SET */
const struct nla_policy const struct nla_policy ethnl_channels_set_policy[] = {
ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_MAX + 1] = {
[ETHTOOL_A_CHANNELS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_CHANNELS_RX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_TX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_OTHER_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_COMBINED_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_CHANNELS_RX_COUNT] = { .type = NLA_U32 }, [ETHTOOL_A_CHANNELS_RX_COUNT] = { .type = NLA_U32 },
[ETHTOOL_A_CHANNELS_TX_COUNT] = { .type = NLA_U32 }, [ETHTOOL_A_CHANNELS_TX_COUNT] = { .type = NLA_U32 },
[ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .type = NLA_U32 }, [ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .type = NLA_U32 },
......
...@@ -51,32 +51,8 @@ __CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS_HIGH); ...@@ -51,32 +51,8 @@ __CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS_HIGH);
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_HIGH); __CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_HIGH);
__CHECK_SUPPORTED_OFFSET(COALESCE_RATE_SAMPLE_INTERVAL); __CHECK_SUPPORTED_OFFSET(COALESCE_RATE_SAMPLE_INTERVAL);
const struct nla_policy const struct nla_policy ethnl_coalesce_get_policy[] = {
ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_MAX + 1] = {
[ETHTOOL_A_COALESCE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_USECS_IRQ] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_USECS] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_USECS_IRQ] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_STATS_BLOCK_USECS] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_PKT_RATE_LOW] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_USECS_LOW] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_USECS_LOW] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_PKT_RATE_HIGH] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_USECS_HIGH] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_USECS_HIGH] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL] = { .type = NLA_REJECT },
}; };
static int coalesce_prepare_data(const struct ethnl_req_info *req_base, static int coalesce_prepare_data(const struct ethnl_req_info *req_base,
...@@ -213,9 +189,7 @@ const struct ethnl_request_ops ethnl_coalesce_request_ops = { ...@@ -213,9 +189,7 @@ const struct ethnl_request_ops ethnl_coalesce_request_ops = {
/* COALESCE_SET */ /* COALESCE_SET */
const struct nla_policy const struct nla_policy ethnl_coalesce_set_policy[] = {
ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1] = {
[ETHTOOL_A_COALESCE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_U32 }, [ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_U32 },
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_U32 }, [ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_U32 },
......
...@@ -16,10 +16,8 @@ struct debug_reply_data { ...@@ -16,10 +16,8 @@ struct debug_reply_data {
#define DEBUG_REPDATA(__reply_base) \ #define DEBUG_REPDATA(__reply_base) \
container_of(__reply_base, struct debug_reply_data, base) container_of(__reply_base, struct debug_reply_data, base)
const struct nla_policy ethnl_debug_get_policy[ETHTOOL_A_DEBUG_MAX + 1] = { const struct nla_policy ethnl_debug_get_policy[] = {
[ETHTOOL_A_DEBUG_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_DEBUG_MSGMASK] = { .type = NLA_REJECT },
}; };
static int debug_prepare_data(const struct ethnl_req_info *req_base, static int debug_prepare_data(const struct ethnl_req_info *req_base,
...@@ -78,8 +76,7 @@ const struct ethnl_request_ops ethnl_debug_request_ops = { ...@@ -78,8 +76,7 @@ const struct ethnl_request_ops ethnl_debug_request_ops = {
/* DEBUG_SET */ /* DEBUG_SET */
const struct nla_policy ethnl_debug_set_policy[ETHTOOL_A_DEBUG_MAX + 1] = { const struct nla_policy ethnl_debug_set_policy[] = {
[ETHTOOL_A_DEBUG_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_DEBUG_MSGMASK] = { .type = NLA_NESTED }, [ETHTOOL_A_DEBUG_MSGMASK] = { .type = NLA_NESTED },
}; };
......
...@@ -19,15 +19,8 @@ struct eee_reply_data { ...@@ -19,15 +19,8 @@ struct eee_reply_data {
#define EEE_REPDATA(__reply_base) \ #define EEE_REPDATA(__reply_base) \
container_of(__reply_base, struct eee_reply_data, base) container_of(__reply_base, struct eee_reply_data, base)
const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_MAX + 1] = { const struct nla_policy ethnl_eee_get_policy[] = {
[ETHTOOL_A_EEE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_EEE_MODES_OURS] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_MODES_PEER] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_ACTIVE] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_ENABLED] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_TX_LPI_TIMER] = { .type = NLA_REJECT },
}; };
static int eee_prepare_data(const struct ethnl_req_info *req_base, static int eee_prepare_data(const struct ethnl_req_info *req_base,
...@@ -128,12 +121,9 @@ const struct ethnl_request_ops ethnl_eee_request_ops = { ...@@ -128,12 +121,9 @@ const struct ethnl_request_ops ethnl_eee_request_ops = {
/* EEE_SET */ /* EEE_SET */
const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_MAX + 1] = { const struct nla_policy ethnl_eee_set_policy[] = {
[ETHTOOL_A_EEE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_EEE_MODES_OURS] = { .type = NLA_NESTED }, [ETHTOOL_A_EEE_MODES_OURS] = { .type = NLA_NESTED },
[ETHTOOL_A_EEE_MODES_PEER] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_ACTIVE] = { .type = NLA_REJECT },
[ETHTOOL_A_EEE_ENABLED] = { .type = NLA_U8 }, [ETHTOOL_A_EEE_ENABLED] = { .type = NLA_U8 },
[ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .type = NLA_U8 }, [ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .type = NLA_U8 },
[ETHTOOL_A_EEE_TX_LPI_TIMER] = { .type = NLA_U32 }, [ETHTOOL_A_EEE_TX_LPI_TIMER] = { .type = NLA_U32 },
......
...@@ -20,14 +20,8 @@ struct features_reply_data { ...@@ -20,14 +20,8 @@ struct features_reply_data {
#define FEATURES_REPDATA(__reply_base) \ #define FEATURES_REPDATA(__reply_base) \
container_of(__reply_base, struct features_reply_data, base) container_of(__reply_base, struct features_reply_data, base)
const struct nla_policy const struct nla_policy ethnl_features_get_policy[] = {
ethnl_features_get_policy[ETHTOOL_A_FEATURES_MAX + 1] = {
[ETHTOOL_A_FEATURES_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_FEATURES_HW] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_WANTED] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_ACTIVE] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_NOCHANGE] = { .type = NLA_REJECT },
}; };
static void ethnl_features_to_bitmap32(u32 *dest, netdev_features_t src) static void ethnl_features_to_bitmap32(u32 *dest, netdev_features_t src)
...@@ -130,14 +124,9 @@ const struct ethnl_request_ops ethnl_features_request_ops = { ...@@ -130,14 +124,9 @@ const struct ethnl_request_ops ethnl_features_request_ops = {
/* FEATURES_SET */ /* FEATURES_SET */
const struct nla_policy const struct nla_policy ethnl_features_set_policy[] = {
ethnl_features_set_policy[ETHTOOL_A_FEATURES_MAX + 1] = {
[ETHTOOL_A_FEATURES_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_FEATURES_HW] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_WANTED] = { .type = NLA_NESTED }, [ETHTOOL_A_FEATURES_WANTED] = { .type = NLA_NESTED },
[ETHTOOL_A_FEATURES_ACTIVE] = { .type = NLA_REJECT },
[ETHTOOL_A_FEATURES_NOCHANGE] = { .type = NLA_REJECT },
}; };
static void ethnl_features_to_bitmap(unsigned long *dest, netdev_features_t val) static void ethnl_features_to_bitmap(unsigned long *dest, netdev_features_t val)
......
...@@ -16,15 +16,8 @@ struct linkinfo_reply_data { ...@@ -16,15 +16,8 @@ struct linkinfo_reply_data {
#define LINKINFO_REPDATA(__reply_base) \ #define LINKINFO_REPDATA(__reply_base) \
container_of(__reply_base, struct linkinfo_reply_data, base) container_of(__reply_base, struct linkinfo_reply_data, base)
const struct nla_policy const struct nla_policy ethnl_linkinfo_get_policy[] = {
ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_MAX + 1] = {
[ETHTOOL_A_LINKINFO_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_LINKINFO_PORT] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_PHYADDR] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_TP_MDIX] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_TRANSCEIVER] = { .type = NLA_REJECT },
}; };
static int linkinfo_prepare_data(const struct ethnl_req_info *req_base, static int linkinfo_prepare_data(const struct ethnl_req_info *req_base,
...@@ -93,15 +86,11 @@ const struct ethnl_request_ops ethnl_linkinfo_request_ops = { ...@@ -93,15 +86,11 @@ const struct ethnl_request_ops ethnl_linkinfo_request_ops = {
/* LINKINFO_SET */ /* LINKINFO_SET */
const struct nla_policy const struct nla_policy ethnl_linkinfo_set_policy[] = {
ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_MAX + 1] = {
[ETHTOOL_A_LINKINFO_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_LINKINFO_PORT] = { .type = NLA_U8 }, [ETHTOOL_A_LINKINFO_PORT] = { .type = NLA_U8 },
[ETHTOOL_A_LINKINFO_PHYADDR] = { .type = NLA_U8 }, [ETHTOOL_A_LINKINFO_PHYADDR] = { .type = NLA_U8 },
[ETHTOOL_A_LINKINFO_TP_MDIX] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .type = NLA_U8 }, [ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .type = NLA_U8 },
[ETHTOOL_A_LINKINFO_TRANSCEIVER] = { .type = NLA_REJECT },
}; };
int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info) int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info)
......
...@@ -18,17 +18,8 @@ struct linkmodes_reply_data { ...@@ -18,17 +18,8 @@ struct linkmodes_reply_data {
#define LINKMODES_REPDATA(__reply_base) \ #define LINKMODES_REPDATA(__reply_base) \
container_of(__reply_base, struct linkmodes_reply_data, base) container_of(__reply_base, struct linkmodes_reply_data, base)
const struct nla_policy const struct nla_policy ethnl_linkmodes_get_policy[] = {
ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_MAX + 1] = {
[ETHTOOL_A_LINKMODES_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_LINKMODES_AUTONEG] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_OURS] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_PEER] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_SPEED] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_DUPLEX] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE] = { .type = NLA_REJECT },
}; };
static int linkmodes_prepare_data(const struct ethnl_req_info *req_base, static int linkmodes_prepare_data(const struct ethnl_req_info *req_base,
...@@ -274,17 +265,13 @@ static const struct link_mode_info link_mode_params[] = { ...@@ -274,17 +265,13 @@ static const struct link_mode_info link_mode_params[] = {
__DEFINE_LINK_MODE_PARAMS(100, FX, Full), __DEFINE_LINK_MODE_PARAMS(100, FX, Full),
}; };
const struct nla_policy const struct nla_policy ethnl_linkmodes_set_policy[] = {
ethnl_linkmodes_set_policy[ETHTOOL_A_LINKMODES_MAX + 1] = {
[ETHTOOL_A_LINKMODES_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_LINKMODES_AUTONEG] = { .type = NLA_U8 }, [ETHTOOL_A_LINKMODES_AUTONEG] = { .type = NLA_U8 },
[ETHTOOL_A_LINKMODES_OURS] = { .type = NLA_NESTED }, [ETHTOOL_A_LINKMODES_OURS] = { .type = NLA_NESTED },
[ETHTOOL_A_LINKMODES_PEER] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKMODES_SPEED] = { .type = NLA_U32 }, [ETHTOOL_A_LINKMODES_SPEED] = { .type = NLA_U32 },
[ETHTOOL_A_LINKMODES_DUPLEX] = { .type = NLA_U8 }, [ETHTOOL_A_LINKMODES_DUPLEX] = { .type = NLA_U8 },
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .type = NLA_U8 }, [ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .type = NLA_U8 },
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE] = { .type = NLA_REJECT },
}; };
/* Set advertised link modes to all supported modes matching requested speed /* Set advertised link modes to all supported modes matching requested speed
......
...@@ -20,15 +20,8 @@ struct linkstate_reply_data { ...@@ -20,15 +20,8 @@ struct linkstate_reply_data {
#define LINKSTATE_REPDATA(__reply_base) \ #define LINKSTATE_REPDATA(__reply_base) \
container_of(__reply_base, struct linkstate_reply_data, base) container_of(__reply_base, struct linkstate_reply_data, base)
const struct nla_policy const struct nla_policy ethnl_linkstate_get_policy[] = {
ethnl_linkstate_get_policy[ETHTOOL_A_LINKSTATE_MAX + 1] = {
[ETHTOOL_A_LINKSTATE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKSTATE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_LINKSTATE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_LINKSTATE_LINK] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKSTATE_SQI] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKSTATE_SQI_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKSTATE_EXT_STATE] = { .type = NLA_REJECT },
[ETHTOOL_A_LINKSTATE_EXT_SUBSTATE] = { .type = NLA_REJECT },
}; };
static int linkstate_get_sqi(struct net_device *dev) static int linkstate_get_sqi(struct net_device *dev)
......
...@@ -9,8 +9,7 @@ static struct genl_family ethtool_genl_family; ...@@ -9,8 +9,7 @@ static struct genl_family ethtool_genl_family;
static bool ethnl_ok __read_mostly; static bool ethnl_ok __read_mostly;
static u32 ethnl_bcast_seq; static u32 ethnl_bcast_seq;
static const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_MAX + 1] = { static const struct nla_policy ethnl_header_policy[] = {
[ETHTOOL_A_HEADER_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_HEADER_DEV_INDEX] = { .type = NLA_U32 }, [ETHTOOL_A_HEADER_DEV_INDEX] = { .type = NLA_U32 },
[ETHTOOL_A_HEADER_DEV_NAME] = { .type = NLA_NUL_STRING, [ETHTOOL_A_HEADER_DEV_NAME] = { .type = NLA_NUL_STRING,
.len = ALTIFNAMSIZ - 1 }, .len = ALTIFNAMSIZ - 1 },
...@@ -37,7 +36,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, ...@@ -37,7 +36,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
const struct nlattr *header, struct net *net, const struct nlattr *header, struct net *net,
struct netlink_ext_ack *extack, bool require_dev) struct netlink_ext_ack *extack, bool require_dev)
{ {
struct nlattr *tb[ETHTOOL_A_HEADER_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(ethnl_header_policy)];
const struct nlattr *devname_attr; const struct nlattr *devname_attr;
struct net_device *dev = NULL; struct net_device *dev = NULL;
u32 flags = 0; u32 flags = 0;
...@@ -47,7 +46,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, ...@@ -47,7 +46,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
NL_SET_ERR_MSG(extack, "request header missing"); NL_SET_ERR_MSG(extack, "request header missing");
return -EINVAL; return -EINVAL;
} }
ret = nla_parse_nested(tb, ETHTOOL_A_HEADER_MAX, header, ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_header_policy) - 1, header,
ethnl_header_policy, extack); ethnl_header_policy, extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -345,34 +345,34 @@ extern const struct ethnl_request_ops ethnl_pause_request_ops; ...@@ -345,34 +345,34 @@ extern const struct ethnl_request_ops ethnl_pause_request_ops;
extern const struct ethnl_request_ops ethnl_eee_request_ops; extern const struct ethnl_request_ops ethnl_eee_request_ops;
extern const struct ethnl_request_ops ethnl_tsinfo_request_ops; extern const struct ethnl_request_ops ethnl_tsinfo_request_ops;
extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_MAX + 1]; extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_STRINGSETS + 1];
extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_MAX + 1]; extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1];
extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_MAX + 1]; extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1];
extern const struct nla_policy ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_MAX + 1]; extern const struct nla_policy ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_HEADER + 1];
extern const struct nla_policy ethnl_linkmodes_set_policy[ETHTOOL_A_LINKMODES_MAX + 1]; extern const struct nla_policy ethnl_linkmodes_set_policy[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG + 1];
extern const struct nla_policy ethnl_linkstate_get_policy[ETHTOOL_A_LINKSTATE_MAX + 1]; extern const struct nla_policy ethnl_linkstate_get_policy[ETHTOOL_A_LINKSTATE_HEADER + 1];
extern const struct nla_policy ethnl_debug_get_policy[ETHTOOL_A_DEBUG_MAX + 1]; extern const struct nla_policy ethnl_debug_get_policy[ETHTOOL_A_DEBUG_HEADER + 1];
extern const struct nla_policy ethnl_debug_set_policy[ETHTOOL_A_DEBUG_MAX + 1]; extern const struct nla_policy ethnl_debug_set_policy[ETHTOOL_A_DEBUG_MSGMASK + 1];
extern const struct nla_policy ethnl_wol_get_policy[ETHTOOL_A_WOL_MAX + 1]; extern const struct nla_policy ethnl_wol_get_policy[ETHTOOL_A_WOL_HEADER + 1];
extern const struct nla_policy ethnl_wol_set_policy[ETHTOOL_A_WOL_MAX + 1]; extern const struct nla_policy ethnl_wol_set_policy[ETHTOOL_A_WOL_SOPASS + 1];
extern const struct nla_policy ethnl_features_get_policy[ETHTOOL_A_FEATURES_MAX + 1]; extern const struct nla_policy ethnl_features_get_policy[ETHTOOL_A_FEATURES_HEADER + 1];
extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_MAX + 1]; extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANTED + 1];
extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_MAX + 1]; extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1];
extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_MAX + 1]; extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1];
extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_MAX + 1]; extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1];
extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_MAX + 1]; extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX + 1];
extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_MAX + 1]; extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1];
extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_MAX + 1]; extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1];
extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_MAX + 1]; extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1];
extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1]; extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL + 1];
extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_MAX + 1]; extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_HEADER + 1];
extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_MAX + 1]; extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_TX + 1];
extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_MAX + 1]; extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_HEADER + 1];
extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_MAX + 1]; extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_TX_LPI_TIMER + 1];
extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_MAX + 1]; extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER + 1];
extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_MAX + 1]; extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_HEADER + 1];
extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1]; extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG + 1];
extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_MAX + 1]; extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_HEADER + 1];
int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info); int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info);
int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info); int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info);
......
...@@ -16,13 +16,8 @@ struct pause_reply_data { ...@@ -16,13 +16,8 @@ struct pause_reply_data {
#define PAUSE_REPDATA(__reply_base) \ #define PAUSE_REPDATA(__reply_base) \
container_of(__reply_base, struct pause_reply_data, base) container_of(__reply_base, struct pause_reply_data, base)
const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_MAX + 1] = { const struct nla_policy ethnl_pause_get_policy[] = {
[ETHTOOL_A_PAUSE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_REJECT },
[ETHTOOL_A_PAUSE_RX] = { .type = NLA_REJECT },
[ETHTOOL_A_PAUSE_TX] = { .type = NLA_REJECT },
[ETHTOOL_A_PAUSE_STATS] = { .type = NLA_REJECT },
}; };
static void ethtool_stats_init(u64 *stats, unsigned int n) static void ethtool_stats_init(u64 *stats, unsigned int n)
...@@ -139,13 +134,11 @@ const struct ethnl_request_ops ethnl_pause_request_ops = { ...@@ -139,13 +134,11 @@ const struct ethnl_request_ops ethnl_pause_request_ops = {
/* PAUSE_SET */ /* PAUSE_SET */
const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_MAX + 1] = { const struct nla_policy ethnl_pause_set_policy[] = {
[ETHTOOL_A_PAUSE_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_U8 }, [ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_U8 },
[ETHTOOL_A_PAUSE_RX] = { .type = NLA_U8 }, [ETHTOOL_A_PAUSE_RX] = { .type = NLA_U8 },
[ETHTOOL_A_PAUSE_TX] = { .type = NLA_U8 }, [ETHTOOL_A_PAUSE_TX] = { .type = NLA_U8 },
[ETHTOOL_A_PAUSE_STATS] = { .type = NLA_REJECT },
}; };
int ethnl_set_pause(struct sk_buff *skb, struct genl_info *info) int ethnl_set_pause(struct sk_buff *skb, struct genl_info *info)
......
...@@ -18,11 +18,8 @@ struct privflags_reply_data { ...@@ -18,11 +18,8 @@ struct privflags_reply_data {
#define PRIVFLAGS_REPDATA(__reply_base) \ #define PRIVFLAGS_REPDATA(__reply_base) \
container_of(__reply_base, struct privflags_reply_data, base) container_of(__reply_base, struct privflags_reply_data, base)
const struct nla_policy const struct nla_policy ethnl_privflags_get_policy[] = {
ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_MAX + 1] = {
[ETHTOOL_A_PRIVFLAGS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_PRIVFLAGS_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_PRIVFLAGS_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_PRIVFLAGS_FLAGS] = { .type = NLA_REJECT },
}; };
static int ethnl_get_priv_flags_info(struct net_device *dev, static int ethnl_get_priv_flags_info(struct net_device *dev,
...@@ -135,9 +132,7 @@ const struct ethnl_request_ops ethnl_privflags_request_ops = { ...@@ -135,9 +132,7 @@ const struct ethnl_request_ops ethnl_privflags_request_ops = {
/* PRIVFLAGS_SET */ /* PRIVFLAGS_SET */
const struct nla_policy const struct nla_policy ethnl_privflags_set_policy[] = {
ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_MAX + 1] = {
[ETHTOOL_A_PRIVFLAGS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_PRIVFLAGS_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_PRIVFLAGS_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_PRIVFLAGS_FLAGS] = { .type = NLA_NESTED }, [ETHTOOL_A_PRIVFLAGS_FLAGS] = { .type = NLA_NESTED },
}; };
......
...@@ -15,17 +15,8 @@ struct rings_reply_data { ...@@ -15,17 +15,8 @@ struct rings_reply_data {
#define RINGS_REPDATA(__reply_base) \ #define RINGS_REPDATA(__reply_base) \
container_of(__reply_base, struct rings_reply_data, base) container_of(__reply_base, struct rings_reply_data, base)
const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_MAX + 1] = { const struct nla_policy ethnl_rings_get_policy[] = {
[ETHTOOL_A_RINGS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_RINGS_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_RINGS_RX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX_MINI_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX_JUMBO_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_TX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX_MINI] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX_JUMBO] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_TX] = { .type = NLA_REJECT },
}; };
static int rings_prepare_data(const struct ethnl_req_info *req_base, static int rings_prepare_data(const struct ethnl_req_info *req_base,
...@@ -106,13 +97,8 @@ const struct ethnl_request_ops ethnl_rings_request_ops = { ...@@ -106,13 +97,8 @@ const struct ethnl_request_ops ethnl_rings_request_ops = {
/* RINGS_SET */ /* RINGS_SET */
const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_MAX + 1] = { const struct nla_policy ethnl_rings_set_policy[] = {
[ETHTOOL_A_RINGS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_RINGS_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_RINGS_RX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX_MINI_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX_JUMBO_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_TX_MAX] = { .type = NLA_REJECT },
[ETHTOOL_A_RINGS_RX] = { .type = NLA_U32 }, [ETHTOOL_A_RINGS_RX] = { .type = NLA_U32 },
[ETHTOOL_A_RINGS_RX_MINI] = { .type = NLA_U32 }, [ETHTOOL_A_RINGS_RX_MINI] = { .type = NLA_U32 },
[ETHTOOL_A_RINGS_RX_JUMBO] = { .type = NLA_U32 }, [ETHTOOL_A_RINGS_RX_JUMBO] = { .type = NLA_U32 },
......
...@@ -99,18 +99,13 @@ struct strset_reply_data { ...@@ -99,18 +99,13 @@ struct strset_reply_data {
#define STRSET_REPDATA(__reply_base) \ #define STRSET_REPDATA(__reply_base) \
container_of(__reply_base, struct strset_reply_data, base) container_of(__reply_base, struct strset_reply_data, base)
const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_MAX + 1] = { const struct nla_policy ethnl_strset_get_policy[] = {
[ETHTOOL_A_STRSET_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_STRSET_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_STRSET_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_STRSET_STRINGSETS] = { .type = NLA_NESTED }, [ETHTOOL_A_STRSET_STRINGSETS] = { .type = NLA_NESTED },
}; };
static const struct nla_policy static const struct nla_policy get_stringset_policy[] = {
get_stringset_policy[ETHTOOL_A_STRINGSET_MAX + 1] = {
[ETHTOOL_A_STRINGSET_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_STRINGSET_ID] = { .type = NLA_U32 }, [ETHTOOL_A_STRINGSET_ID] = { .type = NLA_U32 },
[ETHTOOL_A_STRINGSET_COUNT] = { .type = NLA_REJECT },
[ETHTOOL_A_STRINGSET_STRINGS] = { .type = NLA_REJECT },
}; };
/** /**
...@@ -138,10 +133,10 @@ static bool strset_include(const struct strset_req_info *info, ...@@ -138,10 +133,10 @@ static bool strset_include(const struct strset_req_info *info,
static int strset_get_id(const struct nlattr *nest, u32 *val, static int strset_get_id(const struct nlattr *nest, u32 *val,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct nlattr *tb[ETHTOOL_A_STRINGSET_MAX + 1]; struct nlattr *tb[ARRAY_SIZE(get_stringset_policy)];
int ret; int ret;
ret = nla_parse_nested(tb, ETHTOOL_A_STRINGSET_MAX, nest, ret = nla_parse_nested(tb, ARRAY_SIZE(get_stringset_policy) - 1, nest,
get_stringset_policy, extack); get_stringset_policy, extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -152,9 +147,7 @@ static int strset_get_id(const struct nlattr *nest, u32 *val, ...@@ -152,9 +147,7 @@ static int strset_get_id(const struct nlattr *nest, u32 *val,
return 0; return 0;
} }
static const struct nla_policy static const struct nla_policy strset_stringsets_policy[] = {
strset_stringsets_policy[ETHTOOL_A_STRINGSETS_MAX + 1] = {
[ETHTOOL_A_STRINGSETS_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_STRINGSETS_STRINGSET] = { .type = NLA_NESTED }, [ETHTOOL_A_STRINGSETS_STRINGSET] = { .type = NLA_NESTED },
}; };
...@@ -169,7 +162,8 @@ static int strset_parse_request(struct ethnl_req_info *req_base, ...@@ -169,7 +162,8 @@ static int strset_parse_request(struct ethnl_req_info *req_base,
if (!nest) if (!nest)
return 0; return 0;
ret = nla_validate_nested(nest, ETHTOOL_A_STRINGSETS_MAX, ret = nla_validate_nested(nest,
ARRAY_SIZE(strset_stringsets_policy) - 1,
strset_stringsets_policy, extack); strset_stringsets_policy, extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -18,13 +18,8 @@ struct tsinfo_reply_data { ...@@ -18,13 +18,8 @@ struct tsinfo_reply_data {
#define TSINFO_REPDATA(__reply_base) \ #define TSINFO_REPDATA(__reply_base) \
container_of(__reply_base, struct tsinfo_reply_data, base) container_of(__reply_base, struct tsinfo_reply_data, base)
const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_MAX + 1] = { const struct nla_policy ethnl_tsinfo_get_policy[] = {
[ETHTOOL_A_TSINFO_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_TSINFO_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_TSINFO_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_TSINFO_TIMESTAMPING] = { .type = NLA_REJECT },
[ETHTOOL_A_TSINFO_TX_TYPES] = { .type = NLA_REJECT },
[ETHTOOL_A_TSINFO_RX_FILTERS] = { .type = NLA_REJECT },
[ETHTOOL_A_TSINFO_PHC_INDEX] = { .type = NLA_REJECT },
}; };
static int tsinfo_prepare_data(const struct ethnl_req_info *req_base, static int tsinfo_prepare_data(const struct ethnl_req_info *req_base,
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
#include "common.h" #include "common.h"
#include "netlink.h" #include "netlink.h"
const struct nla_policy const struct nla_policy ethnl_tunnel_info_get_policy[] = {
ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_MAX + 1] = {
[ETHTOOL_A_TUNNEL_INFO_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_TUNNEL_INFO_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_TUNNEL_INFO_HEADER] = { .type = NLA_NESTED },
}; };
......
...@@ -17,11 +17,8 @@ struct wol_reply_data { ...@@ -17,11 +17,8 @@ struct wol_reply_data {
#define WOL_REPDATA(__reply_base) \ #define WOL_REPDATA(__reply_base) \
container_of(__reply_base, struct wol_reply_data, base) container_of(__reply_base, struct wol_reply_data, base)
const struct nla_policy ethnl_wol_get_policy[ETHTOOL_A_WOL_MAX + 1] = { const struct nla_policy ethnl_wol_get_policy[] = {
[ETHTOOL_A_WOL_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_WOL_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_WOL_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_WOL_MODES] = { .type = NLA_REJECT },
[ETHTOOL_A_WOL_SOPASS] = { .type = NLA_REJECT },
}; };
static int wol_prepare_data(const struct ethnl_req_info *req_base, static int wol_prepare_data(const struct ethnl_req_info *req_base,
...@@ -98,8 +95,7 @@ const struct ethnl_request_ops ethnl_wol_request_ops = { ...@@ -98,8 +95,7 @@ const struct ethnl_request_ops ethnl_wol_request_ops = {
/* WOL_SET */ /* WOL_SET */
const struct nla_policy ethnl_wol_set_policy[ETHTOOL_A_WOL_MAX + 1] = { const struct nla_policy ethnl_wol_set_policy[] = {
[ETHTOOL_A_WOL_UNSPEC] = { .type = NLA_REJECT },
[ETHTOOL_A_WOL_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_WOL_HEADER] = { .type = NLA_NESTED },
[ETHTOOL_A_WOL_MODES] = { .type = NLA_NESTED }, [ETHTOOL_A_WOL_MODES] = { .type = NLA_NESTED },
[ETHTOOL_A_WOL_SOPASS] = { .type = NLA_BINARY, [ETHTOOL_A_WOL_SOPASS] = { .type = NLA_BINARY,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment