]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink: do not require assigning negative ifindex at link creation
authorAtzm Watanabe <atzm@stratosphere.co.jp>
Wed, 1 Oct 2014 05:47:50 +0000 (14:47 +0900)
committerStephen Hemminger <shemming@brocade.com>
Thu, 9 Oct 2014 15:24:01 +0000 (08:24 -0700)
Since commit 3c682146aeff, iplink requires assigning negative
ifindex (-1) to the kernel when creating interface without
specifying index.

v2: checking whether index is -1, suggested by Cong Wang.

Cc: Cong Wang <cwang@twopensource.com>
Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
Acked-by: Cong Wang <cwang@twopensource.com>
ip/iplink.c

index cb9c87079a2d94aee20327c7f82f50b613caefe4..5dd606062d9c2673288804a668b5dec5685dba90 100644 (file)
@@ -689,7 +689,10 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
                        addattr_l(&req.n, sizeof(req), IFLA_LINK, &ifindex, 4);
                }
 
-               req.i.ifi_index = index;
+               if (index == -1)
+                       req.i.ifi_index = 0;
+               else
+                       req.i.ifi_index = index;
        }
 
        if (name) {