netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] ipvlan: fix dev_id creation corner case.
@ 2017-01-13 23:48 Mahesh Bandewar
  2017-01-16 19:05 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Mahesh Bandewar @ 2017-01-13 23:48 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Mahesh Bandewar, Mahesh Bandewar, David Miller,
	Eric Dumazet

From: Mahesh Bandewar <maheshb@google.com>

In the last patch da36e13cf65 ("ipvlan: improvise dev_id generation
logic in IPvlan") I missed some part of Dave's suggestion and because
of that the dev_id creation could fail in a corner case scenario. This
would happen when more or less 64k devices have been already created and
several have been deleted. If the devices that are still sticking around
are the last n bits from the bitmap. So in this scenario even if lower
bits are available, the dev_id search is so narrow that it always fails.

Fixes: da36e13cf65 ("ipvlan: improvise dev_id generation logic in IPvlan")
CC: David Miller <davem@davemloft.org>
CC: Eric Dumazet <edumazet@google.com>
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
 drivers/net/ipvlan/ipvlan_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 92b221a03350..b5c390f0f2b3 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -550,6 +550,9 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
 	err = ida_simple_get(&port->ida, port->dev_id_start, 0xFFFE,
 			     GFP_KERNEL);
 	if (err < 0)
+		err = ida_simple_get(&port->ida, 0x1, port->dev_id_start,
+				     GFP_KERNEL);
+	if (err < 0)
 		goto destroy_ipvlan_port;
 	dev->dev_id = err;
 	/* Increment id-base to the next slot for the future assignment */
-- 
2.11.0.483.g087da7b7c-goog

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

* Re: [PATCH next] ipvlan: fix dev_id creation corner case.
  2017-01-13 23:48 [PATCH next] ipvlan: fix dev_id creation corner case Mahesh Bandewar
@ 2017-01-16 19:05 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-01-16 19:05 UTC (permalink / raw)
  To: mahesh; +Cc: netdev, maheshb, davem, edumazet

From: Mahesh Bandewar <mahesh@bandewar.net>
Date: Fri, 13 Jan 2017 15:48:30 -0800

> From: Mahesh Bandewar <maheshb@google.com>
> 
> In the last patch da36e13cf65 ("ipvlan: improvise dev_id generation
> logic in IPvlan") I missed some part of Dave's suggestion and because
> of that the dev_id creation could fail in a corner case scenario. This
> would happen when more or less 64k devices have been already created and
> several have been deleted. If the devices that are still sticking around
> are the last n bits from the bitmap. So in this scenario even if lower
> bits are available, the dev_id search is so narrow that it always fails.
> 
> Fixes: da36e13cf65 ("ipvlan: improvise dev_id generation logic in IPvlan")
> CC: David Miller <davem@davemloft.org>
> CC: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>

Applied, thanks.

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

end of thread, other threads:[~2017-01-16 19:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-13 23:48 [PATCH next] ipvlan: fix dev_id creation corner case Mahesh Bandewar
2017-01-16 19:05 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).