All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] core: Correct an over-stringent device loop detection.
@ 2015-05-03  1:33 Vladislav Yasevich
  2015-05-03 17:46 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vladislav Yasevich @ 2015-05-03  1:33 UTC (permalink / raw)
  To: netdev; +Cc: jpirko, vfalico, Vladislav Yasevich

The code in __netdev_upper_dev_link() has an over-stringent
loop detection logic that actually prevents valid configurations
from working correctly.

In particular, the logic returns an error if an upper device
is already in the list of all upper devices for a given dev.
This particular check seems to be a overzealous as it disallows
perfectly valid configurations.  For example:
  # ip l a link eth0 name eth0.10 type vlan id 10
  # ip l a dev br0 typ bridge
  # ip l s eth0.10 master br0
  # ip l s eth0 master br0  <--- Will fail

If you switch the last two commands (add eth0 first), then both
will succeed.  If after that, you remove eth0 and try to re-add
it, it will fail!

It appears to be enough to simply check adj_list to keeps things
safe.

I've tried stacking multiple devices multiple times in all different
combinations, and either rx_handler registration prevented the stacking
of the device linking cought the error.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index c7ba038..2c1c67f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5209,7 +5209,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
 	if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper))
 		return -EBUSY;
 
-	if (__netdev_find_adj(dev, upper_dev, &dev->all_adj_list.upper))
+	if (__netdev_find_adj(dev, upper_dev, &dev->adj_list.upper))
 		return -EEXIST;
 
 	if (master && netdev_master_upper_dev_get(dev))
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] core: Correct an over-stringent device loop detection.
  2015-05-03  1:33 [PATCH] core: Correct an over-stringent device loop detection Vladislav Yasevich
@ 2015-05-03 17:46 ` Jiri Pirko
  2015-05-03 18:07 ` Veaceslav Falico
  2015-05-04 18:58 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2015-05-03 17:46 UTC (permalink / raw)
  To: Vladislav Yasevich; +Cc: netdev, jpirko, vfalico, Vladislav Yasevich

Sun, May 03, 2015 at 03:33:44AM CEST, vyasevich@gmail.com wrote:
>The code in __netdev_upper_dev_link() has an over-stringent
>loop detection logic that actually prevents valid configurations
>from working correctly.
>
>In particular, the logic returns an error if an upper device
>is already in the list of all upper devices for a given dev.
>This particular check seems to be a overzealous as it disallows
>perfectly valid configurations.  For example:
>  # ip l a link eth0 name eth0.10 type vlan id 10
>  # ip l a dev br0 typ bridge
>  # ip l s eth0.10 master br0
>  # ip l s eth0 master br0  <--- Will fail
>
>If you switch the last two commands (add eth0 first), then both
>will succeed.  If after that, you remove eth0 and try to re-add
>it, it will fail!
>
>It appears to be enough to simply check adj_list to keeps things
>safe.
>
>I've tried stacking multiple devices multiple times in all different
>combinations, and either rx_handler registration prevented the stacking
>of the device linking cought the error.
>
>Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>

Acked-by: Jiri Pirko <jiri@resnulli.us>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] core: Correct an over-stringent device loop detection.
  2015-05-03  1:33 [PATCH] core: Correct an over-stringent device loop detection Vladislav Yasevich
  2015-05-03 17:46 ` Jiri Pirko
@ 2015-05-03 18:07 ` Veaceslav Falico
  2015-05-04 18:58 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Veaceslav Falico @ 2015-05-03 18:07 UTC (permalink / raw)
  To: Vladislav Yasevich; +Cc: netdev, jpirko, Vladislav Yasevich

On Sat, May 02, 2015 at 09:33:44PM -0400, Vladislav Yasevich wrote:
>The code in __netdev_upper_dev_link() has an over-stringent
>loop detection logic that actually prevents valid configurations
>from working correctly.
>
>In particular, the logic returns an error if an upper device
>is already in the list of all upper devices for a given dev.
>This particular check seems to be a overzealous as it disallows
>perfectly valid configurations.  For example:
>  # ip l a link eth0 name eth0.10 type vlan id 10
>  # ip l a dev br0 typ bridge
>  # ip l s eth0.10 master br0
>  # ip l s eth0 master br0  <--- Will fail
>
>If you switch the last two commands (add eth0 first), then both
>will succeed.  If after that, you remove eth0 and try to re-add
>it, it will fail!
>
>It appears to be enough to simply check adj_list to keeps things
>safe.
>
>I've tried stacking multiple devices multiple times in all different
>combinations, and either rx_handler registration prevented the stacking
>of the device linking cought the error.
>
>Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>

Good catch.

Acked-by: Veaceslav Falico <vfalico@gmail.com>

