netlink: pass extended ACK struct where available
authorJohannes Berg <johannes.berg@intel.com>
Wed, 12 Apr 2017 12:34:08 +0000 (14:34 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Apr 2017 17:58:22 +0000 (13:58 -0400)
This is an add-on to the previous patch that passes the extended ACK
structure where it's already available by existing genl_info or extack
function arguments.

This was done with this spatch (with some manual adjustment of
indentation):

@@
expression A, B, C, D, E;
identifier fn, info;
@@
fn(..., struct genl_info *info, ...) {
...
-nlmsg_parse(A, B, C, D, E, NULL)
+nlmsg_parse(A, B, C, D, E, info->extack)
...
}

@@
expression A, B, C, D, E;
identifier fn, info;
@@
fn(..., struct genl_info *info, ...) {
<...
-nla_parse_nested(A, B, C, D, NULL)
+nla_parse_nested(A, B, C, D, info->extack)
...>
}

@@
expression A, B, C, D, E;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
<...
-nlmsg_parse(A, B, C, D, E, NULL)
+nlmsg_parse(A, B, C, D, E, extack)
...>
}

@@
expression A, B, C, D, E;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
<...
-nla_parse(A, B, C, D, E, NULL)
+nla_parse(A, B, C, D, E, extack)
...>
}

@@
expression A, B, C, D, E;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
...
-nlmsg_parse(A, B, C, D, E, NULL)
+nlmsg_parse(A, B, C, D, E, extack)
...
}

@@
expression A, B, C, D;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
<...
-nla_parse_nested(A, B, C, D, NULL)
+nla_parse_nested(A, B, C, D, extack)
...>
}

@@
expression A, B, C, D;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
<...
-nlmsg_validate(A, B, C, D, NULL)
+nlmsg_validate(A, B, C, D, extack)
...>
}

@@
expression A, B, C, D;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
<...
-nla_validate(A, B, C, D, NULL)
+nla_validate(A, B, C, D, extack)
...>
}

@@
expression A, B, C;
identifier fn, extack;
@@
fn(..., struct netlink_ext_ack *extack, ...) {
<...
-nla_validate_nested(A, B, C, NULL)
+nla_validate_nested(A, B, C, extack)
...>
}

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
crypto/crypto_user.c
drivers/net/team/team.c
net/ieee802154/nl802154.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/nfnetlink.c
net/netlink/genetlink.c
net/nfc/netlink.c
net/tipc/bearer.c
net/tipc/net.c
net/tipc/node.c
net/wireless/nl80211.c
net/xfrm/xfrm_user.c

index fc79906c1fe7f222cae838312706ed98c1500436..b5758768920b5aab8d1cf73f61bd30a0d631ce9e 100644 (file)
@@ -523,7 +523,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
        }
 
        err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX,
-                         crypto_policy, NULL);
+                         crypto_policy, extack);
        if (err < 0)
                return err;
 
index 86f227124ba1088461b38443c885f4377bcfc1a1..65c056e2f7056bbb0251620e0c48c9d9678434d9 100644 (file)
@@ -2471,7 +2471,8 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
                        goto team_put;
                }
                err = nla_parse_nested(opt_attrs, TEAM_ATTR_OPTION_MAX,
-                                      nl_option, team_nl_option_policy, NULL);
+                                      nl_option, team_nl_option_policy,
+                                      info->extack);
                if (err)
                        goto team_put;
                if (!opt_attrs[TEAM_ATTR_OPTION_NAME] ||
index d6b1a1b219097a9c3d1ed457c5e6e93d94f5ed4c..99f6c254ea777c8786421d069f8f2414d0eb34e5 100644 (file)
@@ -1564,7 +1564,7 @@ static int nl802154_add_llsec_key(struct sk_buff *skb, struct genl_info *info)
 
        if (nla_parse_nested(attrs, NL802154_KEY_ATTR_MAX,
                             info->attrs[NL802154_ATTR_SEC_KEY],
-                            nl802154_key_policy, NULL))
+                            nl802154_key_policy, info->extack))
                return -EINVAL;
 
        if (!attrs[NL802154_KEY_ATTR_USAGE_FRAMES] ||
@@ -1614,7 +1614,7 @@ static int nl802154_del_llsec_key(struct sk_buff *skb, struct genl_info *info)
 
        if (nla_parse_nested(attrs, NL802154_KEY_ATTR_MAX,
                             info->attrs[NL802154_ATTR_SEC_KEY],
-                            nl802154_key_policy, NULL))
+                            nl802154_key_policy, info->extack))
                return -EINVAL;
 
        if (ieee802154_llsec_parse_key_id(attrs[NL802154_KEY_ATTR_ID], &id) < 0)
