2014-07-17 08:06:32

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 0/9] net: set the correct name_assign_type for more devices

These patches give name assign types to the vast majority of outstanding devices.

Patch 1: give devices with static device names ("lo", etc) the type NET_NAME_PREDICTABLE
Patch 2-3: give devices created over netlink (in particular Wifi-P2P, which is currently
a problem) the correct name assign type
Patch 4: do the same for devices created via ioctls
Patch 5-9: cover a few individual drivers

More individual drivers will be converted in a follow-up series.

Tom Gundersen (9):
net: set name assign type for names assigned using a static string
net: nl80211 - make rdev_add_virtual_intf take name_assign_type
net: nl802154 - make add_iface take name assign type
net: set name_assign_type when setting names via ioctls
net: bond - make bond_create take name_assign_type
net: isdn - set name assign type
net: vlan - set name assign type
net: openvswitch - set name assign type
net: ppp - set name assign type

drivers/isdn/i4l/isdn_common.c | 4 ++--
drivers/isdn/i4l/isdn_net.c | 10 +++++-----
drivers/isdn/i4l/isdn_net.h | 4 ++--
drivers/media/dvb-core/dvb_net.c | 2 +-
drivers/misc/sgi-xp/xpnet.c | 2 +-
drivers/net/bonding/bond_main.c | 7 ++++---
drivers/net/bonding/bond_sysfs.c | 2 +-
drivers/net/bonding/bonding.h | 2 +-
drivers/net/caif/caif_virtio.c | 2 +-
drivers/net/eql.c | 4 ++--
drivers/net/loopback.c | 2 +-
drivers/net/ppp/ppp_generic.c | 1 +
drivers/net/tun.c | 9 ++++++---
drivers/net/wan/sbni.c | 2 +-
drivers/net/wan/sdla.c | 4 ++--
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/s390/net/ctcm_main.c | 4 ++--
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 6 +++++-
drivers/staging/vt6655/wpactl.c | 2 +-
drivers/tty/n_gsm.c | 10 +++++++---
include/net/cfg80211.h | 1 +
include/net/wpan-phy.h | 4 +++-
net/8021q/vlan.c | 7 ++++++-
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/ieee802154/nl-phy.c | 5 ++++-
net/ipv6/ip6_gre.c | 2 +-
net/ipv6/ip6_tunnel.c | 3 ++-
net/ipv6/ip6_vti.c | 2 +-
net/ipv6/sit.c | 2 +-
net/mac80211/cfg.c | 3 ++-
net/mac80211/ieee80211_i.h | 1 +
net/mac80211/iface.c | 3 ++-
net/mac80211/main.c | 2 +-
net/mac802154/ieee802154_dev.c | 7 ++++---
net/openvswitch/vport-internal_dev.c | 2 +-
net/wireless/nl80211.c | 3 ++-
net/wireless/rdev-ops.h | 5 +++--
52 files changed, 120 insertions(+), 73 deletions(-)

--
1.9.3


2014-07-17 08:06:46

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 2/9] 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 a8998eb..4c27a78 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
@@ -171,7 +171,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 588fdbd..0c1e26a 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 9682cf2..7d7dda4 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -566,6 +566,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)
@@ -583,7 +584,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 ca87f92..fae2a4a 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -2114,10 +2114,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)
@@ -2232,7 +2233,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 3e5194f..f1b7e1d 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 a2733b1..7e75ec45 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -1224,6 +1224,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 0a080c4..26450ac 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2321,6 +2321,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 927b4ea..1573258 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 9e025e1..fdbd4472 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1523,6 +1523,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 4edfc7c..29ec67c 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1597,6 +1597,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)
{
@@ -1625,7 +1626,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 e0ab432..7929996 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1019,7 +1019,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 082f5c6..18c5c1d 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 56c2240..8f28587 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-17 08:06:53

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 1/9] 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 758c4ba..ea8ef51 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 5f19dfb..563238e 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1327,7 +1327,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 f9de5a6..b694d7c 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1774,7 +1774,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-17 08:07:46

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 6/9] 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-17 08:07:55

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 9/9] net: ppp - set name assign type

The ifname is of the form pppX where X is the unit number. This is either 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 c38ee90..6526057 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2728,6 +2728,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-17 08:08:04

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 8/9] net: openvswitch - set name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Pravin Shelar <[email protected]>
Cc: [email protected]
---

v9: set NET_NAME_USER directly in internal_dev_create as requested by Pravin Shelar

net/openvswitch/vport-internal_dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index bd65855..2741285 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -165,7 +165,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, NET_NAME_USER,
do_setup);
if (!netdev_vport->dev) {
err = -ENOMEM;
--
1.9.3

2014-07-17 08:07:57

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 7/9] 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..cf88f7b 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -212,6 +212,7 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
{
struct net_device *new_dev;
struct vlan_dev_priv *vlan;
+ unsigned char name_assign_type;
struct net *net = dev_net(real_dev);
struct vlan_net *vn = net_generic(net, vlan_net_id);
char name[IFNAMSIZ];
@@ -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-17 08:09:39

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 5/9] net: bond - make bond_create take name_assign_type

