Commit 75cdbdd0 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net: ieee802154: have genetlink code to parse the attrs during dumpit

Benefit from the fact that the generic netlink code can parse the attrs
for dumpit op and avoid need to parse it in the op callback.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bf813b0a
...@@ -236,21 +236,14 @@ nl802154_prepare_wpan_dev_dump(struct sk_buff *skb, ...@@ -236,21 +236,14 @@ nl802154_prepare_wpan_dev_dump(struct sk_buff *skb,
struct cfg802154_registered_device **rdev, struct cfg802154_registered_device **rdev,
struct wpan_dev **wpan_dev) struct wpan_dev **wpan_dev)
{ {
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
int err; int err;
rtnl_lock(); rtnl_lock();
if (!cb->args[0]) { if (!cb->args[0]) {
err = nlmsg_parse_deprecated(cb->nlh,
GENL_HDRLEN + nl802154_fam.hdrsize,
genl_family_attrbuf(&nl802154_fam),
nl802154_fam.maxattr,
nl802154_policy, NULL);
if (err)
goto out_unlock;
*wpan_dev = __cfg802154_wpan_dev_from_attrs(sock_net(skb->sk), *wpan_dev = __cfg802154_wpan_dev_from_attrs(sock_net(skb->sk),
genl_family_attrbuf(&nl802154_fam)); info->attrs);
if (IS_ERR(*wpan_dev)) { if (IS_ERR(*wpan_dev)) {
err = PTR_ERR(*wpan_dev); err = PTR_ERR(*wpan_dev);
goto out_unlock; goto out_unlock;
...@@ -557,17 +550,8 @@ static int nl802154_dump_wpan_phy_parse(struct sk_buff *skb, ...@@ -557,17 +550,8 @@ static int nl802154_dump_wpan_phy_parse(struct sk_buff *skb,
struct netlink_callback *cb, struct netlink_callback *cb,
struct nl802154_dump_wpan_phy_state *state) struct nl802154_dump_wpan_phy_state *state)
{ {
struct nlattr **tb = genl_family_attrbuf(&nl802154_fam); const struct genl_dumpit_info *info = genl_dumpit_info(cb);
int ret = nlmsg_parse_deprecated(cb->nlh, struct nlattr **tb = info->attrs;
GENL_HDRLEN + nl802154_fam.hdrsize,
tb, nl802154_fam.maxattr,
nl802154_policy, NULL);
/* TODO check if we can handle error here,
* we have no backward compatibility
*/
if (ret)
return 0;
if (tb[NL802154_ATTR_WPAN_PHY]) if (tb[NL802154_ATTR_WPAN_PHY])
state->filter_wpan_phy = nla_get_u32(tb[NL802154_ATTR_WPAN_PHY]); state->filter_wpan_phy = nla_get_u32(tb[NL802154_ATTR_WPAN_PHY]);
...@@ -2203,7 +2187,8 @@ static void nl802154_post_doit(const struct genl_ops *ops, struct sk_buff *skb, ...@@ -2203,7 +2187,8 @@ static void nl802154_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
static const struct genl_ops nl802154_ops[] = { static const struct genl_ops nl802154_ops[] = {
{ {
.cmd = NL802154_CMD_GET_WPAN_PHY, .cmd = NL802154_CMD_GET_WPAN_PHY,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.doit = nl802154_get_wpan_phy, .doit = nl802154_get_wpan_phy,
.dumpit = nl802154_dump_wpan_phy, .dumpit = nl802154_dump_wpan_phy,
.done = nl802154_dump_wpan_phy_done, .done = nl802154_dump_wpan_phy_done,
...@@ -2343,7 +2328,8 @@ static const struct genl_ops nl802154_ops[] = { ...@@ -2343,7 +2328,8 @@ static const struct genl_ops nl802154_ops[] = {
}, },
{ {
.cmd = NL802154_CMD_GET_SEC_KEY, .cmd = NL802154_CMD_GET_SEC_KEY,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
/* TODO .doit by matching key id? */ /* TODO .doit by matching key id? */
.dumpit = nl802154_dump_llsec_key, .dumpit = nl802154_dump_llsec_key,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
...@@ -2369,7 +2355,8 @@ static const struct genl_ops nl802154_ops[] = { ...@@ -2369,7 +2355,8 @@ static const struct genl_ops nl802154_ops[] = {
/* TODO unique identifier must short+pan OR extended_addr */ /* TODO unique identifier must short+pan OR extended_addr */
{ {
.cmd = NL802154_CMD_GET_SEC_DEV, .cmd = NL802154_CMD_GET_SEC_DEV,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
/* TODO .doit by matching extended_addr? */ /* TODO .doit by matching extended_addr? */
.dumpit = nl802154_dump_llsec_dev, .dumpit = nl802154_dump_llsec_dev,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
...@@ -2395,7 +2382,8 @@ static const struct genl_ops nl802154_ops[] = { ...@@ -2395,7 +2382,8 @@ static const struct genl_ops nl802154_ops[] = {
/* TODO remove complete devkey, put it as nested? */ /* TODO remove complete devkey, put it as nested? */
{ {
.cmd = NL802154_CMD_GET_SEC_DEVKEY, .cmd = NL802154_CMD_GET_SEC_DEVKEY,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
/* TODO doit by matching ??? */ /* TODO doit by matching ??? */
.dumpit = nl802154_dump_llsec_devkey, .dumpit = nl802154_dump_llsec_devkey,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
...@@ -2420,7 +2408,8 @@ static const struct genl_ops nl802154_ops[] = { ...@@ -2420,7 +2408,8 @@ static const struct genl_ops nl802154_ops[] = {
}, },
{ {
.cmd = NL802154_CMD_GET_SEC_LEVEL, .cmd = NL802154_CMD_GET_SEC_LEVEL,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
/* TODO .doit by matching frame_type? */ /* TODO .doit by matching frame_type? */
.dumpit = nl802154_dump_llsec_seclevel, .dumpit = nl802154_dump_llsec_seclevel,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment