Skip to content

Commit

Permalink
net: Add warning if any lower device is still in adjacency list
Browse files Browse the repository at this point in the history
Lower list should be empty just like upper.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Ahern authored and David S. Miller committed Oct 18, 2016
1 parent f1170fd commit 0f524a8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5219,6 +5219,20 @@ struct net_device *netdev_master_upper_dev_get(struct net_device *dev)
}
EXPORT_SYMBOL(netdev_master_upper_dev_get);

/**
* netdev_has_any_lower_dev - Check if device is linked to some device
* @dev: device
*
* Find out if a device is linked to a lower device and return true in case
* it is. The caller must hold the RTNL lock.
*/
static bool netdev_has_any_lower_dev(struct net_device *dev)
{
ASSERT_RTNL();

return !list_empty(&dev->adj_list.lower);
}

void *netdev_adjacent_get_private(struct list_head *adj_list)
{
struct netdev_adjacent *adj;
Expand Down Expand Up @@ -6616,6 +6630,7 @@ static void rollback_registered_many(struct list_head *head)

/* Notifier chain MUST detach us all upper devices. */
WARN_ON(netdev_has_any_upper_dev(dev));
WARN_ON(netdev_has_any_lower_dev(dev));

/* Remove entries from kobject tree */
netdev_unregister_kobject(dev);
Expand Down

0 comments on commit 0f524a8

Please sign in to comment.