[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1476494931-31813-11-git-send-email-dsa@cumulusnetworks.com>
Date: Fri, 14 Oct 2016 18:28:50 -0700
From: David Ahern <dsa@...ulusnetworks.com>
To: jiri@...lanox.com, netdev@...r.kernel.org, davem@...emloft.net
Cc: dledford@...hat.com, sean.hefty@...el.com,
hal.rosenstock@...il.com, linux-rdma@...r.kernel.org,
j.vosburgh@...il.com, vfalico@...il.com, andy@...yhouse.net,
jeffrey.t.kirsher@...el.com, intel-wired-lan@...ts.osuosl.org,
David Ahern <dsa@...ulusnetworks.com>
Subject: [PATCH net-next 10/11] net: Add warning if any lower device is still in adjacency list
Lower list should be empty just like upper.
Signed-off-by: David Ahern <dsa@...ulusnetworks.com>
---
net/core/dev.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index a012c7266230..99a1cb432945 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5225,6 +5225,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;
@@ -6622,6 +6636,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);
--
2.1.4
Powered by blists - more mailing lists