From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F05DCC433E6 for ; Wed, 10 Mar 2021 12:02:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3BBA64FF6 for ; Wed, 10 Mar 2021 12:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbhCJMBh (ORCPT ); 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