forked from Minki/linux
cfg80211: pass name_assign_type to rdev_add_virtual_intf()
This will expose in /sys whether the ifname of a device is set by
userspace or generated by the kernel. The latter kind (wlanX, etc)
is not deterministic, so userspace needs to rename these devices
to names that are guaranteed to stay the same between reboots. The
former, however should never be renamed, so userspace needs to be
able to reliably tell the difference.
Similar functionality was introduced for the rtnetlink core in
commit 5517750f05
("net: rtnetlink - make create_link take name_assign_type")
Signed-off-by: Tom Gundersen <teg@jklm.no>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: Brett Rudley <brudley@broadcom.com>
Cc: Arend van Spriel <arend@broadcom.com>
Cc: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Cc: Hante Meuleman <meuleman@broadcom.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
[reformat changelog to fit 72 cols]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
6a8b4adb47
commit
6bab2e19c5
@ -1496,6 +1496,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)
|
||||
@ -1514,7 +1515,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);
|
||||
|
||||
@ -3634,13 +3635,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;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -211,8 +211,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();
|
||||
|
||||
|
@ -625,6 +625,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)
|
||||
@ -648,7 +649,7 @@ 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:
|
||||
wdev = brcmf_p2p_add_vif(wiphy, name, type, flags, params);
|
||||
wdev = brcmf_p2p_add_vif(wiphy, name, name_assign_type, type, flags, params);
|
||||
if (!IS_ERR(wdev))
|
||||
brcmf_cfg80211_update_proto_addr_mode(wdev);
|
||||
return wdev;
|
||||
|
@ -2246,11 +2246,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)
|
||||
{
|
||||
@ -2310,6 +2312,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");
|
||||
|
@ -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);
|
||||
|
@ -2399,10 +2399,11 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info,
|
||||
|
||||
#define MWIFIEX_MAX_WQ_LEN 30
|
||||
/*
|
||||
* 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)
|
||||
@ -2523,7 +2524,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");
|
||||
|
@ -466,7 +466,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");
|
||||
@ -475,7 +475,7 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
|
||||
}
|
||||
|
||||
if (driver_mode & MWIFIEX_DRIVER_MODE_UAP) {
|
||||
wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d",
|
||||
wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM,
|
||||
NL80211_IFTYPE_AP, NULL, NULL);
|
||||
if (IS_ERR(wdev)) {
|
||||
dev_err(adapter->dev, "cannot create AP interface\n");
|
||||
@ -485,7 +485,7 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
|
||||
}
|
||||
|
||||
if (driver_mode & MWIFIEX_DRIVER_MODE_P2P) {
|
||||
wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d",
|
||||
wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM,
|
||||
NL80211_IFTYPE_P2P_CLIENT, NULL,
|
||||
NULL);
|
||||
if (IS_ERR(wdev)) {
|
||||
|
@ -1318,6 +1318,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);
|
||||
|
@ -2580,6 +2580,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;
|
||||
@ -2612,6 +2613,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;
|
||||
@ -2654,6 +2656,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)
|
||||
{
|
||||
@ -2673,7 +2676,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:
|
||||
|
@ -2456,6 +2456,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);
|
||||
|
@ -24,6 +24,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)
|
||||
@ -33,7 +34,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);
|
||||
|
||||
|
@ -1578,6 +1578,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,
|
||||
|
@ -1648,6 +1648,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)
|
||||
{
|
||||
@ -1676,7 +1677,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;
|
||||
|
@ -1057,7 +1057,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) &&
|
||||
!(hw->flags & IEEE80211_HW_NO_AUTO_VIF)) {
|
||||
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,
|
||||
|
@ -2667,7 +2667,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, ¶ms);
|
||||
NET_NAME_USER, type, err ? NULL : &flags,
|
||||
¶ms);
|
||||
if (WARN_ON(!wdev)) {
|
||||
nlmsg_free(msg);
|
||||
return -EPROTO;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user