@@ -1154,6 +1154,24 @@ static int ctrl_dumppolicy_start(struct netlink_callback *cb)
1154
1154
rt -> maxattr );
1155
1155
}
1156
1156
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
+
1157
1175
static int ctrl_dumppolicy (struct sk_buff * skb , struct netlink_callback * cb )
1158
1176
{
1159
1177
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)
1162
1180
void * hdr ;
1163
1181
struct nlattr * nest ;
1164
1182
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 );
1168
1184
if (!hdr )
1169
1185
goto nla_put_failure ;
1170
1186
1171
- if (nla_put_u16 (skb , CTRL_ATTR_FAMILY_ID , ctx -> fam_id ))
1172
- goto nla_put_failure ;
1173
-
1174
1187
nest = nla_nest_start (skb , CTRL_ATTR_POLICY );
1175
1188
if (!nest )
1176
1189
goto nla_put_failure ;
0 commit comments