lkml.org 
[lkml]   [2000]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: devfs / eth micro-problems
On Mon, 14 Aug 2000, Alan Cox wrote:

: > Before allocating a name, init_netdev calls
: > netdev_boot_setup_check and this does some extremely
: > ugly junk. If the kernel was booted with parameters
:
: ok this should be happening after the name is assigned and doing
: comparisons not assignment of the string
:
Ok, I made a patch to fix this and quick tests show that it should now
work correctly. The problem was that we don't have anymore preset names
for devices like eth, they are masked names thus the device name
allocation causes more trouble, especially when we still have some other
devices that doesn't use that scheme. Anyhow, below is the patch, though,
might not be the best way to do it... (against: 2.4.0-test6)

--snip---------
diff -uNr ./drivers/net/net_init.c ../linux-2.4-new/drivers/net/net_init.c
--- ./drivers/net/net_init.c Sat Jul 15 00:46:30 2000
+++ ../linux-2.4-new/drivers/net/net_init.c Tue Aug 22 12:28:44 2000
@@ -117,17 +117,15 @@

if (dev->name[0] == '\0' || dev->name[0] == ' ') {
strcpy(dev->name, mask);
- if (!netdev_boot_setup_check(dev)) {
- if (dev_alloc_name(dev, mask)<0) {
- if (new_device)
- kfree(dev);
- return NULL;
- }
+ if (dev_alloc_name(dev, mask)<0) {
+ if (new_device)
+ kfree(dev);
+ return NULL;
}
- } else {
- netdev_boot_setup_check(dev);
+
}
-
+ netdev_boot_setup_check(dev);
+
/*
* Configure via the caller provided setup function then
* register if needed.
diff -uNr ./net/core/dev.c ../linux-2.4-new/net/core/dev.c
--- ./net/core/dev.c Wed Jun 21 00:32:27 2000
+++ ../linux-2.4-new/net/core/dev.c Tue Aug 22 12:29:13 2000
@@ -303,28 +303,12 @@
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;
@@ -365,6 +349,7 @@

__setup("netdev=", netdev_boot_setup);

+
/*****************************************************************************************

Device Interface Subroutines
@@ -2481,27 +2466,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();
@@ -2511,6 +2495,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;
}
}

--snip---------
Pekka
________________________________________________________________________
Pekka Riikonen | Email: priikone@poseidon.pspt.fi
SSH Communications Security Corp. | http://poseidon.pspt.fi/~priikone
Tel. +358 (0)40 580 6673 | Kasarmikatu 11 A4, SF-70110 Kuopio
PGP KeyID A924ED4F: http://poseidon.pspt.fi/~priikone/pubkey.asc
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:37    [W:0.062 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site