diff options
author | Jakub Kicinski <kuba@kernel.org> | 2020-10-06 00:07:35 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-10-06 15:25:55 +0200 |
commit | ff419afa43109e05d42d75629f21d9fd87f635ea (patch) | |
tree | aea540f88230add4ac90d08ca3d336a2a9a9deea /net/ethtool/features.c | |
parent | ethtool: wire up set policies to ops (diff) | |
download | linux-ff419afa43109e05d42d75629f21d9fd87f635ea.tar.xz linux-ff419afa43109e05d42d75629f21d9fd87f635ea.zip |
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: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool/features.c')
-rw-r--r-- | net/ethtool/features.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/net/ethtool/features.c b/net/ethtool/features.c index e4a91d86824d..920386cf7d0a 100644 --- a/net/ethtool/features.c +++ b/net/ethtool/features.c @@ -20,14 +20,8 @@ struct features_reply_data { #define FEATURES_REPDATA(__reply_base) \ container_of(__reply_base, struct features_reply_data, base) -const struct nla_policy -ethnl_features_get_policy[ETHTOOL_A_FEATURES_MAX + 1] = { - [ETHTOOL_A_FEATURES_UNSPEC] = { .type = NLA_REJECT }, +const struct nla_policy ethnl_features_get_policy[] = { [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) @@ -130,14 +124,9 @@ const struct ethnl_request_ops ethnl_features_request_ops = { /* FEATURES_SET */ -const struct nla_policy -ethnl_features_set_policy[ETHTOOL_A_FEATURES_MAX + 1] = { - [ETHTOOL_A_FEATURES_UNSPEC] = { .type = NLA_REJECT }, +const struct nla_policy ethnl_features_set_policy[] = { [ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED }, - [ETHTOOL_A_FEATURES_HW] = { .type = NLA_REJECT }, [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) |