Skip to content

Commit 25f2d0e

Browse files
Eli BritsteinSaeed Mahameed
authored andcommitted
net/mlx5e: Fix cb_ident duplicate in indirect block register
Previously the identifier used for indirect block callback registry and for block rule cb registry (when done via indirect blocks) was the pointer to the tunnel netdev we were interested in receiving updates on. This worked fine if a single PF existed that registered one callback for the tunnel netdev of interest. However, if multiple PFs are in place then the 2nd PF tries to register with the same tunnel netdev identifier. This leads to EEXIST errors and/or incorrect cb deletions. Prevent this conflict by using the rpriv pointer as the identifier for netdev indirect block cb registry, allowing each PF to register a unique callback per tunnel netdev. For block cb registry, the same PF may register multiple cbs to the same block if using TC shared blocks. Instead of the rpriv, use the pointer to the allocated indr_priv data as the identifier here. This means that there can be a unique block callback for each PF/tunnel netdev combo. Fixes: f5bc2c5 ("net/mlx5e: Support TC indirect block notifications for eswitch uplink reprs") Signed-off-by: Eli Britstein <elibr@mellanox.com> Reviewed-by: Oz Shlomo <ozsh@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 7fdc1ad commit 25f2d0e

File tree

1 file changed

+16
-13
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+16
-13
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ struct mlx5e_rep_indr_block_priv {
5858
struct list_head list;
5959
};
6060

61-
static void mlx5e_rep_indr_unregister_block(struct net_device *netdev);
61+
static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv,
62+
struct net_device *netdev);
6263

6364
static void mlx5e_rep_get_drvinfo(struct net_device *dev,
6465
struct ethtool_drvinfo *drvinfo)
@@ -664,7 +665,7 @@ static void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv)
664665
struct list_head *head = &rpriv->uplink_priv.tc_indr_block_priv_list;
665666

666667
list_for_each_entry_safe(cb_priv, temp, head, list) {
667-
mlx5e_rep_indr_unregister_block(cb_priv->netdev);
668+
mlx5e_rep_indr_unregister_block(rpriv, cb_priv->netdev);
668669
kfree(cb_priv);
669670
}
670671
}
@@ -736,22 +737,23 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
736737

737738
err = tcf_block_cb_register(f->block,
738739
mlx5e_rep_indr_setup_block_cb,
739-
netdev, indr_priv, f->extack);
740+
indr_priv, indr_priv, f->extack);
740741
if (err) {
741742
list_del(&indr_priv->list);
742743
kfree(indr_priv);
743744
}
744745

745746
return err;
746747
case TC_BLOCK_UNBIND:
748+
indr_priv = mlx5e_rep_indr_block_priv_lookup(rpriv, netdev);
749+
if (!indr_priv)
750+
return -ENOENT;
751+
747752
tcf_block_cb_unregister(f->block,
748753
mlx5e_rep_indr_setup_block_cb,
749-
netdev);
750-
indr_priv = mlx5e_rep_indr_block_priv_lookup(rpriv, netdev);
751-
if (indr_priv) {
752-
list_del(&indr_priv->list);
753-
kfree(indr_priv);
754-
}
754+
indr_priv);
755+
list_del(&indr_priv->list);
756+
kfree(indr_priv);
755757

756758
return 0;
757759
default:
@@ -780,7 +782,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv,
780782

781783
err = __tc_indr_block_cb_register(netdev, rpriv,
782784
mlx5e_rep_indr_setup_tc_cb,
783-
netdev);
785+
rpriv);
784786
if (err) {
785787
struct mlx5e_priv *priv = netdev_priv(rpriv->netdev);
786788

@@ -790,10 +792,11 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv,
790792
return err;
791793
}
792794

793-
static void mlx5e_rep_indr_unregister_block(struct net_device *netdev)
795+
static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv,
796+
struct net_device *netdev)
794797
{
795798
__tc_indr_block_cb_unregister(netdev, mlx5e_rep_indr_setup_tc_cb,
796-
netdev);
799+
rpriv);
797800
}
798801

799802
static int mlx5e_nic_rep_netdevice_event(struct notifier_block *nb,
@@ -812,7 +815,7 @@ static int mlx5e_nic_rep_netdevice_event(struct notifier_block *nb,
812815
mlx5e_rep_indr_register_block(rpriv, netdev);
813816
break;
814817
case NETDEV_UNREGISTER:
815-
mlx5e_rep_indr_unregister_block(netdev);
818+
mlx5e_rep_indr_unregister_block(rpriv, netdev);
816819
break;
817820
}
818821
return NOTIFY_OK;

0 commit comments

Comments
 (0)