@@ -8052,63 +8052,80 @@ static int nf_tables_dump_obj_done(struct netlink_callback *cb)
80528052}
80538053
80548054/* 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 )
80578058{
8058- const struct nftables_pernet * nft_net = nft_pernet (info -> net );
80598059 struct netlink_ext_ack * extack = info -> extack ;
80608060 u8 genmask = nft_genmask_cur (info -> net );
80618061 u8 family = info -> nfmsg -> nfgen_family ;
80628062 const struct nft_table * table ;
80638063 struct net * net = info -> net ;
80648064 struct nft_object * obj ;
80658065 struct sk_buff * skb2 ;
8066- bool reset = false;
80678066 u32 objtype ;
8068- char * buf ;
80698067 int err ;
80708068
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-
80838069 if (!nla [NFTA_OBJ_NAME ] ||
80848070 !nla [NFTA_OBJ_TYPE ])
8085- return - EINVAL ;
8071+ return ERR_PTR ( - EINVAL ) ;
80868072
80878073 table = nft_table_lookup (net , nla [NFTA_OBJ_TABLE ], family , genmask , 0 );
80888074 if (IS_ERR (table )) {
80898075 NL_SET_BAD_ATTR (extack , nla [NFTA_OBJ_TABLE ]);
8090- return PTR_ERR (table );
8076+ return ERR_CAST (table );
80918077 }
80928078
80938079 objtype = ntohl (nla_get_be32 (nla [NFTA_OBJ_TYPE ]));
80948080 obj = nft_obj_lookup (net , table , nla [NFTA_OBJ_NAME ], objtype , genmask );
80958081 if (IS_ERR (obj )) {
80968082 NL_SET_BAD_ATTR (extack , nla [NFTA_OBJ_NAME ]);
8097- return PTR_ERR (obj );
8083+ return ERR_CAST (obj );
80988084 }
80998085
81008086 skb2 = alloc_skb (NLMSG_GOODSIZE , GFP_ATOMIC );
81018087 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+ }
81038122
81048123 if (NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_GETOBJ_RESET )
81058124 reset = true;
81068125
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 );
81128129
81138130 if (!reset )
81148131 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,
81218138 AUDIT_NFT_OP_OBJ_RESET , GFP_ATOMIC );
81228139 kfree (buf );
81238140
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 );
81298142}
81308143
81318144static void nft_obj_destroy (const struct nft_ctx * ctx , struct nft_object * obj )
0 commit comments