Skip to content

Commit fceb643

Browse files
jmberg-inteldavem330
authored andcommitted
netlink: pass extended ACK struct to parsing functions
Pass the new extended ACK reporting struct to all of the generic netlink parsing functions. For now, pass NULL in almost all callers (except for some in the core.) Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba0dc5f commit fceb643

File tree

129 files changed

+477
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+477
-391
lines changed

crypto/crypto_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
523523
}
524524

525525
err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX,
526-
crypto_policy);
526+
crypto_policy, NULL);
527527
if (err < 0)
528528
return err;
529529

drivers/block/drbd/drbd_nla.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int drbd_nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
3434

3535
err = drbd_nla_check_mandatory(maxtype, nla);
3636
if (!err)
37-
err = nla_parse_nested(tb, maxtype, nla, policy);
37+
err = nla_parse_nested(tb, maxtype, nla, policy, NULL);
3838

3939
return err;
4040
}

drivers/infiniband/core/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static inline bool ib_nl_is_good_ip_resp(const struct nlmsghdr *nlh)
8888
return false;
8989

9090
ret = nla_parse(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
91-
nlmsg_len(nlh), ib_nl_addr_policy);
91+
nlmsg_len(nlh), ib_nl_addr_policy, NULL);
9292
if (ret)
9393
return false;
9494

drivers/infiniband/core/iwpm_util.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,14 @@ int iwpm_parse_nlmsg(struct netlink_callback *cb, int policy_max,
472472
int ret;
473473
const char *err_str = "";
474474

475-
ret = nlmsg_validate(cb->nlh, nlh_len, policy_max-1, nlmsg_policy);
475+
ret = nlmsg_validate(cb->nlh, nlh_len, policy_max - 1, nlmsg_policy,
476+
NULL);
476477
if (ret) {
477478
err_str = "Invalid attribute";
478479
goto parse_nlmsg_error;
479480
}
480-
ret = nlmsg_parse(cb->nlh, nlh_len, nltb, policy_max-1, nlmsg_policy);
481+
ret = nlmsg_parse(cb->nlh, nlh_len, nltb, policy_max - 1,
482+
nlmsg_policy, NULL);
481483
if (ret) {
482484
err_str = "Unable to parse the nlmsg";
483485
goto parse_nlmsg_error;

drivers/infiniband/core/sa_query.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
808808
return -EPERM;
809809

810810
ret = nla_parse(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
811-
nlmsg_len(nlh), ib_nl_policy);
811+
nlmsg_len(nlh), ib_nl_policy, NULL);
812812
attr = (const struct nlattr *)tb[LS_NLA_TYPE_TIMEOUT];
813813
if (ret || !attr)
814814
goto settimeout_out;
@@ -860,7 +860,7 @@ static inline int ib_nl_is_good_resolve_resp(const struct nlmsghdr *nlh)
860860
return 0;
861861

862862
ret = nla_parse(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
863-
nlmsg_len(nlh), ib_nl_policy);
863+
nlmsg_len(nlh), ib_nl_policy, NULL);
864864
if (ret)
865865
return 0;
866866

drivers/net/macsec.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,8 +1590,9 @@ static int parse_sa_config(struct nlattr **attrs, struct nlattr **tb_sa)
15901590
if (!attrs[MACSEC_ATTR_SA_CONFIG])
15911591
return -EINVAL;
15921592

1593-
if (nla_parse_nested(tb_sa, MACSEC_SA_ATTR_MAX, attrs[MACSEC_ATTR_SA_CONFIG],
1594-
macsec_genl_sa_policy))
1593+
if (nla_parse_nested(tb_sa, MACSEC_SA_ATTR_MAX,
1594+
attrs[MACSEC_ATTR_SA_CONFIG],
1595+
macsec_genl_sa_policy, NULL))
15951596
return -EINVAL;
15961597

15971598
return 0;
@@ -1602,8 +1603,9 @@ static int parse_rxsc_config(struct nlattr **attrs, struct nlattr **tb_rxsc)
16021603
if (!attrs[MACSEC_ATTR_RXSC_CONFIG])
16031604
return -EINVAL;
16041605

1605-
if (nla_parse_nested(tb_rxsc, MACSEC_RXSC_ATTR_MAX, attrs[MACSEC_ATTR_RXSC_CONFIG],
1606-
macsec_genl_rxsc_policy))
1606+
if (nla_parse_nested(tb_rxsc, MACSEC_RXSC_ATTR_MAX,
1607+
attrs[MACSEC_ATTR_RXSC_CONFIG],
1608+
macsec_genl_rxsc_policy, NULL))
16071609
return -EINVAL;
16081610

16091611
return 0;

drivers/net/team/team.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,7 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
24712471
goto team_put;
24722472
}
24732473
err = nla_parse_nested(opt_attrs, TEAM_ATTR_OPTION_MAX,
2474-
nl_option, team_nl_option_policy);
2474+
nl_option, team_nl_option_policy, NULL);
24752475
if (err)
24762476
goto team_put;
24772477
if (!opt_attrs[TEAM_ATTR_OPTION_NAME] ||

drivers/net/veth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
368368
ifmp = nla_data(nla_peer);
369369
err = rtnl_nla_parse_ifla(peer_tb,
370370
nla_data(nla_peer) + sizeof(struct ifinfomsg),
371-
nla_len(nla_peer) - sizeof(struct ifinfomsg));
371+
nla_len(nla_peer) - sizeof(struct ifinfomsg),
372+
NULL);
372373
if (err < 0)
373374
return err;
374375

drivers/net/wireless/ath/ath10k/testmode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ int ath10k_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
420420
struct nlattr *tb[ATH10K_TM_ATTR_MAX + 1];
421421
int ret;
422422

423-
ret = nla_parse(tb, ATH10K_TM_ATTR_MAX, data, len,
424-
ath10k_tm_policy);
423+
ret = nla_parse(tb, ATH10K_TM_ATTR_MAX, data, len, ath10k_tm_policy,
424+
NULL);
425425
if (ret)
426426
return ret;
427427

drivers/net/wireless/ath/ath6kl/testmode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ int ath6kl_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
7474
int err, buf_len;
7575
void *buf;
7676

77-
err = nla_parse(tb, ATH6KL_TM_ATTR_MAX, data, len,
78-
ath6kl_tm_policy);
77+
err = nla_parse(tb, ATH6KL_TM_ATTR_MAX, data, len, ath6kl_tm_policy,
78+
NULL);
7979
if (err)
8080
return err;
8181

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3711,7 +3711,8 @@ static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm,
37113711
int err;
37123712
u32 noa_duration;
37133713

3714-
err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy);
3714+
err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy,
3715+
NULL);
37153716
if (err)
37163717
return err;
37173718

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static int mac80211_hwsim_vendor_cmd_test(struct wiphy *wiphy,
389389
u32 val;
390390

391391
err = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
392-
hwsim_vendor_test_policy);
392+
hwsim_vendor_test_policy, NULL);
393393
if (err)
394394
return err;
395395
if (!tb[QCA_WLAN_VENDOR_ATTR_TEST])
@@ -1852,7 +1852,7 @@ static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw,
18521852
int err, ps;
18531853

18541854
err = nla_parse(tb, HWSIM_TM_ATTR_MAX, data, len,
1855-
hwsim_testmode_policy);
1855+
hwsim_testmode_policy, NULL);
18561856
if (err)
18571857
return err;
18581858

drivers/net/wireless/marvell/mwifiex/cfg80211.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4016,8 +4016,8 @@ static int mwifiex_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
40164016
if (!priv)
40174017
return -EINVAL;
40184018

4019-
err = nla_parse(tb, MWIFIEX_TM_ATTR_MAX, data, len,
4020-
mwifiex_tm_policy);
4019+
err = nla_parse(tb, MWIFIEX_TM_ATTR_MAX, data, len, mwifiex_tm_policy,
4020+
NULL);
40214021
if (err)
40224022
return err;
40234023

drivers/net/wireless/ti/wlcore/testmode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ int wl1271_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
366366
u32 nla_cmd;
367367
int err;
368368

369-
err = nla_parse(tb, WL1271_TM_ATTR_MAX, data, len, wl1271_tm_policy);
369+
err = nla_parse(tb, WL1271_TM_ATTR_MAX, data, len, wl1271_tm_policy,
370+
NULL);
370371
if (err)
371372
return err;
372373

