Commit 21ffedb6 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_router: Propagate 'struct mlxsw_sp' further

Next patch is going to make RIF deletion more robust by removing
reliance on fragile mlxsw_sp_lower_get(). This is because a netdev is
not necessarily our upper anymore when its IP addresses are flushed.

The inet{,6}addr notification blocks are going to resolve 'struct
mlxsw_sp' using container_of(), but the functions they call still use
mlxsw_sp_lower_get().

As a preparation for the next patch, propagate 'struct mlxsw_sp' down to
the functions called from the notification blocks and remove reliance on
mlxsw_sp_lower_get().
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent be2d6f42
...@@ -6568,11 +6568,11 @@ static int mlxsw_sp_inetaddr_lag_event(struct net_device *lag_dev, ...@@ -6568,11 +6568,11 @@ static int mlxsw_sp_inetaddr_lag_event(struct net_device *lag_dev,
extack); extack);
} }
static int mlxsw_sp_inetaddr_bridge_event(struct net_device *l3_dev, static int mlxsw_sp_inetaddr_bridge_event(struct mlxsw_sp *mlxsw_sp,
struct net_device *l3_dev,
unsigned long event, unsigned long event,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(l3_dev);
struct mlxsw_sp_rif_params params = { struct mlxsw_sp_rif_params params = {
.dev = l3_dev, .dev = l3_dev,
}; };
...@@ -6593,7 +6593,8 @@ static int mlxsw_sp_inetaddr_bridge_event(struct net_device *l3_dev, ...@@ -6593,7 +6593,8 @@ static int mlxsw_sp_inetaddr_bridge_event(struct net_device *l3_dev,
return 0; return 0;
} }
static int mlxsw_sp_inetaddr_vlan_event(struct net_device *vlan_dev, static int mlxsw_sp_inetaddr_vlan_event(struct mlxsw_sp *mlxsw_sp,
struct net_device *vlan_dev,
unsigned long event, unsigned long event,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
...@@ -6610,7 +6611,8 @@ static int mlxsw_sp_inetaddr_vlan_event(struct net_device *vlan_dev, ...@@ -6610,7 +6611,8 @@ static int mlxsw_sp_inetaddr_vlan_event(struct net_device *vlan_dev,
return __mlxsw_sp_inetaddr_lag_event(vlan_dev, real_dev, event, return __mlxsw_sp_inetaddr_lag_event(vlan_dev, real_dev, event,
vid, extack); vid, extack);
else if (netif_is_bridge_master(real_dev) && br_vlan_enabled(real_dev)) else if (netif_is_bridge_master(real_dev) && br_vlan_enabled(real_dev))
return mlxsw_sp_inetaddr_bridge_event(vlan_dev, event, extack); return mlxsw_sp_inetaddr_bridge_event(mlxsw_sp, vlan_dev, event,
extack);
return 0; return 0;
} }
...@@ -6711,16 +6713,11 @@ void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, ...@@ -6711,16 +6713,11 @@ void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_fid_index(rif->fid), false); mlxsw_sp_fid_index(rif->fid), false);
} }
static int mlxsw_sp_inetaddr_macvlan_event(struct net_device *macvlan_dev, static int mlxsw_sp_inetaddr_macvlan_event(struct mlxsw_sp *mlxsw_sp,
struct net_device *macvlan_dev,
unsigned long event, unsigned long event,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp *mlxsw_sp;
mlxsw_sp = mlxsw_sp_lower_get(macvlan_dev);
if (!mlxsw_sp)
return 0;
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
return mlxsw_sp_rif_macvlan_add(mlxsw_sp, macvlan_dev, extack); return mlxsw_sp_rif_macvlan_add(mlxsw_sp, macvlan_dev, extack);
...@@ -6759,7 +6756,8 @@ static int mlxsw_sp_router_port_check_rif_addr(struct mlxsw_sp *mlxsw_sp, ...@@ -6759,7 +6756,8 @@ static int mlxsw_sp_router_port_check_rif_addr(struct mlxsw_sp *mlxsw_sp,
return 0; return 0;
} }
static int __mlxsw_sp_inetaddr_event(struct net_device *dev, static int __mlxsw_sp_inetaddr_event(struct mlxsw_sp *mlxsw_sp,
struct net_device *dev,
unsigned long event, unsigned long event,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
...@@ -6768,11 +6766,14 @@ static int __mlxsw_sp_inetaddr_event(struct net_device *dev, ...@@ -6768,11 +6766,14 @@ static int __mlxsw_sp_inetaddr_event(struct net_device *dev,
else if (netif_is_lag_master(dev)) else if (netif_is_lag_master(dev))
return mlxsw_sp_inetaddr_lag_event(dev, event, extack); return mlxsw_sp_inetaddr_lag_event(dev, event, extack);
else if (netif_is_bridge_master(dev)) else if (netif_is_bridge_master(dev))
return mlxsw_sp_inetaddr_bridge_event(dev, event, extack); return mlxsw_sp_inetaddr_bridge_event(mlxsw_sp, dev, event,
extack);
else if (is_vlan_dev(dev)) else if (is_vlan_dev(dev))
return mlxsw_sp_inetaddr_vlan_event(dev, event, extack); return mlxsw_sp_inetaddr_vlan_event(mlxsw_sp, dev, event,
extack);
else if (netif_is_macvlan(dev)) else if (netif_is_macvlan(dev))
return mlxsw_sp_inetaddr_macvlan_event(dev, event, extack); return mlxsw_sp_inetaddr_macvlan_event(mlxsw_sp, dev, event,
extack);
else else
return 0; return 0;
} }
...@@ -6798,7 +6799,7 @@ int mlxsw_sp_inetaddr_event(struct notifier_block *unused, ...@@ -6798,7 +6799,7 @@ int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
if (!mlxsw_sp_rif_should_config(rif, dev, event)) if (!mlxsw_sp_rif_should_config(rif, dev, event))
goto out; goto out;
err = __mlxsw_sp_inetaddr_event(dev, event, NULL); err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, NULL);
out: out:
return notifier_from_errno(err); return notifier_from_errno(err);
} }
...@@ -6825,7 +6826,7 @@ int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, ...@@ -6825,7 +6826,7 @@ int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
if (err) if (err)
goto out; goto out;
err = __mlxsw_sp_inetaddr_event(dev, event, ivi->extack); err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, ivi->extack);
out: out:
return notifier_from_errno(err); return notifier_from_errno(err);
} }
...@@ -6854,7 +6855,7 @@ static void mlxsw_sp_inet6addr_event_work(struct work_struct *work) ...@@ -6854,7 +6855,7 @@ static void mlxsw_sp_inet6addr_event_work(struct work_struct *work)
if (!mlxsw_sp_rif_should_config(rif, dev, event)) if (!mlxsw_sp_rif_should_config(rif, dev, event))
goto out; goto out;
__mlxsw_sp_inetaddr_event(dev, event, NULL); __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, NULL);
out: out:
rtnl_unlock(); rtnl_unlock();
dev_put(dev); dev_put(dev);
...@@ -6911,7 +6912,7 @@ int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, ...@@ -6911,7 +6912,7 @@ int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
if (err) if (err)
goto out; goto out;
err = __mlxsw_sp_inetaddr_event(dev, event, i6vi->extack); err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, i6vi->extack);
out: out:
return notifier_from_errno(err); return notifier_from_errno(err);
} }
...@@ -7030,9 +7031,10 @@ static int mlxsw_sp_port_vrf_join(struct mlxsw_sp *mlxsw_sp, ...@@ -7030,9 +7031,10 @@ static int mlxsw_sp_port_vrf_join(struct mlxsw_sp *mlxsw_sp,
*/ */
rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev);
if (rif) if (rif)
__mlxsw_sp_inetaddr_event(l3_dev, NETDEV_DOWN, extack); __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN,
extack);
return __mlxsw_sp_inetaddr_event(l3_dev, NETDEV_UP, extack); return __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_UP, extack);
} }
static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp, static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp,
...@@ -7043,7 +7045,7 @@ static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp, ...@@ -7043,7 +7045,7 @@ static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp,
rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev);
if (!rif) if (!rif)
return; return;
__mlxsw_sp_inetaddr_event(l3_dev, NETDEV_DOWN, NULL); __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, NULL);
} }
int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment