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

mlxsw: spectrum: Destroy RIFs based on last removed address

We only use the RIF reference count to determine when the last IP
address was removed, but instead we can just test 'in_dev->ifa_list'.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 186962eb
...@@ -3392,16 +3392,16 @@ void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port) ...@@ -3392,16 +3392,16 @@ void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port)
} }
static bool mlxsw_sp_rif_should_config(struct mlxsw_sp_rif *r, static bool mlxsw_sp_rif_should_config(struct mlxsw_sp_rif *r,
const struct in_device *in_dev,
unsigned long event) unsigned long event)
{ {
switch (event) { switch (event) {
case NETDEV_UP: case NETDEV_UP:
if (!r) if (!r)
return true; return true;
r->ref_count++;
return false; return false;
case NETDEV_DOWN: case NETDEV_DOWN:
if (r && --r->ref_count == 0) if (r && !in_dev->ifa_list)
return true; return true;
/* It is possible we already removed the RIF ourselves /* It is possible we already removed the RIF ourselves
* if it was assigned to a netdev that is now a bridge * if it was assigned to a netdev that is now a bridge
...@@ -3484,7 +3484,6 @@ mlxsw_sp_rif_alloc(u16 rif, struct net_device *l3_dev, struct mlxsw_sp_fid *f) ...@@ -3484,7 +3484,6 @@ mlxsw_sp_rif_alloc(u16 rif, struct net_device *l3_dev, struct mlxsw_sp_fid *f)
INIT_LIST_HEAD(&r->neigh_list); INIT_LIST_HEAD(&r->neigh_list);
ether_addr_copy(r->addr, l3_dev->dev_addr); ether_addr_copy(r->addr, l3_dev->dev_addr);
r->mtu = l3_dev->mtu; r->mtu = l3_dev->mtu;
r->ref_count = 1;
r->dev = l3_dev; r->dev = l3_dev;
r->rif = rif; r->rif = rif;
r->f = f; r->f = f;
...@@ -3858,7 +3857,7 @@ static int mlxsw_sp_inetaddr_event(struct notifier_block *unused, ...@@ -3858,7 +3857,7 @@ static int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
goto out; goto out;
r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev);
if (!mlxsw_sp_rif_should_config(r, event)) if (!mlxsw_sp_rif_should_config(r, ifa->ifa_dev, event))
goto out; goto out;
if (mlxsw_sp_port_dev_check(dev)) if (mlxsw_sp_port_dev_check(dev))
......
...@@ -111,7 +111,6 @@ struct mlxsw_sp_rif { ...@@ -111,7 +111,6 @@ struct mlxsw_sp_rif {
struct list_head nexthop_list; struct list_head nexthop_list;
struct list_head neigh_list; struct list_head neigh_list;
struct net_device *dev; struct net_device *dev;
unsigned int ref_count;
struct mlxsw_sp_fid *f; struct mlxsw_sp_fid *f;
unsigned char addr[ETH_ALEN]; unsigned char addr[ETH_ALEN];
int mtu; int mtu;
......
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