2014-07-10 08:17:59

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 00/33] Provide netdev naming-policy via sysfs

This picks up the patch series where David Herrmann left off, incorporating
the feedback from David Miller.

Overview (see Patch 1 for more details):

Patch 1: Introduce the enums, documentation and userspace API
Patch 2: Hook up with device renaming
Patch 3: change the alloc_netdev*() API to take the name_assign_type

The following patches actually converts to the correct name assign type,
these can be applied in any order, and we could even delay some/all
to a subsequent release if that makes things simpler.

Patch 4-6: convert the trivial cases.
Patch 7-9: convert the netlink interfaces to pass down the assign type
Patch 10-33: convert the remaining drivers one-by-one

Cheers,

Tom

Changes since v6:
- change alloc_netdev to take the name assign type as an argument.
- introduce an internal assign type NET_NAME_UNKNOWN, which makes
it simpler to split up the patches, but may eventually be dropped.
- introduce a new assign type NET_NAME_PREDICTABLE to indicate to
userspace that the kernel-assigned names are well-behaved.

Tom Gundersen (33):
net: add name_assign_type netdev attribute
net: set name assign type for renamed devices
net: set name_assign_type in alloc_netdev()
net: set name assign type for names assigned using a static template
net: set name assign type for names assigned using a static string
net: set name assign type for names passed directly from userspace
net: rtnetlink - make create_link take name_assign_type
net: nl80211 - make rdev_add_virtual_intf take name_assign_type
net: nl802154 - make add_iface take name assign type
net: dummy - set name assign type
net: af_netrom - set name assign type
net: af_rose - set name assign type
net: mrt - set name assign type
net: caif_serial - set name assign type
net: xen-netback - set name assign type
net: gdm_lte - set name assign type
net: airo - set name assign type
net: arcdev - label alloc_arcdev names
net: isdn - set name assign type
net: irlan - set name assign type
net: batman-adv - set name assign type
net: hamradio - set name assign type
net: openvswitch - set name assign type
net: vlan - set name assign type
net: infiniband - steal ifname label
net: ipoib - set name assign type
net: tile - set name assign type
net: dsa - set name assign type
net: brcmfmac - set name assign type
net: ppp - set name assign type
net: slcan - set name assign type
net: x25_asy - set name assign type
net: slip - set name assign type

Documentation/ABI/testing/sysfs-class-net | 11 +++++++++++
drivers/firewire/net.c | 3 ++-
drivers/hsi/clients/ssi_protocol.c | 3 ++-
drivers/infiniband/hw/amso1100/c2_provider.c | 2 +-
drivers/infiniband/ulp/ipoib/ipoib.h | 2 +-
drivers/infiniband/ulp/ipoib/ipoib_main.c | 10 ++++++----
drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 +-
drivers/isdn/i4l/isdn_common.c | 4 ++--
drivers/isdn/i4l/isdn_net.c | 9 +++++----
drivers/isdn/i4l/isdn_net.h | 4 ++--
drivers/media/dvb-core/dvb_net.c | 3 ++-
drivers/misc/sgi-xp/xpnet.c | 3 ++-
drivers/net/arcnet/arc-rimi.c | 2 +-
drivers/net/arcnet/arcnet.c | 9 +++++++--
drivers/net/arcnet/com20020-isa.c | 2 +-
drivers/net/arcnet/com20020-pci.c | 2 +-
drivers/net/arcnet/com20020_cs.c | 2 +-
drivers/net/arcnet/com90io.c | 2 +-
drivers/net/arcnet/com90xx.c | 2 +-
drivers/net/bonding/bond_main.c | 1 +
drivers/net/caif/caif_serial.c | 3 ++-
drivers/net/caif/caif_spi.c | 2 +-
drivers/net/caif/caif_virtio.c | 2 +-
drivers/net/can/dev.c | 2 +-
drivers/net/can/slcan.c | 2 +-
drivers/net/dummy.c | 2 +-
drivers/net/eql.c | 3 ++-
drivers/net/ethernet/8390/lib8390.c | 2 +-
drivers/net/ethernet/tile/tilegx.c | 9 +++++----
drivers/net/ethernet/tile/tilepro.c | 14 ++++++++------
drivers/net/hamradio/6pack.c | 3 ++-
drivers/net/hamradio/baycom_epp.c | 2 +-
drivers/net/hamradio/baycom_par.c | 3 ++-
drivers/net/hamradio/baycom_ser_fdx.c | 3 ++-
drivers/net/hamradio/baycom_ser_hdx.c | 3 ++-
drivers/net/hamradio/bpqether.c | 2 +-
drivers/net/hamradio/dmascc.c | 5 +++--
drivers/net/hamradio/hdlcdrv.c | 3 ++-
drivers/net/hamradio/mkiss.c | 3 ++-
drivers/net/hamradio/scc.c | 11 ++++++-----
drivers/net/hamradio/yam.c | 2 +-
drivers/net/ieee802154/fakehard.c | 3 ++-
drivers/net/ifb.c | 2 +-
drivers/net/loopback.c | 2 +-
drivers/net/ppp/ppp_generic.c | 4 +++-
drivers/net/slip/slip.c | 2 +-
drivers/net/tun.c | 8 ++++++--
drivers/net/usb/cdc-phonet.c | 3 ++-
drivers/net/usb/hso.c | 3 ++-
drivers/net/veth.c | 11 ++++++++---
drivers/net/wan/dlci.c | 4 ++--
drivers/net/wan/hdlc.c | 3 ++-
drivers/net/wan/hdlc_fr.c | 4 ++--
drivers/net/wan/lapbether.c | 2 +-
drivers/net/wan/sbni.c | 7 ++++---
drivers/net/wan/sdla.c | 3 ++-
drivers/net/wan/x25_asy.c | 2 +-
drivers/net/wimax/i2400m/usb.c | 2 +-
drivers/net/wireless/airo.c | 6 ++++--
drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 ++++--
drivers/net/wireless/ath/ath6kl/cfg80211.h | 1 +
drivers/net/wireless/ath/ath6kl/core.c | 4 ++--
drivers/net/wireless/ath/wil6210/netdev.c | 2 +-
drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 3 ++-
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 11 +++++++----
drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 3 ++-
drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 3 +++
drivers/net/wireless/brcm80211/brcmfmac/p2p.h | 1 +
.../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 4 +++-
drivers/net/wireless/libertas/main.c | 2 +-
drivers/net/wireless/libertas/mesh.c | 2 +-
drivers/net/wireless/mac80211_hwsim.c | 2 +-
drivers/net/wireless/mwifiex/cfg80211.c | 6 ++++--
drivers/net/wireless/mwifiex/main.c | 2 +-
drivers/net/wireless/mwifiex/main.h | 1 +
drivers/net/xen-netback/interface.c | 2 +-
drivers/s390/net/claw.c | 2 +-
drivers/s390/net/ctcm_main.c | 6 ++++--
drivers/s390/net/netiucv.c | 2 +-
drivers/s390/net/qeth_l2_main.c | 6 ++++--
drivers/s390/net/qeth_l3_main.c | 3 ++-
drivers/staging/cxt1e1/linux.c | 3 ++-
drivers/staging/gdm724x/gdm_lte.c | 2 +-
drivers/staging/gdm72xx/gdm_wimax.c | 2 +-
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 6 +++++-
drivers/staging/vt6655/wpactl.c | 3 ++-
drivers/staging/wlan-ng/p80211netdev.c | 2 +-
drivers/tty/n_gsm.c | 7 +++++--
drivers/usb/gadget/f_phonet.c | 3 ++-
include/linux/arcdevice.h | 3 ++-
include/linux/hdlcdrv.h | 1 +
include/linux/netdevice.h | 12 ++++++++----
include/net/cfg80211.h | 1 +
include/net/irda/irlan_eth.h | 2 +-
include/net/rtnetlink.h | 1 +
include/net/wpan-phy.h | 4 +++-
include/uapi/linux/netdevice.h | 6 ++++++
net/802/fc.c | 2 +-
net/802/fddi.c | 2 +-
net/802/hippi.c | 2 +-
net/8021q/vlan.c | 8 +++++++-
net/appletalk/dev.c | 2 +-
net/atm/br2684.c | 1 +
net/atm/clip.c | 3 ++-
net/batman-adv/hard-interface.c | 5 +++--
net/batman-adv/hard-interface.h | 3 ++-
net/batman-adv/soft-interface.c | 7 +++++--
net/batman-adv/soft-interface.h | 2 +-
net/batman-adv/sysfs.c | 2 +-
net/bluetooth/6lowpan.c | 3 ++-
net/bluetooth/bnep/core.c | 5 +++--
net/bridge/br_if.c | 5 +++--
net/bridge/br_ioctl.c | 4 ++--
net/bridge/br_private.h | 2 +-
net/core/dev.c | 9 +++++++++
net/core/net-sysfs.c | 20 ++++++++++++++++++++
net/core/rtnetlink.c | 14 +++++++++-----
net/dsa/dsa.c | 3 ++-
net/dsa/dsa_priv.h | 3 ++-
net/dsa/slave.c | 4 ++--
net/ethernet/eth.c | 3 ++-
net/ieee802154/nl-phy.c | 5 ++++-
net/ipv4/ip_tunnel.c | 9 ++++++---
net/ipv4/ipmr.c | 2 +-
net/ipv6/ip6_gre.c | 14 ++++++++++----
net/ipv6/ip6_tunnel.c | 14 ++++++++++----
net/ipv6/ip6_vti.c | 12 ++++++++----
net/ipv6/ip6mr.c | 2 +-
net/ipv6/sit.c | 12 +++++++++---
net/irda/irda_device.c | 3 ++-
net/irda/irlan/irlan_common.c | 2 +-
net/irda/irlan/irlan_eth.c | 5 +++--
net/l2tp/l2tp_eth.c | 9 +++++++--
net/mac80211/cfg.c | 3 ++-
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/iface.c | 7 ++++---
net/mac80211/main.c | 2 +-
net/mac802154/ieee802154_dev.c | 9 ++++++---
net/netrom/af_netrom.c | 2 +-
net/openvswitch/datapath.c | 1 +
net/openvswitch/vport-internal_dev.c | 3 ++-
net/openvswitch/vport.h | 2 ++
net/phonet/pep-gprs.c | 3 ++-
net/rose/af_rose.c | 2 +-
net/sched/sch_teql.c | 3 ++-
net/wireless/nl80211.c | 3 ++-
net/wireless/rdev-ops.h | 5 +++--
147 files changed, 408 insertions(+), 203 deletions(-)

--
1.9.3


2014-07-10 08:18:13

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 01/33] net: add name_assign_type netdev attribute

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 <[email protected]>
Reviewed-by: David Herrmann <[email protected]>
Reviewed-by: Kay Sievers <[email protected]>
---
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: [email protected]
+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 */
+#define NET_NAME_USER 3 /* provided by user-space */
+#define NET_NAME_RENAMED 4 /* renamed by user-space */

/* Media selection options. */
enum {
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 1cac29e..7752f2a 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -112,6 +112,25 @@ NETDEVICE_SHOW_RO(ifindex, fmt_dec);
NETDEVICE_SHOW_RO(type, fmt_dec);
NETDEVICE_SHOW_RO(link_mode, fmt_dec);

+static ssize_t format_name_assign_type(const struct net_device *net, char *buf)
+{
+ return sprintf(buf, fmt_dec, net->name_assign_type);
+}
+
+static ssize_t name_assign_type_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct net_device *net = to_net_dev(dev);
+ ssize_t ret = -EINVAL;
+
+ if (net->name_assign_type != NET_NAME_UNKNOWN)
+ ret = netdev_show(dev, attr, buf, format_name_assign_type);
+
+ return ret;
+}
+static DEVICE_ATTR_RO(name_assign_type);
+
/* use same locking rules as GIFHWADDR ioctl's */
static ssize_t address_show(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -387,6 +406,7 @@ static struct attribute *net_class_attrs[] = {
&dev_attr_dev_port.attr,
&dev_attr_iflink.attr,
&dev_attr_ifindex.attr,
+ &dev_attr_name_assign_type.attr,
&dev_attr_addr_assign_type.attr,
&dev_attr_addr_len.attr,
&dev_attr_link_mode.attr,
--
1.9.3

2014-07-10 08:18:32

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 06/33] net: set name assign type for names passed directly from userspace

Such names should be NET_NAME_USER, in case the emptystring is given we
fallback to an enumerated name.

Signed-off-by: Tom Gundersen <[email protected]>
---
drivers/net/bonding/bond_main.c | 3 ++-
drivers/net/tun.c | 9 ++++++---
drivers/tty/n_gsm.c | 10 +++++++---
net/atm/br2684.c | 5 +++--
net/bluetooth/bnep/core.c | 2 +-
net/bridge/br_if.c | 7 ++++---
net/bridge/br_ioctl.c | 4 ++--
net/bridge/br_private.h | 2 +-
net/ipv4/ip_tunnel.c | 9 ++++++---
net/ipv6/ip6_gre.c | 10 +++++++---
net/ipv6/ip6_tunnel.c | 10 +++++++---
net/ipv6/ip6_vti.c | 10 +++++++---
net/ipv6/sit.c | 10 +++++++---
net/l2tp/l2tp_eth.c | 8 ++++++--
14 files changed, 66 insertions(+), 33 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a2678fe..48e28ca 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4440,7 +4440,8 @@ int bond_create(struct net *net, const char *name)
rtnl_lock();

bond_dev = alloc_netdev_mq(sizeof(struct bonding),
- name ? name : "bond%d", NET_NAME_UNKNOWN,
+ name ? name : "bond%d",
+ name ? NET_NAME_USER : NET_NAME_ENUM,
bond_setup, tx_queues);
if (!bond_dev) {
pr_err("%s: eek! can't alloc netdev!\n", name);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index acaaf67..eac34f5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1607,6 +1607,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
}
else {
char *name;
+ unsigned char name_assign_type = NET_NAME_ENUM;
unsigned long flags = 0;
int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ?
MAX_TAP_QUEUES : 1;
@@ -1629,12 +1630,14 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
} else
return -EINVAL;

- if (*ifr->ifr_name)
+ if (*ifr->ifr_name) {
name = ifr->ifr_name;
+ name_assign_type = NET_NAME_USER;
+ }

dev = alloc_netdev_mqs(sizeof(struct tun_struct), name,
- NET_NAME_UNKNOWN, tun_setup, queues,
- queues);
+ name_assign_type, tun_setup,
+ queues, queues);

if (!dev)
return -ENOMEM;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index cde3ab9..d0262d9 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2767,6 +2767,7 @@ static void gsm_destroy_network(struct gsm_dlci *dlci)
static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
{
char *netname;
+ unsigned char name_assign_type = NET_NAME_ENUM;
int retval = 0;
struct net_device *net;
struct gsm_mux_net *mux_net;
@@ -2787,10 +2788,13 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
pr_debug("create network interface");

netname = "gsm%d";
- if (nc->if_name[0] != '\0')
+ if (nc->if_name[0] != '\0') {
netname = nc->if_name;
- net = alloc_netdev(sizeof(struct gsm_mux_net), netname,
- NET_NAME_UNKNOWN, gsm_mux_net_init);
+ name_assign_type = NET_NAME_USER;
+ }
+ net = alloc_netdev(sizeof(struct gsm_mux_net),
+ netname, name_assign_type,
+ gsm_mux_net_init);
if (!net) {
pr_err("alloc_netdev failed");
return -ENOMEM;
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index cc78538..cb8d122 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -682,8 +682,9 @@ static int br2684_create(void __user *arg)

netdev = alloc_netdev(sizeof(struct br2684_dev),
ni.ifname[0] ? ni.ifname : "nas%d",
- NET_NAME_UNKNOWN,
- (payload == p_routed) ? br2684_setup_routed : br2684_setup);
+ ni.ifname[0] ? NET_NAME_USER : NET_NAME_ENUM,
+ (payload == p_routed) ?
+ br2684_setup_routed : br2684_setup);
if (!netdev)
return -ENOMEM;

diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 85bcc21..6bed7b3 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -539,7 +539,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
/* session struct allocated as private part of net_device */
dev = alloc_netdev(sizeof(struct bnep_session),
(*req->device) ? req->device : "bnep%d",
- NET_NAME_UNKNOWN,
+ (*req->device) ? NET_NAME_USER : NET_NAME_ENUM,
bnep_net_setup);
if (!dev)
return -ENOMEM;
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 078d336..f9c6766 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -339,13 +339,14 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
return p;
}

-int br_add_bridge(struct net *net, const char *name)
+int br_add_bridge(struct net *net, const char *name,
+ unsigned char name_assign_type)
{
struct net_device *dev;
int res;

- dev = alloc_netdev(sizeof(struct net_bridge), name, NET_NAME_UNKNOWN,
- br_dev_setup);
+ dev = alloc_netdev(sizeof(struct net_bridge), name,
+ name_assign_type, br_dev_setup);

if (!dev)
return -ENOMEM;
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index a9a4a1b..bdc79a1 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -340,7 +340,7 @@ static int old_deviceless(struct net *net, void __user *uarg)
buf[IFNAMSIZ-1] = 0;

if (args[0] == BRCTL_ADD_BRIDGE)
- return br_add_bridge(net, buf);
+ return br_add_bridge(net, buf, NET_NAME_USER);

return br_del_bridge(net, buf);
}
@@ -369,7 +369,7 @@ int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *uar

buf[IFNAMSIZ-1] = 0;
if (cmd == SIOCBRADDBR)
- return br_add_bridge(net, buf);
+ return br_add_bridge(net, buf, NET_NAME_USER);

return br_del_bridge(net, buf);
}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 23caf5b..1fc6196 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -415,7 +415,7 @@ void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,

/* br_if.c */
void br_port_carrier_check(struct net_bridge_port *p);
-int br_add_bridge(struct net *net, const char *name);
+int br_add_bridge(struct net *net, const char *name, unsigned char name_assign_type);
int br_del_bridge(struct net *net, const char *name);
int br_add_if(struct net_bridge *br, struct net_device *dev);
int br_del_if(struct net_bridge *br, struct net_device *dev);
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0157a7a..cb6248b 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -288,20 +288,23 @@ static struct net_device *__ip_tunnel_create(struct net *net,
struct ip_tunnel *tunnel;
struct net_device *dev;
char name[IFNAMSIZ];
+ unsigned char name_assign_type;

- if (parms->name[0])
+ if (parms->name[0]) {
strlcpy(name, parms->name, IFNAMSIZ);
- else {
+ name_assign_type = NET_NAME_USER;
+ } else {
if (strlen(ops->kind) > (IFNAMSIZ - 3)) {
err = -E2BIG;
goto failed;
}
strlcpy(name, ops->kind, IFNAMSIZ);
strncat(name, "%d", 2);
+ name_assign_type = NET_NAME_ENUM;
}

ASSERT_RTNL();
- dev = alloc_netdev(ops->priv_size, name, NET_NAME_UNKNOWN, ops->setup);
+ dev = alloc_netdev(ops->priv_size, name, name_assign_type, ops->setup);
if (!dev) {
err = -ENOMEM;
goto failed;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 780e6fe..2a25b68 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -311,18 +311,22 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
struct ip6_tnl *t, *nt;
struct net_device *dev;
char name[IFNAMSIZ];
+ unsigned char name_assign_type;
struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);

t = ip6gre_tunnel_find(net, parms, ARPHRD_IP6GRE);
if (t || !create)
return t;

- if (parms->name[0])
+ if (parms->name[0]) {
strlcpy(name, parms->name, IFNAMSIZ);
- else
+ name_assign_type = NET_NAME_USER;
+ } else {
strcpy(name, "ip6gre%d");
+ name_assign_type = NET_NAME_ENUM;
+ }

- dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(*t), name, name_assign_type,
ip6gre_tunnel_setup);
if (!dev)
return NULL;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index cbba655..10d35c4 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -308,14 +308,18 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
struct net_device *dev;
struct ip6_tnl *t;
char name[IFNAMSIZ];
+ unsigned char name_assign_type;
int err;

- if (p->name[0])
+ if (p->name[0]) {
strlcpy(name, p->name, IFNAMSIZ);
- else
+ name_assign_type = NET_NAME_USER;
+ } else {
sprintf(name, "ip6tnl%%d");
+ name_assign_type = NET_NAME_ENUM;
+ }

- dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof (*t), name, name_assign_type,
ip6_tnl_dev_setup);
if (dev == NULL)
goto failed;
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 67fd4e5..337a32e 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -197,14 +197,18 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p
struct net_device *dev;
struct ip6_tnl *t;
char name[IFNAMSIZ];
+ char name_assign_type;
int err;

- if (p->name[0])
+ if (p->name[0]) {
strlcpy(name, p->name, IFNAMSIZ);
- else
+ name_assign_type = NET_NAME_USER;
+ } else {
sprintf(name, "ip6_vti%%d");
+ name_assign_type = NET_NAME_ENUM;
+ }

- dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup);
+ dev = alloc_netdev(sizeof(*t), name, name_assign_type, vti6_dev_setup);
if (dev == NULL)
goto failed;

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index ff5aff8..5699516 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -228,6 +228,7 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
struct ip_tunnel __rcu **tp;
struct net_device *dev;
char name[IFNAMSIZ];
+ unsigned char name_assign_type;
struct sit_net *sitn = net_generic(net, sit_net_id);

for (tp = __ipip6_bucket(sitn, parms);
@@ -245,12 +246,15 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
if (!create)
goto failed;

- if (parms->name[0])
+ if (parms->name[0]) {
strlcpy(name, parms->name, IFNAMSIZ);
- else
+ name_assign_type = NET_NAME_USER;
+ } else {
strcpy(name, "sit%d");
+ name_assign_type = NET_NAME_ENUM;
+ }

- dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(*t), name, name_assign_type,
ipip6_tunnel_setup);
if (dev == NULL)
return NULL;
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index edb78e6..7416b6b 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -209,6 +209,7 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p
{
struct net_device *dev;
char name[IFNAMSIZ];
+ unsigned char name_assign_type;
struct l2tp_tunnel *tunnel;
struct l2tp_session *session;
struct l2tp_eth *priv;
@@ -236,8 +237,11 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p
goto out;
}
strlcpy(name, cfg->ifname, IFNAMSIZ);
- } else
+ name_assign_type = NET_NAME_USER;
+ } else {
strcpy(name, L2TP_ETH_DEV_NAME);
+ name_assign_type = NET_NAME_ENUM;
+ }

session = l2tp_session_create(sizeof(*spriv), tunnel, session_id,
peer_session_id, cfg);
@@ -246,7 +250,7 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p
goto out;
}

- dev = alloc_netdev(sizeof(*priv), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(*priv), name, name_assign_type,
l2tp_eth_dev_setup);
if (!dev) {
rc = -ENOMEM;
--
1.9.3

2014-07-10 08:18:54

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 23/33] net: openvswitch - set name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Pravin Shelar <[email protected]>
Cc: [email protected]
---
net/openvswitch/datapath.c | 1 +
net/openvswitch/vport-internal_dev.c | 2 +-
net/openvswitch/vport.h | 2 ++
3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 0d407bc..f216eca 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1370,6 +1370,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)

/* Set up our datapath device. */
parms.name = nla_data(a[OVS_DP_ATTR_NAME]);
+ parms.name_assign_type = NET_NAME_USER;
parms.type = OVS_VPORT_TYPE_INTERNAL;
parms.options = NULL;
parms.dp = dp;
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 0a5e077..ceb098c 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -159,7 +159,7 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
netdev_vport = netdev_vport_priv(vport);

