patch-2.4.0-test9 linux/net/core/dev.c

Next file: linux/net/core/sock.c
Previous file: linux/net/appletalk/aarp.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/net/core/dev.c linux/net/core/dev.c
@@ -295,37 +295,20 @@
  *	netdev_boot_setup_check	- check boot time settings
  *	@dev: the netdevice
  *
- * 	Check boot time settings for the device.  If device's name is a
- *	mask (eg. eth%d) and settings are found then this will allocate 
- *	name for the device.  The found settings are set for the device
- *	to be used later in the device probing.  Returns 0 if no settings
- *	found, 1 if they are.
+ * 	Check boot time settings for the device.
+ *	The found settings are set for the device to be used
+ *	later in the device probing.
+ *	Returns 0 if no settings found, 1 if they are.
  */
 int netdev_boot_setup_check(struct net_device *dev)
 {
 	struct netdev_boot_setup *s;
-	char buf[IFNAMSIZ + 1];
-	int i, mask = 0;
-
-	memset(buf, 0, sizeof(buf));
-	strcpy(buf, dev->name);
-	if (strchr(dev->name, '%')) {
-		*strchr(buf, '%') = '\0';
-		mask = 1;
-	}
+	int i;
 
 	s = dev_boot_setup;
 	for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
 		if (s[i].name[0] != '\0' && s[i].name[0] != ' ' &&
-		    !strncmp(buf, s[i].name, mask ? strlen(buf) :
-						    strlen(s[i].name))) {
-			if (__dev_get_by_name(s[i].name)) {
-				if (!mask)
-					return 0;
-				continue;
-			}
-			memset(dev->name, 0, IFNAMSIZ);
-			strcpy(dev->name, s[i].name);
+		    !strncmp(dev->name, s[i].name, strlen(s[i].name))) {
 			dev->irq 	= s[i].map.irq;
 			dev->base_addr 	= s[i].map.base_addr;
 			dev->mem_start 	= s[i].map.mem_start;
@@ -333,7 +316,6 @@
 			return 1;
 		}
 	}
-
 	return 0;
 }
 
@@ -1159,6 +1141,7 @@
 			struct net_device *dev = head;
 			head = head->next_sched;
 
+			smp_mb__before_clear_bit();
 			clear_bit(__LINK_STATE_SCHED, &dev->state);
 
 			if (spin_trylock(&dev->queue_lock)) {
@@ -2463,27 +2446,26 @@
 		dev->iflink = -1;
 		dev_hold(dev);
 
+		/*
+		 * Allocate name. If the init() fails
+		 * the name will be reissued correctly.
+		 */
+		if (strchr(dev->name, '%'))
+			dev_alloc_name(dev, dev->name);
+
 		/* 
 		 * Check boot time settings for the device.
 		 */
-		if (!netdev_boot_setup_check(dev)) {
-			/*
-			 * No settings found - allocate name. If the init()
-			 * fails the name will be reissued correctly.
-			 */
-			if (strchr(dev->name, '%'))
-				dev_alloc_name(dev, dev->name);
-		}
+		netdev_boot_setup_check(dev);
 
 		if (dev->init && dev->init(dev)) {
 			/*
-			 *	It failed to come up. Unhook it.
+			 * It failed to come up. It will be unhooked later.
+			 * dev_alloc_name can now advance to next suitable
+			 * name that is checked next.
 			 */
-			write_lock_bh(&dev_base_lock);
-			*dp = dev->next;
 			dev->deadbeaf = 1;
-			write_unlock_bh(&dev_base_lock);
-			dev_put(dev);
+			dp = &dev->next;
 		} else {
 			dp = &dev->next;
 			dev->ifindex = dev_new_index();
@@ -2493,6 +2475,21 @@
 				dev->rebuild_header = default_rebuild_header;
 			dev_init_scheduler(dev);
 			set_bit(__LINK_STATE_PRESENT, &dev->state);
+		}
+	}
+
+	/*
+	 * Unhook devices that failed to come up
+	 */
+	dp = &dev_base;
+	while ((dev = *dp) != NULL) {
+		if (dev->deadbeaf) {
+			write_lock_bh(&dev_base_lock);
+			*dp = dev->next;
+			write_unlock_bh(&dev_base_lock);
+			dev_put(dev);
+		} else {
+			dp = &dev->next;
 		}
 	}
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)