Received: by 10.223.176.46 with SMTP id f43csp3943187wra; Tue, 23 Jan 2018 01:30:56 -0800 (PST) X-Google-Smtp-Source: AH8x227ky7PqtpewulB4TLbpo3l0HYJGS40SF0nZ8m+2sdBfX5xM436wU4lNLvkaGnJ94Uj5wGiM X-Received: by 10.101.78.207 with SMTP id w15mr8683499pgq.349.1516699856768; Tue, 23 Jan 2018 01:30:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516699856; cv=none; d=google.com; s=arc-20160816; b=jfz59i71lybedzSYTSDkaT8BXxXrekHIK6UbI2uj7lKN67mUcEeFIy4EwxExlo7TIu 0pmxBrq4iiFfwkIY8WVXgh3bT0dccEO2FheCBOlBBZ80//TqGIptBenGXck8Q6dQsr8n 1Nm/MGJc777wlnFP72MsJe2Uv1axtBez2s/5eNhZLoqgsqu7Akl74ZksJLv+VFmizDbb 8y//n8KMuJWzxEqyMd4pcBdL0Qmd+ORzN7CDiVm6rbP3U+zDPsIdb/Z/nrbgSH/6Wyhx YrHKhn1i3Y7XNIAR4AnBiMcVTbHcQu2RL/DzHIMXfIOdtP6c7hVPNoThA0d4K6btnol4 MqHQ== 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=/YZyBlZCrXiL2iQIdJiG3BSR97gTq/LSbYaAj5aF7Z8=; b=GobvmuEwcDQiXzbzI2U0oGOVhwsd3iFM8y2w6zsYKJFmFvzsVDmdXgAeTU0fEMQXcM gcd+eegrbcZRQ0f72z6jP9jOeBSUEQudxA1BVgGgCiHt0aiN3mApZX0TCH6NCw8k3FYh UW9PaJ35H3rUNwYQx2QyxCSxLsP4hk8tPKXJmyAKWvyzTpNT62FicAo/aD1ZQpgh0Cq4 z4kxnTVvVsFuldSRNkb5EE7xzjZO9/AXQwZcjOlDFQZ/g/DoDDNLzfAs9505XwsFFw+k DEKL7OCu5lFJ13ntmPpCo3S3Dnu18Vtxwuuw2a3S/uKGwraG6YA1+agdANptoQ0CnIo6 qIzg== 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 l59-v6si4446780plb.743.2018.01.23.01.30.42; Tue, 23 Jan 2018 01:30:56 -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 S1751249AbeAWJaR (ORCPT + 99 others); Tue, 23 Jan 2018 04:30:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59726 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750946AbeAWJaP (ORCPT ); Tue, 23 Jan 2018 04:30:15 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CA994ACA7; Tue, 23 Jan 2018 09:30:15 +0000 (UTC) Received: from localhost (unknown [10.40.205.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 094BBD1FA; Tue, 23 Jan 2018 09:30:11 +0000 (UTC) Date: Tue, 23 Jan 2018 10:30:09 +0100 From: Jiri Benc To: Christian Brauner Cc: Christian Brauner , davem@davemloft.net, dsahern@gmail.com, fw@strlen.de, daniel@iogearbox.net, lucien.xin@gmail.com, mschiffer@universe-factory.net, jakub.kicinski@netronome.com, vyasevich@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stephen@networkplumber.org Subject: Re: [PATCH net-next 1/1] rtnetlink: request RTM_GETLINK by pid or fd Message-ID: <20180123103009.41c2a043@redhat.com> In-Reply-To: <20180122222540.oqrr3apswopavyta@gmail.com> References: <20180118202124.21616-1-christian.brauner@ubuntu.com> <20180118202124.21616-2-christian.brauner@ubuntu.com> <20180118212914.74878b82@redhat.com> <20180118205552.jm7shzcojbumax2k@gmail.com> <20180122220046.7b65a98a@redhat.com> <20180122212353.7n6lrruqedfhrwux@gmail.com> <20180122230616.0c457f55@redhat.com> <20180122222540.oqrr3apswopavyta@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.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 23 Jan 2018 09:30:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Jan 2018 23:25:41 +0100, Christian Brauner wrote: > This is not necessarily true in scenarios where I move a network device > via RTM_NEWLINK + IFLA_NET_NS_PID into a network namespace I haven't > created. Here is an example: > > nlmsghdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; > nlmsghdr->nlmsg_type = RTM_NEWLINK; > /* move to network namespace of pid */ > nla_put_u32(nlmsg, IFLA_NET_NS_PID, pid) > /* give interface new name */ > nla_put_string(nlmsg, IFLA_IFNAME, ifname) > > The only thing I have is the pid that identifies the network namespace. How do you know the interface did not get renamed in the new netns? This is racy and won't work reliably. You really need to know the netnsid before moving the interface to the netns to be able to do meaningful queries. You may argue that for your case, you're fine with the race. But I know about use cases where it matters a lot: those are tools that show network topology including changes in real time, such as Skydive. It's important to have the uAPI designed right. And we don't want two different APIs for the same thing. If you want to do any watching over the interfaces (as opposed to "move to the netns and forget"), you really have to work with netnsids. Let's focus on how to do that more easily. We don't return netnsid at all places where we should return it and we need to fix that. > There's no non-syscall way to learn the netnsid. And that is the primary problem. Jiri