@@ -1782,7 +1782,7 @@ static int nl802154_del_llsec_dev(struct sk_buff *skb, struct genl_info *info)
 
        if (nla_parse_nested(attrs, NL802154_DEV_ATTR_MAX,
                             info->attrs[NL802154_ATTR_SEC_DEVICE],
-                            nl802154_dev_policy, NULL))
+                            nl802154_dev_policy, info->extack))
                return -EINVAL;
 
        if (!attrs[NL802154_DEV_ATTR_EXTENDED_ADDR])
@@ -1910,7 +1910,7 @@ static int nl802154_add_llsec_devkey(struct sk_buff *skb, struct genl_info *info
        if (!info->attrs[NL802154_ATTR_SEC_DEVKEY] ||
            nla_parse_nested(attrs, NL802154_DEVKEY_ATTR_MAX,
                             info->attrs[NL802154_ATTR_SEC_DEVKEY],
-                            nl802154_devkey_policy, NULL) < 0)
+                            nl802154_devkey_policy, info->extack) < 0)
                return -EINVAL;
 
        if (!attrs[NL802154_DEVKEY_ATTR_FRAME_COUNTER] ||
@@ -1942,7 +1942,7 @@ static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info
 
        if (nla_parse_nested(attrs, NL802154_DEVKEY_ATTR_MAX,
                             info->attrs[NL802154_ATTR_SEC_DEVKEY],
-                            nl802154_devkey_policy, NULL))
+                            nl802154_devkey_policy, info->extack))
                return -EINVAL;
 
        if (!attrs[NL802154_DEVKEY_ATTR_EXTENDED_ADDR])
index adb7ee142c5f6f69b992316d2474356a5459759f..892da70866d6407630b5f76a27b682d62ad7de2e 100644 (file)
@@ -3532,7 +3532,7 @@ static int ip_vs_genl_set_daemon(struct sk_buff *skb, struct genl_info *info)
                if (!info->attrs[IPVS_CMD_ATTR_DAEMON] ||
                    nla_parse_nested(daemon_attrs, IPVS_DAEMON_ATTR_MAX,
                                     info->attrs[IPVS_CMD_ATTR_DAEMON],
-                                    ip_vs_daemon_policy, NULL))
+                                    ip_vs_daemon_policy, info->extack))
                        goto out;
 
                if (cmd == IPVS_CMD_NEW_DAEMON)
index 792def00a07df4ec5a699f558d5300d580e138ad..e42f858b91d2479b4df46e0fea10a384787af77f 100644 (file)
@@ -193,7 +193,7 @@ replay:
                __u8 subsys_id = NFNL_SUBSYS_ID(type);
 
                err = nla_parse(cda, ss->cb[cb_id].attr_count, attr, attrlen,
-                               ss->cb[cb_id].policy, NULL);
+                               ss->cb[cb_id].policy, extack);
                if (err < 0) {
                        rcu_read_unlock();
                        return err;
index ff6db5e66eb57f6c7d21d1530c3f8980d24886fa..10f8b4cff40accd99898ea4d0696a2ba5d90080c 100644 (file)
@@ -574,7 +574,7 @@ static int genl_family_rcv_msg(const struct genl_family *family,
 
        if (attrbuf) {
                err = nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr,
-                                 ops->policy, NULL);
+                                 ops->policy, extack);
                if (err < 0)
                        goto out;
        }
index aca903c126713b36b51f33fed3ce5960727ba130..529443acd3bc837ca5302bfd6bae752ec2e2ecc8 100644 (file)
@@ -1162,7 +1162,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
 
        nla_for_each_nested(attr, info->attrs[NFC_ATTR_LLC_SDP], rem) {
                rc = nla_parse_nested(sdp_attrs, NFC_SDP_ATTR_MAX, attr,
-                                     nfc_sdp_genl_policy, NULL);
+                                     nfc_sdp_genl_policy, info->extack);
 
                if (rc != 0) {
                        rc = -EINVAL;
index 9b5c45f48f607525cd59c0960e2e3649e8b8c16e..d174ee3254eecb523dbc86061d80a1e812dcc305 100644 (file)
@@ -802,7 +802,7 @@ int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_BEARER_MAX,
                               info->attrs[TIPC_NLA_BEARER],
-                              tipc_nl_bearer_policy, NULL);
+                              tipc_nl_bearer_policy, info->extack);
        if (err)
                return err;
 
@@ -851,7 +851,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_BEARER_MAX,
                               info->attrs[TIPC_NLA_BEARER],
