From patchwork Fri Oct 3 15:55:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 396287 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 202FB140078 for ; Sat, 4 Oct 2014 01:55:52 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbaJCPzs (ORCPT ); Fri, 3 Oct 2014 11:55:48 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:60962 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754078AbaJCPzq (ORCPT ); Fri, 3 Oct 2014 11:55:46 -0400 Received: by mail-pd0-f178.google.com with SMTP id y10so2775381pdj.9 for ; Fri, 03 Oct 2014 08:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=SQ7xSdHsyE3KaGqhZr3Zv/vwBjxhqLk4KGpdxeBdvpY=; b=iSY9rMG3Jk27/AlHVrDGtBEJAJgk5tplR6h6Wg9Lu30+vWB2So2dpboUxThVvCtiEW DDim1AvRqXUh9Jj47GTSrm5E0de+RYX0CQdh8Xh6Vsnw3tkKeJh7VGXq7VT++RvIS9Ic vzYHf2MgiS/3E+i8y0/oDqezP+R77K/XXzuGEUhbZGMaSqHwpwLz9UkeB5xjKOq4ES8C 2h62z4ZbRP4VfP3SWKFflGZc6bIg5mstby4hySwPixOH8johXp8hy0KZq6BypHVsGonY jOrBY9eOHq+T//yArIYUPulOMygbrWrVsyX+ksZdrItLfVabdK34Os7sEI8J9mOIf7Z4 fNFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SQ7xSdHsyE3KaGqhZr3Zv/vwBjxhqLk4KGpdxeBdvpY=; b=TRNbWjj7TzPssPt7a/T0ePpPQaKKH+IdGfrdfgO1/btjcyxJZQJwGgvGJNx5KqbcvK sYtnK4kIz9+oia6QLGahdTcXqOYrWI64c5KDCdms9l03MLm8zwJaJNllG825ccml1UgJ XfdubJsAfMoEjmuGJrF0cy2OqpQen2ojeqg3dX/6nOwiBcfviSwHTJLG7ffuHkr+Bb2j btQnCGDpJVTe3HRxJAdRql4zUW5sIJ99RHRefoLBxZ7qHEaIYgvD44NVHNXOqCyPu3mr ePlP6KsXqF7vpOg94BIlZnzU/BhKL+9aNjLHlI8SltA6s/q2AOC3kKWyEZvoU26yHVxC rP8Q== X-Gm-Message-State: ALoCoQmY9DdbeSqQp4BJHVnSPW/JFCjkVM423lpm3L2DdPp92OFpODuCSj6mwznMcvixxASkbMqW X-Received: by 10.68.139.232 with SMTP id rb8mr8062829pbb.20.1412351745927; Fri, 03 Oct 2014 08:55:45 -0700 (PDT) Received: from tomh.mtv.corp.google.com (tomh.mtv.corp.google.com [172.18.117.126]) by mx.google.com with ESMTPSA id t11sm4441522pdj.89.2014.10.03.08.55.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Oct 2014 08:55:45 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net, stephen@networkplumber.org, netdev@vger.kernel.org Subject: [PATCH iproute2 1/5] iplink: Fix setting of -1 as ifindex Date: Fri, 3 Oct 2014 08:55:14 -0700 Message-Id: <1412351718-22921-2-git-send-email-therbert@google.com> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1412351718-22921-1-git-send-email-therbert@google.com> References: <1412351718-22921-1-git-send-email-therbert@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 3c682146aeff157ec3540 ("iplink: forbid negative ifindex and modifying ifindex") initializes index to -1 in iplink_modify. When creating a link, req.i.ifi_index is then set to -1 if the link option is not used. In the kernel this is then used to set dev->ifindex. For dev->ifindex, zero is considered to be unset and -1 is treated as a set index, so when a second tunnel is create the new device conflicts with the old one (both have ifindex of -1) so -EBUSY is returned. This patch set zero in req.i.ifi_index is index is unset (still -1). Signed-off-by: Tom Herbert --- ip/iplink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip/iplink.c b/ip/iplink.c index cb9c870..1b6ffc6 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -689,7 +689,7 @@ 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; + req.i.ifi_index = (index > 0) ? : 0; } if (name) {