>---
> net/core/dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/core/dev.c b/net/core/dev.c
>index c7ba038..2c1c67f 100644
>--- a/net/core/dev.c
>+++ b/net/core/dev.c
>@@ -5209,7 +5209,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
> 	if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper))
> 		return -EBUSY;
>
>-	if (__netdev_find_adj(dev, upper_dev, &dev->all_adj_list.upper))
>+	if (__netdev_find_adj(dev, upper_dev, &dev->adj_list.upper))
> 		return -EEXIST;
>
> 	if (master && netdev_master_upper_dev_get(dev))
>-- 
>1.9.3
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] core: Correct an over-stringent device loop detection.
  2015-05-03  1:33 [PATCH] core: Correct an over-stringent device loop detection Vladislav Yasevich
  2015-05-03 17:46 ` Jiri Pirko
  2015-05-03 18:07 ` Veaceslav Falico
@ 2015-05-04 18:58 ` David Miller
  2015-05-04 19:55   ` Vlad Yasevich
  2 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2015-05-04 18:58 UTC (permalink / raw)
  To: vyasevich; +Cc: netdev, jpirko, vfalico, vyasevic

From: Vladislav Yasevich <vyasevich@gmail.com>
Date: Sat,  2 May 2015 21:33:44 -0400

> The code in __netdev_upper_dev_link() has an over-stringent
> loop detection logic that actually prevents valid configurations
> from working correctly.
> 
> In particular, the logic returns an error if an upper device
> is already in the list of all upper devices for a given dev.
> This particular check seems to be a overzealous as it disallows
> perfectly valid configurations.  For example:
>   # ip l a link eth0 name eth0.10 type vlan id 10
>   # ip l a dev br0 typ bridge
>   # ip l s eth0.10 master br0
>   # ip l s eth0 master br0  <--- Will fail
> 
> If you switch the last two commands (add eth0 first), then both
> will succeed.  If after that, you remove eth0 and try to re-add
> it, it will fail!
> 
> It appears to be enough to simply check adj_list to keeps things
> safe.
> 
> I've tried stacking multiple devices multiple times in all different
> combinations, and either rx_handler registration prevented the stacking
> of the device linking cought the error.
> 
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>

Applied, thanks Vlad.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] core: Correct an over-stringent device loop detection.
  2015-05-04 18:58 ` David Miller
@ 2015-05-04 19:55   ` Vlad Yasevich
  2015-05-04 20:22     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Vlad Yasevich @ 2015-05-04 19:55 UTC (permalink / raw)
  To: David Miller, vyasevich; +Cc: netdev, jpirko, vfalico

On 05/04/2015 02:58 PM, David Miller wrote:
> From: Vladislav Yasevich <vyasevich@gmail.com>
> Date: Sat,  2 May 2015 21:33:44 -0400
> 
>> The code in __netdev_upper_dev_link() has an over-stringent
>> loop detection logic that actually prevents valid configurations
>> from working correctly.
>>
>> In particular, the logic returns an error if an upper device
>> is already in the list of all upper devices for a given dev.
>> This particular check seems to be a overzealous as it disallows
>> perfectly valid configurations.  For example:
>>   # ip l a link eth0 name eth0.10 type vlan id 10
>>   # ip l a dev br0 typ bridge
>>   # ip l s eth0.10 master br0
>>   # ip l s eth0 master br0  <--- Will fail
>>
>> If you switch the last two commands (add eth0 first), then both
>> will succeed.  If after that, you remove eth0 and try to re-add
>> it, it will fail!
>>
>> It appears to be enough to simply check adj_list to keeps things
>> safe.
>>
>> I've tried stacking multiple devices multiple times in all different
>> combinations, and either rx_handler registration prevented the stacking
>> of the device linking cought the error.
>>
>> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> 
> Applied, thanks Vlad.
> 

Hi Dave

Can you also queue it for stable.  This has been broken for a while.
Thanks
-vlad

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] core: Correct an over-stringent device loop detection.
  2015-05-04 19:55   ` Vlad Yasevich
@ 2015-05-04 20:22     ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-05-04 20:22 UTC (permalink / raw)
  To: vyasevic; +Cc: vyasevich, netdev, jpirko, vfalico

From: Vlad Yasevich <vyasevic@redhat.com>
Date: Mon, 04 May 2015 15:55:48 -0400

> Can you also queue it for stable.  This has been broken for a while.

Done.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-04 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03  1:33 [PATCH] core: Correct an over-stringent device loop detection Vladislav Yasevich
2015-05-03 17:46 ` Jiri Pirko
2015-05-03 18:07 ` Veaceslav Falico
2015-05-04 18:58 ` David Miller
2015-05-04 19:55   ` Vlad Yasevich
2015-05-04 20:22     ` 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.