cfg80211: pass name_assign_type to rdev_add_virtual_intf()
authorTom Gundersen <teg@jklm.no>
Wed, 18 Mar 2015 10:13:39 +0000 (11:13 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 30 Mar 2015 08:36:17 +0000 (10:36 +0200)
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 5517750f058e ("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>
17 files changed:
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/ath6kl/cfg80211.h
drivers/net/wireless/ath/ath6kl/core.c
drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c
drivers/net/wireless/brcm80211/brcmfmac/p2p.c
drivers/net/wireless/brcm80211/brcmfmac/p2p.h
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/main.c
drivers/net/wireless/mwifiex/main.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
include/net/cfg80211.h
net/mac80211/cfg.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/main.c
net/wireless/nl80211.c
net/wireless/rdev-ops.h

index ff7ba5c..d740f14 100644 (file)
@@ -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;
 
index b59becd..5aa57a7 100644 (file)
@@ -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,
index 0df74b2..4ec02ce 100644 (file)
@@ -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();
 
index b59b8c6..bcbccba 100644 (file)
@@ -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;
index effb48e..b44ea85 100644 (file)
@@ -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");
index 6821b26..872f382 100644 (file)
@@ -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);
index a47eb55..2d489bf 100644 (file)
@@ -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");
index 7e74b4f..6f55e84 100644 (file)
@@ -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)) {
index f0a6af1..3f0625f 100644 (file)
@@ -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);
index 537bd82..a6116fd 100644 (file)
@@ -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:
index c4d873b..ab667fb 100644 (file)
@@ -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);
index e01cea3..4940123 100644 (file)
@@ -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);
 
index ebc8135..3e3cfe8 100644 (file)
@@ -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,
index 9689d3b..a0cd97f 100644 (file)
@@ -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;
index 2f51e6d..4977967 100644 (file)
@@ -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,
index 543dd51..f60ee5b 100644 (file)
@@ -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, &params);
+                               NET_NAME_USER, type, err ? NULL : &flags,
+                               &params);
        if (WARN_ON(!wdev)) {
                nlmsg_free(msg);
                return -EPROTO;
index 35cfb71..c6e83a7 100644 (file)
@@ -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;
 }