* [PATCH] net: Handle NETREG_UNINITIALIZED devices correctly
@ 2009-12-09 8:26 Krishna Kumar
2009-12-09 9:57 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Krishna Kumar @ 2009-12-09 8:26 UTC (permalink / raw)
To: davem, eric.dumazet, herbert; +Cc: netdev, Krishna Kumar
From: Krishna Kumar <krkumar2@in.ibm.com>
Fix two problems:
1. If unregister_netdevice_many() is called with both registered
and unregistered devices, rollback_registered_many() bails out
when it reaches the first unregistered device. The processing
of the prior registered devices is unfinished, and the
remaining devices are skipped, and possible registered netdev's
are leaked/unregistered.
2. System hangs or panics depending on how the devices are passed,
since when netdev_run_todo() runs, some devices were not fully
processed.
Tested by passing intermingled unregistered and registered vlan
devices to unregister_netdevice_many() as follows:
1. dev, fake_dev1, fake_dev2: hangs in run_todo
("unregister_netdevice: waiting for eth1.100 to become
free. Usage count = 1")
2. fake_dev1, dev, fake_dev2: failure during de-registration
and next registration, followed by a vlan driver Oops
during subsequent registration.
Confirmed that the patch fixes both cases.
Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---
net/core/dev.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff -ruNp org/net/core/dev.c new/net/core/dev.c
--- org/net/core/dev.c 2009-12-04 18:46:13.000000000 +0530
+++ new/net/core/dev.c 2009-12-05 10:23:25.000000000 +0530
@@ -4771,21 +4771,23 @@ static void net_set_todo(struct net_devi
static void rollback_registered_many(struct list_head *head)
{
- struct net_device *dev;
+ struct net_device *dev, *tmp;
BUG_ON(dev_boot_phase);
ASSERT_RTNL();
- list_for_each_entry(dev, head, unreg_list) {
+ list_for_each_entry_safe(dev, tmp, head, unreg_list) {
/* Some devices call without registering
- * for initialization unwind.
+ * for initialization unwind. Remove those
+ * devices and proceed with the remaining.
*/
if (dev->reg_state == NETREG_UNINITIALIZED) {
pr_debug("unregister_netdevice: device %s/%p never "
"was registered\n", dev->name, dev);
WARN_ON(1);
- return;
+ list_del(&dev->unreg_list);
+ continue;
}
BUG_ON(dev->reg_state != NETREG_REGISTERED);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: Handle NETREG_UNINITIALIZED devices correctly
2009-12-09 8:26 [PATCH] net: Handle NETREG_UNINITIALIZED devices correctly Krishna Kumar
@ 2009-12-09 9:57 ` Eric Dumazet
2009-12-11 23:12 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2009-12-09 9:57 UTC (permalink / raw)
To: Krishna Kumar; +Cc: davem, herbert, netdev
Krishna Kumar a écrit :
> From: Krishna Kumar <krkumar2@in.ibm.com>
>
> Fix two problems:
>
> 1. If unregister_netdevice_many() is called with both registered
> and unregistered devices, rollback_registered_many() bails out
> when it reaches the first unregistered device. The processing
> of the prior registered devices is unfinished, and the
> remaining devices are skipped, and possible registered netdev's
> are leaked/unregistered.
>
> 2. System hangs or panics depending on how the devices are passed,
> since when netdev_run_todo() runs, some devices were not fully
> processed.
>
> Tested by passing intermingled unregistered and registered vlan
> devices to unregister_netdevice_many() as follows:
> 1. dev, fake_dev1, fake_dev2: hangs in run_todo
> ("unregister_netdevice: waiting for eth1.100 to become
> free. Usage count = 1")
> 2. fake_dev1, dev, fake_dev2: failure during de-registration
> and next registration, followed by a vlan driver Oops
> during subsequent registration.
>
> Confirmed that the patch fixes both cases.
>
> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Thanks !
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: Handle NETREG_UNINITIALIZED devices correctly
2009-12-09 9:57 ` Eric Dumazet
@ 2009-12-11 23:12 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2009-12-11 23:12 UTC (permalink / raw)
To: eric.dumazet; +Cc: krkumar2, herbert, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 09 Dec 2009 10:57:44 +0100
> Krishna Kumar a ^[$(D+1^[(Bcrit :
>> From: Krishna Kumar <krkumar2@in.ibm.com>
>>
>> Fix two problems:
>>
>> 1. If unregister_netdevice_many() is called with both registered
>> and unregistered devices, rollback_registered_many() bails out
>> when it reaches the first unregistered device. The processing
>> of the prior registered devices is unfinished, and the
>> remaining devices are skipped, and possible registered netdev's
>> are leaked/unregistered.
>>
>> 2. System hangs or panics depending on how the devices are passed,
>> since when netdev_run_todo() runs, some devices were not fully
>> processed.
>>
>> Tested by passing intermingled unregistered and registered vlan
>> devices to unregister_netdevice_many() as follows:
>> 1. dev, fake_dev1, fake_dev2: hangs in run_todo
>> ("unregister_netdevice: waiting for eth1.100 to become
>> free. Usage count = 1")
>> 2. fake_dev1, dev, fake_dev2: failure during de-registration
>> and next registration, followed by a vlan driver Oops
>> during subsequent registration.
>>
>> Confirmed that the patch fixes both cases.
>>
>> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
>
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Nice work Krishna, applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-11 23:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09 8:26 [PATCH] net: Handle NETREG_UNINITIALIZED devices correctly Krishna Kumar
2009-12-09 9:57 ` Eric Dumazet
2009-12-11 23:12 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.