Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp187301pxf; Wed, 10 Mar 2021 04:03:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfEWh1d9zlIsipYgaF6b1pRZ4e+iYwwEobiAgoUO1iUf8+QhR0FV9qLLtnzgEZNlIV8Cz5 X-Received: by 2002:aa7:da14:: with SMTP id r20mr2776610eds.181.1615377818282; Wed, 10 Mar 2021 04:03:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615377818; cv=none; d=google.com; s=arc-20160816; b=P+JB+c4wXc8mG/89rWHRoX7acdoi2hhlY2iGyxLH64v4ywis7AlFjhZOEfxRl4voFh c/VIGU+lkuIQwLfFCkgvCWHv9itWhfPXtRyEpdhPbw+X+V2OCLo4LnWpgHLd7j2n9mAU U8oUMc8l0bV6gCV7ro3ByTnPESU0ZKBKyzMSnD9R0YiSlY/ZisAenbWaROVFNiep9v+a Sc8VbXyPfl8rQl3SXw5bK1I5s/7QDVR8LhyWBZ5Uyw14VTCdPEjja0dXvKUJwnlmjgLl Gk794aV3kwdzvsuXHenR0/QU4W7TMCB1Q1GMb2GTF/GdloDcf/1dS6VtgDz4zAJp1bpL tVlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=krqkSuTjxGwBdDqmZNF7sBLBd11MIC7kHB8NzOQXtHE=; b=NU92JRlcMOVVhUEufftU9SpySGd6yh7nXIYoPD4C/J1W4ODaYz7IcDdcSzRHjC/cte jz1YzNllYSy/u6Fva7wp4bdTzipZDFFl6h3OvQzNW/GP+SDDNb2/N2Cfn9VEND5lP10A Ja3A0N6eRwuQ0ovzfUQ9eBkwtuWpV80wFiI1cry9IZlKGR6zn+zlHfVJTtdBgyJgQO2f 4SRe+QeY4MzgSBEdHs7AoYvvrq2fN0H1JaCTLGOf9UizK71ltDQfrPXdMrGsCqJjEWSi t8oMjieCrPYlYdjaKZyoYBOB8o27uSD0o4+EFEIdLMIpLX9HXLTgYeNm6wE9JJ/EHOjE eEkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kf1si12202965ejc.262.2021.03.10.04.03.06; Wed, 10 Mar 2021 04:03:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbhCJMBh (ORCPT + 99 others); Wed, 10 Mar 2021 07:01:37 -0500 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:38566 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231867AbhCJMBT (ORCPT ); Wed, 10 Mar 2021 07:01:19 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R451e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=tonylu@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0URJJq9b_1615377675; Received: from localhost(mailfrom:tonylu@linux.alibaba.com fp:SMTPD_---0URJJq9b_1615377675) by smtp.aliyun-inc.com(127.0.0.1); Wed, 10 Mar 2021 20:01:15 +0800 Date: Wed, 10 Mar 2021 20:01:15 +0800 From: Tony Lu To: Lorenz Bauer Cc: Eric Dumazet , "David S . Miller" , rostedt@goodmis.org, mingo@redhat.com, Networking , LKML Subject: Re: [PATCH] net: add net namespace inode for all net_dev events Message-ID: Reply-To: Tony Lu References: <20210309044349.6605-1-tonylu@linux.alibaba.com> <203c49a3-6dd8-105e-e12a-0e15da0d4df7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 09:22:34AM +0000, Lorenz Bauer wrote: > On Tue, 9 Mar 2021 at 20:12, Eric Dumazet wrote: > > > > On 3/9/21 5:43 AM, Tony Lu wrote: > > > There are lots of net namespaces on the host runs containers like k8s. > > > It is very common to see the same interface names among different net > > > namespaces, such as eth0. It is not possible to distinguish them without > > > net namespace inode. > > > > > > This adds net namespace inode for all net_dev events, help us > > > distinguish between different net devices. > > > > > > Output: > > > -0 [006] ..s. 133.306989: net_dev_xmit: net_inum=4026531992 dev=eth0 skbaddr=0000000011a87c68 len=54 rc=0 > > > > > > Signed-off-by: Tony Lu > > > --- > > > > > > > There was a proposal from Lorenz to use netns cookies (SO_NETNS_COOKIE) instead. > > > > They have a guarantee of being not reused. > > > > After 3d368ab87cf6681f9 ("net: initialize net->net_cookie at netns setup") > > net->net_cookie is directly available. > > The patch set is at > https://lore.kernel.org/bpf/20210219154330.93615-1-lmb@cloudflare.com/ > but I decided to abandon it. I can work around my issue by comparing > the netns inode of two processes, which is "good enough" for now. Without the patch set, it is impossible to get net_cookie from userspace, except bpf prog. AFAIK, netns inode has been widely used to distinguish different netns, it is easy to use for docker (/proc/${container_pid}/ns/net). It would be better to provide a unified approach to do so. Cheers, Tony Lu > > -- > Lorenz Bauer | Systems Engineer > 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK > > www.cloudflare.com