drivers/net/wireless/ti/wlcore/vendor_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ wlcore_vendor_cmd_smart_config_start(struct wiphy *wiphy,
4141
return -EINVAL;
4242

4343
ret = nla_parse(tb, MAX_WLCORE_VENDOR_ATTR, data, data_len,
44-
wlcore_vendor_attr_policy);
44+
wlcore_vendor_attr_policy, NULL);
4545
if (ret)
4646
return ret;
4747

@@ -116,7 +116,7 @@ wlcore_vendor_cmd_smart_config_set_group_key(struct wiphy *wiphy,
116116
return -EINVAL;
117117

118118
ret = nla_parse(tb, MAX_WLCORE_VENDOR_ATTR, data, data_len,
119-
wlcore_vendor_attr_policy);
119+
wlcore_vendor_attr_policy, NULL);
120120
if (ret)
121121
return ret;
122122

include/net/genetlink.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,16 @@ genlmsg_nlhdr(void *user_hdr, const struct genl_family *family)
174174
* @tb: destination array with maxtype+1 elements
175175
* @maxtype: maximum attribute type to be expected
176176
* @policy: validation policy
177-
* */
177+
* @extack: extended ACK report struct
178+
*/
178179
static inline int genlmsg_parse(const struct nlmsghdr *nlh,
179180
const struct genl_family *family,
180181
struct nlattr *tb[], int maxtype,
181-
const struct nla_policy *policy)
182+
const struct nla_policy *policy,
183+
struct netlink_ext_ack *extack)
182184
{
183185
return nlmsg_parse(nlh, family->hdrsize + GENL_HDRLEN, tb, maxtype,
184-
policy);
186+
policy, extack);
185187
}
186188

187189
/**

include/net/netlink.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,11 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
239239
unsigned int group, int report, gfp_t flags);
240240

241241
int nla_validate(const struct nlattr *head, int len, int maxtype,
242-
const struct nla_policy *policy);
242+
const struct nla_policy *policy,
243+
struct netlink_ext_ack *extack);
243244
int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
244-
int len, const struct nla_policy *policy);
245+
int len, const struct nla_policy *policy,
246+
struct netlink_ext_ack *extack);
245247
int nla_policy_len(const struct nla_policy *, int);
246248
struct nlattr *nla_find(const struct nlattr *head, int len, int attrtype);
247249
size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize);
@@ -375,18 +377,20 @@ nlmsg_next(const struct nlmsghdr *nlh, int *remaining)
375377
* @tb: destination array with maxtype+1 elements
376378
* @maxtype: maximum attribute type to be expected
377379
* @policy: validation policy
380+
* @extack: extended ACK report struct
378381
*
379382
* See nla_parse()
380383
*/
381384
static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
382385
struct nlattr *tb[], int maxtype,
383-
const struct nla_policy *policy)
386+
const struct nla_policy *policy,
387+
struct netlink_ext_ack *extack)
384388
{
385389
if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
386390
return -EINVAL;
387391

388392
return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),
389-
nlmsg_attrlen(nlh, hdrlen), policy);
393+
nlmsg_attrlen(nlh, hdrlen), policy, extack);
390394
}
391395

392396
/**
@@ -410,16 +414,19 @@ static inline struct nlattr *nlmsg_find_attr(const struct nlmsghdr *nlh,
410414
* @hdrlen: length of familiy specific header
411415
* @maxtype: maximum attribute type to be expected
412416
* @policy: validation policy
417+
* @extack: extended ACK report struct
413418
*/
414419
static inline int nlmsg_validate(const struct nlmsghdr *nlh,
415420
int hdrlen, int maxtype,
416-
const struct nla_policy *policy)
421+
const struct nla_policy *policy,
422+
struct netlink_ext_ack *extack)
417423
{
418424
if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
419425
return -EINVAL;
420426

421427
return nla_validate(nlmsg_attrdata(nlh, hdrlen),
422-
nlmsg_attrlen(nlh, hdrlen), maxtype, policy);
428+
nlmsg_attrlen(nlh, hdrlen), maxtype, policy,
429+
extack);
423430
}
424431