-                              tipc_nl_bearer_policy, NULL);
+                              tipc_nl_bearer_policy, info->extack);
        if (err)
                return err;
 
@@ -891,7 +891,7 @@ int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_BEARER_MAX,
                               info->attrs[TIPC_NLA_BEARER],
-                              tipc_nl_bearer_policy, NULL);
+                              tipc_nl_bearer_policy, info->extack);
        if (err)
                return err;
 
@@ -939,7 +939,7 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_BEARER_MAX,
                               info->attrs[TIPC_NLA_BEARER],
-                              tipc_nl_bearer_policy, NULL);
+                              tipc_nl_bearer_policy, info->extack);
        if (err)
                return err;
 
@@ -982,7 +982,7 @@ int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_BEARER_MAX,
                               info->attrs[TIPC_NLA_BEARER],
-                              tipc_nl_bearer_policy, NULL);
+                              tipc_nl_bearer_policy, info->extack);
        if (err)
                return err;
 
@@ -1104,7 +1104,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_MEDIA_MAX,
                               info->attrs[TIPC_NLA_MEDIA],
-                              tipc_nl_media_policy, NULL);
+                              tipc_nl_media_policy, info->extack);
        if (err)
                return err;
 
@@ -1152,7 +1152,7 @@ int tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_MEDIA_MAX,
                               info->attrs[TIPC_NLA_MEDIA],
-                              tipc_nl_media_policy, NULL);
+                              tipc_nl_media_policy, info->extack);
 
        if (!attrs[TIPC_NLA_MEDIA_NAME])
                return -EINVAL;
index 836da66cd8522f60a25b880939e0b929886b5b2a..719c5924b6383e6bf548baf57fdb713283012d87 100644 (file)
@@ -212,7 +212,7 @@ int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX,
                               info->attrs[TIPC_NLA_NET], tipc_nl_net_policy,
-                              NULL);
+                              info->extack);
        if (err)
                return err;
 
index 1dcde24c705381d6230065e3380c14371e5a55dc..01b1f077603e50284467f10b8a533bd075fe7c3c 100644 (file)
@@ -1608,7 +1608,7 @@ int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX,
                               info->attrs[TIPC_NLA_NET], tipc_nl_net_policy,
-                              NULL);
+                              info->extack);
        if (err)
                return err;
 
@@ -1774,7 +1774,7 @@ int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_LINK_MAX,
                               info->attrs[TIPC_NLA_LINK],
-                              tipc_nl_link_policy, NULL);
+                              tipc_nl_link_policy, info->extack);
        if (err)
                return err;
 
@@ -1902,7 +1902,7 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_LINK_MAX,
                               info->attrs[TIPC_NLA_LINK],
-                              tipc_nl_link_policy, NULL);
+                              tipc_nl_link_policy, info->extack);
        if (err)
                return err;
 
@@ -2042,7 +2042,7 @@ int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(attrs, TIPC_NLA_MON_MAX,
                               info->attrs[TIPC_NLA_MON],
-                              tipc_nl_monitor_policy, NULL);
+                              tipc_nl_monitor_policy, info->extack);
        if (err)
                return err;
 
index e7594a3a0ab69cccc0bc0862538260bda6ba4374..f280357552b2a5a8c9cc7b533f477c5557eb790f 100644 (file)
@@ -810,7 +810,8 @@ static int nl80211_parse_key_old(struct genl_info *info, struct key_parse *k)
                int err = nla_parse_nested(kdt,
                                           NUM_NL80211_KEY_DEFAULT_TYPES - 1,
                                           info->attrs[NL80211_ATTR_KEY_DEFAULT_TYPES],
-                                          nl80211_key_default_policy, NULL);
+                                          nl80211_key_default_policy,
+                                          info->extack);
                if (err)
                        return err;
 
@@ -2308,7 +2309,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
                                    rem_txq_params) {
                        result = nla_parse_nested(tb, NL80211_TXQ_ATTR_MAX,
                                                  nl_txq_params,
-                                                 txq_params_policy, NULL);
+                                                 txq_params_policy,
+                                                 info->extack);
                        if (result)
                                return result;
                        result = parse_txq_params(tb, &txq_params);