Signed-off-by: Tom Gundersen <[email protected]>
Cc: Jay Vosburgh <[email protected]>
Cc: Veaceslav Falico <[email protected]>
Cc: Andy Gospodarek <[email protected]>
---
drivers/net/bonding/bond_main.c | 7 ++++---
drivers/net/bonding/bond_sysfs.c | 2 +-
drivers/net/bonding/bonding.h | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index d643807..1769745 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4421,7 +4421,7 @@ unsigned int bond_get_num_tx_queues(void)
* Caller must NOT hold rtnl_lock; we need to release it here before we
* set up our sysfs entries.
*/
-int bond_create(struct net *net, const char *name)
+int bond_create(struct net *net, const char *name, unsigned char name_assign_type)
{
struct net_device *bond_dev;
int res;
@@ -4429,7 +4429,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 ? name_assign_type : NET_NAME_ENUM,
bond_setup, tx_queues);
if (!bond_dev) {
pr_err("%s: eek! can't alloc netdev!\n", name);
@@ -4509,7 +4510,7 @@ static int __init bonding_init(void)
bond_create_debugfs();

for (i = 0; i < max_bonds; i++) {
- res = bond_create(&init_net, NULL);
+ res = bond_create(&init_net, NULL, NET_NAME_UNKNOWN);
if (res)
goto err;
}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 98db8ed..7ac498c 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -111,7 +111,7 @@ static ssize_t bonding_store_bonds(struct class *cls,

if (command[0] == '+') {
pr_info("%s is being created...\n", ifname);
- rv = bond_create(bn->net, ifname);
+ rv = bond_create(bn->net, ifname, NET_NAME_USER);
if (rv) {
if (rv == -EEXIST)
pr_info("%s already exists\n", ifname);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index b2e548e..95b5e70 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -496,7 +496,7 @@ struct bond_net {

int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
-int bond_create(struct net *net, const char *name);
+int bond_create(struct net *net, const char *name, unsigned char name_assign_type);
int bond_create_sysfs(struct bond_net *net);
void bond_destroy_sysfs(struct bond_net *net);
void bond_prepare_sysfs_group(struct bonding *bond);
--
1.9.3

2014-07-17 08:09:44

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 3/9] net: nl802154 - make add_iface take name assign type

Signed-off-by: Tom Gundersen <[email protected]>
Acked-by: Alexander Aring <[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 972baf8..5e1a28e 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 b36b2b9..cee12b2 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -159,7 +159,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;
@@ -167,12 +168,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-17 08:09:50

by Tom Gundersen

[permalink] [raw]
Subject: [PATCH net-next v9 4/9] net: set name_assign_type when setting names via ioctls

When the user provides a name, set NET_NAME_USER, otherwise an enumerated
name is used, so set NET_NAME_ENUM.

Signed-off-by: Tom Gundersen <[email protected]>
---
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 +-
7 files changed, 24 insertions(+), 15 deletions(-)

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 62a7fa2..5adc136 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);
--
1.9.3

2014-07-17 09:04:40

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH net-next v9 2/9] net: nl80211 - make rdev_add_virtual_intf take name_assign_type

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

Huh? What's this? Can you explain why?

> static struct wireless_dev *ath6kl_cfg80211_add_iface(struct wiphy *wiphy,
> const char *name,
> + unsigned char name_assign_type,

unsigned char for an enum is really odd.

johannes

2014-07-17 09:17:22

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH net-next v9 2/9] net: nl80211 - make rdev_add_virtual_intf take name_assign_type

On Thu, Jul 17, 2014 at 11:04 AM, Johannes Berg
<[email protected]> wrote:
> On Thu, 2014-07-17 at 10:06 +0200, Tom Gundersen wrote:
>> Pass the value down and set it at the same place the name itself is set.
>
> Huh? What's this? Can you explain why?

Sure, sorry the context got lost.

We want to expose the origin of ifnames so that udev can better decide
whether or not to rename them. In particular, this patch will allow
udev to tell that it should no longer rename Wifi-P2P devices, which
is currently a problem.

A general overview is in the patch introducing the interface:
<http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=685343fc3ba61a1f6eef361b786601123db16c28>.

>> static struct wireless_dev *ath6kl_cfg80211_add_iface(struct wiphy *wiphy,
>> const char *name,
>> + unsigned char name_assign_type,
>
> unsigned char for an enum is really odd.

Hm, this was based on the addr_assign_type attribute, which also is an
unsigned char (and serves a very similar purpose).

Out of interest, what would you have preferred (and why)?

Cheers,

Tom

2014-07-17 09:23:20

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH net-next v9 2/9] net: nl80211 - make rdev_add_virtual_intf take name_assign_type

On Thu, 2014-07-17 at 11:16 +0200, Tom Gundersen wrote:

> >> static struct wireless_dev *ath6kl_cfg80211_add_iface(struct wiphy *wiphy,
> >> const char *name,
> >> + unsigned char name_assign_type,
> >
> > unsigned char for an enum is really odd.
>
> Hm, this was based on the addr_assign_type attribute, which also is an
> unsigned char (and serves a very similar purpose).
>
> Out of interest, what would you have preferred (and why)?

Even if it eventually ends up being assigned to a u8 or something, it
seems passing it around as an enum makes the interfaces better?

johannes

2014-07-17 18:22:24

by Pravin Shelar

[permalink] [raw]
Subject: Re: [PATCH net-next v9 8/9] net: openvswitch - set name assign type

On Thu, Jul 17, 2014 at 1:06 AM, Tom Gundersen <[email protected]> wrote:
> Signed-off-by: Tom Gundersen <[email protected]>
> Cc: Pravin Shelar <[email protected]>
> Cc: [email protected]
Looks good.

Acked-by: Pravin B Shelar <[email protected]>

> ---
>
> v9: set NET_NAME_USER directly in internal_dev_create as requested by Pravin Shelar
>
> net/openvswitch/vport-internal_dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
> index bd65855..2741285 100644
> --- a/net/openvswitch/vport-internal_dev.c
> +++ b/net/openvswitch/vport-internal_dev.c
> @@ -165,7 +165,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, NET_NAME_USER,
> do_setup);
> if (!netdev_vport->dev) {
> err = -ENOMEM;
> --
> 1.9.3
>

2014-07-17 23:19:33

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next v9 3/9] net: nl802154 - make add_iface take name assign type

From: Tom Gundersen <[email protected]>
Date: Thu, 17 Jul 2014 10:06:04 +0200

> @@ -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)

Just wondering what should happen if "%d" appears in a user provided name.

That would seem to be both USER and ENUM.

2014-07-17 23:20:42

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next v9 4/9] net: set name_assign_type when setting names via ioctls

From: Tom Gundersen <[email protected]>
Date: Thu, 17 Jul 2014 10:06:05 +0200

> @@ -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);

