]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ipvlan: fix dev_id creation corner case.
authorMahesh Bandewar <maheshb@google.com>
Fri, 13 Jan 2017 23:48:30 +0000 (15:48 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Jan 2017 19:04:43 +0000 (14:04 -0500)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ipvlan/ipvlan_main.c

index 92b221a033503d982a48a4112c01b0dbbfcb3287..b5c390f0f2b353a159ba4d132613b7bb38ec3692 100644 (file)
@@ -549,6 +549,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;