diff options
author | Jakub Kicinski <kuba@kernel.org> | 2020-10-05 15:07:35 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-10-06 06:25:55 -0700 |
commit | ff419afa43109e05d42d75629f21d9fd87f635ea (patch) | |
tree | aea540f88230add4ac90d08ca3d336a2a9a9deea /net/ethtool/pause.c | |
parent | 5028588b62cbda74744f4f28b35f618e5b1078ef (diff) | |
download | linux-stable-ff419afa43109e05d42d75629f21d9fd87f635ea.tar.gz linux-stable-ff419afa43109e05d42d75629f21d9fd87f635ea.tar.bz2 linux-stable-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/pause.c')
-rw-r--r-- | net/ethtool/pause.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/net/ethtool/pause.c b/net/ethtool/pause.c index ff54e3ca030d..084798d629a8 100644 --- a/net/ethtool/pause.c +++ b/net/ethtool/pause.c @@ -16,13 +16,8 @@ struct pause_reply_data { #define PAUSE_REPDATA(__reply_base) \ container_of(__reply_base, struct pause_reply_data, base) -const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_MAX + 1] = { - [ETHTOOL_A_PAUSE_UNSPEC] = { .type = NLA_REJECT }, +const struct nla_policy ethnl_pause_get_policy[] = { [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) @@ -139,13 +134,11 @@ const struct ethnl_request_ops ethnl_pause_request_ops = { /* PAUSE_SET */ -const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_MAX + 1] = { - [ETHTOOL_A_PAUSE_UNSPEC] = { .type = NLA_REJECT }, +const struct nla_policy ethnl_pause_set_policy[] = { [ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED }, [ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_U8 }, [ETHTOOL_A_PAUSE_RX] = { .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) |