425432
/**
@@ -740,14 +747,17 @@ nla_find_nested(const struct nlattr *nla, int attrtype)
740747
* @maxtype: maximum attribute type to be expected
741748
* @nla: attribute containing the nested attributes
742749
* @policy: validation policy
750+
* @extack: extended ACK report struct
743751
*
744752
* See nla_parse()
745753
*/
746754
static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,
747755
const struct nlattr *nla,
748-
const struct nla_policy *policy)
756+
const struct nla_policy *policy,
757+
struct netlink_ext_ack *extack)
749758
{
750-
return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy);
759+
return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy,
760+
extack);
751761
}
752762

753763
/**
@@ -1253,6 +1263,7 @@ static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
12531263
* @start: container attribute
12541264
* @maxtype: maximum attribute type to be expected
12551265
* @policy: validation policy
1266+
* @extack: extended ACK report struct
12561267
*
12571268
* Validates all attributes in the nested attribute stream against the
12581269
* specified policy. Attributes with a type exceeding maxtype will be
@@ -1261,9 +1272,11 @@ static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
12611272
* Returns 0 on success or a negative error code.
12621273
*/
12631274
static inline int nla_validate_nested(const struct nlattr *start, int maxtype,
1264-
const struct nla_policy *policy)
1275+
const struct nla_policy *policy,
1276+
struct netlink_ext_ack *extack)
12651277
{
1266-
return nla_validate(nla_data(start), nla_len(start), maxtype, policy);
1278+
return nla_validate(nla_data(start), nla_len(start), maxtype, policy,
1279+
extack);
12671280
}
12681281

12691282
/**

include/net/rtnetlink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname,
158158
int rtnl_delete_link(struct net_device *dev);
159159
int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm);
160160

161-
int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len);
161+
int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len,
162+
struct netlink_ext_ack *exterr);
162163

163164
#define MODULE_ALIAS_RTNL_LINK(kind) MODULE_ALIAS("rtnl-link-" kind)
164165

lib/nlattr.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
112112
* @len: length of attribute stream
113113
* @maxtype: maximum attribute type to be expected
114114
* @policy: validation policy
115+
* @extack: extended ACK report struct
115116
*
116117
* Validates all attributes in the specified attribute stream against the
117118
* specified policy. Attributes with a type exceeding maxtype will be
@@ -120,20 +121,23 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
120121
* Returns 0 on success or a negative error code.
121122
*/
122123
int nla_validate(const struct nlattr *head, int len, int maxtype,
123-
const struct nla_policy *policy)
124+
const struct nla_policy *policy,
125+
struct netlink_ext_ack *extack)
124126
{
125127
const struct nlattr *nla;
126-
int rem, err;
128+
int rem;
127129

128130
nla_for_each_attr(nla, head, len, rem) {
129-
err = validate_nla(nla, maxtype, policy);
130-
if (err < 0)
131-
goto errout;
131+
int err = validate_nla(nla, maxtype, policy);
132+
133+
if (err < 0) {
134+
if (extack)
135+
extack->bad_attr = nla;
136+
return err;
137+
}
132138
}
133139

134-
err = 0;
135-
errout:
136-
return err;
140+
return 0;
137141
}
138142
EXPORT_SYMBOL(nla_validate);
139143

@@ -180,7 +184,8 @@ EXPORT_SYMBOL(nla_policy_len);
180184
* Returns 0 on success or a negative error code.
181185
*/
182186
int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
183-
int len, const struct nla_policy *policy)
187+
int len, const struct nla_policy *policy,
188+
struct netlink_ext_ack *extack)
184189
{
185190
const struct nlattr *nla;
186191
int rem, err;
@@ -193,8 +198,11 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
193198
if (type > 0 && type <= maxtype) {
194199
if (policy) {
195200
err = validate_nla(nla, maxtype, policy);
196-
if (err < 0)
201+
if (err < 0) {
202+
if (extack)
203+
extack->bad_attr = nla;
197204
goto errout;
205+
}
198206
}
199207

200208
tb[type] = (struct nlattr *)nla;

net/8021q/vlan_netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ static inline int vlan_validate_qos_map(struct nlattr *attr)
3535
{
3636
if (!attr)
3737
return 0;
38-
return nla_validate_nested(attr, IFLA_VLAN_QOS_MAX, vlan_map_policy);
38+
return nla_validate_nested(attr, IFLA_VLAN_QOS_MAX, vlan_map_policy,
39+
NULL);
3940
}
4041

4142
static int vlan_validate(struct nlattr *tb[], struct nlattr *data[])

0 commit comments

Comments
 (0)