From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH iproute2] ip netns: allow negative nsid Date: Tue, 6 Feb 2018 09:12:47 -0800 Message-ID: <20180206091247.6fe32f37@xeon-e3> References: <20180206151615.4912-1-christian.brauner@ubuntu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Christian Brauner Return-path: Received: from mail-pf0-f182.google.com ([209.85.192.182]:40749 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171AbeBFRMu (ORCPT ); Tue, 6 Feb 2018 12:12:50 -0500 Received: by mail-pf0-f182.google.com with SMTP id a14so885128pfi.7 for ; Tue, 06 Feb 2018 09:12:50 -0800 (PST) In-Reply-To: <20180206151615.4912-1-christian.brauner@ubuntu.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 6 Feb 2018 16:16:15 +0100 Christian Brauner wrote: > If the kernel receives a negative nsid it will automatically assign the > next available nsid. In this case alloc_netid() will set min and max to > 0 for ird_alloc(). And when max == 0 idr_alloc() will interpret this as > the maxium range, i.e. specific to nsids it will try to find an id in > the range [0,INT_MAX). This is intentionally supported in the kernel for > nsids. Commit acbe9118ce8086f765ffb0da15f80c7c01a8903a regressed ip > netns in that respect although previously the use-case was either > accidentally supported or opaquely supported such that it triggered the > original commit. From what I can gather it went as follows before: > atoi() was called with a string indicating a negative value which caused > it to return -1 which was passed to the kernel. Let's make it less > opaque and use get_integer() and set to -1 when a negative nsid was > requested. This restores the old behavior. > > Signed-off-by: Christian Brauner Rather than negative value, it would be better from user interface point of view to use a user readable value like "auto" which encapsulates the kernel behavior.