mirror of https://gitee.com/openkylin/linux.git
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: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
bf813b0afe
commit
75cdbdd089
|
@ -236,21 +236,14 @@ nl802154_prepare_wpan_dev_dump(struct sk_buff *skb,
|
|||
struct cfg802154_registered_device **rdev,
|
||||
struct wpan_dev **wpan_dev)
|
||||
{
|
||||
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
|
||||
int err;
|
||||
|
||||
rtnl_lock();
|
||||
|
||||
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),
|
||||
genl_family_attrbuf(&nl802154_fam));
|
||||
info->attrs);
|
||||
if (IS_ERR(*wpan_dev)) {
|
||||
err = PTR_ERR(*wpan_dev);
|
||||
goto out_unlock;
|
||||
|
@ -557,17 +550,8 @@ static int nl802154_dump_wpan_phy_parse(struct sk_buff *skb,
|
|||
struct netlink_callback *cb,
|
||||
struct nl802154_dump_wpan_phy_state *state)
|
||||
{
|
||||
struct nlattr **tb = genl_family_attrbuf(&nl802154_fam);
|
||||
int ret = nlmsg_parse_deprecated(cb->nlh,
|
||||
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;
|
||||
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
|
||||
struct nlattr **tb = info->attrs;
|
||||
|
||||
if (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,
|
|||
static const struct genl_ops nl802154_ops[] = {
|
||||
{
|
||||
.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,
|
||||
.dumpit = nl802154_dump_wpan_phy,
|
||||
.done = nl802154_dump_wpan_phy_done,
|
||||
|
@ -2343,7 +2328,8 @@ static const struct genl_ops nl802154_ops[] = {
|
|||
},
|
||||
{
|
||||
.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? */
|
||||
.dumpit = nl802154_dump_llsec_key,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
|
@ -2369,7 +2355,8 @@ static const struct genl_ops nl802154_ops[] = {
|
|||
/* TODO unique identifier must short+pan OR extended_addr */
|
||||
{
|
||||
.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? */
|
||||
.dumpit = nl802154_dump_llsec_dev,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
|
@ -2395,7 +2382,8 @@ static const struct genl_ops nl802154_ops[] = {
|
|||
/* TODO remove complete devkey, put it as nested? */
|
||||
{
|
||||
.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 ??? */
|
||||
.dumpit = nl802154_dump_llsec_devkey,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
|
@ -2420,7 +2408,8 @@ static const struct genl_ops nl802154_ops[] = {
|
|||
},
|
||||
{
|
||||
.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? */
|
||||
.dumpit = nl802154_dump_llsec_seclevel,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
|
|
Loading…
Reference in New Issue