Skip to content

Commit a1db217

Browse files
wenxudavem330
authored andcommitted
net: flow_offload: fix flow_indr_dev_unregister path
If the representor is removed, then identify the indirect flow_blocks that need to be removed by the release callback and the port representor structure. To identify the port representor structure, a new indr.cb_priv field needs to be introduced. The flow_block also needs to be removed from the driver list from the cleanup path. Fixes: 1fac52d ("net: flow_offload: consolidate indirect flow_block infrastructure") Signed-off-by: wenxu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 66f1939 commit a1db217

File tree

10 files changed

+27
-18
lines changed

10 files changed

+27
-18
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct bnxt *bp,
19111911
block_cb = flow_indr_block_cb_alloc(bnxt_tc_setup_indr_block_cb,
19121912
cb_priv, cb_priv,
19131913
bnxt_tc_setup_indr_rel, f,
1914-
netdev, data, cleanup);
1914+
netdev, data, bp, cleanup);
19151915
if (IS_ERR(block_cb)) {
19161916
list_del(&cb_priv->list);
19171917
kfree(cb_priv);
@@ -2079,7 +2079,7 @@ void bnxt_shutdown_tc(struct bnxt *bp)
20792079
return;
20802080

20812081
flow_indr_dev_unregister(bnxt_tc_setup_indr_cb, bp,
2082-
bnxt_tc_setup_indr_block_cb);
2082+
bnxt_tc_setup_indr_rel);
20832083
rhashtable_destroy(&tc_info->flow_table);
20842084
rhashtable_destroy(&tc_info->l2_table);
20852085
rhashtable_destroy(&tc_info->decap_l2_table);

drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ mlx5e_rep_indr_setup_block(struct net_device *netdev,
442442

443443
block_cb = flow_indr_block_cb_alloc(setup_cb, indr_priv, indr_priv,
444444
mlx5e_rep_indr_block_unbind,
445-
f, netdev, data, cleanup);
445+
f, netdev, data, rpriv,
446+
cleanup);
446447
if (IS_ERR(block_cb)) {
447448
list_del(&indr_priv->list);
448449
kfree(indr_priv);
@@ -503,7 +504,7 @@ int mlx5e_rep_tc_netdevice_event_register(struct mlx5e_rep_priv *rpriv)
503504
void mlx5e_rep_tc_netdevice_event_unregister(struct mlx5e_rep_priv *rpriv)
504505
{
505506
flow_indr_dev_unregister(mlx5e_rep_indr_setup_cb, rpriv,
506-
mlx5e_rep_indr_setup_tc_cb);
507+
mlx5e_rep_indr_block_unbind);
507508
}
508509

509510
#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)

drivers/net/ethernet/netronome/nfp/flower/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ static void nfp_flower_clean(struct nfp_app *app)
861861
flush_work(&app_priv->cmsg_work);
862862

863863
flow_indr_dev_unregister(nfp_flower_indr_setup_tc_cb, app,
864-
nfp_flower_setup_indr_block_cb);
864+
nfp_flower_setup_indr_tc_release);
865865

866866
if (app_priv->flower_ext_feats & NFP_FL_FEATS_VF_RLIM)
867867
nfp_flower_qos_cleanup(app);

drivers/net/ethernet/netronome/nfp/flower/main.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ int nfp_flower_indr_setup_tc_cb(struct net_device *netdev, void *cb_priv,
462462
enum tc_setup_type type, void *type_data,
463463
void *data,
464464
void (*cleanup)(struct flow_block_cb *block_cb));
465-
int nfp_flower_setup_indr_block_cb(enum tc_setup_type type, void *type_data,
466-
void *cb_priv);
465+
void nfp_flower_setup_indr_tc_release(void *cb_priv);
467466

468467
void
469468
__nfp_flower_non_repr_priv_get(struct nfp_flower_non_repr_priv *non_repr_priv);

drivers/net/ethernet/netronome/nfp/flower/offload.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,8 @@ nfp_flower_indr_block_cb_priv_lookup(struct nfp_app *app,
16191619
return NULL;
16201620
}
16211621

1622-
int nfp_flower_setup_indr_block_cb(enum tc_setup_type type,
1623-
void *type_data, void *cb_priv)
1622+
static int nfp_flower_setup_indr_block_cb(enum tc_setup_type type,
1623+
void *type_data, void *cb_priv)
16241624
{
16251625
struct nfp_flower_indr_block_cb_priv *priv = cb_priv;
16261626
struct flow_cls_offload *flower = type_data;
@@ -1637,7 +1637,7 @@ int nfp_flower_setup_indr_block_cb(enum tc_setup_type type,
16371637
}
16381638
}
16391639

1640-
static void nfp_flower_setup_indr_tc_release(void *cb_priv)
1640+
void nfp_flower_setup_indr_tc_release(void *cb_priv)
16411641
{
16421642
struct nfp_flower_indr_block_cb_priv *priv = cb_priv;
16431643

@@ -1680,7 +1680,7 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,
16801680
block_cb = flow_indr_block_cb_alloc(nfp_flower_setup_indr_block_cb,
16811681
cb_priv, cb_priv,
16821682
nfp_flower_setup_indr_tc_release,
1683-
f, netdev, data, cleanup);
1683+
f, netdev, data, app, cleanup);
16841684
if (IS_ERR(block_cb)) {
16851685
list_del(&cb_priv->list);
16861686
kfree(cb_priv);

include/net/flow_offload.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ struct flow_block_indr {
450450
struct net_device *dev;
451451
enum flow_block_binder_type binder_type;
452452
void *data;
453+
void *cb_priv;
453454
void (*cleanup)(struct flow_block_cb *block_cb);
454455
};
455456

@@ -472,6 +473,7 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,
472473
void (*release)(void *cb_priv),
473474
struct flow_block_offload *bo,
474475
struct net_device *dev, void *data,
476+
void *indr_cb_priv,
475477
void (*cleanup)(struct flow_block_cb *block_cb));
476478
void flow_block_cb_free(struct flow_block_cb *block_cb);
477479

