@@ -286,9 +286,31 @@ static bool tcf_ct_flow_is_outdated(const struct flow_offload *flow)
286
286
!test_bit (NF_FLOW_HW_ESTABLISHED , & flow -> flags );
287
287
}
288
288
289
+ static void tcf_ct_flow_table_get_ref (struct tcf_ct_flow_table * ct_ft );
290
+
291
+ static void tcf_ct_nf_get (struct nf_flowtable * ft )
292
+ {
293
+ struct tcf_ct_flow_table * ct_ft =
294
+ container_of (ft , struct tcf_ct_flow_table , nf_ft );
295
+
296
+ tcf_ct_flow_table_get_ref (ct_ft );
297
+ }
298
+
299
+ static void tcf_ct_flow_table_put (struct tcf_ct_flow_table * ct_ft );
300
+
301
+ static void tcf_ct_nf_put (struct nf_flowtable * ft )
302
+ {
303
+ struct tcf_ct_flow_table * ct_ft =
304
+ container_of (ft , struct tcf_ct_flow_table , nf_ft );
305
+
306
+ tcf_ct_flow_table_put (ct_ft );
307
+ }
308
+
289
309
static struct nf_flowtable_type flowtable_ct = {
290
310
.gc = tcf_ct_flow_is_outdated ,
291
311
.action = tcf_ct_flow_table_fill_actions ,
312
+ .get = tcf_ct_nf_get ,
313
+ .put = tcf_ct_nf_put ,
292
314
.owner = THIS_MODULE ,
293
315
};
294
316
@@ -337,23 +359,23 @@ static int tcf_ct_flow_table_get(struct net *net, struct tcf_ct_params *params)
337
359
return err ;
338
360
}
339
361
362
+ static void tcf_ct_flow_table_get_ref (struct tcf_ct_flow_table * ct_ft )
363
+ {
364
+ refcount_inc (& ct_ft -> ref );
365
+ }
366
+
340
367
static void tcf_ct_flow_table_cleanup_work (struct work_struct * work )
341
368
{
342
- struct flow_block_cb * block_cb , * tmp_cb ;
343
369
struct tcf_ct_flow_table * ct_ft ;
344
370
struct flow_block * block ;
345
371
346
372
ct_ft = container_of (to_rcu_work (work ), struct tcf_ct_flow_table ,
347
373
rwork );
348
374
nf_flow_table_free (& ct_ft -> nf_ft );
349
375
350
- /* Remove any remaining callbacks before cleanup */
351
376
block = & ct_ft -> nf_ft .flow_block ;
352
377
down_write (& ct_ft -> nf_ft .flow_block_lock );
353
- list_for_each_entry_safe (block_cb , tmp_cb , & block -> cb_list , list ) {
354
- list_del (& block_cb -> list );
355
- flow_block_cb_free (block_cb );
356
- }
378
+ WARN_ON (!list_empty (& block -> cb_list ));
357
379
up_write (& ct_ft -> nf_ft .flow_block_lock );
358
380
kfree (ct_ft );
359
381
0 commit comments