From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Delvare Subject: Identifying a network namespace Date: Fri, 14 Dec 2018 12:19:10 +0100 Message-ID: <20181214121910.5ec0fac9@endymion> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: netdev@vger.kernel.org Return-path: Received: from mx2.suse.de ([195.135.220.15]:33676 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726344AbeLNLTM (ORCPT ); Fri, 14 Dec 2018 06:19:12 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 57659AE3C for ; Fri, 14 Dec 2018 11:19:11 +0000 (UTC) Sender: netdev-owner@vger.kernel.org List-ID: Hi all, The question: is there any way to uniquely identify a network namespace in the kernel? The context: for debugging purposes, I need to log information about network devices. netdev_info() uses the device name to identify the device, however there can be several devices by that name in different namespaces. To know which device the message relates to, I would need to know the namespace in addition to the device name. For all I know, the namespace's name is a user-space thing and the kernel has no idea. But I would at least need some kind of unique identifier to group log message by device. So far I'm using the struct address returned by dev_net() as the unique ID, but leaking kernel addresses to userspace is not recommended. So I am wondering, is there another recommended way to uniquely identify a network namespace in a log message? Thanks, -- Jean Delvare SUSE L3 Support