netdev_vport->dev = alloc_netdev(sizeof(struct internal_dev),
- parms->name, NET_NAME_UNKNOWN,
+ parms->name, parms->name_assign_type,
do_setup);
if (!netdev_vport->dev) {
err = -ENOMEM;
diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h
index 8d721e6..a9d7480 100644
--- a/net/openvswitch/vport.h
+++ b/net/openvswitch/vport.h
@@ -97,6 +97,7 @@ struct vport {
* struct vport_parms - parameters for creating a new vport
*
* @name: New vport's name.
+ * @name_assign_type: New vport's name's origin.
* @type: New vport's type.
* @options: %OVS_VPORT_ATTR_OPTIONS attribute from Netlink message, %NULL if
* none was supplied.
@@ -105,6 +106,7 @@ struct vport {
*/
struct vport_parms {
const char *name;
+ unsigned char name_assign_type;
enum ovs_vport_type type;
struct nlattr *options;

--
1.9.3

2014-07-10 08:18:49

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 19/33] net: isdn - set name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Karsten Keil <[email protected]>
---
drivers/isdn/i4l/isdn_common.c | 4 ++--
drivers/isdn/i4l/isdn_net.c | 10 +++++-----
drivers/isdn/i4l/isdn_net.h | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 9b856e1..67840ca 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1364,7 +1364,7 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
}
ret = mutex_lock_interruptible(&dev->mtx);
if (ret) return ret;
- if ((s = isdn_net_new(s, NULL))) {
+ if ((s = isdn_net_new(s, NET_NAME_USER, NULL))) {
if (copy_to_user(argp, s, strlen(s) + 1)) {
ret = -EFAULT;
} else {
@@ -1383,7 +1383,7 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
return -EINVAL;
ret = mutex_lock_interruptible(&dev->mtx);
if (ret) return ret;
- if ((s = isdn_net_newslave(bname))) {
+ if ((s = isdn_net_newslave(bname, NET_NAME_USER))) {
if (copy_to_user(argp, s, strlen(s) + 1)) {
ret = -EFAULT;
} else {
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index c2ed624..d16fec0 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -2573,7 +2573,7 @@ static void _isdn_setup(struct net_device *dev)
* Allocate a new network-interface and initialize its data structures.
*/
char *
-isdn_net_new(char *name, struct net_device *master)
+isdn_net_new(char *name, unsigned char name_assign_type, struct net_device *master)
{
isdn_net_dev *netdev;

@@ -2588,8 +2588,8 @@ isdn_net_new(char *name, struct net_device *master)
printk(KERN_WARNING "isdn_net: Could not allocate net-device\n");
return NULL;
}
- netdev->dev = alloc_netdev(sizeof(isdn_net_local), name,
- NET_NAME_UNKNOWN, _isdn_setup);
+ netdev->dev = alloc_netdev(sizeof(isdn_net_local), name, name_assign_type,
+ _isdn_setup);
if (!netdev->dev) {
printk(KERN_WARNING "isdn_net: Could not allocate network device\n");
kfree(netdev);
@@ -2637,7 +2637,7 @@ isdn_net_new(char *name, struct net_device *master)
}

char *
-isdn_net_newslave(char *parm)
+isdn_net_newslave(char *parm, unsigned char name_assign_type)
{
char *p = strchr(parm, ',');
isdn_net_dev *n;
@@ -2658,7 +2658,7 @@ isdn_net_newslave(char *parm)
/* Master must not be started yet */
if (isdn_net_device_started(n))
return NULL;
- return (isdn_net_new(newname, n->dev));
+ return (isdn_net_new(newname, name_assign_type, n->dev));
}
return NULL;
}
diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h
index cca6d68..99f0c47 100644
--- a/drivers/isdn/i4l/isdn_net.h
+++ b/drivers/isdn/i4l/isdn_net.h
@@ -31,8 +31,8 @@
#define CISCO_SLARP_REPLY 1
#define CISCO_SLARP_KEEPALIVE 2

-extern char *isdn_net_new(char *, struct net_device *);
-extern char *isdn_net_newslave(char *);
+extern char *isdn_net_new(char *, unsigned char, struct net_device *);
+extern char *isdn_net_newslave(char *, unsigned char);
extern int isdn_net_rm(char *);
extern int isdn_net_rmall(void);
extern int isdn_net_stat_callback(int, isdn_ctrl *);
--
1.9.3

2014-07-10 08:19:07

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 29/33] net: brcmfmac - set name assign type

The name is given by the firmware, so we assume it is predictable.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Brett Rudley <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: "Franky (Zhenhui) Lin" <[email protected]>
Cc: Hante Meuleman <[email protected]>
Cc: John Linville <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
index f6990f2..8d32721 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
@@ -201,7 +201,8 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
emsg->addr);
ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
- emsg->ifname, NET_NAME_UNKNOWN, emsg->addr);
+ emsg->ifname, NET_NAME_PREDICTABLE,
+ emsg->addr);
if (IS_ERR(ifp))
return;
brcmf_fws_add_interface(ifp);
--
1.9.3

2014-07-10 08:19:18

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 31/33] net: slcan - set name assign type

Names are given by the first available SLCAN channel, so order
of device creation matters.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Wolfgang Grandegger <[email protected]>
Cc: Marc Kleine-Budde <[email protected]>
Cc: [email protected]
---
drivers/net/can/slcan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index acb5b92..99f2534 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -529,7 +529,7 @@ static struct slcan *slc_alloc(dev_t line)
return NULL;

sprintf(name, "slcan%d", i);
- dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, slc_setup);
+ dev = alloc_netdev(sizeof(*sl), name, NET_NAME_ENUM, slc_setup);
if (!dev)
return NULL;

--
1.9.3

2014-07-10 08:19:15

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 32/33] net: x25_asy - set name assign type

Names are given by the first available X.25 channel, so order
of device creation matters.

Signed-off-by: Tom Gundersen <[email protected]>
---
drivers/net/wan/x25_asy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index df6c073..2821f8b 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -81,8 +81,8 @@ static struct x25_asy *x25_asy_alloc(void)
char name[IFNAMSIZ];
sprintf(name, "x25asy%d", i);

- dev = alloc_netdev(sizeof(struct x25_asy), name,
- NET_NAME_UNKNOWN, x25_asy_setup);
+ dev = alloc_netdev(sizeof(struct x25_asy),
+ name, NET_NAME_ENUM, x25_asy_setup);
if (!dev)
return NULL;

--
1.9.3

2014-07-10 08:20:11

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 33/33] net: slip - set name assign type

Names are given by the first available SLIP channel, so order
of device creation matters.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Tyler Hall <[email protected]>
---
drivers/net/slip/slip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 05387b1..2a305d1 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -749,7 +749,7 @@ static struct slip *sl_alloc(dev_t line)
return NULL;

sprintf(name, "sl%d", i);
- dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, sl_setup);
+ dev = alloc_netdev(sizeof(*sl), name, NET_NAME_ENUM, sl_setup);
if (!dev)
return NULL;

--
1.9.3

2014-07-10 08:21:16

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 30/33] net: ppp - set name assign type

The ifname is of the form pppX where X is the unit number. This is even set
by userspace, or userspace requests the kernel to chose one, which is then
returned to userspace. Either way the creating user knows the name, so we
treat both cases as if the user had explicitly chosen the name and label
it NET_NAME_USER.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
drivers/net/ppp/ppp_generic.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 5c002b1..9757b52 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2726,6 +2726,7 @@ ppp_create_interface(struct net *net, int unit, int *retp)
/* Initialize the new ppp unit */
ppp->file.index = unit;
sprintf(dev->name, "ppp%d", unit);
+ dev->name_assign_type = NET_NAME_USER;

ret = register_netdev(dev);
if (ret != 0) {
--
1.9.3

2014-07-10 08:19:02

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 25/33] net: infiniband - steal ifname label

Use the same assign type, as the name we are basing our new name on.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Tom Tucker <[email protected]>
Cc: Steve Wise <[email protected]>
Cc: Roland Dreier <[email protected]>
Cc: Sean Hefty <[email protected]>
Cc: Hal Rosenstock <[email protected]>
Cc: [email protected]
---
drivers/infiniband/hw/amso1100/c2_provider.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index 2d5cbf4..fc44460 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -734,7 +734,7 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
/* change ethxxx to iwxxx */
strcpy(name, "iw");
strcat(name, &c2dev->netdev->name[3]);
- netdev = alloc_netdev(0, name, NET_NAME_UNKNOWN, setup);
+ netdev = alloc_netdev(0, name, c2dev->netdev->name_assign_type, setup);
if (!netdev) {
printk(KERN_ERR PFX "%s - etherdev alloc failed",
__func__);
--
1.9.3

2014-07-10 08:21:44

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 28/33] net: dsa - set name assign type

The name is given by the firmware, so we assume it is predictable.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Fabian Godehardt <[email protected]>
Cc: Florian Fainelli <[email protected]>
---
net/dsa/dsa.c | 3 ++-
net/dsa/dsa_priv.h | 3 ++-
net/dsa/slave.c | 6 +++---
3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 5db37ce..f3cd203 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -185,7 +185,8 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
if (!(ds->phys_port_mask & (1 << i)))
continue;

- slave_dev = dsa_slave_create(ds, parent, i, pd->port_names[i]);
+ slave_dev = dsa_slave_create(ds, parent, i, pd->port_names[i],
+ NET_NAME_PREDICTABLE);
if (slave_dev == NULL) {
printk(KERN_ERR "%s[%d]: can't create dsa "
"slave device for port %d(%s)\n",
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index d4cf5cc..458881f 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -42,7 +42,8 @@ extern char dsa_driver_version[];
void dsa_slave_mii_bus_init(struct dsa_switch *ds);
struct net_device *dsa_slave_create(struct dsa_switch *ds,
struct device *parent,
- int port, char *name);
+ int port, char *name,
+ unsigned char name_assign_type);

/* tag_dsa.c */
netdev_tx_t dsa_xmit(struct sk_buff *skb, struct net_device *dev);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 45a1e34..d29b0be 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -333,15 +333,15 @@ static const struct net_device_ops trailer_netdev_ops = {
/* slave device setup *******************************************************/
struct net_device *
dsa_slave_create(struct dsa_switch *ds, struct device *parent,
- int port, char *name)
+ int port, char *name, unsigned char name_assign_type)
{
struct net_device *master = ds->dst->master_netdev;
struct net_device *slave_dev;
struct dsa_slave_priv *p;
int ret;

- slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
- NET_NAME_UNKNOWN, ether_setup);
+ slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv),
+ name, name_assign_type, ether_setup);
if (slave_dev == NULL)
return slave_dev;

--
1.9.3

2014-07-10 08:22:31

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 26/33] net: ipoib - set name assign type

When naming a device based on a combination of the parent device, and
the upsr-supplied key, inherit the name assign type from the parent.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Roland Dreier <[email protected]>
Cc: Sean Hefty <[email protected]>
Cc: Hal Rosenstock <[email protected]>
Cc: Erez Shitrit <[email protected]>
Cc: Michal Schmidt <[email protected]>
Cc: Jim Foraker <[email protected]>
Cc: [email protected]
---
drivers/infiniband/ulp/ipoib/ipoib.h | 2 +-
drivers/infiniband/ulp/ipoib/ipoib_main.c | 12 +++++++-----
drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index c639f90..2654288 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -464,7 +464,7 @@ void ipoib_reap_ah(struct work_struct *work);

void ipoib_mark_paths_invalid(struct net_device *dev);
void ipoib_flush_paths(struct net_device *dev);
-struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
+struct ipoib_dev_priv *ipoib_intf_alloc(const char *format, unsigned char name_assign_type);

int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
void ipoib_ib_dev_flush_light(struct work_struct *work);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 4e675f4..b1d58ef 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1390,12 +1390,13 @@ void ipoib_setup(struct net_device *dev)
INIT_DELAYED_WORK(&priv->neigh_reap_task, ipoib_reap_neigh);
}

-struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
+struct ipoib_dev_priv *ipoib_intf_alloc(const char *name,
+ unsigned char name_assign_type)
{
struct net_device *dev;

- dev = alloc_netdev((int)sizeof(struct ipoib_dev_priv), name,
- NET_NAME_UNKNOWN, ipoib_setup);
+ dev = alloc_netdev((int) sizeof (struct ipoib_dev_priv), name,
+ name_assign_type, ipoib_setup);
if (!dev)
return NULL;

@@ -1535,13 +1536,14 @@ int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca)
}

static struct net_device *ipoib_add_port(const char *format,
+ unsigned char name_assign_type,
struct ib_device *hca, u8 port)
{
struct ipoib_dev_priv *priv;
struct ib_port_attr attr;
int result = -ENOMEM;

- priv = ipoib_intf_alloc(format);
+ priv = ipoib_intf_alloc(format, name_assign_type);
if (!priv)
goto alloc_mem_failed;

@@ -1676,7 +1678,7 @@ static void ipoib_add_one(struct ib_device *device)
for (p = s; p <= e; ++p) {
if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND)
continue;
- dev = ipoib_add_port("ib%d", device, p);
+ dev = ipoib_add_port("ib%d", NET_NAME_ENUM, device, p);
if (!IS_ERR(dev)) {
priv = netdev_priv(dev);
list_add_tail(&priv->list, dev_list);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 9fad7b5..88558d3 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -133,7 +133,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)

snprintf(intf_name, sizeof intf_name, "%s.%04x",
ppriv->dev->name, pkey);
- priv = ipoib_intf_alloc(intf_name);
+ priv = ipoib_intf_alloc(intf_name, ppriv->dev->name_assign_type);
if (!priv)
return -ENOMEM;

--
1.9.3

2014-07-10 08:22:30

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 27/33] net: tile - set name assign type

The name is obtained from the 'hardware', so consider it predictable.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Chris Metcalf <[email protected]>
---
drivers/net/ethernet/tile/tilegx.c | 7 ++++---
drivers/net/ethernet/tile/tilepro.c | 13 +++++++------
2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 69557a2..42a6cb4 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -2188,7 +2188,8 @@ static void tile_net_setup(struct net_device *dev)
/* Allocate the device structure, register the device, and obtain the
* MAC address from the hypervisor.
*/
-static void tile_net_dev_init(const char *name, const uint8_t *mac)
+static void tile_net_dev_init(const char *name, unsigned char name_assign_type,
+ const uint8_t *mac)
{
int ret;
struct net_device *dev;
@@ -2201,7 +2202,7 @@ static void tile_net_dev_init(const char *name, const uint8_t *mac)
/* Allocate the device structure. Normally, "name" is a
* template, instantiated by register_netdev(), but not for us.
*/
- dev = alloc_netdev_mqs(sizeof(*priv), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev_mqs(sizeof(*priv), name, name_assign_type,
tile_net_setup, NR_CPUS, 1);
if (!dev) {
pr_err("alloc_netdev_mqs(%s) failed\n", name);
@@ -2270,7 +2271,7 @@ static int __init tile_net_init_module(void)

/* Find out what devices we have, and initialize them. */
for (i = 0; gxio_mpipe_link_enumerate_mac(i, name, mac) >= 0; i++)
- tile_net_dev_init(name, mac);
+ tile_net_dev_init(name, NET_NAME_PREDICTABLE, mac);

if (!network_cpus_init())
network_cpus_map = *cpu_online_mask;
diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index 88c7121..73d1e45 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -2281,7 +2281,8 @@ static void tile_net_setup(struct net_device *dev)
* Allocate the device structure, register the device, and obtain the
* MAC address from the hypervisor.
*/
-static struct net_device *tile_net_dev_init(const char *name)
+static struct net_device *tile_net_dev_init(const char *name,
+ unsigned char name_assign_type)
{
int ret;
struct net_device *dev;
@@ -2292,7 +2293,7 @@ static struct net_device *tile_net_dev_init(const char *name)
* tile_net_setup(), and saves "name". Normally, "name" is a
* template, instantiated by register_netdev(), but not for us.
*/
- dev = alloc_netdev(sizeof(*priv), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(*priv), name, name_assign_type,
tile_net_setup);
if (!dev) {
pr_err("alloc_netdev(%s) failed\n", name);
@@ -2372,10 +2373,10 @@ static int tile_net_init_module(void)
{
pr_info("Tilera Network Driver\n");

- tile_net_devs[0] = tile_net_dev_init("xgbe0");
- tile_net_devs[1] = tile_net_dev_init("xgbe1");
- tile_net_devs[2] = tile_net_dev_init("gbe0");
- tile_net_devs[3] = tile_net_dev_init("gbe1");
+ tile_net_devs[0] = tile_net_dev_init("xgbe0", NET_NAME_PREDICTABLE);
+ tile_net_devs[1] = tile_net_dev_init("xgbe1", NET_NAME_PREDICTABLE);
+ tile_net_devs[2] = tile_net_dev_init("gbe0", NET_NAME_PREDICTABLE);
+ tile_net_devs[3] = tile_net_dev_init("gbe1", NET_NAME_PREDICTABLE);

return 0;
}
--
1.9.3

2014-07-10 08:23:29

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 24/33] net: vlan - set name assign type

When deriving the name from the real device, inherit the assign type, otherwise
set PREDICTABLE as the name will be uniquely determined by the VLANID.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Patrick McHardy <[email protected]>
---
net/8021q/vlan.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index cba9c21..2fa26b6 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -215,6 +215,7 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
struct net *net = dev_net(real_dev);
struct vlan_net *vn = net_generic(net, vlan_net_id);
char name[IFNAMSIZ];
+ unsigned char name_assign_type;
int err;

if (vlan_id >= VLAN_VID_MASK)
@@ -229,18 +230,21 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
case VLAN_NAME_TYPE_RAW_PLUS_VID:
/* name will look like: eth1.0005 */
snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, vlan_id);
+ name_assign_type = real_dev->name_assign_type;
break;
case VLAN_NAME_TYPE_PLUS_VID_NO_PAD:
/* Put our vlan.VID in the name.
* Name will look like: vlan5
*/
snprintf(name, IFNAMSIZ, "vlan%i", vlan_id);
+ name_assign_type = NET_NAME_PREDICTABLE;
break;
case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
/* Put our vlan.VID in the name.
* Name will look like: eth0.5
*/
snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, vlan_id);
+ name_assign_type = real_dev->name_assign_type;
break;
case VLAN_NAME_TYPE_PLUS_VID:
/* Put our vlan.VID in the name.
@@ -248,10 +252,11 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
*/
default:
snprintf(name, IFNAMSIZ, "vlan%.4i", vlan_id);
+ name_assign_type = NET_NAME_PREDICTABLE;
}

new_dev = alloc_netdev(sizeof(struct vlan_dev_priv), name,
- NET_NAME_UNKNOWN, vlan_setup);
+ name_assign_type, vlan_setup);

if (new_dev == NULL)
return -ENOBUFS;
--
1.9.3

2014-07-10 08:23:59

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 22/33] net: hamradio - set name assign type

The hamradio devices are created the same way with the same names on module
init time so should therefore be PREDICTABLE rather than ENUM.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Thomas Sailer <[email protected]>
Cc: Joerg Reuter <[email protected]>
Cc: Jean-Paul Roubelat <[email protected]>
Cc: Wenliang Fan <[email protected]>
Cc: [email protected]
---
drivers/net/hamradio/baycom_par.c | 3 ++-
drivers/net/hamradio/baycom_ser_fdx.c | 3 ++-
drivers/net/hamradio/baycom_ser_hdx.c | 3 ++-
drivers/net/hamradio/dmascc.c | 1 +
drivers/net/hamradio/hdlcdrv.c | 3 ++-
drivers/net/hamradio/scc.c | 11 ++++++-----
drivers/net/hamradio/yam.c | 2 +-
include/linux/hdlcdrv.h | 1 +
8 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c
index acb6369..234df52 100644
--- a/drivers/net/hamradio/baycom_par.c
+++ b/drivers/net/hamradio/baycom_par.c
@@ -513,7 +513,8 @@ static int __init init_baycompar(void)

dev = hdlcdrv_register(&par96_ops,
sizeof(struct baycom_state),
- ifname, iobase[i], 0, 0);
+ ifname, NET_NAME_PREDICTABLE,
+ iobase[i], 0, 0);
if (IS_ERR(dev))
break;

diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 636b65c..c7786fc 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -648,7 +648,8 @@ static int __init init_baycomserfdx(void)

dev = hdlcdrv_register(&ser12_ops,
sizeof(struct baycom_state),
- ifname, iobase[i], irq[i], 0);
+ ifname, NET_NAME_PREDICTABLE,
+ iobase[i], irq[i], 0);
if (IS_ERR(dev))
break;

diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c
index f9a8976..8d9f85f 100644
--- a/drivers/net/hamradio/baycom_ser_hdx.c
+++ b/drivers/net/hamradio/baycom_ser_hdx.c
@@ -676,7 +676,8 @@ static int __init init_baycomserhdx(void)

dev = hdlcdrv_register(&ser12_ops,
sizeof(struct baycom_state),
- ifname, iobase[i], irq[i], 0);
+ ifname, NET_NAME_PREDICTABLE,
+ iobase[i], irq[i], 0);
if (IS_ERR(dev))
break;

diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0fad408..d7918ce 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -577,6 +577,7 @@ static int __init setup_adapter(int card_base, int type, int n)
INIT_WORK(&priv->rx_work, rx_bh);
dev->ml_priv = priv;
sprintf(dev->name, "dmascc%i", 2 * n + i);
+ dev->name_assign_type = NET_NAME_ENUM;
dev->base_addr = card_base;
dev->irq = irq;
dev->netdev_ops = &scc_netdev_ops;
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index c67a272..13cbfde 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -687,6 +687,7 @@ static void hdlcdrv_setup(struct net_device *dev)
/* --------------------------------------------------------------------- */
struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
unsigned int privsize, const char *ifname,
+ unsigned char name_assign_type,
unsigned int baseaddr, unsigned int irq,
unsigned int dma)
{
@@ -699,7 +700,7 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
if (privsize < sizeof(struct hdlcdrv_state))
privsize = sizeof(struct hdlcdrv_state);

- dev = alloc_netdev(privsize, ifname, NET_NAME_UNKNOWN, hdlcdrv_setup);
+ dev = alloc_netdev(privsize, ifname, name_assign_type, hdlcdrv_setup);
if (!dev)
return ERR_PTR(-ENOMEM);

diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index 57be9e0..a4fe9ba 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -202,7 +202,7 @@ static void init_channel(struct scc_channel *scc);
static void scc_key_trx (struct scc_channel *scc, char tx);
static void scc_init_timer(struct scc_channel *scc);

-static int scc_net_alloc(const char *name, struct scc_channel *scc);
+static int scc_net_alloc(const char *name, unsigned char name_assign_type, struct scc_channel *scc);
static void scc_net_setup(struct net_device *dev);
static int scc_net_open(struct net_device *dev);
static int scc_net_close(struct net_device *dev);
@@ -1510,12 +1510,13 @@ static void z8530_init(void)
* Allocate device structure, err, instance, and register driver
*/

-static int scc_net_alloc(const char *name, struct scc_channel *scc)
+static int scc_net_alloc(const char *name, unsigned char name_assign_type,
+ struct scc_channel *scc)
{
int err;
struct net_device *dev;

- dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, scc_net_setup);
+ dev = alloc_netdev(0, name, name_assign_type, scc_net_setup);
if (!dev)
return -ENOMEM;

@@ -1815,7 +1816,7 @@ static int scc_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
request_region(SCC_Info[2*Nchips+chan].ctrl, 1, "scc ctrl");
request_region(SCC_Info[2*Nchips+chan].data, 1, "scc data");
if (Nchips+chan != 0 &&
- scc_net_alloc(device_name,
+ scc_net_alloc(device_name, NET_NAME_PREDICTABLE,
&SCC_Info[2*Nchips+chan]))
return -EINVAL;
}
@@ -2111,7 +2112,7 @@ static int __init scc_init_driver (void)
sprintf(devname,"%s0", SCC_DriverName);

rtnl_lock();
- if (scc_net_alloc(devname, SCC_Info)) {
+ if (scc_net_alloc(devname, NET_NAME_PREDICTABLE, SCC_Info)) {
rtnl_unlock();
printk(KERN_ERR "z8530drv: cannot initialize module\n");
return -EIO;
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 717433c..3e73e4d 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -1147,7 +1147,7 @@ static int __init yam_init_driver(void)
sprintf(name, "yam%d", i);

dev = alloc_netdev(sizeof(struct yam_port), name,
- NET_NAME_UNKNOWN, yam_setup);
+ NET_NAME_PREDICTABLE, yam_setup);
if (!dev) {
pr_err("yam: cannot allocate net device\n");
err = -ENOMEM;
diff --git a/include/linux/hdlcdrv.h b/include/linux/hdlcdrv.h
index be3be25..2cb8295 100644
--- a/include/linux/hdlcdrv.h
+++ b/include/linux/hdlcdrv.h
@@ -264,6 +264,7 @@ void hdlcdrv_transmitter(struct net_device *, struct hdlcdrv_state *);
void hdlcdrv_arbitrate(struct net_device *, struct hdlcdrv_state *);
struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
unsigned int privsize, const char *ifname,
+ unsigned char name_assign_type,
unsigned int baseaddr, unsigned int irq,
unsigned int dma);
void hdlcdrv_unregister(struct net_device *dev);
--
1.9.3

2014-07-10 08:24:49

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 20/33] net: irlan - set name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Samuel Ortiz <[email protected]>
Cc: Dragos Foianu <[email protected]>
---
include/net/irda/irlan_eth.h | 2 +-
net/irda/irlan/irlan_common.c | 2 +-
net/irda/irlan/irlan_eth.c | 7 ++++---
3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/net/irda/irlan_eth.h b/include/net/irda/irlan_eth.h
index de5c816..00fd2f8 100644
--- a/include/net/irda/irlan_eth.h
+++ b/include/net/irda/irlan_eth.h
@@ -25,7 +25,7 @@
#ifndef IRLAN_ETH_H
#define IRLAN_ETH_H

-struct net_device *alloc_irlandev(const char *name);
+struct net_device *alloc_irlandev(const char *name, unsigned char name_assign_type);
int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb);

void irlan_eth_flow_indication( void *instance, void *sap, LOCAL_FLOW flow);
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 7ac4d1b..5a458b0 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -204,7 +204,7 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
IRDA_DEBUG(2, "%s()\n", __func__ );

/* Create network device with irlan */
- dev = alloc_irlandev(eth ? "eth%d" : "irlan%d");
+ dev = alloc_irlandev(eth ? "eth%d" : "irlan%d", NET_NAME_ENUM);
if (!dev)
return NULL;

diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index dc13f1a..b62a822 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -94,10 +94,11 @@ static void irlan_eth_setup(struct net_device *dev)
* Allocate network device and control block
*
*/
-struct net_device *alloc_irlandev(const char *name)
+struct net_device *alloc_irlandev(const char *name,
+ unsigned char name_assign_type)
{
- return alloc_netdev(sizeof(struct irlan_cb), name, NET_NAME_UNKNOWN,
- irlan_eth_setup);
+ return alloc_netdev(sizeof(struct irlan_cb), name,
+ name_assign_type, irlan_eth_setup);
}

/*
--
1.9.3

2014-07-10 08:24:50

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 18/33] net: arcdev - label alloc_arcdev names

Let the drivers pass in the name assign type. They all get the name as a module
parameter.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Dan Carpenter <[email protected]>
Cc: Paul Gortmaker <[email protected]>
---
drivers/net/arcnet/arc-rimi.c | 2 +-
drivers/net/arcnet/arcnet.c | 8 ++++++--
drivers/net/arcnet/com20020-isa.c | 2 +-
drivers/net/arcnet/com20020-pci.c | 2 +-
drivers/net/arcnet/com20020_cs.c | 2 +-
drivers/net/arcnet/com90io.c | 2 +-
drivers/net/arcnet/com90xx.c | 2 +-
include/linux/arcdevice.h | 3 ++-
8 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index b8b4c7b..c6fc1ce 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -337,7 +337,7 @@ static int __init arc_rimi_init(void)
{
struct net_device *dev;

- dev = alloc_arcdev(device);
+ dev = alloc_arcdev(device, NET_NAME_USER);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 3b790de..710fe54 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -341,12 +341,16 @@ static void arcdev_setup(struct net_device *dev)

}

-struct net_device *alloc_arcdev(const char *name)
+struct net_device *alloc_arcdev(const char *name, unsigned char name_assign_type)
{
struct net_device *dev;

+ if (name && !*name)
+ name = NULL;
+
dev = alloc_netdev(sizeof(struct arcnet_local),
- name && *name ? name : "arc%d", NET_NAME_UNKNOWN,
+ name ? name : "arc%d",
+ name ? name_assign_type : NET_NAME_ENUM,
arcdev_setup);
if(dev) {
struct arcnet_local *lp = netdev_priv(dev);
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index 45c61a2..4b48598 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -144,7 +144,7 @@ static int __init com20020_init(void)
struct net_device *dev;
struct arcnet_local *lp;

- dev = alloc_arcdev(device);
+ dev = alloc_arcdev(device, NET_NAME_USER);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index cbc44f5..b1d0dc7 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -69,7 +69,7 @@ static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *i

if (pci_enable_device(pdev))
return -EIO;
- dev = alloc_arcdev(device);
+ dev = alloc_arcdev(device, NET_NAME_USER);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index 326a612..de09df0 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -129,7 +129,7 @@ static int com20020_probe(struct pcmcia_device *p_dev)
if (!info)
goto fail_alloc_info;

- dev = alloc_arcdev("");
+ dev = alloc_arcdev("", NET_NAME_UNKNOWN);
if (!dev)
goto fail_alloc_dev;

diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 487d780..f3b2938 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -394,7 +394,7 @@ static int __init com90io_init(void)
struct net_device *dev;
int err;

- dev = alloc_arcdev(device);
+ dev = alloc_arcdev(device, NET_NAME_USER);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index b80fbe4..875efbd 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -463,7 +463,7 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem
int mirror_size;

/* allocate struct net_device */
- dev = alloc_arcdev(device);
+ dev = alloc_arcdev(device, NET_NAME_USER);
if (!dev) {
BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n");
iounmap(p);
diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index 7216b0d..1e9a473 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -334,7 +334,8 @@ void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);

void arcnet_unregister_proto(struct ArcProto *proto);
irqreturn_t arcnet_interrupt(int irq, void *dev_id);
-struct net_device *alloc_arcdev(const char *name);
+struct net_device *alloc_arcdev(const char *name,
+ unsigned char name_assgin_type);

int arcnet_open(struct net_device *dev);
int arcnet_close(struct net_device *dev);
--
1.9.3

2014-07-10 08:24:48

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 21/33] net: batman-adv - set name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Marek Lindner <[email protected]>
Cc: Simon Wunderlich <[email protected]>
Cc: Antonio Quartulli <[email protected]>
Cc: [email protected]
---
net/batman-adv/hard-interface.c | 5 +++--
net/batman-adv/hard-interface.h | 3 ++-
net/batman-adv/soft-interface.c | 9 ++++++---
net/batman-adv/soft-interface.h | 2 +-
net/batman-adv/sysfs.c | 2 +-
5 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index fbda6b5..b25241f 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -365,7 +365,8 @@ static int batadv_master_del_slave(struct batadv_hard_iface *slave,
}

int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
- const char *iface_name)
+ const char *iface_name,
+ unsigned char name_assign_type)
{
struct batadv_priv *bat_priv;
struct net_device *soft_iface, *master;
@@ -382,7 +383,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
soft_iface = dev_get_by_name(&init_net, iface_name);

if (!soft_iface) {
- soft_iface = batadv_softif_create(iface_name);
+ soft_iface = batadv_softif_create(iface_name, name_assign_type);

if (!soft_iface) {
ret = -ENOMEM;
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 1918cd5..45dc1ba 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -44,7 +44,8 @@ bool batadv_is_wifi_iface(int ifindex);
struct batadv_hard_iface*
batadv_hardif_get_by_netdev(const struct net_device *net_dev);
int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
- const char *iface_name);
+ const char *iface_name,
+ unsigned char name_assign_type);
void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
enum batadv_hard_if_cleanup autodel);
void batadv_hardif_remove_interfaces(void);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index d551e63..6de7ae3 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -790,7 +790,8 @@ static int batadv_softif_slave_add(struct net_device *dev,
if (!hard_iface || hard_iface->soft_iface != NULL)
goto out;

- ret = batadv_hardif_enable_interface(hard_iface, dev->name);
+ ret = batadv_hardif_enable_interface(hard_iface, dev->name,
+ dev->name_assign_type);

out:
if (hard_iface)
@@ -889,13 +890,15 @@ static void batadv_softif_init_early(struct net_device *dev)
memset(priv, 0, sizeof(*priv));
}

-struct net_device *batadv_softif_create(const char *name)
+struct net_device *batadv_softif_create(const char *name,
+ unsigned char name_assign_type)
{
struct net_device *soft_iface;
int ret;

soft_iface = alloc_netdev(sizeof(struct batadv_priv), name,
- NET_NAME_UNKNOWN, batadv_softif_init_early);
+ name_assign_type,
+ batadv_softif_init_early);
if (!soft_iface)
return NULL;

diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h
index dbab22f..1ea6f05 100644
--- a/net/batman-adv/soft-interface.h
+++ b/net/batman-adv/soft-interface.h
@@ -22,7 +22,7 @@ int batadv_skb_head_push(struct sk_buff *skb, unsigned int len);
void batadv_interface_rx(struct net_device *soft_iface,
struct sk_buff *skb, struct batadv_hard_iface *recv_if,
int hdr_size, struct batadv_orig_node *orig_node);
-struct net_device *batadv_softif_create(const char *name);
+struct net_device *batadv_softif_create(const char *name, unsigned char name_assign_type);
void batadv_softif_destroy_sysfs(struct net_device *soft_iface);
int batadv_softif_is_valid(const struct net_device *net_dev);
extern struct rtnl_link_ops batadv_link_ops;
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index fc47baa..f2295c1 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -797,7 +797,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
batadv_hardif_disable_interface(hard_iface,
BATADV_IF_CLEANUP_AUTO);

- ret = batadv_hardif_enable_interface(hard_iface, buff);
+ ret = batadv_hardif_enable_interface(hard_iface, buff, NET_NAME_USER);

unlock:
rtnl_unlock();
--
1.9.3

2014-07-10 08:26:39

by Varka Bhadram

[permalink] [raw]
Subject: Re: [PATCH v7 15/33] net: xen-netback - set name assign type

On 07/10/2014 01:47 PM, Tom Gundersen wrote:
> The name contains then xen handle, which is not guaranteed to be
> stable between restarts, so label this NET_NAME_ENUM.
>
> Signed-off-by: Tom Gundersen <[email protected]>
> Cc: Ian Campbell <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: [email protected]
> ---
> drivers/net/xen-netback/interface.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
> index 793275d..da906d1 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -418,8 +418,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
> * When the guest selects the desired number, it will be updated
> * via netif_set_real_num_*_queues().
> */
> - dev = alloc_netdev_mq(sizeof(struct xenvif), name, NET_NAME_UNKNOWN,
> - ether_setup, xenvif_max_queues);
> + dev = alloc_netdev_mq(sizeof(struct xenvif), name, NET_NAME_ENUM, ether_setup,
> + xenvif_max_queues);

What i am suggesting is irrelavent to this patch. But also consider this suggestion

In place sizeof(struct xenvif) --> sizeof(*vif) ???

> if (dev == NULL) {
> pr_warn("Could not allocate netdev for %s\n", name);
> return ERR_PTR(-ENOMEM);


--
Regards,
Varka Bhadram.

2014-07-10 08:27:29

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 15/33] net: xen-netback - set name assign type

The name contains then xen handle, which is not guaranteed to be
stable between restarts, so label this NET_NAME_ENUM.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: [email protected]
---
drivers/net/xen-netback/interface.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 793275d..da906d1 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -418,8 +418,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
* When the guest selects the desired number, it will be updated
* via netif_set_real_num_*_queues().
*/
- dev = alloc_netdev_mq(sizeof(struct xenvif), name, NET_NAME_UNKNOWN,
- ether_setup, xenvif_max_queues);
+ dev = alloc_netdev_mq(sizeof(struct xenvif), name, NET_NAME_ENUM, ether_setup,
+ xenvif_max_queues);
if (dev == NULL) {
pr_warn("Could not allocate netdev for %s\n", name);
return ERR_PTR(-ENOMEM);
--
1.9.3

2014-07-10 08:27:23

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 16/33] net: gdm_lte - set name assign type

Devices are named according to the scheme lteXpdnY, where Y is the
nic type, and X is the normal enumeration, so the scheme is NET_NAME_ENUM.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Won Kang <[email protected]>
Cc: Rashika Kheria <[email protected]>
Cc: [email protected]
---
drivers/staging/gdm724x/gdm_lte.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index c226852..094a91a 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -885,7 +885,7 @@ int register_lte_device(struct phy_dev *phy_dev,

/* Allocate netdev */
net = alloc_netdev(sizeof(struct nic), pdn_dev_name,
- NET_NAME_UNKNOWN, ether_setup);
+ NET_NAME_ENUM, ether_setup);
if (net == NULL) {
pr_err("alloc_netdev failed\n");
ret = -ENOMEM;
--
1.9.3

2014-07-10 08:27:21

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 17/33] net: airo - set name assign type

alloc_netdev is first called without a name, before the name and name assign
type is open-coded later.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: John Linville <[email protected]>
Cc: [email protected]
---
drivers/net/wireless/airo.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 8a93e78..2156b03 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2859,6 +2859,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
}

strcpy(dev->name, "eth%d");
+ dev->name_assign_type = NET_NAME_ENUM;
rc = register_netdev(dev);
if (rc) {
airo_print_err(dev->name, "Couldn't register_netdev");
--
1.9.3

2014-07-10 08:29:41

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 14/33] net: caif_serial - set name assign type

The name is uniquely determined by the name of the TTY.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Dmitry Tarnyagin <[email protected]>
---
drivers/net/caif/caif_serial.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 27bbc56..4432462 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -349,7 +349,7 @@ static int ldisc_open(struct tty_struct *tty)
result = snprintf(name, sizeof(name), "cf%s", tty->name);
if (result >= IFNAMSIZ)
return -EINVAL;
- dev = alloc_netdev(sizeof(*ser), name, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(*ser), name, NET_NAME_PREDICTABLE,
caifdev_setup);
if (!dev)
return -ENOMEM;
--
1.9.3

2014-07-10 08:30:25

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 13/33] net: mrt - set name assign type

We have one device per routing table, so the naming is predictable.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Alexey Kuznetsov <[email protected]>
Cc: James Morris <[email protected]>
Cc: Hideaki YOSHIFUJI <[email protected]>
Cc: Patrick McHardy <[email protected]>
---
net/ipv4/ipmr.c | 2 +-
net/ipv6/ip6mr.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index c803458..a0658a2 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -500,7 +500,7 @@ static struct net_device *ipmr_reg_vif(struct net *net, struct mr_table *mrt)
else
sprintf(name, "pimreg%u", mrt->id);

- dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, reg_vif_setup);
+ dev = alloc_netdev(0, name, NET_NAME_PREDICTABLE, reg_vif_setup);

if (dev == NULL)
return NULL;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index f9a3fd3..cb25ff0 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -744,7 +744,7 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt)
else
sprintf(name, "pim6reg%u", mrt->id);

- dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, reg_vif_setup);
+ dev = alloc_netdev(0, name, NET_NAME_PREDICTABLE, reg_vif_setup);
if (dev == NULL)
return NULL;

--
1.9.3

2014-07-10 08:18:28

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 07/33] net: rtnetlink - make create_link take name_assign_type

Signed-off-by: Tom Gundersen <[email protected]>
---
drivers/net/veth.c | 11 ++++++++---
include/net/rtnetlink.h | 1 +
net/core/rtnetlink.c | 12 ++++++++----
3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index b4a10bc..5058700 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -319,6 +319,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *peer_tb[IFLA_MAX + 1], **tbp;
struct ifinfomsg *ifmp;
struct net *net;
+ unsigned char name_assign_type;

/*
* create and register peer first
@@ -344,16 +345,20 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
tbp = tb;
}

- if (tbp[IFLA_IFNAME])
+ if (tbp[IFLA_IFNAME]) {
nla_strlcpy(ifname, tbp[IFLA_IFNAME], IFNAMSIZ);
- else
+ name_assign_type = NET_NAME_USER;
+ } else {
snprintf(ifname, IFNAMSIZ, DRV_NAME "%%d");
+ name_assign_type = NET_NAME_ENUM;
+ }

net = rtnl_link_get_net(src_net, tbp);
if (IS_ERR(net))
return PTR_ERR(net);

- peer = rtnl_create_link(net, ifname, &veth_link_ops, tbp);
+ peer = rtnl_create_link(net, ifname, name_assign_type,
+ &veth_link_ops, tbp);
if (IS_ERR(peer)) {
put_net(net);
return PTR_ERR(peer);
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 72240e5..e21b9f9 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -136,6 +136,7 @@ void rtnl_af_unregister(struct rtnl_af_ops *ops);

struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
struct net_device *rtnl_create_link(struct net *net, char *ifname,
+ unsigned char name_assign_type,
const struct rtnl_link_ops *ops,
struct nlattr *tb[]);
int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 899de40..09456ff 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1805,7 +1805,8 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
EXPORT_SYMBOL(rtnl_configure_link);

struct net_device *rtnl_create_link(struct net *net,
- char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[])
+ char *ifname, unsigned char name_assign_type,
+ const struct rtnl_link_ops *ops, struct nlattr *tb[])
{
int err;
struct net_device *dev;
@@ -1823,7 +1824,7 @@ struct net_device *rtnl_create_link(struct net *net,
num_rx_queues = ops->get_num_rx_queues();

err = -ENOMEM;
- dev = alloc_netdev_mqs(ops->priv_size, ifname, NET_NAME_UNKNOWN,
+ dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type,
ops->setup, num_tx_queues, num_rx_queues);
if (!dev)
goto err;
@@ -1889,6 +1890,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
char ifname[IFNAMSIZ];
struct nlattr *tb[IFLA_MAX+1];
struct nlattr *linkinfo[IFLA_INFO_MAX+1];
+ unsigned char name_assign_type = NET_NAME_USER;
int err;

#ifdef CONFIG_MODULES
@@ -2038,14 +2040,16 @@ replay:
return -EOPNOTSUPP;
}

- if (!ifname[0])
+ if (!ifname[0]) {
snprintf(ifname, IFNAMSIZ, "%s%%d", ops->kind);
+ name_assign_type = NET_NAME_ENUM;
+ }

dest_net = rtnl_link_get_net(net, tb);
if (IS_ERR(dest_net))
return PTR_ERR(dest_net);

- dev = rtnl_create_link(dest_net, ifname, ops, tb);
+ dev = rtnl_create_link(dest_net, ifname, name_assign_type, ops, tb);
if (IS_ERR(dev)) {
err = PTR_ERR(dev);
goto out;
--
1.9.3

2014-07-10 08:31:50

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 11/33] net: af_netrom - set name assign type

A given number of indistinguishable interfaces are allocated at init time, so
consider their names predictable.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: [email protected]
---
net/netrom/af_netrom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 71cf1bf..beb7cbe 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1418,7 +1418,7 @@ static int __init nr_proto_init(void)
struct net_device *dev;

sprintf(name, "nr%d", i);
- dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, nr_setup);
+ dev = alloc_netdev(0, name, NET_NAME_PREDICTABLE, nr_setup);
if (!dev) {
printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n");
goto fail;
--
1.9.3

2014-07-10 08:31:48

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 12/33] net: af_rose - set name assign type

A given number of indistinguishable interfaces are allocated at init time, so
consider their names predictable.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: [email protected]
---
net/rose/af_rose.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index a85c1a0..5a6b150 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1538,7 +1538,7 @@ static int __init rose_proto_init(void)
char name[IFNAMSIZ];

sprintf(name, "rose%d", i);
- dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, rose_setup);
+ dev = alloc_netdev(0, name, NET_NAME_PREDICTABLE, rose_setup);
if (!dev) {
printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
rc = -ENOMEM;
--
1.9.3

2014-07-10 08:33:20

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 08/33] net: nl80211 - make rdev_add_virtual_intf take name_assign_type

Pass the value down and set it at the same place the name itself is set.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: John Linville <[email protected]>
---
drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 ++++--
drivers/net/wireless/ath/ath6kl/cfg80211.h | 1 +
drivers/net/wireless/ath/ath6kl/core.c | 4 ++--
drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 3 ++-
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 10 ++++++----
drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 2 +-
drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 3 +++
drivers/net/wireless/brcm80211/brcmfmac/p2p.h | 1 +
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 4 +++-
drivers/net/wireless/mwifiex/cfg80211.c | 5 +++--
drivers/net/wireless/mwifiex/main.c | 2 +-
drivers/net/wireless/mwifiex/main.h | 1 +
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 6 +++++-
include/net/cfg80211.h | 1 +
net/mac80211/cfg.c | 3 ++-
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/iface.c | 3 ++-
net/mac80211/main.c | 2 +-
net/wireless/nl80211.c | 3 ++-
net/wireless/rdev-ops.h | 5 +++--
20 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 1c4ce8e..3e0bc77 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -1494,6 +1494,7 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy,

static struct wireless_dev *ath6kl_cfg80211_add_iface(struct wiphy *wiphy,
const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
@@ -1512,7 +1513,7 @@ static struct wireless_dev *ath6kl_cfg80211_add_iface(struct wiphy *wiphy,
return ERR_PTR(-EINVAL);
}

- wdev = ath6kl_interface_add(ar, name, type, if_idx, nw_type);
+ wdev = ath6kl_interface_add(ar, name, name_assign_type, type, if_idx, nw_type);
if (!wdev)
return ERR_PTR(-ENOMEM);

@@ -3630,13 +3631,14 @@ void ath6kl_cfg80211_vif_cleanup(struct ath6kl_vif *vif)
}

struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u8 fw_vif_idx, u8 nw_type)
{
struct net_device *ndev;
struct ath6kl_vif *vif;

- ndev = alloc_netdev(sizeof(*vif), name, NET_NAME_UNKNOWN, ether_setup);
+ ndev = alloc_netdev(sizeof(*vif), name, name_assign_type, ether_setup);
if (!ndev)
return NULL;

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h
index b59becd..5aa57a7 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.h
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h
@@ -25,6 +25,7 @@ enum ath6kl_cfg_suspend_mode {
};

struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u8 fw_vif_idx, u8 nw_type);
void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index b0b6520..997ef42 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -195,8 +195,8 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
rtnl_lock();

/* Add an initial station interface */
- wdev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0,
- INFRA_NETWORK);
+ wdev = ath6kl_interface_add(ar, "wlan%d", NET_NAME_ENUM,
+ NL80211_IFTYPE_STATION, 0, INFRA_NETWORK);

rtnl_unlock();

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
index 16f9ab2..3eaddc4 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
@@ -181,7 +181,8 @@ char *brcmf_ifname(struct brcmf_pub *drvr, int idx);

int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
- char *name, u8 *mac_addr);
+ char *name, unsigned char name_assign_type,
+ u8 *mac_addr);
void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx);
void brcmf_txflowblock_if(struct brcmf_if *ifp,
enum brcmf_netif_stop_reason reason, bool state);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
index 2699441..89845cb 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
@@ -773,7 +773,8 @@ fail:
}

struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
- char *name, u8 *mac_addr)
+ char *name, unsigned char name_assign_type,
+ u8 *mac_addr)
{
struct brcmf_if *ifp;
struct net_device *ndev;
@@ -808,7 +809,7 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
} else {
brcmf_dbg(INFO, "allocate netdev interface\n");
/* Allocate netdev, including space for private structure */
- ndev = alloc_netdev(sizeof(*ifp), name, NET_NAME_UNKNOWN,
+ ndev = alloc_netdev(sizeof(*ifp), name, name_assign_type,
ether_setup);
if (!ndev)
return ERR_PTR(-ENOMEM);
@@ -918,12 +919,13 @@ int brcmf_bus_start(struct device *dev)
brcmf_dbg(TRACE, "\n");

/* add primary networking interface */
- ifp = brcmf_add_if(drvr, 0, 0, "wlan%d", NULL);
+ ifp = brcmf_add_if(drvr, 0, 0, "wlan%d", NET_NAME_ENUM, NULL);
if (IS_ERR(ifp))
return PTR_ERR(ifp);

if (brcmf_p2p_enable)
- p2p_ifp = brcmf_add_if(drvr, 1, 0, "p2p%d", NULL);
+ p2p_ifp = brcmf_add_if(drvr, 1, 0, "p2p%d", NET_NAME_ENUM,
+ NULL);
else
p2p_ifp = NULL;
if (IS_ERR(p2p_ifp))
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
index fad77dd..f6990f2 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
@@ -201,7 +201,7 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
emsg->addr);
ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
- emsg->ifname, emsg->addr);
+ emsg->ifname, NET_NAME_UNKNOWN, emsg->addr);
if (IS_ERR(ifp))
return;
brcmf_fws_add_interface(ifp);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
index f3445ac..ff1b3ac 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
@@ -2245,11 +2245,13 @@ static void brcmf_p2p_delete_p2pdev(struct brcmf_p2p_info *p2p,
*
* @wiphy: wiphy device of new interface.
* @name: name of the new interface.
+ * @name_assign_type: origin of the interface name
* @type: nl80211 interface type.
* @flags: not used.
* @params: contains mac address for P2P device.
*/
struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params)
{
@@ -2309,6 +2311,7 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
}

strncpy(ifp->ndev->name, name, sizeof(ifp->ndev->name) - 1);
+ ifp->ndev->name_assign_type = name_assign_type;
err = brcmf_net_attach(ifp, true);
if (err) {
brcmf_err("Registering netdevice failed\n");
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/p2p.h b/drivers/net/wireless/brcm80211/brcmfmac/p2p.h
index 6821b26..872f382 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.h
@@ -149,6 +149,7 @@ struct brcmf_p2p_info {
s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg);
void brcmf_p2p_detach(struct brcmf_p2p_info *p2p);
struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params);
int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index d8fa276..5330196 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -564,6 +564,7 @@ static bool brcmf_is_ibssmode(struct brcmf_cfg80211_vif *vif)

static struct wireless_dev *brcmf_cfg80211_add_iface(struct wiphy *wiphy,
const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
@@ -581,7 +582,8 @@ static struct wireless_dev *brcmf_cfg80211_add_iface(struct wiphy *wiphy,
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_P2P_DEVICE:
- return brcmf_p2p_add_vif(wiphy, name, type, flags, params);
+ return brcmf_p2p_add_vif(wiphy, name, name_assign_type, type,
+ flags, params);
case NL80211_IFTYPE_UNSPECIFIED:
default:
return ERR_PTR(-EINVAL);
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 30e8fd9..5710cc2 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -2145,10 +2145,11 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info,
}

/*
- * create a new virtual interface with the given name
+ * create a new virtual interface with the given name and name assign type
*/
struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
@@ -2263,7 +2264,7 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
}

dev = alloc_netdev_mqs(sizeof(struct mwifiex_private *), name,
- NET_NAME_UNKNOWN, ether_setup,
+ name_assign_type, ether_setup,
IEEE80211_NUM_ACS, 1);
if (!dev) {
wiphy_err(wiphy, "no memory available for netdevice\n");
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index cbabc12..472c32c 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -476,7 +476,7 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)

