Skip to content

Commit ff419af

Browse files
kuba-moodavem330
authored andcommitted
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>
1 parent 5028588 commit ff419af

19 files changed

Lines changed: 83 additions & 229 deletions

‎net/ethtool/bitset.c‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ int ethnl_put_bitset32(struct sk_buff *skb, int attrtype, const u32 *val,
302302
return -EMSGSIZE;
303303
}
304304

305-
static const struct nla_policy bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = {
306-
[ETHTOOL_A_BITSET_UNSPEC] = { .type = NLA_REJECT },
305+
static const struct nla_policy bitset_policy[] = {
307306
[ETHTOOL_A_BITSET_NOMASK] = { .type = NLA_FLAG },
308307
[ETHTOOL_A_BITSET_SIZE] = NLA_POLICY_MAX(NLA_U32,
309308
ETHNL_MAX_BITSET_SIZE),
@@ -312,8 +311,7 @@ static const struct nla_policy bitset_policy[ETHTOOL_A_BITSET_MAX + 1] = {
312311
[ETHTOOL_A_BITSET_MASK] = { .type = NLA_BINARY },
313312
};
314313

315-
static const struct nla_policy bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = {
316-
[ETHTOOL_A_BITSET_BIT_UNSPEC] = { .type = NLA_REJECT },
314+
static const struct nla_policy bit_policy[] = {
317315
[ETHTOOL_A_BITSET_BIT_INDEX] = { .type = NLA_U32 },
318316
[ETHTOOL_A_BITSET_BIT_NAME] = { .type = NLA_NUL_STRING },
319317
[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] = {
329327
*/
330328
int ethnl_bitset_is_compact(const struct nlattr *bitset, bool *compact)
331329
{
332-
struct nlattr *tb[ETHTOOL_A_BITSET_MAX + 1];
330+
struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
333331
int ret;
334332

335-
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_MAX, bitset,
333+
ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, bitset,
336334
bitset_policy, NULL);
337335
if (ret < 0)
338336
return ret;
@@ -381,10 +379,10 @@ static int ethnl_parse_bit(unsigned int *index, bool *val, unsigned int nbits,
381379
ethnl_string_array_t names,
382380
struct netlink_ext_ack *extack)
383381
{
384-
struct nlattr *tb[ETHTOOL_A_BITSET_BIT_MAX + 1];
382+
struct nlattr *tb[ARRAY_SIZE(bit_policy)];
385383
int ret, idx;
386384

387-
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_BIT_MAX, bit_attr,
385+
ret = nla_parse_nested(tb, ARRAY_SIZE(bit_policy) - 1, bit_attr,
388386
bit_policy, extack);
389387
if (ret < 0)
390388
return ret;
@@ -555,15 +553,15 @@ int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits,
555553
const struct nlattr *attr, ethnl_string_array_t names,
556554
struct netlink_ext_ack *extack, bool *mod)
557555
{
558-
struct nlattr *tb[ETHTOOL_A_BITSET_MAX + 1];
556+
struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
559557
unsigned int change_bits;
560558
bool no_mask;
561559
int ret;
562560

563561
if (!attr)
564562
return 0;
565-
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_MAX, attr, bitset_policy,
566-
extack);
563+
ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr,
564+
bitset_policy, extack);
567565
if (ret < 0)
568566
return ret;
569567

@@ -608,16 +606,16 @@ int ethnl_parse_bitset(unsigned long *val, unsigned long *mask,
608606
ethnl_string_array_t names,
609607
struct netlink_ext_ack *extack)
610608
{
611-
struct nlattr *tb[ETHTOOL_A_BITSET_MAX + 1];
609+
struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
612610
const struct nlattr *bit_attr;
613611
bool no_mask;
614612
int rem;
615613
int ret;
616614

617615
if (!attr)
618616
return 0;
619-
ret = nla_parse_nested(tb, ETHTOOL_A_BITSET_MAX, attr, bitset_policy,
620-
extack);
617+
ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr,
618+
bitset_policy, extack);
621619
if (ret < 0)
622620
return ret;
623621
no_mask = tb[ETHTOOL_A_BITSET_NOMASK];

‎net/ethtool/cabletest.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
*/
1212
#define MAX_CABLE_LENGTH_CM (150 * 100)
1313

14-
const struct nla_policy
15-
ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = {
16-
[ETHTOOL_A_CABLE_TEST_UNSPEC] = { .type = NLA_REJECT },
14+
const struct nla_policy ethnl_cable_test_act_policy[] = {
1715
[ETHTOOL_A_CABLE_TEST_HEADER] = { .type = NLA_NESTED },
1816
};
1917

@@ -212,17 +210,14 @@ struct cable_test_tdr_req_info {
212210
struct ethnl_req_info base;
213211
};
214212

215-
static const struct nla_policy
216-
cable_test_tdr_act_cfg_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX + 1] = {
213+
static const struct nla_policy cable_test_tdr_act_cfg_policy[] = {
217214
[ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .type = NLA_U32 },
218215
[ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST] = { .type = NLA_U32 },
219216
[ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP] = { .type = NLA_U32 },
220217
[ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR] = { .type = NLA_U8 },
221218
};
222219

223-
const struct nla_policy
224-
ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1] = {
225-
[ETHTOOL_A_CABLE_TEST_TDR_UNSPEC] = { .type = NLA_REJECT },
220+
const struct nla_policy ethnl_cable_test_tdr_act_policy[] = {
226221
[ETHTOOL_A_CABLE_TEST_TDR_HEADER] = { .type = NLA_NESTED },
227222
[ETHTOOL_A_CABLE_TEST_TDR_CFG] = { .type = NLA_NESTED },
228223
};
@@ -232,7 +227,7 @@ static int ethnl_act_cable_test_tdr_cfg(const struct nlattr *nest,
232227
struct genl_info *info,
233228
struct phy_tdr_config *cfg)
234229
{
235-
struct nlattr *tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX + 1];
230+
struct nlattr *tb[ARRAY_SIZE(cable_test_tdr_act_cfg_policy)];
236231
int ret;
237232

238233
cfg->first = 100;
@@ -243,8 +238,10 @@ static int ethnl_act_cable_test_tdr_cfg(const struct nlattr *nest,
243238
if (!nest)
244239
return 0;
245240

246-
ret = nla_parse_nested(tb, ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX, nest,
247-
cable_test_tdr_act_cfg_policy, info->extack);
241+
ret = nla_parse_nested(tb,
242+
ARRAY_SIZE(cable_test_tdr_act_cfg_policy) - 1,
243+
nest, cable_test_tdr_act_cfg_policy,
244+
info->extack);
248245
if (ret < 0)
249246
return ret;
250247

‎net/ethtool/channels.c‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@ struct channels_reply_data {
1717
#define CHANNELS_REPDATA(__reply_base) \
1818
container_of(__reply_base, struct channels_reply_data, base)
1919

20-
const struct nla_policy
21-
ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_MAX + 1] = {
22-
[ETHTOOL_A_CHANNELS_UNSPEC] = { .type = NLA_REJECT },
20+
const struct nla_policy ethnl_channels_get_policy[] = {
2321
[ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED },
24-
[ETHTOOL_A_CHANNELS_RX_MAX] = { .type = NLA_REJECT },
25-
[ETHTOOL_A_CHANNELS_TX_MAX] = { .type = NLA_REJECT },
26-
[ETHTOOL_A_CHANNELS_OTHER_MAX] = { .type = NLA_REJECT },
27-
[ETHTOOL_A_CHANNELS_COMBINED_MAX] = { .type = NLA_REJECT },
28-
[ETHTOOL_A_CHANNELS_RX_COUNT] = { .type = NLA_REJECT },
29-
[ETHTOOL_A_CHANNELS_TX_COUNT] = { .type = NLA_REJECT },
30-
[ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .type = NLA_REJECT },
31-
[ETHTOOL_A_CHANNELS_COMBINED_COUNT] = { .type = NLA_REJECT },
3222
};
3323

3424
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 = {
10999

110100
/* CHANNELS_SET */
111101

112-
const struct nla_policy
113-
ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_MAX + 1] = {
114-
[ETHTOOL_A_CHANNELS_UNSPEC] = { .type = NLA_REJECT },
102+
const struct nla_policy ethnl_channels_set_policy[] = {
115103
[ETHTOOL_A_CHANNELS_HEADER] = { .type = NLA_NESTED },
116-
[ETHTOOL_A_CHANNELS_RX_MAX] = { .type = NLA_REJECT },
117-
[ETHTOOL_A_CHANNELS_TX_MAX] = { .type = NLA_REJECT },
118-
[ETHTOOL_A_CHANNELS_OTHER_MAX] = { .type = NLA_REJECT },
119-
[ETHTOOL_A_CHANNELS_COMBINED_MAX] = { .type = NLA_REJECT },
120104
[ETHTOOL_A_CHANNELS_RX_COUNT] = { .type = NLA_U32 },
121105
[ETHTOOL_A_CHANNELS_TX_COUNT] = { .type = NLA_U32 },
122106
[ETHTOOL_A_CHANNELS_OTHER_COUNT] = { .type = NLA_U32 },

‎net/ethtool/coalesce.c‎

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,8 @@ __CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS_HIGH);
5151
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_HIGH);
5252
__CHECK_SUPPORTED_OFFSET(COALESCE_RATE_SAMPLE_INTERVAL);
5353

54-
const struct nla_policy
55-
ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_MAX + 1] = {
56-
[ETHTOOL_A_COALESCE_UNSPEC] = { .type = NLA_REJECT },
54+
const struct nla_policy ethnl_coalesce_get_policy[] = {
5755
[ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED },
58-
[ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_REJECT },
59-
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_REJECT },
60-
[ETHTOOL_A_COALESCE_RX_USECS_IRQ] = { .type = NLA_REJECT },
61-
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ] = { .type = NLA_REJECT },
62-
[ETHTOOL_A_COALESCE_TX_USECS] = { .type = NLA_REJECT },
63-
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES] = { .type = NLA_REJECT },
64-
[ETHTOOL_A_COALESCE_TX_USECS_IRQ] = { .type = NLA_REJECT },
65-
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ] = { .type = NLA_REJECT },
66-
[ETHTOOL_A_COALESCE_STATS_BLOCK_USECS] = { .type = NLA_REJECT },
67-
[ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX] = { .type = NLA_REJECT },
68-
[ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX] = { .type = NLA_REJECT },
69-
[ETHTOOL_A_COALESCE_PKT_RATE_LOW] = { .type = NLA_REJECT },
70-
[ETHTOOL_A_COALESCE_RX_USECS_LOW] = { .type = NLA_REJECT },
71-
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW] = { .type = NLA_REJECT },
72-
[ETHTOOL_A_COALESCE_TX_USECS_LOW] = { .type = NLA_REJECT },
73-
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW] = { .type = NLA_REJECT },
74-
[ETHTOOL_A_COALESCE_PKT_RATE_HIGH] = { .type = NLA_REJECT },
75-
[ETHTOOL_A_COALESCE_RX_USECS_HIGH] = { .type = NLA_REJECT },
76-
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH] = { .type = NLA_REJECT },
77-
[ETHTOOL_A_COALESCE_TX_USECS_HIGH] = { .type = NLA_REJECT },
78-
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH] = { .type = NLA_REJECT },
79-
[ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL] = { .type = NLA_REJECT },
8056
};
8157

