On Tue, Jun 16, 2020 at 11:19:38AM +0800, we...@ucloud.cn wrote:
> From: wenxu <we...@ucloud.cn>
> 
> In the function __flow_block_indr_cleanup, The match stataments
> this->cb_priv == cb_priv is always false, the flow_block_cb->cb_priv
> is totally different data with the flow_indr_dev->cb_priv.
> 
> Store the representor cb_priv to the flow_block_cb->indr.cb_priv in
> the driver.
> 
> Fixes: 1fac52da5942 ("net: flow_offload: consolidate indirect flow_block 
> infrastructure")
> Signed-off-by: wenxu <we...@ucloud.cn>

Hi Wenxu,

I wonder if this can be resolved by using the cb_ident field of struct
flow_block_cb.

I observe that mlx5e_rep_indr_setup_block() seems to be the only call-site
where the value of the cb_ident parameter of flow_block_cb_alloc() is
per-block rather than per-device. So part of my proposal is to change
that.

The other part of my proposal is to make use of cb_ident in
__flow_block_indr_cleanup(). Which does seem to match the intended
purpose of cb_ident. Perhaps it would also be good to document what
the intended purpose of cb_ident (and the other fields of struct
flow_block_cb) is.

Compile tested only.

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
index a62bcf0cf512..4de6fcae5252 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
@@ -438,7 +438,7 @@ mlx5e_rep_indr_setup_block(struct net_device *netdev,
                list_add(&indr_priv->list,
                         &rpriv->uplink_priv.tc_indr_block_priv_list);
 
-               block_cb = flow_block_cb_alloc(setup_cb, indr_priv, indr_priv,
+               block_cb = flow_block_cb_alloc(setup_cb, rpriv, indr_priv,
                                               mlx5e_rep_indr_block_unbind);
                if (IS_ERR(block_cb)) {
                        list_del(&indr_priv->list);
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index b288d2f03789..d281fb182894 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -373,14 +373,13 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, 
void *cb_priv)
 EXPORT_SYMBOL(flow_indr_dev_register);
 
 static void __flow_block_indr_cleanup(void (*release)(void *cb_priv),
-                                     void *cb_priv,
+                                     void *cb_ident,
                                      struct list_head *cleanup_list)
 {
        struct flow_block_cb *this, *next;
 
        list_for_each_entry_safe(this, next, &flow_block_indr_list, indr.list) {
-               if (this->release == release &&
-                   this->cb_priv == cb_priv) {
+               if (this->release == release && this->cb_ident == cb_ident) {
                        list_move(&this->indr.list, cleanup_list);
                        return;
                }

Reply via email to