@@ -8020,6 +8020,19 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
8020
8020
return skb -> len ;
8021
8021
}
8022
8022
8023
+ static int nf_tables_dumpreset_obj (struct sk_buff * skb ,
8024
+ struct netlink_callback * cb )
8025
+ {
8026
+ struct nftables_pernet * nft_net = nft_pernet (sock_net (skb -> sk ));
8027
+ int ret ;
8028
+
8029
+ mutex_lock (& nft_net -> commit_mutex );
8030
+ ret = nf_tables_dump_obj (skb , cb );
8031
+ mutex_unlock (& nft_net -> commit_mutex );
8032
+
8033
+ return ret ;
8034
+ }
8035
+
8023
8036
static int nf_tables_dump_obj_start (struct netlink_callback * cb )
8024
8037
{
8025
8038
struct nft_obj_dump_ctx * ctx = (void * )cb -> ctx ;
@@ -8036,12 +8049,18 @@ static int nf_tables_dump_obj_start(struct netlink_callback *cb)
8036
8049
if (nla [NFTA_OBJ_TYPE ])
8037
8050
ctx -> type = ntohl (nla_get_be32 (nla [NFTA_OBJ_TYPE ]));
8038
8051
8039
- if (NFNL_MSG_TYPE (cb -> nlh -> nlmsg_type ) == NFT_MSG_GETOBJ_RESET )
8040
- ctx -> reset = true;
8041
-
8042
8052
return 0 ;
8043
8053
}
8044
8054
8055
+ static int nf_tables_dumpreset_obj_start (struct netlink_callback * cb )
8056
+ {
8057
+ struct nft_obj_dump_ctx * ctx = (void * )cb -> ctx ;
8058
+
8059
+ ctx -> reset = true;
8060
+
8061
+ return nf_tables_dump_obj_start (cb );
8062
+ }
8063
+
8045
8064
static int nf_tables_dump_obj_done (struct netlink_callback * cb )
8046
8065
{
8047
8066
struct nft_obj_dump_ctx * ctx = (void * )cb -> ctx ;
@@ -8100,18 +8119,43 @@ nf_tables_getobj_single(u32 portid, const struct nfnl_info *info,
8100
8119
8101
8120
static int nf_tables_getobj (struct sk_buff * skb , const struct nfnl_info * info ,
8102
8121
const struct nlattr * const nla [])
8122
+ {
8123
+ u32 portid = NETLINK_CB (skb ).portid ;
8124
+ struct sk_buff * skb2 ;
8125
+
8126
+ if (info -> nlh -> nlmsg_flags & NLM_F_DUMP ) {
8127
+ struct netlink_dump_control c = {
8128
+ .start = nf_tables_dump_obj_start ,
8129
+ .dump = nf_tables_dump_obj ,
8130
+ .done = nf_tables_dump_obj_done ,
8131
+ .module = THIS_MODULE ,
8132
+ .data = (void * )nla ,
8133
+ };
8134
+
8135
+ return nft_netlink_dump_start_rcu (info -> sk , skb , info -> nlh , & c );
8136
+ }
8137
+
8138
+ skb2 = nf_tables_getobj_single (portid , info , nla , false);
8139
+ if (IS_ERR (skb2 ))
8140
+ return PTR_ERR (skb2 );
8141
+
8142
+ return nfnetlink_unicast (skb2 , info -> net , portid );
8143
+ }
8144
+
8145
+ static int nf_tables_getobj_reset (struct sk_buff * skb ,
8146
+ const struct nfnl_info * info ,
8147
+ const struct nlattr * const nla [])
8103
8148
{
8104
8149
struct nftables_pernet * nft_net = nft_pernet (info -> net );
8105
8150
u32 portid = NETLINK_CB (skb ).portid ;
8106
8151
struct net * net = info -> net ;
8107
8152
struct sk_buff * skb2 ;
8108
- bool reset = false;
8109
8153
char * buf ;
8110
8154
8111
8155
if (info -> nlh -> nlmsg_flags & NLM_F_DUMP ) {
8112
8156
struct netlink_dump_control c = {
8113
- .start = nf_tables_dump_obj_start ,
8114
- .dump = nf_tables_dump_obj ,
8157
+ .start = nf_tables_dumpreset_obj_start ,
8158
+ .dump = nf_tables_dumpreset_obj ,
8115
8159
.done = nf_tables_dump_obj_done ,
8116
8160
.module = THIS_MODULE ,
8117
8161
.data = (void * )nla ,
@@ -8120,16 +8164,18 @@ static int nf_tables_getobj(struct sk_buff *skb, const struct nfnl_info *info,
8120
8164
return nft_netlink_dump_start_rcu (info -> sk , skb , info -> nlh , & c );
8121
8165
}
8122
8166
8123
- if (NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_GETOBJ_RESET )
8124
- reset = true;
8167
+ if (!try_module_get (THIS_MODULE ))
8168
+ return - EINVAL ;
8169
+ rcu_read_unlock ();
8170
+ mutex_lock (& nft_net -> commit_mutex );
8171
+ skb2 = nf_tables_getobj_single (portid , info , nla , true);
8172
+ mutex_unlock (& nft_net -> commit_mutex );
8173
+ rcu_read_lock ();
8174
+ module_put (THIS_MODULE );
8125
8175
8126
- skb2 = nf_tables_getobj_single (portid , info , nla , reset );
8127
8176
if (IS_ERR (skb2 ))
8128
8177
return PTR_ERR (skb2 );
8129
8178
8130
- if (!reset )
8131
- return nfnetlink_unicast (skb2 , net , NETLINK_CB (skb ).portid );
8132
-
8133
8179
buf = kasprintf (GFP_ATOMIC , "%.*s:%u" ,
8134
8180
nla_len (nla [NFTA_OBJ_TABLE ]),
8135
8181
(char * )nla_data (nla [NFTA_OBJ_TABLE ]),
@@ -9421,7 +9467,7 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
9421
9467
.policy = nft_obj_policy ,
9422
9468
},
9423
9469
[NFT_MSG_GETOBJ_RESET ] = {
9424
- .call = nf_tables_getobj ,
9470
+ .call = nf_tables_getobj_reset ,
9425
9471
.type = NFNL_CB_RCU ,
9426
9472
.attr_count = NFTA_OBJ_MAX ,
9427
9473
.policy = nft_obj_policy ,
0 commit comments