Received: by 10.223.176.5 with SMTP id f5csp680614wra; Wed, 7 Feb 2018 05:54:29 -0800 (PST) X-Google-Smtp-Source: AH8x224hKRXmgi0O4HfkxrRv20HoR83NfcUBanAEf4R3awQ1UMH6bxBObpWTDoRhvcv2rdccXFJE X-Received: by 10.98.6.130 with SMTP id 124mr6132714pfg.117.1518011669308; Wed, 07 Feb 2018 05:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518011669; cv=none; d=google.com; s=arc-20160816; b=pO19SqimNcpSg8DOdVfbr6OVQw0eIE0CXgfuNm8f2oFaf6WTUa/d1/5Hw5WuuNTFRh 72vmQ2CIBMG3usPvCvJ79jzEC9G7g+XLSRsPWglCVRe0MVUWpB7fqJTKo3W+2WCG3e+y TsBoghcxy7a2G/9SaunAKgfyM0bOb6b9/00w8pggM9XbPbzZnNIQTX1go2Rib6dCpk3I SlAdrVUhWMb1gjqkLWQaPmACzkMAqNgcpop2VgWayr5ohakhZ+D5ldxmMgxEWK/NIZ9p pq1gR7C/jpZPG4GuuMapqoa9mFY3doY/u9DMyS6PtJHktpB0eQkuejpnGafx4q7ltvag +AnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=k8ObnK7yfKbsz3tnyu8QYhKVf4MqceF+A34PiDOSv28=; b=KVtpjHgIAo19Z+KsFb5WOc4D+pwWGnx5F3Ctau21Rd2GiMCundg5bjSl1jbOyLSXVF 2Z3MzVJl3J1Kx7D4AE6+vUHkTHnTi6T08uWQgs7Idljf1UcsTHDk7BWm4SnPe7bmgxXU SefwxEOaJIfsoMRuHZZQuTMgwjxDwnt/1DBcI7RQ6+aByoT2WipZ+zVSDu9bLXzS5Fkk rhXg10CMnVUHQUq0q87h16jlIhWxiT93QXTMb4XiAasS2JGqXQWUxmu2CO6Ltlbm6/Gx H/S8OmvtESHnz5MieHTkg0YslB+IYmxsKot1MO05Y3BnpWTImqp0lQo2Daj9o+RNpOWd HAig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c190si951028pga.810.2018.02.07.05.54.15; Wed, 07 Feb 2018 05:54:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932079AbeBGNxc (ORCPT + 99 others); Wed, 7 Feb 2018 08:53:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39038 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753731AbeBGNxb (ORCPT ); Wed, 7 Feb 2018 08:53:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A05D77D67B; Wed, 7 Feb 2018 13:53:30 +0000 (UTC) Received: from localhost (unknown [10.40.205.88]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CAB8AE7C6; Wed, 7 Feb 2018 13:53:28 +0000 (UTC) Date: Wed, 7 Feb 2018 14:53:26 +0100 From: Jiri Benc To: Christian Brauner Cc: Kirill Tkhai , Christian Brauner , netdev@vger.kernel.org, stephen@networkplumber.org, w.bumiller@proxmox.com, ebiederm@xmission.com, nicolas.dichtel@6wind.com, linux-kernel@vger.kernel.org, dsahern@gmail.com, davem@davemloft.net Subject: Re: [PATCH net 1/1 v4] rtnetlink: require unique netns identifier Message-ID: <20180207145326.7e4adf24@redhat.com> In-Reply-To: <20180207133620.GA3589@gmail.com> References: <20180207125320.9103-1-christian.brauner@ubuntu.com> <20180207125320.9103-2-christian.brauner@ubuntu.com> <942f99e9-086d-25dc-e008-8de2c5c721b1@virtuozzo.com> <20180207133620.GA3589@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Feb 2018 13:53:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Feb 2018 13:53:30 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jbenc@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 Feb 2018 14:36:21 +0100, Christian Brauner wrote: > On Wed, Feb 07, 2018 at 04:20:01PM +0300, Kirill Tkhai wrote: > > Can't we write these 3 above branches more compact? Something like this: > > > > if (!!tb[IFLA_NET_NS_FD] + !!tb[IFLA_IF_NETNSID] + !!tb[IFLA_NET_NS_PID] <= 1) > > return 0; > > I always prefer for conditions to be separate and readable even if it > means additional code. But if others feel that there's value in avoiding > two additional conditions I'm happy to adapt the patch. FWIW, I don't like the n x n conditions much. But Kirill's proposal seems not to be much better. I was thinking about: int cnt = 0; if (tb[IFLA_NET_NS_FD]) cnt++; if (tb[IFLA_NET_NS_PID]) cnt++; if (tb[IFLA_NET_NETNSID]) cnt++; if (cnt > 1) { ...errorr... } but that's not better, either. As we're unlikely to add a fourth value, I guess I'm okay with the current approach in the patch. > Before I added support for netns ids for additional requests Jiri made > it so that all request that specified properties that they did not > support returned ENOTSUPP instead of EINVAL. This just keeps things > consistent. Users would now suddenly receive EINVAL. That's potentially > confusing. Yes, please, keep -EOPNOTSUPP. > As for the case of passing multiple netns identifying properties into > the same request EINVAL seems the perfect candidate and the error > message seems instructive to userspace programs. Agreed. Acked-by: Jiri Benc Thanks, Jiri