Commit 33d11c4e authored by Petr Machata's avatar Petr Machata Committed by Paolo Abeni

mlxsw: spectrum_router: Add a helper to check if netdev has addresses

This function will be useful later as the driver will need to retroactively
create RIFs for new uppers with addresses.

Add another helper that assumes RCU lock, and restructure the code to
skip the IPv6 branch not through conditioning on the addr_list_empty
variable, but by directly returning the result value. This makes the skip
more obvious than it previously was.
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarAmit Cohen <amcohen@nvidia.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 571c5691
......@@ -7794,28 +7794,44 @@ static void mlxsw_sp_router_rif_gone_sync(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_neigh_rif_gone_sync(mlxsw_sp, rif);
}
static bool __mlxsw_sp_dev_addr_list_empty(const struct net_device *dev)
{
struct inet6_dev *inet6_dev;
struct in_device *idev;
idev = __in_dev_get_rcu(dev);
if (idev && idev->ifa_list)
return false;
inet6_dev = __in6_dev_get(dev);
if (inet6_dev && !list_empty(&inet6_dev->addr_list))
return false;
return true;
}
static bool mlxsw_sp_dev_addr_list_empty(const struct net_device *dev)
{
bool addr_list_empty;
rcu_read_lock();
addr_list_empty = __mlxsw_sp_dev_addr_list_empty(dev);
rcu_read_unlock();
return addr_list_empty;
}
static bool
mlxsw_sp_rif_should_config(struct mlxsw_sp_rif *rif, struct net_device *dev,
unsigned long event)
{
struct inet6_dev *inet6_dev;
bool addr_list_empty = true;
struct in_device *idev;
bool addr_list_empty;
switch (event) {
case NETDEV_UP:
return rif == NULL;
case NETDEV_DOWN:
rcu_read_lock();
idev = __in_dev_get_rcu(dev);
if (idev && idev->ifa_list)
addr_list_empty = false;
inet6_dev = __in6_dev_get(dev);
if (addr_list_empty && inet6_dev &&
!list_empty(&inet6_dev->addr_list))
addr_list_empty = false;
rcu_read_unlock();
addr_list_empty = mlxsw_sp_dev_addr_list_empty(dev);
/* macvlans do not have a RIF, but rather piggy back on the
* RIF of their lower device.
......
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