Commit ff14adbd authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

genetlink: refactor the cmd <> policy mapping dump

The code at the top of ctrl_dumppolicy() dumps mappings between
ops and policies. It supports dumping both the entire family and
single op if dump is filtered. But both of those cases are handled
inside a loop, which makes the logic harder to follow and change.
Refactor to split the two cases more clearly.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e2dbda0f
...@@ -1319,21 +1319,24 @@ static int ctrl_dumppolicy(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1319,21 +1319,24 @@ static int ctrl_dumppolicy(struct sk_buff *skb, struct netlink_callback *cb)
void *hdr; void *hdr;
if (!ctx->policies) { if (!ctx->policies) {
while (ctx->opidx < genl_get_cmd_cnt(ctx->rt)) { struct genl_ops op;
struct genl_ops op;
if (ctx->single_op) { if (ctx->single_op) {
int err; int err;
err = genl_get_cmd(ctx->op, ctx->rt, &op); err = genl_get_cmd(ctx->op, ctx->rt, &op);
if (WARN_ON(err)) if (WARN_ON(err))
return skb->len; return err;
/* break out of the loop after this one */ if (ctrl_dumppolicy_put_op(skb, cb, &op))
ctx->opidx = genl_get_cmd_cnt(ctx->rt); return skb->len;
} else {
genl_get_cmd_by_index(ctx->opidx, ctx->rt, &op); /* don't enter the loop below */
} ctx->opidx = genl_get_cmd_cnt(ctx->rt);
}
while (ctx->opidx < genl_get_cmd_cnt(ctx->rt)) {
genl_get_cmd_by_index(ctx->opidx, ctx->rt, &op);
if (ctrl_dumppolicy_put_op(skb, cb, &op)) if (ctrl_dumppolicy_put_op(skb, cb, &op))
return skb->len; return skb->len;
......
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