rtnl_lock();
/* Create station interface by default */
- wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d",
+ wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM,
NL80211_IFTYPE_STATION, NULL, NULL);
if (IS_ERR(wdev)) {
dev_err(adapter->dev, "cannot create default STA interface\n");
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 1398afa..53fcaf5 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -1192,6 +1192,7 @@ u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);

struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params);
diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index f0839f6..969bf40 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -2655,6 +2655,7 @@ static const struct net_device_ops rtw_cfg80211_monitor_if_ops = {
};

static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name,
+ unsigned char name_assign_type,
struct net_device **ndev)
{
int ret = 0;
@@ -2687,6 +2688,7 @@ static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name,
mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP;
strncpy(mon_ndev->name, name, IFNAMSIZ);
mon_ndev->name[IFNAMSIZ - 1] = 0;
+ mon_ndev->name_assign_type = name_assign_type;
mon_ndev->destructor = rtw_ndev_destructor;

mon_ndev->netdev_ops = &rtw_cfg80211_monitor_if_ops;
@@ -2729,6 +2731,7 @@ out:

static struct wireless_dev *
cfg80211_rtw_add_virtual_intf(struct wiphy *wiphy, const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params)
{
@@ -2748,7 +2751,8 @@ cfg80211_rtw_add_virtual_intf(struct wiphy *wiphy, const char *name,
break;
case NL80211_IFTYPE_MONITOR:
ret =
- rtw_cfg80211_add_monitor_if(padapter, (char *)name, &ndev);
+ rtw_cfg80211_add_monitor_if(padapter, (char *)name,
+ name_assign_type, &ndev);
break;

case NL80211_IFTYPE_P2P_CLIENT:
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index e46c437..ba42fd6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2330,6 +2330,7 @@ struct cfg80211_ops {

struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params);
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index d7513a5..485f308 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -22,6 +22,7 @@

static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
const char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
@@ -31,7 +32,7 @@ static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
struct ieee80211_sub_if_data *sdata;
int err;

- err = ieee80211_if_add(local, name, &wdev, type, params);
+ err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
if (err)
return ERR_PTR(err);

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index ac9836e..40603fd 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1485,6 +1485,7 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
int ieee80211_iface_init(void);
void ieee80211_iface_exit(void);
int ieee80211_if_add(struct ieee80211_local *local, const char *name,
+ unsigned char name_assign_type,
struct wireless_dev **new_wdev, enum nl80211_iftype type,
struct vif_params *params);
int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 036eebf..4c0f8c8 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1596,6 +1596,7 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
}

int ieee80211_if_add(struct ieee80211_local *local, const char *name,
+ unsigned char name_assign_type,
struct wireless_dev **new_wdev, enum nl80211_iftype type,
struct vif_params *params)
{
@@ -1624,7 +1625,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
txqs = IEEE80211_NUM_ACS;

ndev = alloc_netdev_mqs(sizeof(*sdata) + local->hw.vif_data_size,
- name, NET_NAME_UNKNOWN,
+ name, name_assign_type,
ieee80211_if_setup, txqs, 1);
if (!ndev)
return -ENOMEM;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index d17c26d..5a6ff6c 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1018,7 +1018,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)

/* add one default STA interface if supported */
if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
- result = ieee80211_if_add(local, "wlan%d", NULL,
+ result = ieee80211_if_add(local, "wlan%d", NET_NAME_ENUM, NULL,
NL80211_IFTYPE_STATION, NULL);
if (result)
wiphy_warn(local->hw.wiphy,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ba4f172..9f7caa6 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2613,7 +2613,8 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)

wdev = rdev_add_virtual_intf(rdev,
nla_data(info->attrs[NL80211_ATTR_IFNAME]),
- type, err ? NULL : &flags, &params);
+ NET_NAME_USER, type, err ? NULL : &flags,
+ &params);
if (IS_ERR(wdev)) {
nlmsg_free(msg);
return PTR_ERR(wdev);
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index d95bbe3..9e63251 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -35,13 +35,14 @@ static inline void rdev_set_wakeup(struct cfg80211_registered_device *rdev,

static inline struct wireless_dev
*rdev_add_virtual_intf(struct cfg80211_registered_device *rdev, char *name,
+ unsigned char name_assign_type,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params)
{
struct wireless_dev *ret;
trace_rdev_add_virtual_intf(&rdev->wiphy, name, type);
- ret = rdev->ops->add_virtual_intf(&rdev->wiphy, name, type, flags,
- params);
+ ret = rdev->ops->add_virtual_intf(&rdev->wiphy, name, name_assign_type,
+ type, flags, params);
trace_rdev_return_wdev(&rdev->wiphy, ret);
return ret;
}
--
1.9.3

2014-07-10 08:33:18

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 09/33] net: nl802154 - make add_iface take name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Dmitry Eremin-Solenikov <[email protected]>
Cc: [email protected]
---
include/net/wpan-phy.h | 4 +++-
net/ieee802154/nl-phy.c | 5 ++++-
net/mac802154/ieee802154_dev.c | 7 ++++---
3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index 10ab0fc..bb07a1b 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -58,7 +58,9 @@ struct wpan_phy {
int idx;

struct net_device *(*add_iface)(struct wpan_phy *phy,
- const char *name, int type);
+ const char *name,
+ unsigned char name_assign_type,
+ int type);
void (*del_iface)(struct wpan_phy *phy, struct net_device *dev);

int (*set_txpower)(struct wpan_phy *phy, int db);
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 89b265a..dc0c8f7 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -174,6 +174,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
struct wpan_phy *phy;
const char *name;
const char *devname;
+ unsigned char name_assign_type;
int rc = -ENOBUFS;
struct net_device *dev;
int type = __IEEE802154_DEV_INVALID;
@@ -192,8 +193,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1]
!= '\0')
return -EINVAL; /* phy name should be null-terminated */
+ name_assign_type = NET_NAME_USER;
} else {
devname = "wpan%d";
+ name_assign_type = NET_NAME_ENUM;
}

if (strlen(devname) >= IFNAMSIZ)
@@ -227,7 +230,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
}
}

- dev = phy->add_iface(phy, devname, type);
+ dev = phy->add_iface(phy, devname, name_assign_type, type);
if (IS_ERR(dev)) {
rc = PTR_ERR(dev);
goto nla_put_failure;
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 1a79072..ebd9e79 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -158,7 +158,8 @@ mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
}

static struct net_device *
-mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
+mac802154_add_iface(struct wpan_phy *phy, const char *name,
+ unsigned char name_assign_type, int type)
{
struct net_device *dev;
int err = -ENOMEM;
@@ -166,12 +167,12 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
switch (type) {
case IEEE802154_DEV_MONITOR:
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
- name, NET_NAME_UNKNOWN,
+ name, name_assign_type,
mac802154_monitor_setup);
break;
case IEEE802154_DEV_WPAN:
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
- name, NET_NAME_UNKNOWN,
+ name, name_assign_type,
mac802154_wpan_setup);
break;
default:
--
1.9.3

2014-07-10 08:33:16

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 10/33] net: dummy - set name assign type

A fixed number of indistinguishable dummy devices are allocated at module init time,
the names are therefore PREDICTABLE rather than ENUM.

Signed-off-by: Tom Gundersen <[email protected]>
Cc: dingtianhong <[email protected]>
Cc: Tan Xiaojun <[email protected]>
Cc: WANG Cong <[email protected]>
---
drivers/net/dummy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index ff435fb..3eef710 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -164,7 +164,7 @@ static int __init dummy_init_one(void)
struct net_device *dev_dummy;
int err;

- dev_dummy = alloc_netdev(0, "dummy%d", NET_NAME_UNKNOWN, dummy_setup);
+ dev_dummy = alloc_netdev(0, "dummy%d", NET_NAME_PREDICTABLE, dummy_setup);
if (!dev_dummy)
return -ENOMEM;

--
1.9.3

2014-07-10 08:34:54

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 05/33] net: set name assign type for names assigned using a static string

This covers the trivial case:

alloc_netdev(_, "bar", NET_NAME_PREDICTABLE, _);

Signed-off-by: Tom Gundersen <[email protected]>
---
drivers/media/dvb-core/dvb_net.c | 2 +-
drivers/misc/sgi-xp/xpnet.c | 2 +-
drivers/net/caif/caif_virtio.c | 2 +-
drivers/net/eql.c | 4 ++--
drivers/net/loopback.c | 2 +-
drivers/net/wan/sbni.c | 2 +-
drivers/net/wan/sdla.c | 4 ++--
drivers/s390/net/ctcm_main.c | 4 ++--
drivers/staging/vt6655/wpactl.c | 2 +-
net/ipv6/ip6_gre.c | 2 +-
net/ipv6/ip6_tunnel.c | 3 ++-
net/ipv6/ip6_vti.c | 2 +-
net/ipv6/sit.c | 2 +-
13 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index 059e611..998baf6 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -1277,7 +1277,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
return -EINVAL;

net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb",
- NET_NAME_UNKNOWN, dvb_net_setup);
+ NET_NAME_PREDICTABLE, dvb_net_setup);
if (!net)
return -ENOMEM;

diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 557f978..2adb022 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -544,7 +544,7 @@ xpnet_init(void)
* use ether_setup() to init the majority of our device
* structure and then override the necessary pieces.
*/
- xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN,
+ xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_PREDICTABLE,
ether_setup);
if (xpnet_device == NULL) {
kfree(xpnet_broadcast_partitions);
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index a5fefb9..07c6a24 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -661,7 +661,7 @@ static int cfv_probe(struct virtio_device *vdev)
int err = -EINVAL;

netdev = alloc_netdev(sizeof(struct cfv_info), cfv_netdev_name,
- NET_NAME_UNKNOWN, cfv_netdev_setup);
+ NET_NAME_PREDICTABLE, cfv_netdev_setup);
if (!netdev)
return -ENOMEM;

diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index 957e5c0..5c1d986 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -585,8 +585,8 @@ static int __init eql_init_module(void)

pr_info("%s\n", version);

- dev_eql = alloc_netdev(sizeof(equalizer_t), "eql", NET_NAME_UNKNOWN,
- eql_setup);
+ dev_eql = alloc_netdev(sizeof(equalizer_t), "eql",
+ NET_NAME_PREDICTABLE, eql_setup);
if (!dev_eql)
return -ENOMEM;

diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 8f22625..6077691 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -195,7 +195,7 @@ static __net_init int loopback_net_init(struct net *net)
int err;

err = -ENOMEM;
- dev = alloc_netdev(0, "lo", NET_NAME_UNKNOWN, loopback_setup);
+ dev = alloc_netdev(0, "lo", NET_NAME_PREDICTABLE, loopback_setup);
if (!dev)
goto out;

diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index a9b7e9a..516b2ac 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -228,7 +228,7 @@ int __init sbni_probe(int unit)
int err;

dev = alloc_netdev(sizeof(struct net_local), "sbni",
- NET_NAME_UNKNOWN, sbni_devsetup);
+ NET_NAME_PREDICTABLE, sbni_devsetup);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index 421ac5f..128d196 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -1631,8 +1631,8 @@ static int __init init_sdla(void)

printk("%s.\n", version);

- sdla = alloc_netdev(sizeof(struct frad_local), "sdla0",
- NET_NAME_UNKNOWN, setup_sdla);
+ sdla = alloc_netdev(sizeof(struct frad_local), "sdla0", NET_NAME_PREDICTABLE,
+ setup_sdla);
if (!sdla)
return -ENOMEM;

diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index e056dd4..5bf3254 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1137,10 +1137,10 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv)
return NULL;

if (IS_MPC(priv))
- dev = alloc_netdev(0, MPC_DEVICE_GENE, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(0, MPC_DEVICE_GENE, NET_NAME_PREDICTABLE,
ctcm_dev_setup);
else
- dev = alloc_netdev(0, CTC_DEVICE_GENE, NET_NAME_UNKNOWN,
+ dev = alloc_netdev(0, CTC_DEVICE_GENE, NET_NAME_PREDICTABLE,
ctcm_dev_setup);

if (!dev) {
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
index 0814bfd..6167117 100644
--- a/drivers/staging/vt6655/wpactl.c
+++ b/drivers/staging/vt6655/wpactl.c
@@ -90,7 +90,7 @@ static int wpa_init_wpadev(PSDevice pDevice)
int ret = 0;

pDevice->wpadev = alloc_netdev(sizeof(PSDevice), "vntwpa",
- NET_NAME_UNKNOWN, wpadev_setup);
+ NET_NAME_PREDICTABLE, wpadev_setup);
if (pDevice->wpadev == NULL)
return -ENOMEM;

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 1b7acfb..780e6fe 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1324,7 +1324,7 @@ static int __net_init ip6gre_init_net(struct net *net)
int err;

ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
- NET_NAME_UNKNOWN,
+ NET_NAME_PREDICTABLE,
ip6gre_tunnel_setup);
if (!ign->fb_tunnel_dev) {
err = -ENOMEM;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 71bd2ad..cbba655 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1773,7 +1773,8 @@ static int __net_init ip6_tnl_init_net(struct net *net)

err = -ENOMEM;
ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
- NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
+ NET_NAME_PREDICTABLE,
+ ip6_tnl_dev_setup);

if (!ip6n->fb_tnl_dev)
goto err_alloc_dev;
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 17ee4fc..67fd4e5 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -1020,7 +1020,7 @@ static int __net_init vti6_init_net(struct net *net)

err = -ENOMEM;
ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6_vti0",
- NET_NAME_UNKNOWN, vti6_dev_setup);
+ NET_NAME_PREDICTABLE, vti6_dev_setup);

if (!ip6n->fb_tnl_dev)
goto err_alloc_dev;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 2e9ba03..ff5aff8 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1730,7 +1730,7 @@ static int __net_init sit_init_net(struct net *net)
sitn->tunnels[3] = sitn->tunnels_r_l;

sitn->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0",
- NET_NAME_UNKNOWN,
+ NET_NAME_PREDICTABLE,
ipip6_tunnel_setup);
if (!sitn->fb_tunnel_dev) {
err = -ENOMEM;
--
1.9.3

2014-07-10 08:35:20

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 04/33] net: set name assign type for names assigned using a static template

This covers the trivial case:

alloc_netdev(_, "foo%d", NET_NAME_ENUM, _);

Signed-off-by: Tom Gundersen <[email protected]>
---
drivers/firewire/net.c | 2 +-
drivers/hsi/clients/ssi_protocol.c | 3 ++-
drivers/net/caif/caif_spi.c | 4 ++--
drivers/net/can/dev.c | 2 +-
drivers/net/ethernet/8390/lib8390.c | 2 +-
drivers/net/hamradio/6pack.c | 2 +-
drivers/net/hamradio/baycom_epp.c | 2 +-
drivers/net/hamradio/bpqether.c | 4 ++--
drivers/net/hamradio/mkiss.c | 2 +-
drivers/net/ieee802154/fakehard.c | 2 +-
drivers/net/ifb.c | 4 ++--
drivers/net/usb/cdc-phonet.c | 3 ++-
drivers/net/usb/hso.c | 2 +-
drivers/net/wan/dlci.c | 2 +-
drivers/net/wan/hdlc.c | 4 ++--
drivers/net/wan/hdlc_fr.c | 5 ++---
drivers/net/wan/lapbether.c | 4 ++--
drivers/net/wan/sbni.c | 4 ++--
drivers/net/wimax/i2400m/usb.c | 4 ++--
drivers/net/wireless/airo.c | 2 +-
drivers/net/wireless/ath/wil6210/netdev.c | 2 +-
drivers/net/wireless/libertas/main.c | 2 +-
drivers/net/wireless/libertas/mesh.c | 2 +-
drivers/net/wireless/mac80211_hwsim.c | 3 +--
drivers/s390/net/claw.c | 2 +-
drivers/s390/net/netiucv.c | 2 +-
drivers/s390/net/qeth_l2_main.c | 4 ++--
drivers/s390/net/qeth_l3_main.c | 2 +-
drivers/staging/cxt1e1/linux.c | 2 +-
drivers/staging/gdm72xx/gdm_wimax.c | 3 +--
drivers/staging/wlan-ng/p80211netdev.c | 2 +-
drivers/usb/gadget/f_phonet.c | 2 +-
net/802/fc.c | 2 +-
net/802/fddi.c | 3 +--
net/802/hippi.c | 3 +--
net/appletalk/dev.c | 3 +--
net/bluetooth/6lowpan.c | 2 +-
net/ethernet/eth.c | 2 +-
net/irda/irda_device.c | 2 +-
net/phonet/pep-gprs.c | 3 ++-
net/sched/sch_teql.c | 5 +++--
41 files changed, 55 insertions(+), 57 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 2c68da1..158266c 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1460,7 +1460,7 @@ static int fwnet_probe(struct fw_unit *unit,
goto have_dev;
}

- net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
+ net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_ENUM,
fwnet_init_dev);
if (net == NULL) {
mutex_unlock(&fwnet_device_mutex);
diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c
index 737fa2e..a0d3e99 100644
--- a/drivers/hsi/clients/ssi_protocol.c
+++ b/drivers/hsi/clients/ssi_protocol.c
@@ -1069,6 +1069,7 @@ static void ssip_pn_setup(struct net_device *dev)
static int ssi_protocol_probe(struct device *dev)
{
static const char ifname[] = "phonet%d";
+ unsigned char name_assign_type = NET_NAME_ENUM;
struct hsi_client *cl = to_hsi_client(dev);
struct ssi_protocol *ssi;
int err;
@@ -1115,7 +1116,7 @@ static int ssi_protocol_probe(struct device *dev)
goto out;
}

- ssi->netdev = alloc_netdev(0, ifname, NET_NAME_UNKNOWN, ssip_pn_setup);
+ ssi->netdev = alloc_netdev(0, ifname, name_assign_type, ssip_pn_setup);
if (!ssi->netdev) {
dev_err(dev, "No memory for netdev\n");
err = -ENOMEM;
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index 72ea9ff..cd5121e 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -730,8 +730,8 @@ int cfspi_spi_probe(struct platform_device *pdev)
int res;
dev = (struct cfspi_dev *)pdev->dev.platform_data;

- ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
- NET_NAME_UNKNOWN, cfspi_setup);
+ ndev = alloc_netdev(sizeof(struct cfspi),
+ "cfspi%d", NET_NAME_ENUM, cfspi_setup);
if (!dev)
return -ENODEV;

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 9f91fcb..2441348 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -565,7 +565,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
else
size = sizeof_priv;

- dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup);
+ dev = alloc_netdev(size, "can%d", NET_NAME_ENUM, can_setup);
if (!dev)
return NULL;

diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c
index b96e885..96e9610 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -986,7 +986,7 @@ static void ethdev_setup(struct net_device *dev)
static struct net_device *____alloc_ei_netdev(int size)
{
return alloc_netdev(sizeof(struct ei_device) + size, "eth%d",
- NET_NAME_UNKNOWN, ethdev_setup);
+ NET_NAME_ENUM, ethdev_setup);
}


diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index c3c4051..7d38828 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -596,7 +596,7 @@ static int sixpack_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;

- dev = alloc_netdev(sizeof(struct sixpack), "sp%d", NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(struct sixpack), "sp%d", NET_NAME_ENUM,
sp_setup);
if (!dev) {
err = -ENOMEM;
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index a98c153..4d3667e 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -1206,7 +1206,7 @@ static int __init init_baycomepp(void)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct baycom_state), "bce%d",
- NET_NAME_UNKNOWN, baycom_epp_dev_setup);
+ NET_NAME_ENUM, baycom_epp_dev_setup);

if (!dev) {
printk(KERN_WARNING "bce%d : out of memory\n", i);
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index c2894e4..c90e7df 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -501,8 +501,8 @@ static int bpq_new_device(struct net_device *edev)
struct net_device *ndev;
struct bpqdev *bpq;

- ndev = alloc_netdev(sizeof(struct bpqdev), "bpq%d", NET_NAME_UNKNOWN,
- bpq_setup);
+ ndev = alloc_netdev(sizeof(struct bpqdev), "bpq%d",
+ NET_NAME_ENUM, bpq_setup);
if (!ndev)
return -ENOMEM;

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index f990bb1c..c216b0a 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -734,7 +734,7 @@ static int mkiss_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;

- dev = alloc_netdev(sizeof(struct mkiss), "ax%d", NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(struct mkiss), "ax%d", NET_NAME_ENUM,
ax_setup);
if (!dev) {
err = -ENOMEM;
diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
index 9ce854f..8f9b1dd 100644
--- a/drivers/net/ieee802154/fakehard.c
+++ b/drivers/net/ieee802154/fakehard.c
@@ -344,7 +344,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
return -ENOMEM;

dev = alloc_netdev(sizeof(struct fakehard_priv), "hardwpan%d",
- NET_NAME_UNKNOWN, ieee802154_fake_setup);
+ NET_NAME_ENUM, ieee802154_fake_setup);
if (!dev) {
wpan_phy_free(phy);
return -ENOMEM;
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index d2d4a3d..da88b3c 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -269,8 +269,8 @@ static int __init ifb_init_one(int index)
struct ifb_private *dp;
int err;

- dev_ifb = alloc_netdev(sizeof(struct ifb_private), "ifb%d",
- NET_NAME_UNKNOWN, ifb_setup);
+ dev_ifb = alloc_netdev(sizeof(struct ifb_private),
+ "ifb%d", NET_NAME_ENUM, ifb_setup);

if (!dev_ifb)
return -ENOMEM;
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 2ec1500..2495667 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -331,6 +331,7 @@ static struct usb_driver usbpn_driver;
static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
static const char ifname[] = "usbpn%d";
+ unsigned char name_assign_type = NET_NAME_ENUM;
const struct usb_cdc_union_desc *union_header = NULL;
const struct usb_host_interface *data_desc;
struct usb_interface *data_intf;
@@ -387,7 +388,7 @@ static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *i
return -EINVAL;

dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size,
- ifname, NET_NAME_UNKNOWN, usbpn_setup);
+ ifname, name_assign_type, usbpn_setup);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 50b36b2..cf4691e 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2520,7 +2520,7 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,

/* allocate our network device, then we can put in our private data */
/* call hso_net_init to do the basic initialization */
- net = alloc_netdev(sizeof(struct hso_net), "hso%d", NET_NAME_UNKNOWN,
+ net = alloc_netdev(sizeof(struct hso_net), "hso%d", NET_NAME_ENUM,
hso_net_init);
if (!net) {
dev_err(&interface->dev, "Unable to create ethernet device\n");
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index a463613..56e6622 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -328,7 +328,7 @@ static int dlci_add(struct dlci_add *dlci)

/* create device name */
master = alloc_netdev(sizeof(struct dlci_local), "dlci%d",
- NET_NAME_UNKNOWN, dlci_setup);
+ NET_NAME_ENUM, dlci_setup);
if (!master) {
err = -ENOMEM;
goto err1;
diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c
index 51f6cee..6ff23ec 100644
--- a/drivers/net/wan/hdlc.c
+++ b/drivers/net/wan/hdlc.c
@@ -256,8 +256,8 @@ static void hdlc_setup(struct net_device *dev)
struct net_device *alloc_hdlcdev(void *priv)
{
struct net_device *dev;
- dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d",
- NET_NAME_UNKNOWN, hdlc_setup);
+ dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d", NET_NAME_ENUM,
+ hdlc_setup);
if (dev)
dev_to_hdlc(dev)->priv = priv;
return dev;
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 7cc64ea..5925ac8 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -1075,11 +1075,10 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
used = pvc_is_used(pvc);

if (type == ARPHRD_ETHER) {
- dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN,
- ether_setup);
+ dev = alloc_netdev(0, "pvceth%d", NET_NAME_ENUM, ether_setup);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
} else
- dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup);
+ dev = alloc_netdev(0, "pvc%d", NET_NAME_ENUM, pvc_setup);

if (!dev) {
netdev_warn(frad, "Memory squeeze on fr_pvc()\n");
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 2f5eda8..a09f08f 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -325,8 +325,8 @@ static int lapbeth_new_device(struct net_device *dev)

ASSERT_RTNL();

- ndev = alloc_netdev(sizeof(*lapbeth), "lapb%d", NET_NAME_UNKNOWN,
- lapbeth_setup);
+ ndev = alloc_netdev(sizeof(*lapbeth), "lapb%d", NET_NAME_ENUM,
+ lapbeth_setup);
if (!ndev)
goto out;

diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 758c4ba..a9b7e9a 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -1478,8 +1478,8 @@ int __init init_module( void )
int err;

while( num < SBNI_MAX_NUM_CARDS ) {
- dev = alloc_netdev(sizeof(struct net_local), "sbni%d",
- NET_NAME_UNKNOWN, sbni_devsetup);
+ dev = alloc_netdev(sizeof(struct net_local),
+ "sbni%d", NET_NAME_ENUM, sbni_devsetup);
if( !dev)
break;

diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index e7f5910..aa51b49 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -472,8 +472,8 @@ int i2400mu_probe(struct usb_interface *iface,

/* Allocate instance [calls i2400m_netdev_setup() on it]. */
result = -ENOMEM;
- net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d", NET_NAME_UNKNOWN,
- i2400mu_netdev_setup);
+ net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d",
+ NET_NAME_ENUM, i2400mu_netdev_setup);
if (net_dev == NULL) {
dev_err(dev, "no memory for network device instance\n");
goto error_alloc_netdev;
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 29d8873..8a93e78 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2685,7 +2685,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
struct net_device *ethdev)
{
int err;
- struct net_device *dev = alloc_netdev(0, "wifi%d", NET_NAME_UNKNOWN,
+ struct net_device *dev = alloc_netdev(0, "wifi%d", NET_NAME_ENUM,
wifi_setup);
if (!dev)
return NULL;
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c
index 7afce6e..f837d01 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -132,7 +132,7 @@ void *wil_if_alloc(struct device *dev, void __iomem *csr)
ch = wdev->wiphy->bands[IEEE80211_BAND_60GHZ]->channels;
cfg80211_chandef_create(&wdev->preset_chandef, ch, NL80211_CHAN_NO_HT);

- ndev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, ether_setup);
+ ndev = alloc_netdev(0, "wlan%d", NET_NAME_ENUM, ether_setup);
if (!ndev) {
dev_err(dev, "alloc_netdev_mqs failed\n");
rc = -ENOMEM;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 569b64e..ff78e91 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -981,7 +981,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
goto err_wdev;
}

- dev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, ether_setup);
+ dev = alloc_netdev(0, "wlan%d", NET_NAME_ENUM, ether_setup);
if (!dev) {
dev_err(dmdev, "no memory for network device instance\n");
goto err_adapter;
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index 01a67f6..8007ac4 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -1000,7 +1000,7 @@ static int lbs_add_mesh(struct lbs_private *priv)
goto done;
}

- mesh_dev = alloc_netdev(0, "msh%d", NET_NAME_UNKNOWN, ether_setup);
+ mesh_dev = alloc_netdev(0, "msh%d", NET_NAME_ENUM, ether_setup);
if (!mesh_dev) {
lbs_deb_mesh("init mshX device failed\n");
ret = -ENOMEM;
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index a000b22..916799f 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2679,8 +2679,7 @@ static int __init init_mac80211_hwsim(void)
goto out_free_radios;
}

- hwsim_mon = alloc_netdev(0, "hwsim%d", NET_NAME_UNKNOWN,
- hwsim_mon_setup);
+ hwsim_mon = alloc_netdev(0, "hwsim%d", NET_NAME_ENUM, hwsim_mon_setup);
if (hwsim_mon == NULL) {
err = -ENOMEM;
goto out_free_radios;
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index fbc6701..2041966 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -2915,7 +2915,7 @@ claw_new_device(struct ccwgroup_device *cgdev)
"failed with error code %d\n", ret);
goto out;
}
- dev = alloc_netdev(0, "claw%d", NET_NAME_UNKNOWN, claw_init_netdevice);
+ dev = alloc_netdev(0, "claw%d", NET_NAME_ENUM, claw_init_netdevice);
if (!dev) {
dev_warn(&cgdev->dev,
"Activating the CLAW device failed\n");
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 0a87809..8c07aa3 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -2015,7 +2015,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct netiucv_priv), "iucv%d",
- NET_NAME_UNKNOWN, netiucv_setup_netdevice);
+ NET_NAME_ENUM, netiucv_setup_netdevice);
if (!dev)
return NULL;
rtnl_lock();
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index c2679bf..b2d7f9d 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -952,11 +952,11 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
{
switch (card->info.type) {
case QETH_CARD_TYPE_IQD:
- card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN,
+ card->dev = alloc_netdev(0, "hsi%d", NET_NAME_ENUM,
ether_setup);
break;
case QETH_CARD_TYPE_OSN:
- card->dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN,
+ card->dev = alloc_netdev(0, "osn%d", NET_NAME_ENUM,
ether_setup);
card->dev->flags |= IFF_NOARP;
break;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index f8427a2..e82a555 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3287,7 +3287,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
}
}
} else if (card->info.type == QETH_CARD_TYPE_IQD) {
- card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN,
+ card->dev = alloc_netdev(0, "hsi%d", NET_NAME_ENUM,
ether_setup);
if (!card->dev)
return -ENODEV;
diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 85d776b..35da3af 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -917,7 +917,7 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,
struct net_device *ndev;
ci_t *ci;

- ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETMPL, NET_NAME_UNKNOWN,
+ ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETMPL, NET_NAME_ENUM,
c4_setup);
if (!ndev) {
pr_warning("%s: no memory for struct net_device !\n",
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index a9a6fc5..d381d5b 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -886,8 +886,7 @@ int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev)
struct net_device *dev;
int ret;

- dev = alloc_netdev(sizeof(*nic), "wm%d", NET_NAME_UNKNOWN,
- ether_setup);
+ dev = alloc_netdev(sizeof(*nic), "wm%d", NET_NAME_ENUM, ether_setup);

if (dev == NULL) {
pr_err("alloc_etherdev failed\n");
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 6c78f91..a03a0c6 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -769,7 +769,7 @@ int wlan_setup(wlandevice_t *wlandev, struct device *physdev)

/* Allocate and initialize the struct device */
netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d",
- NET_NAME_UNKNOWN, ether_setup);
+ NET_NAME_ENUM, ether_setup);
if (netdev == NULL) {
dev_err(physdev, "Failed to alloc netdev.\n");
wlan_free_wiphy(wiphy);
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index b9cfc15..6aa6dfa 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -721,7 +721,7 @@ struct net_device *gphonet_setup_default(void)
struct phonet_port *port;

/* Create net device */
- dev = alloc_netdev(sizeof(*port), "upnlink%d", NET_NAME_UNKNOWN,
+ dev = alloc_netdev(sizeof(*port), "upnlink%d", NET_NAME_ENUM,
pn_net_setup);
if (!dev)
return ERR_PTR(-ENOMEM);
diff --git a/net/802/fc.c b/net/802/fc.c
index 7c174b6..de923d9 100644
--- a/net/802/fc.c
+++ b/net/802/fc.c
@@ -126,6 +126,6 @@ static void fc_setup(struct net_device *dev)
*/
struct net_device *alloc_fcdev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "fc%d", NET_NAME_UNKNOWN, fc_setup);
+ return alloc_netdev(sizeof_priv, "fc%d", NET_NAME_ENUM, fc_setup);
}
EXPORT_SYMBOL(alloc_fcdev);
diff --git a/net/802/fddi.c b/net/802/fddi.c
index 59e7346..d12f238 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -207,8 +207,7 @@ static void fddi_setup(struct net_device *dev)
*/
struct net_device *alloc_fddidev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "fddi%d", NET_NAME_UNKNOWN,
- fddi_setup);
+ return alloc_netdev(sizeof_priv, "fddi%d", NET_NAME_ENUM, fddi_setup);
}
EXPORT_SYMBOL(alloc_fddidev);

diff --git a/net/802/hippi.c b/net/802/hippi.c
index 2e03f82..33a6d2e 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -228,8 +228,7 @@ static void hippi_setup(struct net_device *dev)

struct net_device *alloc_hippi_dev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "hip%d", NET_NAME_UNKNOWN,
- hippi_setup);
+ return alloc_netdev(sizeof_priv, "hip%d", NET_NAME_ENUM, hippi_setup);
}

EXPORT_SYMBOL(alloc_hippi_dev);
diff --git a/net/appletalk/dev.c b/net/appletalk/dev.c
index e4158b8..f604588 100644
--- a/net/appletalk/dev.c
+++ b/net/appletalk/dev.c
@@ -39,7 +39,6 @@ static void ltalk_setup(struct net_device *dev)

struct net_device *alloc_ltalkdev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "lt%d", NET_NAME_UNKNOWN,
- ltalk_setup);
+ return alloc_netdev(sizeof_priv, "lt%d", NET_NAME_ENUM, ltalk_setup);
}
EXPORT_SYMBOL(alloc_ltalkdev);
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index faf96fc..50ecf95 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -733,7 +733,7 @@ int bt_6lowpan_add_conn(struct l2cap_conn *conn)
return add_peer_conn(conn, dev);

netdev = alloc_netdev(sizeof(*dev), IFACE_NAME_TEMPLATE,
- NET_NAME_UNKNOWN, netdev_setup);
+ NET_NAME_ENUM, netdev_setup);
if (!netdev)
return -ENOMEM;

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index f405e05..1386afa 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -390,7 +390,7 @@ EXPORT_SYMBOL(ether_setup);
struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
unsigned int rxqs)
{
- return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
+ return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_ENUM,
ether_setup, txqs, rxqs);
}
EXPORT_SYMBOL(alloc_etherdev_mqs);
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index 9e0d909..c313091 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -293,7 +293,7 @@ static void irda_device_setup(struct net_device *dev)
*/
struct net_device *alloc_irdadev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "irda%d", NET_NAME_UNKNOWN,
+ return alloc_netdev(sizeof_priv, "irda%d", NET_NAME_ENUM,
irda_device_setup);
}
EXPORT_SYMBOL(alloc_irdadev);
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index e9a83a6..41b51df 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -259,6 +259,7 @@ static void gprs_setup(struct net_device *dev)
int gprs_attach(struct sock *sk)
{
static const char ifname[] = "gprs%d";
+ unsigned char name_assign_type = NET_NAME_ENUM;
struct gprs_dev *gp;
struct net_device *dev;
int err;
@@ -267,7 +268,7 @@ int gprs_attach(struct sock *sk)
return -EINVAL; /* need packet boundaries */

/* Create net device */
- dev = alloc_netdev(sizeof(*gp), ifname, NET_NAME_UNKNOWN, gprs_setup);
+ dev = alloc_netdev(sizeof(*gp), ifname, name_assign_type, gprs_setup);
if (!dev)
return -ENOMEM;
gp = netdev_priv(dev);
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index bd33793..b1bfd06 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -485,8 +485,9 @@ static int __init teql_init(void)
struct net_device *dev;
struct teql_master *master;

- dev = alloc_netdev(sizeof(struct teql_master), "teql%d",
- NET_NAME_UNKNOWN, teql_master_setup);
+ dev = alloc_netdev(sizeof(struct teql_master),
+ "teql%d", NET_NAME_ENUM,
+ teql_master_setup);
if (!dev) {
err = -ENOMEM;
break;
--
1.9.3

2014-07-10 08:18:10

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 02/33] net: set name assign type for renamed devices

Based on a patch from David Herrmann.

This is the only place devices can be renamed.

Signed-off-by: Tom Gundersen <[email protected]>
Reviewed-by: David Herrmann <[email protected]>
---
net/core/dev.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 30eedf6..7765ec5 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1083,6 +1083,7 @@ static int dev_get_valid_name(struct net *net,
int dev_change_name(struct net_device *dev, const char *newname)
{
char oldname[IFNAMSIZ];
+ unsigned char old_assign_type;
int err = 0;
int ret;
struct net *net;
@@ -1109,10 +1110,14 @@ int dev_change_name(struct net_device *dev, const char *newname)
return err;
}

+ old_assign_type = dev->name_assign_type;
+ dev->name_assign_type = NET_NAME_RENAMED;
+
rollback:
ret = device_rename(&dev->dev, dev->name);
if (ret) {
memcpy(dev->name, oldname, IFNAMSIZ);
+ dev->name_assign_type = old_assign_type;
write_seqcount_end(&devnet_rename_seq);
return ret;
}
@@ -1141,6 +1146,8 @@ rollback:
write_seqcount_begin(&devnet_rename_seq);
memcpy(dev->name, oldname, IFNAMSIZ);
memcpy(oldname, newname, IFNAMSIZ);
+ dev->name_assign_type = old_assign_type;
+ old_assign_type = NET_NAME_RENAMED;
goto rollback;
} else {
pr_err("%s: name change rollback failed: %d\n",
--
1.9.3

2014-07-10 08:36:34

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH v7 03/33] net: set name_assign_type in alloc_netdev()

Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
all users to pass NET_NAME_UNKNOWN.

Coccinelle patch:

@@
expression sizeof_priv, name, setup, txqs, rxqs, count;
@@

(
-alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
+alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
|
-alloc_netdev_mq(sizeof_priv, name, setup, count)
+alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
|
-alloc_netdev(sizeof_priv, name, setup)
+alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
)

Signed-off-by: Tom Gundersen <[email protected]>
Reviewed-by: David Herrmann <[email protected]>
---
drivers/firewire/net.c | 3 ++-
drivers/hsi/clients/ssi_protocol.c | 2 +-
drivers/infiniband/hw/amso1100/c2_provider.c | 2 +-
drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++--
drivers/isdn/i4l/isdn_net.c | 3 ++-
drivers/media/dvb-core/dvb_net.c | 3 ++-
drivers/misc/sgi-xp/xpnet.c | 3 ++-
drivers/net/arcnet/arcnet.c | 3 ++-
drivers/net/bonding/bond_main.c | 2 +-
drivers/net/caif/caif_serial.c | 3 ++-
drivers/net/caif/caif_spi.c | 4 ++--
drivers/net/caif/caif_virtio.c | 2 +-
drivers/net/can/dev.c | 2 +-
drivers/net/can/slcan.c | 2 +-
drivers/net/dummy.c | 2 +-
drivers/net/eql.c | 3 ++-
drivers/net/ethernet/8390/lib8390.c | 2 +-
drivers/net/ethernet/tile/tilegx.c | 4 ++--
drivers/net/ethernet/tile/tilepro.c | 3 ++-
drivers/net/hamradio/6pack.c | 3 ++-
drivers/net/hamradio/baycom_epp.c | 2 +-
drivers/net/hamradio/bpqether.c | 4 ++--
drivers/net/hamradio/dmascc.c | 4 ++--
drivers/net/hamradio/hdlcdrv.c | 2 +-
drivers/net/hamradio/mkiss.c | 3 ++-
drivers/net/hamradio/scc.c | 2 +-
drivers/net/hamradio/yam.c | 2 +-
drivers/net/ieee802154/fakehard.c | 3 ++-
drivers/net/ifb.c | 4 ++--
drivers/net/loopback.c | 2 +-
drivers/net/ppp/ppp_generic.c | 3 ++-
drivers/net/slip/slip.c | 2 +-
drivers/net/tun.c | 3 ++-
drivers/net/usb/cdc-phonet.c | 2 +-
drivers/net/usb/hso.c | 3 ++-
drivers/net/wan/dlci.c | 4 ++--
drivers/net/wan/hdlc.c | 3 ++-
drivers/net/wan/hdlc_fr.c | 5 +++--
drivers/net/wan/lapbether.c | 4 ++--
drivers/net/wan/sbni.c | 7 ++++---
drivers/net/wan/sdla.c | 3 ++-
drivers/net/wan/x25_asy.c | 4 ++--
drivers/net/wimax/i2400m/usb.c | 2 +-
drivers/net/wireless/airo.c | 5 +++--
drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 +-
drivers/net/wireless/ath/wil6210/netdev.c | 2 +-
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 3 ++-
drivers/net/wireless/libertas/main.c | 2 +-
drivers/net/wireless/libertas/mesh.c | 2 +-
drivers/net/wireless/mac80211_hwsim.c | 3 ++-
drivers/net/wireless/mwifiex/cfg80211.c | 3 ++-
drivers/net/xen-netback/interface.c | 4 ++--
drivers/s390/net/claw.c | 2 +-
drivers/s390/net/ctcm_main.c | 6 ++++--
drivers/s390/net/netiucv.c | 2 +-
drivers/s390/net/qeth_l2_main.c | 6 ++++--
drivers/s390/net/qeth_l3_main.c | 3 ++-
drivers/staging/cxt1e1/linux.c | 3 ++-
drivers/staging/gdm724x/gdm_lte.c | 2 +-
drivers/staging/gdm72xx/gdm_wimax.c | 3 ++-
drivers/staging/vt6655/wpactl.c | 3 ++-
drivers/staging/wlan-ng/p80211netdev.c | 2 +-
drivers/tty/n_gsm.c | 5 ++---
drivers/usb/gadget/f_phonet.c | 3 ++-
include/linux/netdevice.h | 10 ++++++----
net/802/fc.c | 2 +-
net/802/fddi.c | 3 ++-
net/802/hippi.c | 3 ++-
net/8021q/vlan.c | 3 ++-
net/appletalk/dev.c | 3 ++-
net/atm/br2684.c | 4 ++--
net/atm/clip.c | 3 ++-
net/batman-adv/soft-interface.c | 2 +-
net/bluetooth/6lowpan.c | 3 ++-
net/bluetooth/bnep/core.c | 5 +++--
net/bridge/br_if.c | 2 +-
net/core/dev.c | 2 ++
net/core/rtnetlink.c | 4 ++--
net/dsa/slave.c | 4 ++--
net/ethernet/eth.c | 3 ++-
net/ipv4/ip_tunnel.c | 2 +-
net/ipv4/ipmr.c | 2 +-
net/ipv6/ip6_gre.c | 6 ++++--
net/ipv6/ip6_tunnel.c | 5 +++--
net/ipv6/ip6_vti.c | 4 ++--
net/ipv6/ip6mr.c | 2 +-
net/ipv6/sit.c | 4 +++-
net/irda/irda_device.c | 3 ++-
net/irda/irlan/irlan_eth.c | 2 +-
net/l2tp/l2tp_eth.c | 3 ++-
net/mac80211/iface.c | 6 +++---
net/mac802154/ieee802154_dev.c | 6 ++++--
net/netrom/af_netrom.c | 2 +-
net/openvswitch/vport-internal_dev.c | 3 ++-
net/phonet/pep-gprs.c | 2 +-
net/rose/af_rose.c | 2 +-
net/sched/sch_teql.c | 4 ++--
97 files changed, 180 insertions(+), 128 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index c398645..2c68da1 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1460,7 +1460,8 @@ static int fwnet_probe(struct fw_unit *unit,
goto have_dev;
}

- net = alloc_netdev(sizeof(*dev), "firewire%d", fwnet_init_dev);
+ net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
+ fwnet_init_dev);
if (net == NULL) {
mutex_unlock(&fwnet_device_mutex);
return -ENOMEM;
diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c
index ce4be37..737fa2e 100644
--- a/drivers/hsi/clients/ssi_protocol.c
+++ b/drivers/hsi/clients/ssi_protocol.c
@@ -1115,7 +1115,7 @@ static int ssi_protocol_probe(struct device *dev)
goto out;
}

- ssi->netdev = alloc_netdev(0, ifname, ssip_pn_setup);
+ ssi->netdev = alloc_netdev(0, ifname, NET_NAME_UNKNOWN, ssip_pn_setup);
if (!ssi->netdev) {
dev_err(dev, "No memory for netdev\n");
err = -ENOMEM;
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index 8af33cf..2d5cbf4 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -734,7 +734,7 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
/* change ethxxx to iwxxx */
strcpy(name, "iw");
strcat(name, &c2dev->netdev->name[3]);
- netdev = alloc_netdev(0, name, setup);
+ netdev = alloc_netdev(0, name, NET_NAME_UNKNOWN, setup);
if (!netdev) {
printk(KERN_ERR PFX "%s - etherdev alloc failed",
__func__);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 5786a78..4e675f4 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1394,8 +1394,8 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
{
struct net_device *dev;

- dev = alloc_netdev((int) sizeof (struct ipoib_dev_priv), name,
- ipoib_setup);
+ dev = alloc_netdev((int)sizeof(struct ipoib_dev_priv), name,
+ NET_NAME_UNKNOWN, ipoib_setup);
if (!dev)
return NULL;

diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index d9aebbc..c2ed624 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -2588,7 +2588,8 @@ isdn_net_new(char *name, struct net_device *master)
printk(KERN_WARNING "isdn_net: Could not allocate net-device\n");
return NULL;
}
- netdev->dev = alloc_netdev(sizeof(isdn_net_local), name, _isdn_setup);
+ netdev->dev = alloc_netdev(sizeof(isdn_net_local), name,
+ NET_NAME_UNKNOWN, _isdn_setup);
if (!netdev->dev) {
printk(KERN_WARNING "isdn_net: Could not allocate network device\n");
kfree(netdev);
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index 8a86b30..059e611 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -1276,7 +1276,8 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL;

- net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup);
+ net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb",
+ NET_NAME_UNKNOWN, dvb_net_setup);
if (!net)
return -ENOMEM;

diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 3fac67a..557f978 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -544,7 +544,8 @@ xpnet_init(void)
* use ether_setup() to init the majority of our device
* structure and then override the necessary pieces.
*/
- xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, ether_setup);
+ xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN,
+ ether_setup);
if (xpnet_device == NULL) {
kfree(xpnet_broadcast_partitions);
return -ENOMEM;
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index a956053..3b790de 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -346,7 +346,8 @@ struct net_device *alloc_arcdev(const char *name)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct arcnet_local),
- name && *name ? name : "arc%d", arcdev_setup);
+ name && *name ? name : "arc%d", NET_NAME_UNKNOWN,
+ arcdev_setup);
if(dev) {
struct arcnet_local *lp = netdev_priv(dev);
spin_lock_init(&lp->lock);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3a451b6..a2678fe 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4440,7 +4440,7 @@ int bond_create(struct net *net, const char *name)
rtnl_lock();

bond_dev = alloc_netdev_mq(sizeof(struct bonding),
- name ? name : "bond%d",
+ name ? name : "bond%d", NET_NAME_UNKNOWN,
bond_setup, tx_queues);
if (!bond_dev) {
pr_err("%s: eek! can't alloc netdev!\n", name);
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index fc73865..27bbc56 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -349,7 +349,8 @@ static int ldisc_open(struct tty_struct *tty)
result = snprintf(name, sizeof(name), "cf%s", tty->name);
if (result >= IFNAMSIZ)
return -EINVAL;
- dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
+ dev = alloc_netdev(sizeof(*ser), name, NET_NAME_UNKNOWN,
+ caifdev_setup);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index ff54c0e..72ea9ff 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -730,8 +730,8 @@ int cfspi_spi_probe(struct platform_device *pdev)
int res;
dev = (struct cfspi_dev *)pdev->dev.platform_data;

- ndev = alloc_netdev(sizeof(struct cfspi),
- "cfspi%d", cfspi_setup);
+ ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
+ NET_NAME_UNKNOWN, cfspi_setup);
if (!dev)
return -ENODEV;

diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index 9856086..a5fefb9 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -661,7 +661,7 @@ static int cfv_probe(struct virtio_device *vdev)
int err = -EINVAL;

netdev = alloc_netdev(sizeof(struct cfv_info), cfv_netdev_name,
- cfv_netdev_setup);
+ NET_NAME_UNKNOWN, cfv_netdev_setup);
if (!netdev)
return -ENOMEM;

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index e318e87..9f91fcb 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -565,7 +565,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
else
size = sizeof_priv;

- dev = alloc_netdev(size, "can%d", can_setup);
+ dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup);
if (!dev)
return NULL;

diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index ea4d4f1..acb5b92 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -529,7 +529,7 @@ static struct slcan *slc_alloc(dev_t line)
return NULL;

sprintf(name, "slcan%d", i);
- dev = alloc_netdev(sizeof(*sl), name, slc_setup);
+ dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, slc_setup);
if (!dev)
return NULL;

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 0932ffb..ff435fb 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -164,7 +164,7 @@ static int __init dummy_init_one(void)
struct net_device *dev_dummy;
int err;

- dev_dummy = alloc_netdev(0, "dummy%d", dummy_setup);
+ dev_dummy = alloc_netdev(0, "dummy%d", NET_NAME_UNKNOWN, dummy_setup);
if (!dev_dummy)
return -ENOMEM;

diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index 7a79b60..957e5c0 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -585,7 +585,8 @@ static int __init eql_init_module(void)

pr_info("%s\n", version);

- dev_eql = alloc_netdev(sizeof(equalizer_t), "eql", eql_setup);
+ dev_eql = alloc_netdev(sizeof(equalizer_t), "eql", NET_NAME_UNKNOWN,
+ eql_setup);
if (!dev_eql)
return -ENOMEM;

diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c
index 599311f..b96e885 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -986,7 +986,7 @@ static void ethdev_setup(struct net_device *dev)
static struct net_device *____alloc_ei_netdev(int size)
{
return alloc_netdev(sizeof(struct ei_device) + size, "eth%d",
- ethdev_setup);
+ NET_NAME_UNKNOWN, ethdev_setup);
}


diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 4c70360..69557a2 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -2201,8 +2201,8 @@ static void tile_net_dev_init(const char *name, const uint8_t *mac)
/* Allocate the device structure. Normally, "name" is a
* template, instantiated by register_netdev(), but not for us.
*/
- dev = alloc_netdev_mqs(sizeof(*priv), name, tile_net_setup,
- NR_CPUS, 1);
+ dev = alloc_netdev_mqs(sizeof(*priv), name, NET_NAME_UNKNOWN,
+ tile_net_setup, NR_CPUS, 1);
if (!dev) {
pr_err("alloc_netdev_mqs(%s) failed\n", name);
return;
diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index e5a5c5d..88c7121 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -2292,7 +2292,8 @@ static struct net_device *tile_net_dev_init(const char *name)
* tile_net_setup(), and saves "name". Normally, "name" is a
* template, instantiated by register_netdev(), but not for us.
*/
- dev = alloc_netdev(sizeof(*priv), name, tile_net_setup);
+ dev = alloc_netdev(sizeof(*priv), name, NET_NAME_UNKNOWN,
+ tile_net_setup);
if (!dev) {
pr_err("alloc_netdev(%s) failed\n", name);
return NULL;
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 66e2b19..c3c4051 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -596,7 +596,8 @@ static int sixpack_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;

- dev = alloc_netdev(sizeof(struct sixpack), "sp%d", sp_setup);
+ dev = alloc_netdev(sizeof(struct sixpack), "sp%d", NET_NAME_UNKNOWN,
+ sp_setup);
if (!dev) {
err = -ENOMEM;
goto out;
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 484f77e..a98c153 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -1206,7 +1206,7 @@ static int __init init_baycomepp(void)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct baycom_state), "bce%d",
- baycom_epp_dev_setup);
+ NET_NAME_UNKNOWN, baycom_epp_dev_setup);

if (!dev) {
printk(KERN_WARNING "bce%d : out of memory\n", i);
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index d50b23c..c2894e4 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -501,8 +501,8 @@ static int bpq_new_device(struct net_device *edev)
struct net_device *ndev;
struct bpqdev *bpq;

- ndev = alloc_netdev(sizeof(struct bpqdev), "bpq%d",
- bpq_setup);
+ ndev = alloc_netdev(sizeof(struct bpqdev), "bpq%d", NET_NAME_UNKNOWN,
+ bpq_setup);
if (!ndev)
return -ENOMEM;

diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 6636022..0fad408 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -466,7 +466,7 @@ static int __init setup_adapter(int card_base, int type, int n)
if (!info)
goto out;

- info->dev[0] = alloc_netdev(0, "", dev_setup);
+ info->dev[0] = alloc_netdev(0, "", NET_NAME_UNKNOWN, dev_setup);
if (!info->dev[0]) {
printk(KERN_ERR "dmascc: "
"could not allocate memory for %s at %#3x\n",
@@ -474,7 +474,7 @@ static int __init setup_adapter(int card_base, int type, int n)
goto out1;
}

- info->dev[1] = alloc_netdev(0, "", dev_setup);
+ info->dev[1] = alloc_netdev(0, "", NET_NAME_UNKNOWN, dev_setup);
if (!info->dev[1]) {
printk(KERN_ERR "dmascc: "
"could not allocate memory for %s at %#3x\n",
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 5d78c1d..c67a272 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -699,7 +699,7 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
if (privsize < sizeof(struct hdlcdrv_state))
privsize = sizeof(struct hdlcdrv_state);

- dev = alloc_netdev(privsize, ifname, hdlcdrv_setup);
+ dev = alloc_netdev(privsize, ifname, NET_NAME_UNKNOWN, hdlcdrv_setup);
if (!dev)
return ERR_PTR(-ENOMEM);

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 8a6c720..f990bb1c 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -734,7 +734,8 @@ static int mkiss_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;

- dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup);
+ dev = alloc_netdev(sizeof(struct mkiss), "ax%d", NET_NAME_UNKNOWN,
+ ax_setup);
if (!dev) {
err = -ENOMEM;
goto out;
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index 4bc6ee8..57be9e0 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1515,7 +1515,7 @@ static int scc_net_alloc(const char *name, struct scc_channel *scc)
int err;
struct net_device *dev;

- dev = alloc_netdev(0, name, scc_net_setup);
+ dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, scc_net_setup);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 8190165..717433c 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -1147,7 +1147,7 @@ static int __init yam_init_driver(void)
sprintf(name, "yam%d", i);

dev = alloc_netdev(sizeof(struct yam_port), name,
- yam_setup);
+ NET_NAME_UNKNOWN, yam_setup);
if (!dev) {
pr_err("yam: cannot allocate net device\n");
err = -ENOMEM;
diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
index 78f18be..9ce854f 100644
--- a/drivers/net/ieee802154/fakehard.c
+++ b/drivers/net/ieee802154/fakehard.c
@@ -343,7 +343,8 @@ static int ieee802154fake_probe(struct platform_device *pdev)
if (!phy)
return -ENOMEM;

- dev = alloc_netdev(sizeof(struct fakehard_priv), "hardwpan%d", ieee802154_fake_setup);
+ dev = alloc_netdev(sizeof(struct fakehard_priv), "hardwpan%d",
+ NET_NAME_UNKNOWN, ieee802154_fake_setup);
if (!dev) {
wpan_phy_free(phy);
return -ENOMEM;
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 46a7790..d2d4a3d 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -269,8 +269,8 @@ static int __init ifb_init_one(int index)
struct ifb_private *dp;
int err;

- dev_ifb = alloc_netdev(sizeof(struct ifb_private),
- "ifb%d", ifb_setup);
+ dev_ifb = alloc_netdev(sizeof(struct ifb_private), "ifb%d",
+ NET_NAME_UNKNOWN, ifb_setup);

if (!dev_ifb)
return -ENOMEM;
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index bb96409..8f22625 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -195,7 +195,7 @@ static __net_init int loopback_net_init(struct net *net)
int err;

err = -ENOMEM;
- dev = alloc_netdev(0, "lo", loopback_setup);
+ dev = alloc_netdev(0, "lo", NET_NAME_UNKNOWN, loopback_setup);
if (!dev)
goto out;

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 91d6c12..5c002b1 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2665,7 +2665,8 @@ ppp_create_interface(struct net *net, int unit, int *retp)
int ret = -ENOMEM;
int i;

- dev = alloc_netdev(sizeof(struct ppp), "", ppp_setup);
+ dev = alloc_netdev(sizeof(struct ppp), "", NET_NAME_UNKNOWN,
+ ppp_setup);
if (!dev)
goto out1;

diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 8752644..05387b1 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -749,7 +749,7 @@ static struct slip *sl_alloc(dev_t line)
return NULL;

sprintf(name, "sl%d", i);
- dev = alloc_netdev(sizeof(*sl), name, sl_setup);
+ dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, sl_setup);
if (!dev)
return NULL;

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 98bad1f..acaaf67 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1633,7 +1633,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
name = ifr->ifr_name;

dev = alloc_netdev_mqs(sizeof(struct tun_struct), name,
- tun_setup, queues, queues);
+ NET_NAME_UNKNOWN, tun_setup, queues,
+ queues);

if (!dev)
return -ENOMEM;
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 6358d42..2ec1500 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -387,7 +387,7 @@ static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *i
return -EINVAL;

dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size,
- ifname, usbpn_setup);
+ ifname, NET_NAME_UNKNOWN, usbpn_setup);
if (!dev)
return -ENOMEM;

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index a3a0586..50b36b2 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2520,7 +2520,8 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,

/* allocate our network device, then we can put in our private data */
/* call hso_net_init to do the basic initialization */
- net = alloc_netdev(sizeof(struct hso_net), "hso%d", hso_net_init);
+ net = alloc_netdev(sizeof(struct hso_net), "hso%d", NET_NAME_UNKNOWN,
+ hso_net_init);
if (!net) {
dev_err(&interface->dev, "Unable to create ethernet device\n");
goto exit;
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index 19f7cb2..a463613 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -327,8 +327,8 @@ static int dlci_add(struct dlci_add *dlci)
goto err1;

/* create device name */
- master = alloc_netdev( sizeof(struct dlci_local), "dlci%d",
- dlci_setup);
+ master = alloc_netdev(sizeof(struct dlci_local), "dlci%d",
+ NET_NAME_UNKNOWN, dlci_setup);
if (!master) {
err = -ENOMEM;
goto err1;
diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c
index 9c33ca9..51f6cee 100644
--- a/drivers/net/wan/hdlc.c
+++ b/drivers/net/wan/hdlc.c
@@ -256,7 +256,8 @@ static void hdlc_setup(struct net_device *dev)
struct net_device *alloc_hdlcdev(void *priv)
{
struct net_device *dev;
- dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d", hdlc_setup);
+ dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d",
+ NET_NAME_UNKNOWN, hdlc_setup);
if (dev)
dev_to_hdlc(dev)->priv = priv;
return dev;
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 7c6cb4f3..7cc64ea 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -1075,10 +1075,11 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
used = pvc_is_used(pvc);

if (type == ARPHRD_ETHER) {
- dev = alloc_netdev(0, "pvceth%d", ether_setup);
+ dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN,
+ ether_setup);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
} else
- dev = alloc_netdev(0, "pvc%d", pvc_setup);
+ dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup);

if (!dev) {
netdev_warn(frad, "Memory squeeze on fr_pvc()\n");
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index a33a46f..2f5eda8 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -325,8 +325,8 @@ static int lapbeth_new_device(struct net_device *dev)

ASSERT_RTNL();

- ndev = alloc_netdev(sizeof(*lapbeth), "lapb%d",
- lapbeth_setup);
+ ndev = alloc_netdev(sizeof(*lapbeth), "lapb%d", NET_NAME_UNKNOWN,
+ lapbeth_setup);
if (!ndev)
goto out;

diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 1b89ecf..758c4ba 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -227,7 +227,8 @@ int __init sbni_probe(int unit)
struct net_device *dev;
int err;

- dev = alloc_netdev(sizeof(struct net_local), "sbni", sbni_devsetup);
+ dev = alloc_netdev(sizeof(struct net_local), "sbni",
+ NET_NAME_UNKNOWN, sbni_devsetup);
if (!dev)
return -ENOMEM;

@@ -1477,8 +1478,8 @@ int __init init_module( void )
int err;

while( num < SBNI_MAX_NUM_CARDS ) {
- dev = alloc_netdev(sizeof(struct net_local),
- "sbni%d", sbni_devsetup);
+ dev = alloc_netdev(sizeof(struct net_local), "sbni%d",
+ NET_NAME_UNKNOWN, sbni_devsetup);
if( !dev)
break;

diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index cdd45fb..421ac5f 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -1631,7 +1631,8 @@ static int __init init_sdla(void)

printk("%s.\n", version);

- sdla = alloc_netdev(sizeof(struct frad_local), "sdla0", setup_sdla);
+ sdla = alloc_netdev(sizeof(struct frad_local), "sdla0",
+ NET_NAME_UNKNOWN, setup_sdla);
if (!sdla)
return -ENOMEM;

diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 5895f19..df6c073 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -81,8 +81,8 @@ static struct x25_asy *x25_asy_alloc(void)
char name[IFNAMSIZ];
sprintf(name, "x25asy%d", i);

- dev = alloc_netdev(sizeof(struct x25_asy),
- name, x25_asy_setup);
+ dev = alloc_netdev(sizeof(struct x25_asy), name,
+ NET_NAME_UNKNOWN, x25_asy_setup);
if (!dev)
return NULL;

diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index cd15a93..e7f5910 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -472,7 +472,7 @@ int i2400mu_probe(struct usb_interface *iface,

/* Allocate instance [calls i2400m_netdev_setup() on it]. */
result = -ENOMEM;
- net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d",
+ net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d", NET_NAME_UNKNOWN,
i2400mu_netdev_setup);
if (net_dev == NULL) {
dev_err(dev, "no memory for network device instance\n");
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 64747d4..29d8873 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2685,7 +2685,8 @@ static struct net_device *init_wifidev(struct airo_info *ai,
struct net_device *ethdev)
{
int err;
- struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup);
+ struct net_device *dev = alloc_netdev(0, "wifi%d", NET_NAME_UNKNOWN,
+ wifi_setup);
if (!dev)
return NULL;
dev->ml_priv = ethdev->ml_priv;
@@ -2785,7 +2786,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
CapabilityRid cap_rid;

/* Create the network device object. */
- dev = alloc_netdev(sizeof(*ai), "", ether_setup);
+ dev = alloc_netdev(sizeof(*ai), "", NET_NAME_UNKNOWN, ether_setup);
if (!dev) {
airo_print_err("", "Couldn't alloc_etherdev");
return NULL;
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 0e26f4a..1c4ce8e 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3636,7 +3636,7 @@ struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name,
struct net_device *ndev;
struct ath6kl_vif *vif;

- ndev = alloc_netdev(sizeof(*vif), name, ether_setup);
+ ndev = alloc_netdev(sizeof(*vif), name, NET_NAME_UNKNOWN, ether_setup);
if (!ndev)
return NULL;

diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c
index 106b6dc..7afce6e 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -132,7 +132,7 @@ void *wil_if_alloc(struct device *dev, void __iomem *csr)
ch = wdev->wiphy->bands[IEEE80211_BAND_60GHZ]->channels;
cfg80211_chandef_create(&wdev->preset_chandef, ch, NL80211_CHAN_NO_HT);

- ndev = alloc_netdev(0, "wlan%d", ether_setup);
+ ndev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, ether_setup);
if (!ndev) {
dev_err(dev, "alloc_netdev_mqs failed\n");
rc = -ENOMEM;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
index 09dd8c1..2699441 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
@@ -808,7 +808,8 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
} else {
brcmf_dbg(INFO, "allocate netdev interface\n");
/* Allocate netdev, including space for private structure */
- ndev = alloc_netdev(sizeof(*ifp), name, ether_setup);
+ ndev = alloc_netdev(sizeof(*ifp), name, NET_NAME_UNKNOWN,
+ ether_setup);
if (!ndev)
return ERR_PTR(-ENOMEM);

diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 0c02f04..569b64e 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -981,7 +981,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
goto err_wdev;
}

- dev = alloc_netdev(0, "wlan%d", ether_setup);
+ dev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, ether_setup);
if (!dev) {
dev_err(dmdev, "no memory for network device instance\n");
goto err_adapter;
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index 6fef746..01a67f6 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -1000,7 +1000,7 @@ static int lbs_add_mesh(struct lbs_private *priv)
goto done;
}

- mesh_dev = alloc_netdev(0, "msh%d", ether_setup);
+ mesh_dev = alloc_netdev(0, "msh%d", NET_NAME_UNKNOWN, ether_setup);
if (!mesh_dev) {
lbs_deb_mesh("init mshX device failed\n");
ret = -ENOMEM;
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index a312c65..a000b22 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2679,7 +2679,8 @@ static int __init init_mac80211_hwsim(void)
goto out_free_radios;
}

- hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup);
+ hwsim_mon = alloc_netdev(0, "hwsim%d", NET_NAME_UNKNOWN,
+ hwsim_mon_setup);
if (hwsim_mon == NULL) {
err = -ENOMEM;
goto out_free_radios;
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index e95dec9..30e8fd9 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -2263,7 +2263,8 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
}

dev = alloc_netdev_mqs(sizeof(struct mwifiex_private *), name,
- ether_setup, IEEE80211_NUM_ACS, 1);
+ NET_NAME_UNKNOWN, ether_setup,
+ IEEE80211_NUM_ACS, 1);
if (!dev) {
wiphy_err(wiphy, "no memory available for netdevice\n");
priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 9e97c7c..793275d 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -418,8 +418,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
* When the guest selects the desired number, it will be updated
* via netif_set_real_num_*_queues().
*/
- dev = alloc_netdev_mq(sizeof(struct xenvif), name, ether_setup,
- xenvif_max_queues);
+ dev = alloc_netdev_mq(sizeof(struct xenvif), name, NET_NAME_UNKNOWN,
+ ether_setup, xenvif_max_queues);
if (dev == NULL) {
pr_warn("Could not allocate netdev for %s\n", name);
return ERR_PTR(-ENOMEM);
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index d837c3c..fbc6701 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -2915,7 +2915,7 @@ claw_new_device(struct ccwgroup_device *cgdev)
"failed with error code %d\n", ret);
goto out;
}
- dev = alloc_netdev(0,"claw%d",claw_init_netdevice);
+ dev = alloc_netdev(0, "claw%d", NET_NAME_UNKNOWN, claw_init_netdevice);
if (!dev) {
dev_warn(&cgdev->dev,
"Activating the CLAW device failed\n");
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index 03b6ad0..e056dd4 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1137,9 +1137,11 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv)
return NULL;

if (IS_MPC(priv))
- dev = alloc_netdev(0, MPC_DEVICE_GENE, ctcm_dev_setup);
+ dev = alloc_netdev(0, MPC_DEVICE_GENE, NET_NAME_UNKNOWN,
+ ctcm_dev_setup);
else
- dev = alloc_netdev(0, CTC_DEVICE_GENE, ctcm_dev_setup);
+ dev = alloc_netdev(0, CTC_DEVICE_GENE, NET_NAME_UNKNOWN,
+ ctcm_dev_setup);

if (!dev) {
CTCM_DBF_TEXT_(ERROR, CTC_DBF_CRIT,
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index ce16d1b..0a87809 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -2015,7 +2015,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct netiucv_priv), "iucv%d",
- netiucv_setup_netdevice);
+ NET_NAME_UNKNOWN, netiucv_setup_netdevice);
if (!dev)
return NULL;
rtnl_lock();
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 5ef5b4f..c2679bf 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -952,10 +952,12 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
{
switch (card->info.type) {
case QETH_CARD_TYPE_IQD:
- card->dev = alloc_netdev(0, "hsi%d", ether_setup);
+ card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN,
+ ether_setup);
break;
case QETH_CARD_TYPE_OSN:
- card->dev = alloc_netdev(0, "osn%d", ether_setup);
+ card->dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN,
+ ether_setup);
card->dev->flags |= IFF_NOARP;
break;
default:
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 14e0b58..f8427a2 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3287,7 +3287,8 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
}
}
} else if (card->info.type == QETH_CARD_TYPE_IQD) {
- card->dev = alloc_netdev(0, "hsi%d", ether_setup);
+ card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN,
+ ether_setup);
if (!card->dev)
return -ENODEV;
card->dev->flags |= IFF_NOARP;
diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index 09f3d5c..85d776b 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -917,7 +917,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1,
struct net_device *ndev;
ci_t *ci;

- ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETMPL, c4_setup);
+ ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETMPL, NET_NAME_UNKNOWN,
+ c4_setup);
if (!ndev) {
pr_warning("%s: no memory for struct net_device !\n",
hi->devname);
diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index 64c55b9..c226852 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -885,7 +885,7 @@ int register_lte_device(struct phy_dev *phy_dev,

/* Allocate netdev */
net = alloc_netdev(sizeof(struct nic), pdn_dev_name,
- ether_setup);
+ NET_NAME_UNKNOWN, ether_setup);
if (net == NULL) {
pr_err("alloc_netdev failed\n");
ret = -ENOMEM;
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index e5e5115..a9a6fc5 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -886,7 +886,8 @@ int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev)
struct net_device *dev;
int ret;

- dev = alloc_netdev(sizeof(*nic), "wm%d", ether_setup);
+ dev = alloc_netdev(sizeof(*nic), "wm%d", NET_NAME_UNKNOWN,
+ ether_setup);

if (dev == NULL) {
pr_err("alloc_etherdev failed\n");
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
index 8392d4d..0814bfd 100644
--- a/drivers/staging/vt6655/wpactl.c
+++ b/drivers/staging/vt6655/wpactl.c
@@ -89,7 +89,8 @@ static int wpa_init_wpadev(PSDevice pDevice)
struct net_device *dev = pDevice->dev;
int ret = 0;

- pDevice->wpadev = alloc_netdev(sizeof(PSDevice), "vntwpa", wpadev_setup);
+ pDevice->wpadev = alloc_netdev(sizeof(PSDevice), "vntwpa",
+ NET_NAME_UNKNOWN, wpadev_setup);
if (pDevice->wpadev == NULL)
return -ENOMEM;

diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 00b186c..6c78f91 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -769,7 +769,7 @@ int wlan_setup(wlandevice_t *wlandev, struct device *physdev)

/* Allocate and initialize the struct device */
netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d",
- ether_setup);
+ NET_NAME_UNKNOWN, ether_setup);
if (netdev == NULL) {
dev_err(physdev, "Failed to alloc netdev.\n");
wlan_free_wiphy(wiphy);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 2ebe47b..cde3ab9 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2789,9 +2789,8 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
netname = "gsm%d";
if (nc->if_name[0] != '\0')
netname = nc->if_name;
- net = alloc_netdev(sizeof(struct gsm_mux_net),
- netname,
- gsm_mux_net_init);
+ net = alloc_netdev(sizeof(struct gsm_mux_net), netname,
+ NET_NAME_UNKNOWN, gsm_mux_net_init);
if (!net) {
pr_err("alloc_netdev failed");
return -ENOMEM;
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index f2b7817..b9cfc15 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -721,7 +721,8 @@ struct net_device *gphonet_setup_default(void)
struct phonet_port *port;

/* Create net device */
- dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
+ dev = alloc_netdev(sizeof(*port), "upnlink%d", NET_NAME_UNKNOWN,
+ pn_net_setup);
if (!dev)
return ERR_PTR(-ENOMEM);

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 551e187..80d5f5f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2989,13 +2989,15 @@ void ether_setup(struct net_device *dev);

/* Support for loadable net-drivers */
struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
+ unsigned char name_assign_type,
void (*setup)(struct net_device *),
unsigned int txqs, unsigned int rxqs);
-#define alloc_netdev(sizeof_priv, name, setup) \
- alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
+#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
+ alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1)

-#define alloc_netdev_mq(sizeof_priv, name, setup, count) \
- alloc_netdev_mqs(sizeof_priv, name, setup, count, count)
+#define alloc_netdev_mq(sizeof_priv, name, name_assign_type, setup, count) \
+ alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, count, \
+ count)

int register_netdev(struct net_device *dev);
void unregister_netdev(struct net_device *dev);
diff --git a/net/802/fc.c b/net/802/fc.c
index 05eea6b..7c174b6 100644
--- a/net/802/fc.c
+++ b/net/802/fc.c
@@ -126,6 +126,6 @@ static void fc_setup(struct net_device *dev)
*/
struct net_device *alloc_fcdev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "fc%d", fc_setup);
+ return alloc_netdev(sizeof_priv, "fc%d", NET_NAME_UNKNOWN, fc_setup);
}
EXPORT_SYMBOL(alloc_fcdev);
diff --git a/net/802/fddi.c b/net/802/fddi.c
index 9cda4066..59e7346 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -207,7 +207,8 @@ static void fddi_setup(struct net_device *dev)
*/
struct net_device *alloc_fddidev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "fddi%d", fddi_setup);
+ return alloc_netdev(sizeof_priv, "fddi%d", NET_NAME_UNKNOWN,
+ fddi_setup);
}
EXPORT_SYMBOL(alloc_fddidev);

diff --git a/net/802/hippi.c b/net/802/hippi.c
index 5ff2a71..2e03f82 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -228,7 +228,8 @@ static void hippi_setup(struct net_device *dev)

struct net_device *alloc_hippi_dev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "hip%d", hippi_setup);
+ return alloc_netdev(sizeof_priv, "hip%d", NET_NAME_UNKNOWN,
+ hippi_setup);
}

EXPORT_SYMBOL(alloc_hippi_dev);
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 44ebd5c..cba9c21 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -250,7 +250,8 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
snprintf(name, IFNAMSIZ, "vlan%.4i", vlan_id);
}

- new_dev = alloc_netdev(sizeof(struct vlan_dev_priv), name, vlan_setup);
+ new_dev = alloc_netdev(sizeof(struct vlan_dev_priv), name,
+ NET_NAME_UNKNOWN, vlan_setup);

if (new_dev == NULL)
return -ENOBUFS;
diff --git a/net/appletalk/dev.c b/net/appletalk/dev.c
index 6c8016f..e4158b8 100644
--- a/net/appletalk/dev.c
+++ b/net/appletalk/dev.c
@@ -39,6 +39,7 @@ static void ltalk_setup(struct net_device *dev)

struct net_device *alloc_ltalkdev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "lt%d", ltalk_setup);
+ return alloc_netdev(sizeof_priv, "lt%d", NET_NAME_UNKNOWN,
+ ltalk_setup);
}
EXPORT_SYMBOL(alloc_ltalkdev);
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 403e71f..cc78538 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -682,8 +682,8 @@ static int br2684_create(void __user *arg)

netdev = alloc_netdev(sizeof(struct br2684_dev),
ni.ifname[0] ? ni.ifname : "nas%d",
- (payload == p_routed) ?
- br2684_setup_routed : br2684_setup);
+ NET_NAME_UNKNOWN,
+ (payload == p_routed) ? br2684_setup_routed : br2684_setup);
if (!netdev)
return -ENOMEM;

diff --git a/net/atm/clip.c b/net/atm/clip.c
index ba291ce..4633904 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -520,7 +520,8 @@ static int clip_create(int number)
if (PRIV(dev)->number >= number)
number = PRIV(dev)->number + 1;
}
- dev = alloc_netdev(sizeof(struct clip_priv), "", clip_setup);
+ dev = alloc_netdev(sizeof(struct clip_priv), "", NET_NAME_UNKNOWN,
+ clip_setup);
if (!dev)
return -ENOMEM;
clip_priv = PRIV(dev);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index e7ee65d..d551e63 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -895,7 +895,7 @@ struct net_device *batadv_softif_create(const char *name)
int ret;