@@ -3561,7 +3563,7 @@ static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
                if (sband == NULL)
                        return -EINVAL;
                err = nla_parse_nested(tb, NL80211_TXRATE_MAX, tx_rates,
-                                      nl80211_txattr_policy, NULL);
+                                      nl80211_txattr_policy, info->extack);
                if (err)
                        return err;
                if (tb[NL80211_TXRATE_LEGACY]) {
@@ -4101,7 +4103,7 @@ static int parse_station_flags(struct genl_info *info,
                return 0;
 
        if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX, nla,
-                            sta_flags_policy, NULL))
+                            sta_flags_policy, info->extack))
                return -EINVAL;
 
        /*
@@ -4728,7 +4730,7 @@ static int nl80211_parse_sta_wme(struct genl_info *info,
 
        nla = info->attrs[NL80211_ATTR_STA_WME];
        err = nla_parse_nested(tb, NL80211_STA_WME_MAX, nla,
-                              nl80211_sta_wme_policy, NULL);
+                              nl80211_sta_wme_policy, info->extack);
        if (err)
                return err;
 
@@ -5853,7 +5855,7 @@ do {                                                                          \
                return -EINVAL;
        if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
                             info->attrs[NL80211_ATTR_MESH_CONFIG],
-                            nl80211_meshconf_params_policy, NULL))
+                            nl80211_meshconf_params_policy, info->extack))
                return -EINVAL;
 
        /* This makes sure that there aren't more than 32 mesh config
@@ -6002,7 +6004,7 @@ static int nl80211_parse_mesh_setup(struct genl_info *info,
                return -EINVAL;
        if (nla_parse_nested(tb, NL80211_MESH_SETUP_ATTR_MAX,
                             info->attrs[NL80211_ATTR_MESH_SETUP],
-                            nl80211_mesh_setup_params_policy, NULL))
+                            nl80211_mesh_setup_params_policy, info->extack))
                return -EINVAL;
 
        if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC])
@@ -6393,7 +6395,8 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
        nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
                            rem_reg_rules) {
                r = nla_parse_nested(tb, NL80211_REG_RULE_ATTR_MAX,
-                                    nl_reg_rule, reg_rule_policy, NULL);
+                                    nl_reg_rule, reg_rule_policy,
+                                    info->extack);
                if (r)
                        goto bad_reg;
                r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
@@ -7435,7 +7438,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(csa_attrs, NL80211_ATTR_MAX,
                               info->attrs[NL80211_ATTR_CSA_IES],
-                              nl80211_policy, NULL);
+                              nl80211_policy, info->extack);
        if (err)
                return err;
 
@@ -9533,7 +9536,7 @@ static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info)
                return -EINVAL;
 
        err = nla_parse_nested(attrs, NL80211_ATTR_CQM_MAX, cqm,
-                              nl80211_attr_cqm_policy, NULL);
+                              nl80211_attr_cqm_policy, info->extack);
        if (err)
                return err;
 
@@ -10126,7 +10129,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(tb, MAX_NL80211_WOWLAN_TRIG,
                               info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS],
-                              nl80211_wowlan_policy, NULL);
+                              nl80211_wowlan_policy, info->extack);
        if (err)
                return err;
 
@@ -10209,7 +10212,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
                        u8 *mask_pat;
 
                        nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
-                                        NULL, NULL);
+                                        NULL, info->extack);
                        err = -EINVAL;
                        if (!pat_tb[NL80211_PKTPAT_MASK] ||
                            !pat_tb[NL80211_PKTPAT_PATTERN])
@@ -10579,7 +10582,7 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info)
 
        err = nla_parse_nested(tb, MAX_NL80211_REKEY_DATA,
                               info->attrs[NL80211_ATTR_REKEY_DATA],
-                              nl80211_rekey_policy, NULL);
+                              nl80211_rekey_policy, info->extack);
        if (err)
                return err;
 
@@ -10896,7 +10899,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 
        err = nla_parse_nested(tb, NL80211_NAN_FUNC_ATTR_MAX,
                               info->attrs[NL80211_ATTR_NAN_FUNC],
-                              nl80211_nan_func_policy, NULL);
+                              nl80211_nan_func_policy, info->extack);
        if (err)
                return err;
 
@@ -10993,7 +10996,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 
                err = nla_parse_nested(srf_tb, NL80211_NAN_SRF_ATTR_MAX,
                                       tb[NL80211_NAN_FUNC_SRF],
-                                      nl80211_nan_srf_policy, NULL);
+                                      nl80211_nan_srf_policy, info->extack);
                if (err)
                        goto out;
 
index 804e99a3227c969388d53a2ef5a5f53dd717f5c7..5f691fd53a6c2ebd6f31342050c332f53ca42de7 100644 (file)
@@ -2489,7 +2489,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
 
        err = nlmsg_parse(nlh, xfrm_msg_min[type], attrs,
                          link->nla_max ? : XFRMA_MAX,
-                         link->nla_pol ? : xfrma_policy, NULL);
+                         link->nla_pol ? : xfrma_policy, extack);
        if (err < 0)
                return err;