@@ -8052,63 +8052,80 @@ static int nf_tables_dump_obj_done(struct netlink_callback *cb)
8052
8052
}
8053
8053
8054
8054
/* called with rcu_read_lock held */
8055
- static int nf_tables_getobj (struct sk_buff * skb , const struct nfnl_info * info ,
8056
- const struct nlattr * const nla [])
8055
+ static struct sk_buff *
8056
+ nf_tables_getobj_single (u32 portid , const struct nfnl_info * info ,
8057
+ const struct nlattr * const nla [], bool reset )
8057
8058
{
8058
- const struct nftables_pernet * nft_net = nft_pernet (info -> net );
8059
8059
struct netlink_ext_ack * extack = info -> extack ;
8060
8060
u8 genmask = nft_genmask_cur (info -> net );
8061
8061
u8 family = info -> nfmsg -> nfgen_family ;
8062
8062
const struct nft_table * table ;
8063
8063
struct net * net = info -> net ;
8064
8064
struct nft_object * obj ;
8065
8065
struct sk_buff * skb2 ;
8066
- bool reset = false;
8067
8066
u32 objtype ;
8068
- char * buf ;
8069
8067
int err ;
8070
8068
8071
- if (info -> nlh -> nlmsg_flags & NLM_F_DUMP ) {
8072
- struct netlink_dump_control c = {
8073
- .start = nf_tables_dump_obj_start ,
8074
- .dump = nf_tables_dump_obj ,
8075
- .done = nf_tables_dump_obj_done ,
8076
- .module = THIS_MODULE ,
8077
- .data = (void * )nla ,
8078
- };
8079
-
8080
- return nft_netlink_dump_start_rcu (info -> sk , skb , info -> nlh , & c );
8081
- }
8082
-
8083
8069
if (!nla [NFTA_OBJ_NAME ] ||
8084
8070
!nla [NFTA_OBJ_TYPE ])
8085
- return - EINVAL ;
8071
+ return ERR_PTR ( - EINVAL ) ;
8086
8072
8087
8073
table = nft_table_lookup (net , nla [NFTA_OBJ_TABLE ], family , genmask , 0 );
8088
8074
if (IS_ERR (table )) {
8089
8075
NL_SET_BAD_ATTR (extack , nla [NFTA_OBJ_TABLE ]);
8090
- return PTR_ERR (table );
8076
+ return ERR_CAST (table );
8091
8077
}
8092
8078
8093
8079
objtype = ntohl (nla_get_be32 (nla [NFTA_OBJ_TYPE ]));
8094
8080
obj = nft_obj_lookup (net , table , nla [NFTA_OBJ_NAME ], objtype , genmask );
8095
8081
if (IS_ERR (obj )) {
8096
8082
NL_SET_BAD_ATTR (extack , nla [NFTA_OBJ_NAME ]);
8097
- return PTR_ERR (obj );
8083
+ return ERR_CAST (obj );
8098
8084
}
8099
8085
8100
8086
skb2 = alloc_skb (NLMSG_GOODSIZE , GFP_ATOMIC );
8101
8087
if (!skb2 )
8102
- return - ENOMEM ;
8088
+ return ERR_PTR (- ENOMEM );
8089
+
8090
+ err = nf_tables_fill_obj_info (skb2 , net , portid ,
8091
+ info -> nlh -> nlmsg_seq , NFT_MSG_NEWOBJ , 0 ,
8092
+ family , table , obj , reset );
8093
+ if (err < 0 ) {
8094
+ kfree_skb (skb2 );
8095
+ return ERR_PTR (err );
8096
+ }
8097
+
8098
+ return skb2 ;
8099
+ }
8100
+
8101
+ static int nf_tables_getobj (struct sk_buff * skb , const struct nfnl_info * info ,
8102
+ const struct nlattr * const nla [])
8103
+ {
8104
+ struct nftables_pernet * nft_net = nft_pernet (info -> net );
8105
+ u32 portid = NETLINK_CB (skb ).portid ;
8106
+ struct net * net = info -> net ;
8107
+ struct sk_buff * skb2 ;
8108
+ bool reset = false;
8109
+ char * buf ;
8110
+
8111
+ if (info -> nlh -> nlmsg_flags & NLM_F_DUMP ) {
8112
+ struct netlink_dump_control c = {
8113
+ .start = nf_tables_dump_obj_start ,
8114
+ .dump = nf_tables_dump_obj ,
8115
+ .done = nf_tables_dump_obj_done ,
8116
+ .module = THIS_MODULE ,
8117
+ .data = (void * )nla ,
8118
+ };
8119
+
8120
+ return nft_netlink_dump_start_rcu (info -> sk , skb , info -> nlh , & c );
8121
+ }
8103
8122
8104
8123
if (NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_GETOBJ_RESET )
8105
8124
reset = true;
8106
8125
8107
- err = nf_tables_fill_obj_info (skb2 , net , NETLINK_CB (skb ).portid ,
8108
- info -> nlh -> nlmsg_seq , NFT_MSG_NEWOBJ , 0 ,
8109
- family , table , obj , reset );
8110
- if (err < 0 )
8111
- goto err_fill_obj_info ;
8126
+ skb2 = nf_tables_getobj_single (portid , info , nla , reset );
8127
+ if (IS_ERR (skb2 ))
8128
+ return PTR_ERR (skb2 );
8112
8129
8113
8130
if (!reset )
8114
8131
return nfnetlink_unicast (skb2 , net , NETLINK_CB (skb ).portid );
@@ -8121,11 +8138,7 @@ static int nf_tables_getobj(struct sk_buff *skb, const struct nfnl_info *info,
8121
8138
AUDIT_NFT_OP_OBJ_RESET , GFP_ATOMIC );
8122
8139
kfree (buf );
8123
8140
8124
- return nfnetlink_unicast (skb2 , net , NETLINK_CB (skb ).portid );
8125
-
8126
- err_fill_obj_info :
8127
- kfree_skb (skb2 );
8128
- return err ;
8141
+ return nfnetlink_unicast (skb2 , net , portid );
8129
8142
}
8130
8143
8131
8144
static void nft_obj_destroy (const struct nft_ctx * ctx , struct nft_object * obj )
0 commit comments