@@ -4424,6 +4424,24 @@ static int __init dev_proc_init(void)
#define dev_proc_init() 0
#endif /* CONFIG_PROC_FS */
+bool netdev_check_loop(struct net_device *master, struct net_device *dev)
+{
+ if (master == dev)
+ return true;
+
+ if (is_vlan_dev(dev))
+ return nedev_check_loop(vlan_dev_real_dev(dev));
+
+ /* is a bridge ?*/
+ if (dev->priv_flags & IFF_EBRIDGE) {
+ list_for_each_entry(p, &br->port_list, list) {
+ if (nedev_check_loop(p->dev))
+ return true;
+ }
+ }
+
+ return false;
+}
/**
* netdev_set_master - set up master pointer
@@ -4447,6 +4465,9 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
dev_hold(master);
}
+ if (netdev_check_loop(master, slave))
+ return -EINVAL;
+
slave->master = master;
if (old)