8258
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 = {
213189

214190
/* COALESCE_SET */
215191

216-
const struct nla_policy
217-
ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1] = {
218-
[ETHTOOL_A_COALESCE_UNSPEC] = { .type = NLA_REJECT },
192+
const struct nla_policy ethnl_coalesce_set_policy[] = {
219193
[ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED },
220194
[ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_U32 },
221195
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_U32 },

‎net/ethtool/debug.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ struct debug_reply_data {
1616
#define DEBUG_REPDATA(__reply_base) \
1717
container_of(__reply_base, struct debug_reply_data, base)
1818

19-
const struct nla_policy ethnl_debug_get_policy[ETHTOOL_A_DEBUG_MAX + 1] = {
20-
[ETHTOOL_A_DEBUG_UNSPEC] = { .type = NLA_REJECT },
19+
const struct nla_policy ethnl_debug_get_policy[] = {
2120
[ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED },
22-
[ETHTOOL_A_DEBUG_MSGMASK] = { .type = NLA_REJECT },
2321
};
2422

2523
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 = {
7876

7977
/* DEBUG_SET */
8078

81-
const struct nla_policy ethnl_debug_set_policy[ETHTOOL_A_DEBUG_MAX + 1] = {
82-
[ETHTOOL_A_DEBUG_UNSPEC] = { .type = NLA_REJECT },
79+
const struct nla_policy ethnl_debug_set_policy[] = {
8380
[ETHTOOL_A_DEBUG_HEADER] = { .type = NLA_NESTED },
8481
[ETHTOOL_A_DEBUG_MSGMASK] = { .type = NLA_NESTED },
8582
};

‎net/ethtool/eee.c‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,8 @@ struct eee_reply_data {
1919
#define EEE_REPDATA(__reply_base) \
2020
container_of(__reply_base, struct eee_reply_data, base)
2121

22-
const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_MAX + 1] = {
23-
[ETHTOOL_A_EEE_UNSPEC] = { .type = NLA_REJECT },
22+
const struct nla_policy ethnl_eee_get_policy[] = {
2423
[ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED },
25-
[ETHTOOL_A_EEE_MODES_OURS] = { .type = NLA_REJECT },
26-
[ETHTOOL_A_EEE_MODES_PEER] = { .type = NLA_REJECT },
27-
[ETHTOOL_A_EEE_ACTIVE] = { .type = NLA_REJECT },
28-
[ETHTOOL_A_EEE_ENABLED] = { .type = NLA_REJECT },
29-
[ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .type = NLA_REJECT },
30-
[ETHTOOL_A_EEE_TX_LPI_TIMER] = { .type = NLA_REJECT },
3124
};
3225

3326
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 = {
128121

129122
/* EEE_SET */
130123

131-
const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_MAX + 1] = {
132-
[ETHTOOL_A_EEE_UNSPEC] = { .type = NLA_REJECT },
124+
const struct nla_policy ethnl_eee_set_policy[] = {
133125
[ETHTOOL_A_EEE_HEADER] = { .type = NLA_NESTED },
134126
[ETHTOOL_A_EEE_MODES_OURS] = { .type = NLA_NESTED },
135-
[ETHTOOL_A_EEE_MODES_PEER] = { .type = NLA_REJECT },
136-
[ETHTOOL_A_EEE_ACTIVE] = { .type = NLA_REJECT },
137127
[ETHTOOL_A_EEE_ENABLED] = { .type = NLA_U8 },
138128
[ETHTOOL_A_EEE_TX_LPI_ENABLED] = { .type = NLA_U8 },
139129
[ETHTOOL_A_EEE_TX_LPI_TIMER] = { .type = NLA_U32 },

‎net/ethtool/features.c‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ struct features_reply_data {
2020
#define FEATURES_REPDATA(__reply_base) \
2121
container_of(__reply_base, struct features_reply_data, base)
2222

23-
const struct nla_policy
24-
ethnl_features_get_policy[ETHTOOL_A_FEATURES_MAX + 1] = {
25-
[ETHTOOL_A_FEATURES_UNSPEC] = { .type = NLA_REJECT },
23+
const struct nla_policy ethnl_features_get_policy[] = {
2624
[ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED },
27-
[ETHTOOL_A_FEATURES_HW] = { .type = NLA_REJECT },
28-
[ETHTOOL_A_FEATURES_WANTED] = { .type = NLA_REJECT },
29-
[ETHTOOL_A_FEATURES_ACTIVE] = { .type = NLA_REJECT },
30-
[ETHTOOL_A_FEATURES_NOCHANGE] = { .type = NLA_REJECT },
3125
};
3226

3327
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 = {
130124

131125
/* FEATURES_SET */
132126

133-
const struct nla_policy
134-
ethnl_features_set_policy[ETHTOOL_A_FEATURES_MAX + 1] = {
135-
[ETHTOOL_A_FEATURES_UNSPEC] = { .type = NLA_REJECT },
127+
const struct nla_policy ethnl_features_set_policy[] = {
136128
[ETHTOOL_A_FEATURES_HEADER] = { .type = NLA_NESTED },
137-
[ETHTOOL_A_FEATURES_HW] = { .type = NLA_REJECT },
138129
[ETHTOOL_A_FEATURES_WANTED] = { .type = NLA_NESTED },
139-
[ETHTOOL_A_FEATURES_ACTIVE] = { .type = NLA_REJECT },
140-
[ETHTOOL_A_FEATURES_NOCHANGE] = { .type = NLA_REJECT },
141130
};
142131

143132
static void ethnl_features_to_bitmap(unsigned long *dest, netdev_features_t val)

‎net/ethtool/linkinfo.c‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ struct linkinfo_reply_data {
1616
#define LINKINFO_REPDATA(__reply_base) \
1717
container_of(__reply_base, struct linkinfo_reply_data, base)
1818

19-
const struct nla_policy
20-
ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_MAX + 1] = {
21-
[ETHTOOL_A_LINKINFO_UNSPEC] = { .type = NLA_REJECT },
19+
const struct nla_policy ethnl_linkinfo_get_policy[] = {
2220
[ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED },
23-
[ETHTOOL_A_LINKINFO_PORT] = { .type = NLA_REJECT },
24-
[ETHTOOL_A_LINKINFO_PHYADDR] = { .type = NLA_REJECT },
25-
[ETHTOOL_A_LINKINFO_TP_MDIX] = { .type = NLA_REJECT },
26-
[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .type = NLA_REJECT },
27-
[ETHTOOL_A_LINKINFO_TRANSCEIVER] = { .type = NLA_REJECT },
2821
};
2922

3023
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 = {
9386

9487
/* LINKINFO_SET */
9588

96-
const struct nla_policy
97-
ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_MAX + 1] = {
98-
[ETHTOOL_A_LINKINFO_UNSPEC] = { .type = NLA_REJECT },
89+
const struct nla_policy ethnl_linkinfo_set_policy[] = {
9990
[ETHTOOL_A_LINKINFO_HEADER] = { .type = NLA_NESTED },
10091
[ETHTOOL_A_LINKINFO_PORT] = { .type = NLA_U8 },
10192
[ETHTOOL_A_LINKINFO_PHYADDR] = { .type = NLA_U8 },
102-
[ETHTOOL_A_LINKINFO_TP_MDIX] = { .type = NLA_REJECT },
10393
[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL] = { .type = NLA_U8 },
104-
[ETHTOOL_A_LINKINFO_TRANSCEIVER] = { .type = NLA_REJECT },
10594
};
10695

10796
int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info)

‎net/ethtool/linkmodes.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,8 @@ struct linkmodes_reply_data {
1818
#define LINKMODES_REPDATA(__reply_base) \
1919
container_of(__reply_base, struct linkmodes_reply_data, base)
2020

21-
const struct nla_policy
22-
ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_MAX + 1] = {
23-
[ETHTOOL_A_LINKMODES_UNSPEC] = { .type = NLA_REJECT },
21+
const struct nla_policy ethnl_linkmodes_get_policy[] = {
2422
[ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED },
25-
[ETHTOOL_A_LINKMODES_AUTONEG] = { .type = NLA_REJECT },
26-
[ETHTOOL_A_LINKMODES_OURS] = { .type = NLA_REJECT },
27-
[ETHTOOL_A_LINKMODES_PEER] = { .type = NLA_REJECT },
28-
[ETHTOOL_A_LINKMODES_SPEED] = { .type = NLA_REJECT },
29-
[ETHTOOL_A_LINKMODES_DUPLEX] = { .type = NLA_REJECT },
30-
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .type = NLA_REJECT },
31-
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE] = { .type = NLA_REJECT },
3223
};
3324

3425
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[] = {
274265
__DEFINE_LINK_MODE_PARAMS(100, FX, Full),
275266
};
276267

277-
const struct nla_policy
278-
ethnl_linkmodes_set_policy[ETHTOOL_A_LINKMODES_MAX + 1] = {
279-
[ETHTOOL_A_LINKMODES_UNSPEC] = { .type = NLA_REJECT },
268+
const struct nla_policy ethnl_linkmodes_set_policy[] = {
280269
[ETHTOOL_A_LINKMODES_HEADER] = { .type = NLA_NESTED },
281270
[ETHTOOL_A_LINKMODES_AUTONEG] = { .type = NLA_U8 },
282271
[ETHTOOL_A_LINKMODES_OURS] = { .type = NLA_NESTED },
283-
[ETHTOOL_A_LINKMODES_PEER] = { .type = NLA_REJECT },
284272
[ETHTOOL_A_LINKMODES_SPEED] = { .type = NLA_U32 },
285273
[ETHTOOL_A_LINKMODES_DUPLEX] = { .type = NLA_U8 },
286274
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG] = { .type = NLA_U8 },
287-
[ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE] = { .type = NLA_REJECT },
288275
};
289276

290277
/* Set advertised link modes to all supported modes matching requested speed

‎net/ethtool/linkstate.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@ struct linkstate_reply_data {
2020
#define LINKSTATE_REPDATA(__reply_base) \
2121
container_of(__reply_base, struct linkstate_reply_data, base)
2222

23-
const struct nla_policy
24-
ethnl_linkstate_get_policy[ETHTOOL_A_LINKSTATE_MAX + 1] = {
25-
[ETHTOOL_A_LINKSTATE_UNSPEC] = { .type = NLA_REJECT },
23+
const struct nla_policy ethnl_linkstate_get_policy[] = {
2624
[ETHTOOL_A_LINKSTATE_HEADER] = { .type = NLA_NESTED },
27-
[ETHTOOL_A_LINKSTATE_LINK] = { .type = NLA_REJECT },
28-
[ETHTOOL_A_LINKSTATE_SQI] = { .type = NLA_REJECT },
29-
[ETHTOOL_A_LINKSTATE_SQI_MAX] = { .type = NLA_REJECT },
30-
[ETHTOOL_A_LINKSTATE_EXT_STATE] = { .type = NLA_REJECT },
31-
[ETHTOOL_A_LINKSTATE_EXT_SUBSTATE] = { .type = NLA_REJECT },
3225
};
3326

3427
static int linkstate_get_sqi(struct net_device *dev)

0 commit comments

Comments
 (0)