soft_iface = alloc_netdev(sizeof(struct batadv_priv), name,
- batadv_softif_init_early);
+ NET_NAME_UNKNOWN, batadv_softif_init_early);
if (!soft_iface)
return NULL;

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 8796ffa..faf96fc 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -732,7 +732,8 @@ int bt_6lowpan_add_conn(struct l2cap_conn *conn)
if (dev)
return add_peer_conn(conn, dev);

- netdev = alloc_netdev(sizeof(*dev), IFACE_NAME_TEMPLATE, netdev_setup);
+ netdev = alloc_netdev(sizeof(*dev), IFACE_NAME_TEMPLATE,
+ NET_NAME_UNKNOWN, netdev_setup);
if (!netdev)
return -ENOMEM;

diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index a841d3e..85bcc21 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -538,8 +538,9 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)

/* session struct allocated as private part of net_device */
dev = alloc_netdev(sizeof(struct bnep_session),
- (*req->device) ? req->device : "bnep%d",
- bnep_net_setup);
+ (*req->device) ? req->device : "bnep%d",
+ NET_NAME_UNKNOWN,
+ bnep_net_setup);
if (!dev)
return -ENOMEM;

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 3eca3fd..078d336 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -344,7 +344,7 @@ int br_add_bridge(struct net *net, const char *name)
struct net_device *dev;
int res;

- dev = alloc_netdev(sizeof(struct net_bridge), name,
+ dev = alloc_netdev(sizeof(struct net_bridge), name, NET_NAME_UNKNOWN,
br_dev_setup);

if (!dev)
diff --git a/net/core/dev.c b/net/core/dev.c
index 7765ec5..d4b01ef 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6456,6 +6456,7 @@ void netdev_freemem(struct net_device *dev)
* for each queue on the device.
*/
struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
+ unsigned char name_assign_type,
void (*setup)(struct net_device *),
unsigned int txqs, unsigned int rxqs)
{
@@ -6534,6 +6535,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
#endif

strcpy(dev->name, name);
+ dev->name_assign_type = name_assign_type;
dev->group = INIT_NETDEV_GROUP;
if (!dev->ethtool_ops)
dev->ethtool_ops = &default_ethtool_ops;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 1063996..899de40 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1823,8 +1823,8 @@ struct net_device *rtnl_create_link(struct net *net,
num_rx_queues = ops->get_num_rx_queues();

err = -ENOMEM;
- dev = alloc_netdev_mqs(ops->priv_size, ifname, ops->setup,
- num_tx_queues, num_rx_queues);
+ dev = alloc_netdev_mqs(ops->priv_size, ifname, NET_NAME_UNKNOWN,
+ ops->setup, num_tx_queues, num_rx_queues);
if (!dev)
goto err;

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 64c5af0..45a1e34 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -340,8 +340,8 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
struct dsa_slave_priv *p;
int ret;

- slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv),
- name, ether_setup);
+ slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
+ NET_NAME_UNKNOWN, ether_setup);
if (slave_dev == NULL)
return slave_dev;

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 5dc638c..f405e05 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -390,7 +390,8 @@ EXPORT_SYMBOL(ether_setup);
struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
unsigned int rxqs)
{
- return alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs);
+ return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
+ ether_setup, txqs, rxqs);
}
EXPORT_SYMBOL(alloc_etherdev_mqs);

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 54b6731..0157a7a 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -301,7 +301,7 @@ static struct net_device *__ip_tunnel_create(struct net *net,
}

ASSERT_RTNL();
- dev = alloc_netdev(ops->priv_size, name, ops->setup);
+ dev = alloc_netdev(ops->priv_size, name, NET_NAME_UNKNOWN, ops->setup);
if (!dev) {
err = -ENOMEM;
goto failed;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 65bcaa7..c803458 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -500,7 +500,7 @@ static struct net_device *ipmr_reg_vif(struct net *net, struct mr_table *mrt)
else
sprintf(name, "pimreg%u", mrt->id);

- dev = alloc_netdev(0, name, reg_vif_setup);
+ dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, reg_vif_setup);

if (dev == NULL)
return NULL;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 3873181..1b7acfb 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -322,7 +322,8 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
else
strcpy(name, "ip6gre%d");

- dev = alloc_netdev(sizeof(*t), name, ip6gre_tunnel_setup);
+ dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
+ ip6gre_tunnel_setup);
if (!dev)
return NULL;

@@ -1323,7 +1324,8 @@ static int __net_init ip6gre_init_net(struct net *net)
int err;

ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
- ip6gre_tunnel_setup);
+ NET_NAME_UNKNOWN,
+ ip6gre_tunnel_setup);
if (!ign->fb_tunnel_dev) {
err = -ENOMEM;
goto err_alloc_dev;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index afa0824..71bd2ad 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -315,7 +315,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
else
sprintf(name, "ip6tnl%%d");

- dev = alloc_netdev(sizeof (*t), name, ip6_tnl_dev_setup);
+ dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
+ ip6_tnl_dev_setup);
if (dev == NULL)
goto failed;

@@ -1772,7 +1773,7 @@ static int __net_init ip6_tnl_init_net(struct net *net)

err = -ENOMEM;
ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
- ip6_tnl_dev_setup);
+ NET_NAME_UNKNOWN, ip6_tnl_dev_setup);

if (!ip6n->fb_tnl_dev)
goto err_alloc_dev;
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 9aaa6bb..17ee4fc 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -204,7 +204,7 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p
else
sprintf(name, "ip6_vti%%d");

- dev = alloc_netdev(sizeof(*t), name, vti6_dev_setup);
+ dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup);
if (dev == NULL)
goto failed;

@@ -1020,7 +1020,7 @@ static int __net_init vti6_init_net(struct net *net)

err = -ENOMEM;
ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6_vti0",
- vti6_dev_setup);
+ NET_NAME_UNKNOWN, vti6_dev_setup);

if (!ip6n->fb_tnl_dev)
goto err_alloc_dev;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 8250474..f9a3fd3 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -744,7 +744,7 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt)
else
sprintf(name, "pim6reg%u", mrt->id);

- dev = alloc_netdev(0, name, reg_vif_setup);
+ dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, reg_vif_setup);
if (dev == NULL)
return NULL;

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 4f40817..2e9ba03 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -250,7 +250,8 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
else
strcpy(name, "sit%d");

- dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup);
+ dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
+ ipip6_tunnel_setup);
if (dev == NULL)
return NULL;

@@ -1729,6 +1730,7 @@ static int __net_init sit_init_net(struct net *net)
sitn->tunnels[3] = sitn->tunnels_r_l;

sitn->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0",
+ NET_NAME_UNKNOWN,
ipip6_tunnel_setup);
if (!sitn->fb_tunnel_dev) {
err = -ENOMEM;
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index 365b895..9e0d909 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -293,7 +293,8 @@ static void irda_device_setup(struct net_device *dev)
*/
struct net_device *alloc_irdadev(int sizeof_priv)
{
- return alloc_netdev(sizeof_priv, "irda%d", irda_device_setup);
+ return alloc_netdev(sizeof_priv, "irda%d", NET_NAME_UNKNOWN,
+ irda_device_setup);
}
EXPORT_SYMBOL(alloc_irdadev);

diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index ffcec22..dc13f1a 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -96,7 +96,7 @@ static void irlan_eth_setup(struct net_device *dev)
*/
struct net_device *alloc_irlandev(const char *name)
{
- return alloc_netdev(sizeof(struct irlan_cb), name,
+ return alloc_netdev(sizeof(struct irlan_cb), name, NET_NAME_UNKNOWN,
irlan_eth_setup);
}

diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 76125c5..edb78e6 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -246,7 +246,8 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p
goto out;
}

- dev = alloc_netdev(sizeof(*priv), name, l2tp_eth_dev_setup);
+ dev = alloc_netdev(sizeof(*priv), name, NET_NAME_UNKNOWN,
+ l2tp_eth_dev_setup);
if (!dev) {
rc = -ENOMEM;
goto out_del_session;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 388b863..036eebf 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1623,9 +1623,9 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
if (local->hw.queues >= IEEE80211_NUM_ACS)
txqs = IEEE80211_NUM_ACS;

- ndev = alloc_netdev_mqs(sizeof(*sdata) +
- local->hw.vif_data_size,
- name, ieee80211_if_setup, txqs, 1);
+ ndev = alloc_netdev_mqs(sizeof(*sdata) + local->hw.vif_data_size,
+ name, NET_NAME_UNKNOWN,
+ ieee80211_if_setup, txqs, 1);
if (!ndev)
return -ENOMEM;
dev_net_set(ndev, wiphy_net(local->hw.wiphy));
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 2cf66d8..1a79072 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -166,11 +166,13 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
switch (type) {
case IEEE802154_DEV_MONITOR:
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
- name, mac802154_monitor_setup);
+ name, NET_NAME_UNKNOWN,
+ mac802154_monitor_setup);
break;
case IEEE802154_DEV_WPAN:
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
- name, mac802154_wpan_setup);
+ name, NET_NAME_UNKNOWN,
+ mac802154_wpan_setup);
break;
default:
dev = NULL;
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index ede50d1..71cf1bf 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1418,7 +1418,7 @@ static int __init nr_proto_init(void)
struct net_device *dev;

sprintf(name, "nr%d", i);
- dev = alloc_netdev(0, name, nr_setup);
+ dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, nr_setup);
if (!dev) {
printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n");
goto fail;
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 789af92..0a5e077 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -159,7 +159,8 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
netdev_vport = netdev_vport_priv(vport);

netdev_vport->dev = alloc_netdev(sizeof(struct internal_dev),
- parms->name, do_setup);
+ parms->name, NET_NAME_UNKNOWN,
+ do_setup);
if (!netdev_vport->dev) {
err = -ENOMEM;
goto error_free_vport;
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index 66dc65e..e9a83a6 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -267,7 +267,7 @@ int gprs_attach(struct sock *sk)
return -EINVAL; /* need packet boundaries */

/* Create net device */
- dev = alloc_netdev(sizeof(*gp), ifname, gprs_setup);
+ dev = alloc_netdev(sizeof(*gp), ifname, NET_NAME_UNKNOWN, gprs_setup);
if (!dev)
return -ENOMEM;
gp = netdev_priv(dev);
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 8451c8c..a85c1a0 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1538,7 +1538,7 @@ static int __init rose_proto_init(void)
char name[IFNAMSIZ];

sprintf(name, "rose%d", i);
- dev = alloc_netdev(0, name, rose_setup);
+ dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, rose_setup);
if (!dev) {
printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
rc = -ENOMEM;
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 4741671..bd33793 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -485,8 +485,8 @@ static int __init teql_init(void)
struct net_device *dev;
struct teql_master *master;

- dev = alloc_netdev(sizeof(struct teql_master),
- "teql%d", teql_master_setup);
+ dev = alloc_netdev(sizeof(struct teql_master), "teql%d",
+ NET_NAME_UNKNOWN, teql_master_setup);
if (!dev) {
err = -ENOMEM;
break;
--
1.9.3

2014-07-10 08:44:00

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v7 00/33] Provide netdev naming-policy via sysfs


It is not reasonable to expect people to review such a large number of
patches at one time.

Split your series up into logical, and more reasonably sized chunks.

I'd say 14 or 15 at a time is the limit.

I'm not even looking at this series until you submit it more reasonably.

Thank you.

2014-07-10 08:51:20

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH v7 31/33] net: slcan - set name assign type

On 07/10/2014 10:17 AM, Tom Gundersen wrote:
> Names are given by the first available SLCAN channel, so order
> of device creation matters.
>
> Signed-off-by: Tom Gundersen <[email protected]>
> Cc: Wolfgang Grandegger <[email protected]>
> Cc: Marc Kleine-Budde <[email protected]>
> Cc: [email protected]

Acked-by: Marc Kleine-Budde <[email protected]>

--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |


Attachments:
signature.asc (242.00 B)
OpenPGP digital signature

2014-07-10 08:52:37

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH v7 04/33] net: set name assign type for names assigned using a static template

On 07/10/2014 10:17 AM, Tom Gundersen wrote:
> This covers the trivial case:
>
> alloc_netdev(_, "foo%d", NET_NAME_ENUM, _);
>
> Signed-off-by: Tom Gundersen <[email protected]>
> ---
> drivers/net/can/dev.c | 2 +-

> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 9f91fcb..2441348 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -565,7 +565,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
> else
> size = sizeof_priv;
>
> - dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup);
> + dev = alloc_netdev(size, "can%d", NET_NAME_ENUM, can_setup);
> if (!dev)
> return NULL;
>

For can/dev.c:

Acked-by: Marc Kleine-Budde <[email protected]>

--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |


Attachments:
signature.asc (242.00 B)
OpenPGP digital signature

2014-07-10 09:01:32

by Ian Campbell

[permalink] [raw]
Subject: Re: [PATCH v7 15/33] net: xen-netback - set name assign type

On Thu, 2014-07-10 at 10:17 +0200, Tom Gundersen wrote:
> The name contains then xen handle, which is not guaranteed to be
> stable between restarts, so label this NET_NAME_ENUM.

FWIW the N'th interface for domain with domid D will always be named
vifD.N.

If you reboot domain D then it's domid will change to E and the new
device will be vifE.N.

I don't know if that counts as predictable as far as the interface you
are introducing is concerned.

Ian.

2014-07-10 09:17:09

by Bjørn Mork

[permalink] [raw]
Subject: Re: [PATCH v7 03/33] net: set name_assign_type in alloc_netdev()

Tom Gundersen <[email protected]> writes:

> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
> index 5dc638c..f405e05 100644
> --- a/net/ethernet/eth.c
> +++ b/net/ethernet/eth.c
> @@ -390,7 +390,8 @@ EXPORT_SYMBOL(ether_setup);
> struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
> unsigned int rxqs)
> {
> - return alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs);
> + return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
> + ether_setup, txqs, rxqs);
> }
> EXPORT_SYMBOL(alloc_etherdev_mqs);

I believe this chunk makes the rest of this exercise pretty pointless.

bjorn@nemi:/usr/local/src/git/linux$ git grep alloc_etherdev drivers/net/|wc -l
283

I don't care enough to go look, but I'd be surprised if none of those
drivers rename the device before registering it.


Bjørn

2014-07-10 09:20:05

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 00/33] Provide netdev naming-policy via sysfs

Thanks for the quick answer.

On Thu, Jul 10, 2014 at 10:43 AM, David Miller <[email protected]> wrote:
> It is not reasonable to expect people to review such a large number of
> patches at one time.
>
> Split your series up into logical, and more reasonably sized chunks.
>
> I'd say 14 or 15 at a time is the limit.
>
> I'm not even looking at this series until you submit it more reasonably.
>
> Thank you.

Ok. I suggest you review patches 1-7, as these are the generic ones.
Then once they have been applied I can resubmit the subsequent patches
individually.

Do you want me to resubmit patches 1-7, or do you just want to pick
them from this series as they are?

Cheers,

Tom

2014-07-10 09:33:43

by Bjørn Mork

[permalink] [raw]
Subject: Re: [PATCH v7 10/33] net: dummy - set name assign type

Tom Gundersen <[email protected]> writes:

> A fixed number of indistinguishable dummy devices are allocated at module init time,
> the names are therefore PREDICTABLE rather than ENUM.

OK? So if I go do

modprobe dummy numdummies=2
ip link add type dummy
ip link add type dummy

then I'd have dummy0 and dummy1 with NET_NAME_PREDICTABLE, but dummy2 and
dummy3 with NET_NAME_ENUM (from your rtnetlink patch).

I think this just demonstrates that there aren't that many different
name types. There is no real difference between your NET_NAME_ENUM and
NET_NAME_PREDICTABLE, resulting in arbitrary choices like this one.

The same goes for NET_NAME_USER and NET_NAME_RENAMED. These are the same
from a kernel point of view. If userspace wants to keep track of device
name history then it is free to do so without any need for a RENAMED
type.


Bjørn

2014-07-10 10:12:51

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 10/33] net: dummy - set name assign type

On Thu, Jul 10, 2014 at 11:31 AM, Bjørn Mork <[email protected]> wrote:
> Tom Gundersen <[email protected]> writes:
>
>> A fixed number of indistinguishable dummy devices are allocated at module init time,
>> the names are therefore PREDICTABLE rather than ENUM.
>
> OK? So if I go do
>
> modprobe dummy numdummies=2
> ip link add type dummy
> ip link add type dummy
>
> then I'd have dummy0 and dummy1 with NET_NAME_PREDICTABLE, but dummy2 and
> dummy3 with NET_NAME_ENUM (from your rtnetlink patch).

Correct. Granted, this is definitely a grey area (the distinction
between the name assign types is less important for virtual devices),
but I still think this makes sense:

The result of

modprobe dummy numdummies=2

is to create dummy0 and dummy1, always with the same names.

The result of

ip link add type dummy

is to create dummyX, where X depends on what came before.

> I think this just demonstrates that there aren't that many different
> name types. There is no real difference between your NET_NAME_ENUM and
> NET_NAME_PREDICTABLE, resulting in arbitrary choices like this one.

It is true that in some cases the distinction is less important, but
that does not negate the usefulness: For instance, the kernel may
assign names to interfaces based on information provided by their
firmware. These names may be useful to keep, and it may be important
for userspace to be told that they are backed by something sensible.

> The same goes for NET_NAME_USER and NET_NAME_RENAMED. These are the same
> from a kernel point of view.

You mean to collapse the two, and just label renamed interfaces
NET_NAME_USER instead?

> If userspace wants to keep track of device
> name history then it is free to do so without any need for a RENAMED
> type.

Just for the record, I don't see how userspace can keep track of
device name history (as some of the history may predate userspace
being around). Getting the history is not important though, what we
care about is the nature of the current name.

Cheers,

Tom

2014-07-10 10:22:07

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 03/33] net: set name_assign_type in alloc_netdev()

On Thu, Jul 10, 2014 at 11:16 AM, Bjørn Mork <[email protected]> wrote:
> Tom Gundersen <[email protected]> writes:
>
>> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
>> index 5dc638c..f405e05 100644
>> --- a/net/ethernet/eth.c
>> +++ b/net/ethernet/eth.c
>> @@ -390,7 +390,8 @@ EXPORT_SYMBOL(ether_setup);
>> struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
>> unsigned int rxqs)
>> {
>> - return alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs);
>> + return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
>> + ether_setup, txqs, rxqs);
>> }
>> EXPORT_SYMBOL(alloc_etherdev_mqs);
>
> I believe this chunk makes the rest of this exercise pretty pointless.
>
> bjorn@nemi:/usr/local/src/git/linux$ git grep alloc_etherdev drivers/net/|wc -l
> 283
>
> I don't care enough to go look, but I'd be surprised if none of those
> drivers rename the device before registering it.

I did look for that, and I only found devices being renamed to the
same name assign type as eth%d (wlan%d, etc).

Cheers,

Tom

2014-07-10 10:26:28

by David Herrmann

[permalink] [raw]
Subject: Re: [PATCH v7 10/33] net: dummy - set name assign type

Hi

>> The same goes for NET_NAME_USER and NET_NAME_RENAMED. These are the same
>> from a kernel point of view.
>
> You mean to collapse the two, and just label renamed interfaces
> NET_NAME_USER instead?

I have no real objections to merging NAME_USER and NAME_RENAMED. Both
values imply that there is a user-space authority that applied some
kind of rules to the naming-scheme. Therefore, anyone reacting to
those names should better treat them equally and fix the
naming-authority instead of overwriting it.

However, at the same time I think there's no real harm in keeping them
separate, either. My original thinking was to provide a second layer
for anyone overwriting system defaults. For instance, if there's a
user-space given name and a system-administrator wants to rename that
for administrative purposes, they can safely match on NAME_USER and be
sure, it wasn't renamed, yet. If it is set to NAME_RENAMED, though,
then the administrator has some kind of safety-net that tells him he
already has a rule that renamed the device and he shouldn't add
another one (like placing one in initrd and one in the real root).

Anyhow, if no-one cares about that, please go ahead and squash both
into NET_NAME_USER.

Thanks
David

2014-07-10 10:34:20

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 10/33] net: dummy - set name assign type

On Thu, Jul 10, 2014 at 12:26 PM, David Herrmann <[email protected]> wrote:
> Hi
>
>>> The same goes for NET_NAME_USER and NET_NAME_RENAMED. These are the same
>>> from a kernel point of view.
>>
>> You mean to collapse the two, and just label renamed interfaces
>> NET_NAME_USER instead?
>
> I have no real objections to merging NAME_USER and NAME_RENAMED. Both
> values imply that there is a user-space authority that applied some
> kind of rules to the naming-scheme. Therefore, anyone reacting to
> those names should better treat them equally and fix the
> naming-authority instead of overwriting it.

I basically agree. There is no strong reason to keep these separate,
so I would not object strongly to merging them.

However, I also don't see any harm in keeping the distinction. If
userspace wants to treat them the same, it easily can. However, if a
usecase appears in the future where the distinction is important, we
can no longer split them apart again. For that reason, I'd slightly
prefer keeping them separate, unless there is a compelling reason not
to...

Cheers,

Tom

2014-07-10 10:47:20

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 15/33] net: xen-netback - set name assign type

On Thu, Jul 10, 2014 at 11:01 AM, Ian Campbell <[email protected]> wrote:
> On Thu, 2014-07-10 at 10:17 +0200, Tom Gundersen wrote:
>> The name contains then xen handle, which is not guaranteed to be
>> stable between restarts, so label this NET_NAME_ENUM.
>
> FWIW the N'th interface for domain with domid D will always be named
> vifD.N.
>
> If you reboot domain D then it's domid will change to E and the new
> device will be vifE.N.
>
> I don't know if that counts as predictable as far as the interface you
> are introducing is concerned.

That was my understanding, thanks for confirming.

The idea is that the same interface on the same machine must get the
same name between reboots in order to be considered predictable. So
under the assumption that a rebooted domain should be considered "the
same machine" (i.e., it still has the same local configuration,
possibly referencing the interface names), then we should consider the
names not predictable, so NET_NAME_ENUM.

Cheers,

Tom

2014-07-10 10:53:09

by Alexander Aring

[permalink] [raw]
Subject: Re: [PATCH v7 09/33] net: nl802154 - make add_iface take name assign type

On Thu, Jul 10, 2014 at 10:17:14AM +0200, Tom Gundersen wrote:
> Signed-off-by: Tom Gundersen <[email protected]>
> Cc: Dmitry Eremin-Solenikov <[email protected]>
> Cc: [email protected]

Acked-by: Alexander Aring <[email protected]>

- Alex

2014-07-10 11:30:03

by Bjørn Mork

[permalink] [raw]
Subject: Re: [PATCH v7 03/33] net: set name_assign_type in alloc_netdev()

Tom Gundersen <[email protected]> writes:
> On Thu, Jul 10, 2014 at 11:16 AM, Bjørn Mork <[email protected]> wrote:
>> Tom Gundersen <[email protected]> writes:
>>
>>> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
>>> index 5dc638c..f405e05 100644
>>> --- a/net/ethernet/eth.c
>>> +++ b/net/ethernet/eth.c
>>> @@ -390,7 +390,8 @@ EXPORT_SYMBOL(ether_setup);
>>> struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
>>> unsigned int rxqs)
>>> {
>>> - return alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs);
>>> + return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
>>> + ether_setup, txqs, rxqs);
>>> }
>>> EXPORT_SYMBOL(alloc_etherdev_mqs);
>>
>> I believe this chunk makes the rest of this exercise pretty pointless.
>>
>> bjorn@nemi:/usr/local/src/git/linux$ git grep alloc_etherdev drivers/net/|wc -l
>> 283
>>
>> I don't care enough to go look, but I'd be surprised if none of those
>> drivers rename the device before registering it.
>
> I did look for that, and I only found devices being renamed to the
> same name assign type as eth%d (wlan%d, etc).

You explain the vlan patch as follows:

"When deriving the name from the real device, inherit the assign type, otherwise
set PREDICTABLE as the name will be uniquely determined by the VLANID."


How come the same doesn't apply here?:

