From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Tom Gundersen <teg@jklm.no>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>,
David Herrmann <dh.herrmann@gmail.com>,
Kay Sievers <kay@vrfy.org>
Subject: Re: [PATCH v7 01/33] net: add name_assign_type netdev attribute
Date: Thu, 10 Jul 2014 17:53:29 +0200 [thread overview]
Message-ID: <53BEB6F9.7030004@6wind.com> (raw)
In-Reply-To: <1404980258-30853-2-git-send-email-teg@jklm.no>
Le 10/07/2014 10:17, Tom Gundersen a écrit :
> Based on a patch by David Herrmann.
>
> The name_assign_type attribute gives hints where the interface name of a
> given net-device comes from. These values are currently defined:
> NET_NAME_ENUM:
> The ifname is provided by the kernel with an enumerated
> suffix, typically based on order of discovery. Names may
> be reused and unpredictable.
> NET_NAME_PREDICTABLE:
> The ifname has been assigned by the kernel in a predictable way
> that is guaranteed to avoid reuse and always be the same for a
> given device. Examples include statically created devices like
> the loopback device and names deduced from hardware properties
> (including being given explicitly by the firmware). Names
> depending on the order of discovery, or in any other way on the
> existence of other devices, must not be marked as PREDICTABLE.
> NET_NAME_USER:
> The ifname was provided by user-space during net-device setup.
> NET_NAME_RENAMED:
> The net-device has been renamed from userspace. Once this type is set,
> it cannot change again.
> NET_NAME_UNKNOWN:
> This is an internal placeholder to indicate that we yet haven't yet
> categorized the name. It will not be exposed to userspace, rather
> -EINVAL is returned.
>
> The aim of these patches is to improve user-space renaming of interfaces. As
> a general rule, userspace must rename interfaces to guarantee that names stay
> the same every time a given piece of hardware appears (at boot, or when
> attaching it). However, there are several situations where userspace should
> not perform the renaming, and that depends on both the policy of the local
> admin, but crucially also on the nature of the current interface name.
>
> If an interface was created in repsonse to a userspace request, and userspace
> already provided a name, we most probably want to leave that name alone. The
> main instance of this is wifi-P2P devices created over nl80211, which currently
> have a long-standing bug where they are getting renamed by udev. We label such
> names NET_NAME_USER.
>
> If an interface, unbeknown to us, has already been renamed from userspace, we
> most probably want to leave also that alone. This will typically happen when
> third-party plugins (for instance to udev, but the interface is generic so could
> be from anywhere) renames the interface without informing udev about it. A
> typical situation is when you switch root from an installer or an initrd to the
> real system and the new instance of udev does not know what happened before
> the switch. These types of problems have caused repeated issues in the past. To
> solve this, once an interface has been renamed, its name is labelled
> NET_NAME_RENAMED.
>
> In many cases, the kernel is actually able to name interfaces in such a
> way that there is no need for userspace to rename them. This is the case when
> the enumeration order of devices, or in fact any other (non-parent) device on
> the system, can not influence the name of the interface. Examples include
> statically created devices, or any naming schemes based on hardware properties
> of the interface. In this case the admin may prefer to use the kernel-provided
> names, and to make that possible we label such names NET_NAME_PREDICTABLE.
> We want the kernel to have tho possibilty of performing predictable interface
> naming itself (and exposing to userspace that it has), as the information
> necessary for a proper naming scheme for a certain class of devices may not
> be exposed to userspace.
>
> The case where renaming is almost certainly desired, is when the kernel has
> given the interface a name using global device enumeration based on order of
> discovery (ethX, wlanY, etc). These naming schemes are labelled NET_NAME_ENUM.
>
> Lastly, a fallback is left as NET_NAME_UNKNOWN, to indicate that a driver has
> not yet been ported. This is mostly useful as a transitionary measure, allowing
> us to label the various naming schemes bit by bit.
>
> Signed-off-by: Tom Gundersen <teg@jklm.no>
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
> Reviewed-by: Kay Sievers <kay@vrfy.org>
> ---
> Documentation/ABI/testing/sysfs-class-net | 11 +++++++++++
> include/linux/netdevice.h | 2 ++
> include/uapi/linux/netdevice.h | 6 ++++++
> net/core/net-sysfs.c | 20 ++++++++++++++++++++
> 4 files changed, 39 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-class-net b/Documentation/ABI/testing/sysfs-class-net
> index 416c5d5..d34280a 100644
> --- a/Documentation/ABI/testing/sysfs-class-net
> +++ b/Documentation/ABI/testing/sysfs-class-net
> @@ -1,3 +1,14 @@
> +What: /sys/class/net/<iface>/name_assign_type
> +Date: July 2014
> +KernelVersion: 3.2
> +Contact: netdev@vger.kernel.org
> +Description:
> + Indicates the name assignment type. Possible values are:
> + 1: enumerated by the kernel, possibly in an unpredictable way
> + 2: predictably named by the kernel
> + 3: named by userspace
> + 4: renamed
> +
> What: /sys/class/net/<iface>/addr_assign_type
> Date: July 2010
> KernelVersion: 3.2
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 66f9a04..551e187 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1379,6 +1379,8 @@ struct net_device {
> struct kset *queues_kset;
> #endif
>
> + unsigned char name_assign_type;
> +
> bool uc_promisc;
> unsigned int promiscuity;
> unsigned int allmulti;
> diff --git a/include/uapi/linux/netdevice.h b/include/uapi/linux/netdevice.h
> index fdfbd1c..82e630a 100644
> --- a/include/uapi/linux/netdevice.h
> +++ b/include/uapi/linux/netdevice.h
> @@ -37,6 +37,12 @@
> #define INIT_NETDEV_GROUP 0
>
>
> +/* interface name assignment types (sysfs name_assign_type attribute) */
> +#define NET_NAME_UNKNOWN 0 /* unknown origin (not exposed to userspace) */
> +#define NET_NAME_ENUM 1 /* enumerated by kernel */
> +#define NET_NAME_PREDICTABLE 2 /* predictably named by the kernel */
Nitpicking: there is spaces instead tabs between '2' and the comment.
next prev parent reply other threads:[~2014-07-10 15:53 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-10 8:17 [PATCH v7 00/33] Provide netdev naming-policy via sysfs Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 01/33] net: add name_assign_type netdev attribute Tom Gundersen
2014-07-10 15:53 ` Nicolas Dichtel [this message]
2014-07-10 20:00 ` Tom Gundersen
2014-07-10 19:58 ` Arend van Spriel
2014-07-10 20:01 ` Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 02/33] net: set name assign type for renamed devices Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 03/33] net: set name_assign_type in alloc_netdev() Tom Gundersen
2014-07-10 9:16 ` Bjørn Mork
2014-07-10 10:21 ` Tom Gundersen
2014-07-10 11:29 ` Bjørn Mork
2014-07-10 13:02 ` Tom Gundersen
2014-07-10 13:27 ` Bjørn Mork
2014-07-10 8:17 ` [PATCH v7 04/33] net: set name assign type for names assigned using a static template Tom Gundersen
2014-07-10 8:52 ` Marc Kleine-Budde
2014-07-10 8:17 ` [PATCH v7 05/33] net: set name assign type for names assigned using a static string Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 06/33] net: set name assign type for names passed directly from userspace Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 07/33] net: rtnetlink - make create_link take name_assign_type Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 08/33] net: nl80211 - make rdev_add_virtual_intf " Tom Gundersen
2014-07-21 9:40 ` Johannes Berg
2014-07-21 17:03 ` Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 09/33] net: nl802154 - make add_iface take name assign type Tom Gundersen
2014-07-10 10:52 ` Alexander Aring
2014-07-10 8:17 ` [PATCH v7 10/33] net: dummy - set " Tom Gundersen
2014-07-10 9:31 ` Bjørn Mork
2014-07-10 10:12 ` Tom Gundersen
2014-07-10 10:26 ` David Herrmann
2014-07-10 10:33 ` Tom Gundersen
2014-07-10 11:44 ` Bjørn Mork
2014-07-10 12:18 ` Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 11/33] net: af_netrom " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 12/33] net: af_rose " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 13/33] net: mrt " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 14/33] net: caif_serial " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 15/33] net: xen-netback " Tom Gundersen
2014-07-10 8:25 ` Varka Bhadram
2014-07-10 9:01 ` Ian Campbell
2014-07-10 10:46 ` Tom Gundersen
2014-07-10 12:13 ` Ian Campbell
2014-07-10 8:17 ` [PATCH v7 16/33] net: gdm_lte " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 17/33] net: airo " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 18/33] net: arcdev - label alloc_arcdev names Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 19/33] net: isdn - set name assign type Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 20/33] net: irlan " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 21/33] net: batman-adv " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 22/33] net: hamradio " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 23/33] net: openvswitch " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 24/33] net: vlan " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 25/33] net: infiniband - steal ifname label Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 26/33] net: ipoib - set name assign type Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 27/33] net: tile " Tom Gundersen
2014-07-16 17:49 ` Chris Metcalf
2014-07-10 8:17 ` [PATCH v7 28/33] net: dsa " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 29/33] net: brcmfmac " Tom Gundersen
2014-07-10 20:08 ` Arend van Spriel
2014-07-10 20:24 ` Tom Gundersen
2014-07-11 7:45 ` Arend van Spriel
2014-07-15 19:39 ` John W. Linville
2014-07-15 19:57 ` Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 30/33] net: ppp " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 31/33] net: slcan " Tom Gundersen
2014-07-10 8:51 ` Marc Kleine-Budde
2014-07-10 8:17 ` [PATCH v7 32/33] net: x25_asy " Tom Gundersen
2014-07-10 8:17 ` [PATCH v7 33/33] net: slip " Tom Gundersen
2014-07-10 8:43 ` [PATCH v7 00/33] Provide netdev naming-policy via sysfs David Miller
2014-07-10 9:19 ` Tom Gundersen
2014-07-10 19:11 ` Tom Gundersen
2014-07-10 19:19 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53BEB6F9.7030004@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=davem@davemloft.net \
--cc=dh.herrmann@gmail.com \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=teg@jklm.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox