Skip to content

Commit aa85ee5

Browse files
jmberg-inteldavem330
authored andcommitted
genetlink: factor skb preparation out of ctrl_dumppolicy()
We'll need this later for the per-op policy index dump. Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 04a351a commit aa85ee5

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

net/netlink/genetlink.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,24 @@ static int ctrl_dumppolicy_start(struct netlink_callback *cb)
11541154
rt->maxattr);
11551155
}
11561156

1157+
static void *ctrl_dumppolicy_prep(struct sk_buff *skb,
1158+
struct netlink_callback *cb)
1159+
{
1160+
struct ctrl_dump_policy_ctx *ctx = (void *)cb->ctx;
1161+
void *hdr;
1162+
1163+
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
1164+
cb->nlh->nlmsg_seq, &genl_ctrl,
1165+
NLM_F_MULTI, CTRL_CMD_GETPOLICY);
1166+
if (!hdr)
1167+
return NULL;
1168+
1169+
if (nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, ctx->fam_id))
1170+
return NULL;
1171+
1172+
return hdr;
1173+
}
1174+
11571175
static int ctrl_dumppolicy(struct sk_buff *skb, struct netlink_callback *cb)
11581176
{
11591177
struct ctrl_dump_policy_ctx *ctx = (void *)cb->ctx;
@@ -1162,15 +1180,10 @@ static int ctrl_dumppolicy(struct sk_buff *skb, struct netlink_callback *cb)
11621180
void *hdr;
11631181
struct nlattr *nest;
11641182

1165-
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
1166-
cb->nlh->nlmsg_seq, &genl_ctrl,
1167-
NLM_F_MULTI, CTRL_CMD_GETPOLICY);
1183+
hdr = ctrl_dumppolicy_prep(skb, cb);
11681184
if (!hdr)
11691185
goto nla_put_failure;
11701186

1171-
if (nla_put_u16(skb, CTRL_ATTR_FAMILY_ID, ctx->fam_id))
1172-
goto nla_put_failure;
1173-
11741187
nest = nla_nest_start(skb, CTRL_ATTR_POLICY);
11751188
if (!nest)
11761189
goto nla_put_failure;

0 commit comments

Comments
 (0)