iplink: do not require assigning negative ifindex at link creation

Since commit 3c682146ae, 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>
This commit is contained in:
Atzm Watanabe 2014-10-01 14:47:50 +09:00 committed by Stephen Hemminger
parent ae0d90737c
commit 68ac9ab339
1 changed files with 4 additions and 1 deletions

View 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) {