From mboxrd@z Thu Jan 1 00:00:00 1970 From: Atzm Watanabe Subject: [PATCH iproute2 v2] iplink: do not require assigning negative ifindex at link creation Date: Wed, 01 Oct 2014 14:47:50 +0900 Message-ID: <87tx3o5ojd.wl%atzm@stratosphere.co.jp> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: Cong Wang , Stephen Hemminger To: netdev@vger.kernel.org Return-path: Received: from mail-pd0-f169.google.com ([209.85.192.169]:37391 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbaJAFrw (ORCPT ); Wed, 1 Oct 2014 01:47:52 -0400 Received: by mail-pd0-f169.google.com with SMTP id w10so151286pde.0 for ; Tue, 30 Sep 2014 22:47:52 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: 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 Signed-off-by: Atzm Watanabe --- ip/iplink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) { -- 1.8.1.5