@@ -551,7 +553,7 @@ typedef int flow_indr_block_bind_cb_t(struct net_device *dev, void *cb_priv,
551553

552554
int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv);
553555
void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv,
554-
flow_setup_cb_t *setup_cb);
556+
void (*release)(void *cb_priv));
555557
int flow_indr_dev_setup_offload(struct net_device *dev,
556558
enum tc_setup_type type, void *data,
557559
struct flow_block_offload *bo,

net/core/flow_offload.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,15 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)
372372
}
373373
EXPORT_SYMBOL(flow_indr_dev_register);
374374

375-
static void __flow_block_indr_cleanup(flow_setup_cb_t *setup_cb, void *cb_priv,
375+
static void __flow_block_indr_cleanup(void (*release)(void *cb_priv),
376+
void *cb_priv,
376377
struct list_head *cleanup_list)
377378
{
378379
struct flow_block_cb *this, *next;
379380

380381
list_for_each_entry_safe(this, next, &flow_block_indr_list, indr.list) {
381-
if (this->cb == setup_cb &&
382-
this->cb_priv == cb_priv) {
382+
if (this->release == release &&
383+
this->indr.cb_priv == cb_priv) {
383384
list_move(&this->indr.list, cleanup_list);
384385
return;
385386
}
@@ -397,7 +398,7 @@ static void flow_block_indr_notify(struct list_head *cleanup_list)
397398
}
398399

399400
void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv,
400-
flow_setup_cb_t *setup_cb)
401+
void (*release)(void *cb_priv))
401402
{
402403
struct flow_indr_dev *this, *next, *indr_dev = NULL;
403404
LIST_HEAD(cleanup_list);
@@ -418,7 +419,7 @@ void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv,
418419
return;
419420
}
420421

421-
__flow_block_indr_cleanup(setup_cb, cb_priv, &cleanup_list);
422+
__flow_block_indr_cleanup(release, cb_priv, &cleanup_list);
422423
mutex_unlock(&flow_indr_block_lock);
423424

424425
flow_block_indr_notify(&cleanup_list);
@@ -429,10 +430,12 @@ EXPORT_SYMBOL(flow_indr_dev_unregister);
429430
static void flow_block_indr_init(struct flow_block_cb *flow_block,
430431
struct flow_block_offload *bo,
431432
struct net_device *dev, void *data,
433+
void *cb_priv,
432434
void (*cleanup)(struct flow_block_cb *block_cb))
433435
{
434436
flow_block->indr.binder_type = bo->binder_type;
435437
flow_block->indr.data = data;
438+
flow_block->indr.cb_priv = cb_priv;
436439
flow_block->indr.dev = dev;
437440
flow_block->indr.cleanup = cleanup;
438441
}
@@ -442,6 +445,7 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,
442445
void (*release)(void *cb_priv),
443446
struct flow_block_offload *bo,
444447
struct net_device *dev, void *data,
448+
void *indr_cb_priv,
445449
void (*cleanup)(struct flow_block_cb *block_cb))
446450
{
447451
struct flow_block_cb *block_cb;
@@ -450,7 +454,7 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,
450454
if (IS_ERR(block_cb))
451455
goto out;
452456

453-
flow_block_indr_init(block_cb, bo, dev, data, cleanup);
457+
flow_block_indr_init(block_cb, bo, dev, data, indr_cb_priv, cleanup);
454458
list_add(&block_cb->indr.list, &flow_block_indr_list);
455459

456460
out:

net/netfilter/nf_flow_table_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ static void nf_flow_table_indr_cleanup(struct flow_block_cb *block_cb)
950950
nf_flow_table_gc_cleanup(flowtable, dev);
951951
down_write(&flowtable->flow_block_lock);
952952
list_del(&block_cb->list);
953+
list_del(&block_cb->driver_list);
953954
flow_block_cb_free(block_cb);
954955
up_write(&flowtable->flow_block_lock);
955956
}

net/netfilter/nf_tables_offload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ static void nft_indr_block_cleanup(struct flow_block_cb *block_cb)
296296
nft_flow_block_offload_init(&bo, dev_net(dev), FLOW_BLOCK_UNBIND,
297297
basechain, &extack);
298298
mutex_lock(&net->nft.commit_mutex);
299+
list_del(&block_cb->driver_list);
299300
list_move(&block_cb->list, &bo.cb_list);
300301
nft_flow_offload_unbind(&bo, basechain);
301302
mutex_unlock(&net->nft.commit_mutex);

net/sched/cls_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static void tc_block_indr_cleanup(struct flow_block_cb *block_cb)
652652
&block->flow_block, tcf_block_shared(block),
653653
&extack);
654654
down_write(&block->cb_lock);
655+
list_del(&block_cb->driver_list);
655656
list_move(&block_cb->list, &bo.cb_list);
656657
up_write(&block->cb_lock);
657658
rtnl_lock();

0 commit comments

Comments
 (0)