Commit 09917a12 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-allow-per-net-notifier-to-follow-netdev-into-namespace'



Jiri Pirko says:

====================
net: allow per-net notifier to follow netdev into namespace

Currently we have per-net notifier, which allows to get only
notifications relevant to particular network namespace. That is enough
for drivers that have netdevs local in a particular namespace (cannot
move elsewhere).

However if netdev can change namespace, per-net notifier cannot be used.
Introduce dev_net variant that is basically per-net notifier with an
extension that re-registers the per-net notifier upon netdev namespace
change. Basically the per-net notifier follows the netdev into
namespace.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents cd94ef06 d48834f9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ struct mlx5e_tc_table {
	DECLARE_HASHTABLE(hairpin_tbl, 8);

	struct notifier_block     netdevice_nb;
	struct netdev_net_notifier	netdevice_nn;
};

struct mlx5e_flow_table {
+2 −1
Original line number Diff line number Diff line
@@ -5144,6 +5144,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)

static void mlx5e_nic_disable(struct mlx5e_priv *priv)
{
	struct net_device *netdev = priv->netdev;
	struct mlx5_core_dev *mdev = priv->mdev;

#ifdef CONFIG_MLX5_CORE_EN_DCB
@@ -5164,7 +5165,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
		mlx5e_monitor_counter_cleanup(priv);

	mlx5e_disable_async_events(priv);
	mlx5_lag_remove(mdev);
	mlx5_lag_remove(mdev, netdev);
}

int mlx5e_update_nic_rx(struct mlx5e_priv *priv)
+10 −3
Original line number Diff line number Diff line
@@ -1731,7 +1731,9 @@ static int mlx5e_init_uplink_rep_tx(struct mlx5e_rep_priv *rpriv)
	/* init indirect block notifications */
	INIT_LIST_HEAD(&uplink_priv->tc_indr_block_priv_list);
	uplink_priv->netdevice_nb.notifier_call = mlx5e_nic_rep_netdevice_event;
	err = register_netdevice_notifier(&uplink_priv->netdevice_nb);
	err = register_netdevice_notifier_dev_net(rpriv->netdev,
						  &uplink_priv->netdevice_nb,
						  &uplink_priv->netdevice_nn);
	if (err) {
		mlx5_core_err(priv->mdev, "Failed to register netdev notifier\n");
		goto tc_esw_cleanup;
@@ -1770,8 +1772,12 @@ destroy_tises:

static void mlx5e_cleanup_uplink_rep_tx(struct mlx5e_rep_priv *rpriv)
{
	struct mlx5_rep_uplink_priv *uplink_priv = &rpriv->uplink_priv;

	/* clean indirect TC block notifications */
	unregister_netdevice_notifier(&rpriv->uplink_priv.netdevice_nb);
	unregister_netdevice_notifier_dev_net(rpriv->netdev,
					      &uplink_priv->netdevice_nb,
					      &uplink_priv->netdevice_nn);
	mlx5e_rep_indr_clean_block_privs(rpriv);

	/* delete shared tc flow table */
@@ -1855,6 +1861,7 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)

static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
{
	struct net_device *netdev = priv->netdev;
	struct mlx5_core_dev *mdev = priv->mdev;
	struct mlx5e_rep_priv *rpriv = priv->ppriv;

@@ -1863,7 +1870,7 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
#endif
	mlx5_notifier_unregister(mdev, &priv->events_nb);
	cancel_work_sync(&rpriv->uplink_priv.reoffload_flows_work);
	mlx5_lag_remove(mdev);
	mlx5_lag_remove(mdev, netdev);
}

static MLX5E_DEFINE_STATS_GRP(sw_rep, 0);
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ struct mlx5_rep_uplink_priv {
	 */
	struct list_head	    tc_indr_block_priv_list;
	struct notifier_block	    netdevice_nb;
	struct netdev_net_notifier  netdevice_nn;

	struct mlx5_tun_entropy tun_entropy;

+7 −2
Original line number Diff line number Diff line
@@ -4251,7 +4251,10 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv)
		return err;

	tc->netdevice_nb.notifier_call = mlx5e_tc_netdev_event;
	if (register_netdevice_notifier(&tc->netdevice_nb)) {
	err = register_netdevice_notifier_dev_net(priv->netdev,
						  &tc->netdevice_nb,
						  &tc->netdevice_nn);
	if (err) {
		tc->netdevice_nb.notifier_call = NULL;
		mlx5_core_warn(priv->mdev, "Failed to register netdev notifier\n");
	}
@@ -4273,7 +4276,9 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv)
	struct mlx5e_tc_table *tc = &priv->fs.tc;

	if (tc->netdevice_nb.notifier_call)
		unregister_netdevice_notifier(&tc->netdevice_nb);
		unregister_netdevice_notifier_dev_net(priv->netdev,
						      &tc->netdevice_nb,
						      &tc->netdevice_nn);

	mutex_destroy(&tc->mod_hdr.lock);
	mutex_destroy(&tc->hairpin_tbl_lock);
Loading