Received: by 10.223.176.46 with SMTP id f43csp3991928wra; Tue, 23 Jan 2018 02:28:19 -0800 (PST) X-Google-Smtp-Source: AH8x227Ssik3Y+yKOGZCDwOUlZjHLP30zJjbkCTed0tE7PAMekvdJLwKxg7uLj1PX0ZWxS++aDP0 X-Received: by 2002:a17:902:183:: with SMTP id b3-v6mr4728955plb.337.1516703298950; Tue, 23 Jan 2018 02:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516703298; cv=none; d=google.com; s=arc-20160816; b=llJlYHBXeG6wLKmmVL2N6+b1oTEhOfmopSpqHBvB2VoGlAVTgiz2YVabGpmDSYex1W kwLr4+a0jspEyAyBbSeSpGac5PcSPo0R8spphx7GcMUf0QMU9BZxMsT7KS2KrUVwScyN Uyp1FPgEe66k3Sx8GTNM2bitTmuNQEbJxFT4lKQoE4gJlqN31wqlfraKbs+Hj3iG/KeU 4yl0jdzTK8KFgXRvaRtp2kWiyRGihe8025np34ExyoRhTCBeSl7N/+3Rd7lbSYw+vRAm d+gf0QVX+g7vXD3IpxG2UQ6QNxPJvUfAWAD8s0BVrd+bvl7jTeHB3sxR2ytj4Tulzqar NEoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=MBEZJDAFsdtJ7DZBmFg3pneiuqRvbxCbDXW67JDxcwM=; b=UzNkDyM23CWAbFr+nQsUC74ejqXFbYsl8TbeW5Y4qL0h2COLsUPaDVCaQQwSh/X+94 sXxv+dqYtkoBD9JYjFODgQcXxbVAZ32+Bkzt22iGjtiHs7hDc7r4ugI4dXI6hmW75Hu6 7JlIDFeO2Ku0gtb3IYw1TYFTwUtflo/Jvn64Y5sbrDrEzHw7Vc5pV77zGriTg1M5q0QN +xsoAOcwgM/UzPcIWu/yGUy3EEKa2QkHhEw/v9zeVdxfy1pka5s0kZWYSHtRHOSTt+/s OJtVelWULUiGct2r4y9TaHWyPpSM3xlfPtJZ5zOCulLjgfYDVZek0lWbkHVJ17fRAB6x xvnw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g59-v6si2339424plb.469.2018.01.23.02.28.05; Tue, 23 Jan 2018 02:28:18 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbeAWK1D (ORCPT + 99 others); Tue, 23 Jan 2018 05:27:03 -0500 Received: from proxmox-new.maurer-it.com ([212.186.127.180]:42528 "EHLO proxmox-new.maurer-it.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbeAWK1B (ORCPT ); Tue, 23 Jan 2018 05:27:01 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A9A9442798; Tue, 23 Jan 2018 11:26:59 +0100 (CET) Date: Tue, 23 Jan 2018 11:26:58 +0100 From: Wolfgang Bumiller To: Jiri Benc Cc: Christian Brauner , 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: <20180123102658.wll4xb7ewjjy5x55@olga.proxmox.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> <20180123103009.41c2a043@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180123103009.41c2a043@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 23, 2018 at 10:30:09AM +0100, Jiri Benc wrote: > 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. Even if you know the netnsid, do the mentioned watches work for nested/child namespaces if eg. a container creates new namespace before and/or after the watch was established and moves interfaces to these child namespaces, would you just see them disappear, or can you keep track of them later on as well? Even if that works, from what the documentation tells me netlink is an unreliable protocol, so if my watcher's socket buffer is full, wouldn't I be losing important tracking information? I think one possible solution to tracking interfaces would be to have a unique identifier that never changes (even if it's just a simple uint64_t incremented whenever an interface is created). But since they're not local to the current namespace that may require a lot of extra permission checks (but I'm just speculating here...). In any case, IFLA_NET_NS_FD/PID are already there and I had been wondering previously why they couldn't be used with RTM_GETLINK, it would just make sense.