The indentation is now not correct. For a function call, all arguments on the
second and subsequent line, must start exactly at the first column after the
openning parenthesis of the function call.

2014-07-18 08:18:28

by Alexander Aring

[permalink] [raw]
Subject: Re: [Linux-zigbee-devel] [PATCH net-next v9 3/9] net: nl802154 - make add_iface take name assign type

On Thu, Jul 17, 2014 at 04:19:31PM -0700, David Miller wrote:
> From: Tom Gundersen <[email protected]>
> Date: Thu, 17 Jul 2014 10:06:04 +0200
>
> > @@ -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)
>
> Just wondering what should happen if "%d" appears in a user provided name.
>

I tested it. If I use a name like "foobar%d" then I get a foobar0,
foobar1 ... foobarX.

> That would seem to be both USER and ENUM.
>

yes.


- Alex

2014-07-18 08:30:22

by David Laight

[permalink] [raw]
Subject: RE: [PATCH net-next v9 3/9] net: nl802154 - make add_iface take name assign type

From: David Miller
> From: Tom Gundersen <[email protected]>
> Date: Thu, 17 Jul 2014 10:06:04 +0200
>
> > @@ -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)
>
> Just wondering what should happen if "%d" appears in a user provided name.
>
> That would seem to be both USER and ENUM.

Is a training %d detected by special code?
Or is the string used as a printf format?
If the latter is true what happens if the user provides foo%s

David


2014-07-18 08:41:57

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH net-next v9 3/9] net: nl802154 - make add_iface take name assign type

On Fri, Jul 18, 2014 at 1:19 AM, David Miller <[email protected]> wrote:
> From: Tom Gundersen <[email protected]>
> Date: Thu, 17 Jul 2014 10:06:04 +0200
>
>> @@ -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)
>
> Just wondering what should happen if "%d" appears in a user provided name.
>
> That would seem to be both USER and ENUM.

Yes, this is a bit of a grey area.

I discussed this a bit with David Herrmann, and we landed on that
these names should be USER. As the user has explicitly asked for the
enumerated name, nobody should rename them to anything else (so ENUM
would have the wrong effect as it indicates that userspace should
rename the device), moreover, we should assume that the user knows
what they are doing, and that the enumerated names are fine in this
context.

Cheers,

Tom

2014-07-18 08:59:27

by Tom Gundersen

[permalink] [raw]
Subject: Re: [PATCH net-next v9 4/9] net: set name_assign_type when setting names via ioctls

On Fri, Jul 18, 2014 at 1:20 AM, David Miller <[email protected]> wrote:
> From: Tom Gundersen <[email protected]>
> Date: Thu, 17 Jul 2014 10:06:05 +0200
>
>> @@ -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);
>
> The indentation is now not correct. For a function call, all arguments on the
> second and subsequent line, must start exactly at the first column after the
> openning parenthesis of the function call.

Indeed. Thanks, I'll fix this up.

Cheers,

Tom