struct net_device * hostap_add_interface(struct local_info *local,
int type, int rtnl_locked,
const char *prefix,
const char *name)
{
struct net_device *dev, *mdev;
struct hostap_interface *iface;
int ret;

dev = alloc_etherdev(sizeof(struct hostap_interface));
if (dev == NULL)
return NULL;

iface = netdev_priv(dev);
iface->dev = dev;
iface->local = local;
iface->type = type;
list_add(&iface->list, &local->hostap_interfaces);

mdev = local->dev;
eth_hw_addr_inherit(dev, mdev);
dev->base_addr = mdev->base_addr;
dev->irq = mdev->irq;
dev->mem_start = mdev->mem_start;
dev->mem_end = mdev->mem_end;

hostap_setup_dev(dev, local, type);
dev->destructor = free_netdev;

sprintf(dev->name, "%s%s", prefix, name);
..

when this is called as

dev = hostap_add_interface(local, HOSTAP_INTERFACE_WDS, rtnl_locked,
local->ddev->name, "wds%d");

..
local->apdev = hostap_add_interface(local, HOSTAP_INTERFACE_AP,
rtnl_locked, local->ddev->name,
"ap");
..
local->stadev = hostap_add_interface(local, HOSTAP_INTERFACE_STA,
rtnl_locked, local->ddev->name,
"sta");


?

Yes, this is an exception. But so are every instance of alloc_netdev
ending up with something different from NET_NAME_ENUM...

How much would this patchset reduce to if you just set
dev->name_assign_type = NET_NAME_UNKNOWN in alloc_netdev() and changed
it only in the few places where you actually *know* the name_assign_type?

My fear wrt this pathset is that the 'name_assign_type' will end up as
yet another useless field like 'addr_assign_type' and 'type'. There is
no way the kernel will be able to set these with 100% confidence, and
the value is therefore next to nothing. If userspace is stupid enough
to trust them, then you end up with extremely hard to fix errors in the
cases where the driver/kernel guesswork is wrong.

Just one example of this, affecting the 'type': Huawei happens to use
the same device IDs for modems requiring userspace management (should
have a wwan_type) and modems with built-in management (should have a
default type). So which 'type' should we choose for this device?
userspace can figure out by careful probing, but if it trusts the 'type'
set by the driver then it will get it wrong. The field provides no value
at all.

But if you limit the scope of the 'name_assign_type' patches to only
those cases where you actually have some information, then I guess it
might provide some value for userspace.


Bjørn

2014-07-10 11:45:39

by Bjørn Mork

[permalink] [raw]
Subject: Re: [PATCH v7 10/33] net: dummy - set name assign type

Tom Gundersen <[email protected]> writes:

> The result of
>
> modprobe dummy numdummies=2
>
> is to create dummy0 and dummy1, always with the same names.
>
> The result of
>
> ip link add type dummy
>
> is to create dummyX, where X depends on what came before.

Which is no different. That's exacly what happens when
"modprobe dummy numdummies=2" creates the two first interfaces.


ip link add link wwan0 name dummy0 type vlan id 2
modprobe dummy numdummies=2

ends up with dummy1 and dummy2 created by the dummy driver.

You are trying to make up differences that just aren't there.



Bjørn

2014-07-10 12:13:23

by Ian Campbell

[permalink] [raw]
Subject: Re: [PATCH v7 15/33] net: xen-netback - set name assign type

On Thu, 2014-07-10 at 12:46 +0200, Tom Gundersen wrote:
> On Thu, Jul 10, 2014 at 11:01 AM, Ian Campbell <[email protected]> wrote:
> > On Thu, 2014-07-10 at 10:17 +0200, Tom Gundersen wrote:
> >> The name contains then xen handle, which is not guaranteed to be
> >> stable between restarts, so label this NET_NAME_ENUM.
> >
> > FWIW the N'th interface for domain with domid D will always be named
> > vifD.N.
> >
> > If you reboot domain D then it's domid will change to E and the new
> > device will be vifE.N.
> >
> > I don't know if that counts as predictable as far as the interface you
> > are introducing is concerned.
>
> That was my understanding, thanks for confirming.
>
> The idea is that the same interface on the same machine must get the
> same name between reboots in order to be considered predictable. So
> under the assumption that a rebooted domain should be considered "the
> same machine" (i.e., it still has the same local configuration,
> possibly referencing the interface names), then we should consider the
> names not predictable, so NET_NAME_ENUM.

OK, thanks. I'll defer to you understanding of what this interface is
supposed to mean: Acked-by: Ian Campbell <[email protected]>

Ian.

2014-07-10 12:18:55

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 10/33] net: dummy - set name assign type

On Thu, Jul 10, 2014 at 1:44 PM, Bjørn Mork <[email protected]> wrote:
> Tom Gundersen <[email protected]> writes:
>
>> The result of
>>
>> modprobe dummy numdummies=2
>>
>> is to create dummy0 and dummy1, always with the same names.
>>
>> The result of
>>
>> ip link add type dummy
>>
>> is to create dummyX, where X depends on what came before.
>
> Which is no different. That's exacly what happens when
> "modprobe dummy numdummies=2" creates the two first interfaces.
>
>
> ip link add link wwan0 name dummy0 type vlan id 2
> modprobe dummy numdummies=2
>
> ends up with dummy1 and dummy2 created by the dummy driver.
>
> You are trying to make up differences that just aren't there.

Ah, good point. You are right. So the dummy interfaces should be
labelled NET_NAME_ENUM.

I suppose the distinction should be that statically created devices
like these should be NET_NAME_PREDICTABLE only if they fail when the
name they want is already taken (rather than just picking the next
one).

Thanks for looking into this!

Cheers,

Tom

2014-07-10 13:03:05

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 03/33] net: set name_assign_type in alloc_netdev()

On Thu, Jul 10, 2014 at 1:29 PM, Bjørn Mork <[email protected]> wrote:
> Tom Gundersen <[email protected]> writes:
>> On Thu, Jul 10, 2014 at 11:16 AM, Bjørn Mork <[email protected]> wrote:
>>> Tom Gundersen <[email protected]> writes:
>>>
>>>> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
>>>> index 5dc638c..f405e05 100644
>>>> --- a/net/ethernet/eth.c
>>>> +++ b/net/ethernet/eth.c
>>>> @@ -390,7 +390,8 @@ EXPORT_SYMBOL(ether_setup);
>>>> struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
>>>> unsigned int rxqs)
>>>> {
>>>> - return alloc_netdev_mqs(sizeof_priv, "eth%d", ether_setup, txqs, rxqs);
>>>> + return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
>>>> + ether_setup, txqs, rxqs);
>>>> }
>>>> EXPORT_SYMBOL(alloc_etherdev_mqs);
>>>
>>> I believe this chunk makes the rest of this exercise pretty pointless.
>>>
>>> bjorn@nemi:/usr/local/src/git/linux$ git grep alloc_etherdev drivers/net/|wc -l
>>> 283
>>>
>>> I don't care enough to go look, but I'd be surprised if none of those
>>> drivers rename the device before registering it.
>>
>> I did look for that, and I only found devices being renamed to the
>> same name assign type as eth%d (wlan%d, etc).
>
> You explain the vlan patch as follows:
>
> "When deriving the name from the real device, inherit the assign type, otherwise
> set PREDICTABLE as the name will be uniquely determined by the VLANID."
>
>
> How come the same doesn't apply here?:
>
> struct net_device * hostap_add_interface(struct local_info *local,
> int type, int rtnl_locked,
> const char *prefix,
> const char *name)
> {
> struct net_device *dev, *mdev;
> struct hostap_interface *iface;
> int ret;
>
> dev = alloc_etherdev(sizeof(struct hostap_interface));
> if (dev == NULL)
> return NULL;
>
> iface = netdev_priv(dev);
> iface->dev = dev;
> iface->local = local;
> iface->type = type;
> list_add(&iface->list, &local->hostap_interfaces);
>
> mdev = local->dev;
> eth_hw_addr_inherit(dev, mdev);
> dev->base_addr = mdev->base_addr;
> dev->irq = mdev->irq;
> dev->mem_start = mdev->mem_start;
> dev->mem_end = mdev->mem_end;
>
> hostap_setup_dev(dev, local, type);
> dev->destructor = free_netdev;
>
> sprintf(dev->name, "%s%s", prefix, name);
> ..
>
> when this is called as
>
> dev = hostap_add_interface(local, HOSTAP_INTERFACE_WDS, rtnl_locked,
> local->ddev->name, "wds%d");
>
> ..
> local->apdev = hostap_add_interface(local, HOSTAP_INTERFACE_AP,
> rtnl_locked, local->ddev->name,
> "ap");
> ..
> local->stadev = hostap_add_interface(local, HOSTAP_INTERFACE_STA,
> rtnl_locked, local->ddev->name,
> "sta");
>
>
> ?
>
> Yes, this is an exception. But so are every instance of alloc_netdev
> ending up with something different from NET_NAME_ENUM...

Indeed, I missed this case. And given I missed that one, you are
probably right there are others.

> How much would this patchset reduce to if you just set
> dev->name_assign_type = NET_NAME_UNKNOWN in alloc_netdev() and changed
> it only in the few places where you actually *know* the name_assign_type?

This is what David Herrmann's initial patch-set did. I do tend to
agree with David Miller that changing the alloc_netdev() API makes it
easier to review which cases we have covered, and which remain.

I agree that we should absolutely leave NET_NAME_UNKNOWN in the places
where we are not certain though.

> My fear wrt this pathset is that the 'name_assign_type' will end up as
> yet another useless field like 'addr_assign_type' and 'type'. There is
> no way the kernel will be able to set these with 100% confidence, and
> the value is therefore next to nothing. If userspace is stupid enough
> to trust them, then you end up with extremely hard to fix errors in the
> cases where the driver/kernel guesswork is wrong.

Well, if the kernel doesn't know, then userspace certainly does not.
So I think the best thing we can do is to expose this information as
best we can from the kernel, and make userspace follow. That said, I'm
absolutely ok with the kernel exposing "don't know", and let userspace
deal with that as best they can (which probably means it will assume
the kernel name (or hwaddr) is useless and assign its own).

> Just one example of this, affecting the 'type': Huawei happens to use
> the same device IDs for modems requiring userspace management (should
> have a wwan_type) and modems with built-in management (should have a
> default type). So which 'type' should we choose for this device?
> userspace can figure out by careful probing, but if it trusts the 'type'
> set by the driver then it will get it wrong. The field provides no value
> at all.

Sounds to me the kernel in this case should simply set some other type
indicating "don't know"?

> But if you limit the scope of the 'name_assign_type' patches to only
> those cases where you actually have some information, then I guess it
> might provide some value for userspace.

What I suggest to do is:

Leave NET_NAME_UNKNOWN in alloc_etherdev() (and any similar
constructs), but in the cases where we know that the final name set
before netdev_register() is some template, I'd still set this to
NET_NAME_ENUM as we do now to make it clear which cases have been
reviewed. So the patchset does not change much, but it would eliminate
any risk of false positives.

Does that sound reasonable to you?

Cheers,

Tom

2014-07-10 13:27:29

by Bjørn Mork

[permalink] [raw]
Subject: Re: [PATCH v7 03/33] net: set name_assign_type in alloc_netdev()

Tom Gundersen <[email protected]> writes:

> What I suggest to do is:
>
> Leave NET_NAME_UNKNOWN in alloc_etherdev() (and any similar
> constructs), but in the cases where we know that the final name set
> before netdev_register() is some template, I'd still set this to
> NET_NAME_ENUM as we do now to make it clear which cases have been
> reviewed. So the patchset does not change much, but it would eliminate
> any risk of false positives.
>
> Does that sound reasonable to you?

Yes, sure. Although I'm not at all convinced about the value. But I
don't need to be, as that is not for me to decide :-)



Bjørn

2014-07-10 15:53:35

by Nicolas Dichtel

[permalink] [raw]
Subject: Re: [PATCH v7 01/33] net: add name_assign_type netdev attribute

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 <[email protected]>
> Reviewed-by: David Herrmann <[email protected]>
> Reviewed-by: Kay Sievers <[email protected]>
> ---
> 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: [email protected]
> +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.

2014-07-10 19:12:09

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 00/33] Provide netdev naming-policy via sysfs

On Thu, Jul 10, 2014 at 11:19 AM, Tom Gundersen <[email protected]> wrote:
> Thanks for the quick answer.
>
> On Thu, Jul 10, 2014 at 10:43 AM, David Miller <[email protected]> wrote:
>> It is not reasonable to expect people to review such a large number of
>> patches at one time.
>>
>> Split your series up into logical, and more reasonably sized chunks.
>>
>> I'd say 14 or 15 at a time is the limit.
>>
>> I'm not even looking at this series until you submit it more reasonably.
>>
>> Thank you.
>
> Ok. I suggest you review patches 1-7, as these are the generic ones.
> Then once they have been applied I can resubmit the subsequent patches
> individually.
>
> Do you want me to resubmit patches 1-7, or do you just want to pick
> them from this series as they are?

I'll redo the first few patches based on the comments received so far,
and resend them in a shorter series, so no need to review the current
one.

Thanks.

Tom

2014-07-10 19:19:41

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v7 00/33] Provide netdev naming-policy via sysfs

From: Tom Gundersen <[email protected]>
Date: Thu, 10 Jul 2014 11:19:42 +0200

> Thanks for the quick answer.
>
> On Thu, Jul 10, 2014 at 10:43 AM, David Miller <[email protected]> wrote:
>> It is not reasonable to expect people to review such a large number of
>> patches at one time.
>>
>> Split your series up into logical, and more reasonably sized chunks.
>>
>> I'd say 14 or 15 at a time is the limit.
>>
>> I'm not even looking at this series until you submit it more reasonably.
>>
>> Thank you.
>
> Ok. I suggest you review patches 1-7, as these are the generic ones.
> Then once they have been applied I can resubmit the subsequent patches
> individually.
>
> Do you want me to resubmit patches 1-7, or do you just want to pick
> them from this series as they are?

I said submit it more reasonably, what do you think that means?

2014-07-10 19:58:51

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH v7 01/33] net: add name_assign_type netdev attribute

On 10-07-14 10:17, Tom Gundersen wrote:
> 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 <[email protected]>
> Reviewed-by: David Herrmann <[email protected]>
> Reviewed-by: Kay Sievers <[email protected]>
> ---
> 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

Is this a copy&paste error. I guess it will be 3.17+, right?

> +Contact: [email protected]
> +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 */
> +#define NET_NAME_USER 3 /* provided by user-space */
> +#define NET_NAME_RENAMED 4 /* renamed by user-space */
>
> /* Media selection options. */
> enum {
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 1cac29e..7752f2a 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -112,6 +112,25 @@ NETDEVICE_SHOW_RO(ifindex, fmt_dec);
> NETDEVICE_SHOW_RO(type, fmt_dec);
> NETDEVICE_SHOW_RO(link_mode, fmt_dec);
>
> +static ssize_t format_name_assign_type(const struct net_device *net, char *buf)
> +{
> + return sprintf(buf, fmt_dec, net->name_assign_type);
> +}
> +
> +static ssize_t name_assign_type_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct net_device *net = to_net_dev(dev);
> + ssize_t ret = -EINVAL;
> +
> + if (net->name_assign_type != NET_NAME_UNKNOWN)
> + ret = netdev_show(dev, attr, buf, format_name_assign_type);
> +
> + return ret;
> +}
> +static DEVICE_ATTR_RO(name_assign_type);
> +
> /* use same locking rules as GIFHWADDR ioctl's */
> static ssize_t address_show(struct device *dev, struct device_attribute *attr,
> char *buf)
> @@ -387,6 +406,7 @@ static struct attribute *net_class_attrs[] = {
> &dev_attr_dev_port.attr,
> &dev_attr_iflink.attr,
> &dev_attr_ifindex.attr,
> + &dev_attr_name_assign_type.attr,
> &dev_attr_addr_assign_type.attr,
> &dev_attr_addr_len.attr,
> &dev_attr_link_mode.attr,
>

2014-07-10 20:00:46

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 01/33] net: add name_assign_type netdev attribute

On Thu, Jul 10, 2014 at 5:53 PM, Nicolas Dichtel
<[email protected]> wrote:
> 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 <[email protected]>
>> Reviewed-by: David Herrmann <[email protected]>
>> Reviewed-by: Kay Sievers <[email protected]>
>> ---
>> 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: [email protected]
>> +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.

Indeed. Fixed.

Thanks.

Tom

2014-07-10 20:01:25

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 01/33] net: add name_assign_type netdev attribute

On Thu, Jul 10, 2014 at 9:58 PM, Arend van Spriel <[email protected]> wrote:
> On 10-07-14 10:17, Tom Gundersen wrote:
>> 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 <[email protected]>
>> Reviewed-by: David Herrmann <[email protected]>
>> Reviewed-by: Kay Sievers <[email protected]>
>> ---
>> 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
>
> Is this a copy&paste error. I guess it will be 3.17+, right?

Yeah. Fixed that one too.

Thanks.

Tom

>> +Contact: [email protected]
>> +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 */
>> +#define NET_NAME_USER 3 /* provided by user-space */
>> +#define NET_NAME_RENAMED 4 /* renamed by user-space */
>>
>> /* Media selection options. */
>> enum {
>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>> index 1cac29e..7752f2a 100644
>> --- a/net/core/net-sysfs.c
>> +++ b/net/core/net-sysfs.c
>> @@ -112,6 +112,25 @@ NETDEVICE_SHOW_RO(ifindex, fmt_dec);
>> NETDEVICE_SHOW_RO(type, fmt_dec);
>> NETDEVICE_SHOW_RO(link_mode, fmt_dec);
>>
>> +static ssize_t format_name_assign_type(const struct net_device *net, char *buf)
>> +{
>> + return sprintf(buf, fmt_dec, net->name_assign_type);
>> +}
>> +
>> +static ssize_t name_assign_type_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + struct net_device *net = to_net_dev(dev);
>> + ssize_t ret = -EINVAL;
>> +
>> + if (net->name_assign_type != NET_NAME_UNKNOWN)
>> + ret = netdev_show(dev, attr, buf, format_name_assign_type);
>> +
>> + return ret;
>> +}
>> +static DEVICE_ATTR_RO(name_assign_type);
>> +
>> /* use same locking rules as GIFHWADDR ioctl's */
>> static ssize_t address_show(struct device *dev, struct device_attribute *attr,
>> char *buf)
>> @@ -387,6 +406,7 @@ static struct attribute *net_class_attrs[] = {
>> &dev_attr_dev_port.attr,
>> &dev_attr_iflink.attr,
>> &dev_attr_ifindex.attr,
>> + &dev_attr_name_assign_type.attr,
>> &dev_attr_addr_assign_type.attr,
>> &dev_attr_addr_len.attr,
>> &dev_attr_link_mode.attr,
>>
>

2014-07-10 20:08:23

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH v7 29/33] net: brcmfmac - set name assign type

On 10-07-14 10:17, Tom Gundersen wrote:
> The name is given by the firmware, so we assume it is predictable.

How about the scenario where one would have multiple broadcom wifi
devices in the system. Both driver instances would alloc_netdev with
predictable but also the same ifname. Wondering whether we should ignore
the firmware ifname altogether.

Regards,
Arend

> Signed-off-by: Tom Gundersen <[email protected]>
> Cc: Brett Rudley <[email protected]>
> Cc: Arend van Spriel <[email protected]>
> Cc: "Franky (Zhenhui) Lin" <[email protected]>
> Cc: Hante Meuleman <[email protected]>
> Cc: John Linville <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
> index f6990f2..8d32721 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
> @@ -201,7 +201,8 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
> brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
> emsg->addr);
> ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
> - emsg->ifname, NET_NAME_UNKNOWN, emsg->addr);
> + emsg->ifname, NET_NAME_PREDICTABLE,
> + emsg->addr);
> if (IS_ERR(ifp))
> return;
> brcmf_fws_add_interface(ifp);
>

2014-07-10 20:25:10

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 29/33] net: brcmfmac - set name assign type

On Thu, Jul 10, 2014 at 10:08 PM, Arend van Spriel <[email protected]> wrote:
> On 10-07-14 10:17, Tom Gundersen wrote:
>> The name is given by the firmware, so we assume it is predictable.
>
> How about the scenario where one would have multiple broadcom wifi
> devices in the system. Both driver instances would alloc_netdev with
> predictable but also the same ifname. Wondering whether we should ignore
> the firmware ifname altogether.

Hm, that would just fail irrespective of this patch, right? Sounds
like ignoring the firmware names is the right thing to do.

Cheers,

Tom

2014-07-11 07:46:31

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH v7 29/33] net: brcmfmac - set name assign type

On 10-07-14 22:24, Tom Gundersen wrote:
> On Thu, Jul 10, 2014 at 10:08 PM, Arend van Spriel <[email protected]> wrote:
>> On 10-07-14 10:17, Tom Gundersen wrote:
>>> The name is given by the firmware, so we assume it is predictable.
>>
>> How about the scenario where one would have multiple broadcom wifi
>> devices in the system. Both driver instances would alloc_netdev with
>> predictable but also the same ifname. Wondering whether we should ignore
>> the firmware ifname altogether.
>
> Hm, that would just fail irrespective of this patch, right? Sounds
> like ignoring the firmware names is the right thing to do.

True. I realized that when starting to type my reply. I think at the
moment we never run into the scenario that trigger this code path. Will
make a separate patch for that. Probably on top of your changes.

Regards,
Arend

> Cheers,
>
> Tom
>

2014-07-15 19:45:17

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH v7 29/33] net: brcmfmac - set name assign type

I don't seem to have a line with "NET_NAME_UNKNOWN" in this driver
in any of my kernel trees. What tree are you using for development?

On Thu, Jul 10, 2014 at 10:17:34AM +0200, Tom Gundersen wrote:
> The name is given by the firmware, so we assume it is predictable.
>
> Signed-off-by: Tom Gundersen <[email protected]>
> Cc: Brett Rudley <[email protected]>
> Cc: Arend van Spriel <[email protected]>
> Cc: "Franky (Zhenhui) Lin" <[email protected]>
> Cc: Hante Meuleman <[email protected]>
> Cc: John Linville <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
> index f6990f2..8d32721 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
> @@ -201,7 +201,8 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
> brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
> emsg->addr);
> ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
> - emsg->ifname, NET_NAME_UNKNOWN, emsg->addr);
> + emsg->ifname, NET_NAME_PREDICTABLE,
> + emsg->addr);
> if (IS_ERR(ifp))
> return;
> brcmf_fws_add_interface(ifp);
> --
> 1.9.3
>
>

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2014-07-15 19:57:58

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 29/33] net: brcmfmac - set name assign type

On Tue, Jul 15, 2014 at 9:39 PM, John W. Linville
<[email protected]> wrote:
> I don't seem to have a line with "NET_NAME_UNKNOWN" in this driver
> in any of my kernel trees. What tree are you using for development?

This was patch part of the series introducing NET_NAME_UNKNOWN [0].
I'll resubmit this patch once the earlier patches introducing the
infrastructure have been applied.

Cheers,

Tom

[0]: <https://lkml.org/lkml/2014/7/10/94>.

> On Thu, Jul 10, 2014 at 10:17:34AM +0200, Tom Gundersen wrote:
>> The name is given by the firmware, so we assume it is predictable.
>>
>> Signed-off-by: Tom Gundersen <[email protected]>
>> Cc: Brett Rudley <[email protected]>
>> Cc: Arend van Spriel <[email protected]>
>> Cc: "Franky (Zhenhui) Lin" <[email protected]>
>> Cc: Hante Meuleman <[email protected]>
>> Cc: John Linville <[email protected]>
>> Cc: [email protected]
>> Cc: [email protected]
>> ---
>> drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
>> index f6990f2..8d32721 100644
>> --- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
>> +++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
>> @@ -201,7 +201,8 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
>> brcmf_dbg(EVENT, "adding %s (%pM)\n", emsg->ifname,
>> emsg->addr);
>> ifp = brcmf_add_if(drvr, ifevent->bssidx, ifevent->ifidx,
>> - emsg->ifname, NET_NAME_UNKNOWN, emsg->addr);
>> + emsg->ifname, NET_NAME_PREDICTABLE,
>> + emsg->addr);
>> if (IS_ERR(ifp))
>> return;
>> brcmf_fws_add_interface(ifp);
>> --
>> 1.9.3
>>
>>
>
> --
> John W. Linville Someday the world will need a hero, and you
> [email protected] might be all we have. Be ready.

2014-07-16 17:49:53

by Chris Metcalf

[permalink] [raw]
Subject: Re: [PATCH v7 27/33] net: tile - set name assign type

On 7/10/2014 4:23 AM, Tom Gundersen wrote:
> The name is obtained from the 'hardware', so consider it predictable.
>
> Signed-off-by: Tom Gundersen<[email protected]>
> Cc: Chris Metcalf<[email protected]>
> ---
> drivers/net/ethernet/tile/tilegx.c | 7 ++++---
> drivers/net/ethernet/tile/tilepro.c | 13 +++++++------
> 2 files changed, 11 insertions(+), 9 deletions(-)

Acked-by: Chris Metcalf <[email protected]>

--
Chris Metcalf, Tilera Corp.
http://www.tilera.com

2014-07-21 09:40:31

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v7 08/33] net: nl80211 - make rdev_add_virtual_intf take name_assign_type

On Thu, 2014-07-10 at 10:17 +0200, Tom Gundersen wrote:
> Pass the value down and set it at the same place the name itself is set.

Is this going to be applied as part of one bigger series?

johannes

2014-07-21 17:03:26

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH v7 08/33] net: nl80211 - make rdev_add_virtual_intf take name_assign_type

Hi Johannes,

On Mon, Jul 21, 2014 at 11:40 AM, Johannes Berg
<[email protected]> wrote:
> On Thu, 2014-07-10 at 10:17 +0200, Tom Gundersen wrote:
>> Pass the value down and set it at the same place the name itself is set.
>
> Is this going to be applied as part of one bigger series?

This patch is superceded by "[PATCH net-next v9 2/9] net: nl80211 -
make rdev_add_virtual_intf take name_assign_type", which indeed is
part of a bigger series.

However, if you and David prefer to take it through your tree, let me
know and I'll split it out from the series and resubmit it to you
independently.

Cheers,

Tom