diff mbox

[iproute2,v2] iplink: do not require assigning negative ifindex at link creation

Message ID 87tx3o5ojd.wl%atzm@stratosphere.co.jp
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Atzm Watanabe Oct. 1, 2014, 5:47 a.m. UTC
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>
---
 ip/iplink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Cong Wang Oct. 2, 2014, 4:16 a.m. UTC | #1
On Tue, Sep 30, 2014 at 10:47 PM, Atzm Watanabe <atzm@stratosphere.co.jp> wrote:
> 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>

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ip/iplink.c b/ip/iplink.c
index cb9c870..5dd6060 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -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) {