Subject: Identifying a network namespace

From: Jean Delvare <[email-masked]>
Date: Fri, 14 Dec 2018 12:19:10 +0100

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