Skip to content

Commit

Permalink
genetlink: use parsed attrs in dumppolicy
Browse files Browse the repository at this point in the history
Attributes are already parsed based on the policy specified
in the family and ready-to-use in info->attrs. No need to
call genlmsg_parse() again.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Oct 3, 2020
1 parent 7c1e092 commit 8e1ed28
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions net/netlink/genetlink.c
Original file line number Diff line number Diff line change
@@ -1117,18 +1117,13 @@ struct ctrl_dump_policy_ctx {

static int ctrl_dumppolicy_start(struct netlink_callback *cb)
{
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
struct ctrl_dump_policy_ctx *ctx = (void *)cb->ctx;
struct nlattr *tb[CTRL_ATTR_MAX + 1];
struct nlattr **tb = info->attrs;
const struct genl_family *rt;
int err;

BUILD_BUG_ON(sizeof(*ctx) > sizeof(cb->ctx));

err = genlmsg_parse(cb->nlh, &genl_ctrl, tb, genl_ctrl.maxattr,
genl_ctrl.policy, cb->extack);
if (err)
return err;

if (!tb[CTRL_ATTR_FAMILY_ID] && !tb[CTRL_ATTR_FAMILY_NAME])
return -EINVAL;

0 comments on commit 8e1ed28

Please sign in to comment.