@@ -214,6 +214,34 @@ static int nft_delchain(struct nft_ctx *ctx)
214
214
return err ;
215
215
}
216
216
217
+ static void nft_rule_expr_activate (const struct nft_ctx * ctx ,
218
+ struct nft_rule * rule )
219
+ {
220
+ struct nft_expr * expr ;
221
+
222
+ expr = nft_expr_first (rule );
223
+ while (expr != nft_expr_last (rule ) && expr -> ops ) {
224
+ if (expr -> ops -> activate )
225
+ expr -> ops -> activate (ctx , expr );
226
+
227
+ expr = nft_expr_next (expr );
228
+ }
229
+ }
230
+
231
+ static void nft_rule_expr_deactivate (const struct nft_ctx * ctx ,
232
+ struct nft_rule * rule )
233
+ {
234
+ struct nft_expr * expr ;
235
+
236
+ expr = nft_expr_first (rule );
237
+ while (expr != nft_expr_last (rule ) && expr -> ops ) {
238
+ if (expr -> ops -> deactivate )
239
+ expr -> ops -> deactivate (ctx , expr );
240
+
241
+ expr = nft_expr_next (expr );
242
+ }
243
+ }
244
+
217
245
static int
218
246
nf_tables_delrule_deactivate (struct nft_ctx * ctx , struct nft_rule * rule )
219
247
{
@@ -259,6 +287,7 @@ static int nft_delrule(struct nft_ctx *ctx, struct nft_rule *rule)
259
287
nft_trans_destroy (trans );
260
288
return err ;
261
289
}
290
+ nft_rule_expr_deactivate (ctx , rule );
262
291
263
292
return 0 ;
264
293
}
@@ -2238,6 +2267,13 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
2238
2267
kfree (rule );
2239
2268
}
2240
2269
2270
+ static void nf_tables_rule_release (const struct nft_ctx * ctx ,
2271
+ struct nft_rule * rule )
2272
+ {
2273
+ nft_rule_expr_deactivate (ctx , rule );
2274
+ nf_tables_rule_destroy (ctx , rule );
2275
+ }
2276
+
2241
2277
#define NFT_RULE_MAXEXPRS 128
2242
2278
2243
2279
static struct nft_expr_info * info ;
@@ -2402,7 +2438,7 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
2402
2438
return 0 ;
2403
2439
2404
2440
err2 :
2405
- nf_tables_rule_destroy (& ctx , rule );
2441
+ nf_tables_rule_release (& ctx , rule );
2406
2442
err1 :
2407
2443
for (i = 0 ; i < n ; i ++ ) {
2408
2444
if (info [i ].ops != NULL )
@@ -4130,7 +4166,7 @@ static int nf_tables_newsetelem(struct net *net, struct sock *nlsk,
4130
4166
* NFT_GOTO verdicts. This function must be called on active data objects
4131
4167
* from the second phase of the commit protocol.
4132
4168
*/
4133
- static void nft_data_hold (const struct nft_data * data , enum nft_data_types type )
4169
+ void nft_data_hold (const struct nft_data * data , enum nft_data_types type )
4134
4170
{
4135
4171
if (type == NFT_DATA_VERDICT ) {
4136
4172
switch (data -> verdict .code ) {
@@ -6015,10 +6051,12 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb)
6015
6051
case NFT_MSG_NEWRULE :
6016
6052
trans -> ctx .chain -> use -- ;
6017
6053
list_del_rcu (& nft_trans_rule (trans )-> list );
6054
+ nft_rule_expr_deactivate (& trans -> ctx , nft_trans_rule (trans ));
6018
6055
break ;
6019
6056
case NFT_MSG_DELRULE :
6020
6057
trans -> ctx .chain -> use ++ ;
6021
6058
nft_clear (trans -> ctx .net , nft_trans_rule (trans ));
6059
+ nft_rule_expr_activate (& trans -> ctx , nft_trans_rule (trans ));
6022
6060
nft_trans_destroy (trans );
6023
6061
break ;
6024
6062
case NFT_MSG_NEWSET :
@@ -6594,7 +6632,7 @@ int __nft_release_basechain(struct nft_ctx *ctx)
6594
6632
list_for_each_entry_safe (rule , nr , & ctx -> chain -> rules , list ) {
6595
6633
list_del (& rule -> list );
6596
6634
ctx -> chain -> use -- ;
6597
- nf_tables_rule_destroy (ctx , rule );
6635
+ nf_tables_rule_release (ctx , rule );
6598
6636
}
6599
6637
list_del (& ctx -> chain -> list );
6600
6638
ctx -> table -> use -- ;
@@ -6632,7 +6670,7 @@ static void __nft_release_tables(struct net *net)
6632
6670
list_for_each_entry_safe (rule , nr , & chain -> rules , list ) {
6633
6671
list_del (& rule -> list );
6634
6672
chain -> use -- ;
6635
- nf_tables_rule_destroy (& ctx , rule );
6673
+ nf_tables_rule_release (& ctx , rule );
6636
6674
}
6637
6675
}
6638
6676
list_for_each_entry_safe (flowtable , nf , & table -> flowtables , list ) {
0 commit comments