nl80211: clarify nl80211_set_reg() success path
[cascardo/linux.git] / net / wireless / nl80211.c
index 056a730..c503e96 100644 (file)
@@ -103,7 +103,7 @@ __cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs)
                if (have_wdev_id && rdev->wiphy_idx != wiphy_idx)
                        continue;
 
-               list_for_each_entry(wdev, &rdev->wdev_list, list) {
+               list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
                        if (have_ifidx && wdev->netdev &&
                            wdev->netdev->ifindex == ifidx) {
                                result = wdev;
@@ -149,7 +149,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr **attrs)
                tmp = cfg80211_rdev_by_wiphy_idx(wdev_id >> 32);
                if (tmp) {
                        /* make sure wdev exists */
-                       list_for_each_entry(wdev, &tmp->wdev_list, list) {
+                       list_for_each_entry(wdev, &tmp->wiphy.wdev_list, list) {
                                if (wdev->identifier != (u32)wdev_id)
                                        continue;
                                found = true;
@@ -167,6 +167,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr **attrs)
 
        if (attrs[NL80211_ATTR_IFINDEX]) {
                int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
+
                netdev = __dev_get_by_index(netns, ifindex);
                if (netdev) {
                        if (netdev->ieee80211_ptr)
@@ -402,6 +403,8 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
        [NL80211_ATTR_SCHED_SCAN_DELAY] = { .type = NLA_U32 },
        [NL80211_ATTR_REG_INDOOR] = { .type = NLA_FLAG },
        [NL80211_ATTR_PBSS] = { .type = NLA_FLAG },
+       [NL80211_ATTR_BSS_SELECT] = { .type = NLA_NESTED },
+       [NL80211_ATTR_STA_SUPPORT_P2P_PS] = { .type = NLA_U8 },
 };
 
 /* policy for the key attributes */
@@ -486,6 +489,15 @@ nl80211_plan_policy[NL80211_SCHED_SCAN_PLAN_MAX + 1] = {
        [NL80211_SCHED_SCAN_PLAN_ITERATIONS] = { .type = NLA_U32 },
 };
 
+static const struct nla_policy
+nl80211_bss_select_policy[NL80211_BSS_SELECT_ATTR_MAX + 1] = {
+       [NL80211_BSS_SELECT_ATTR_RSSI] = { .type = NLA_FLAG },
+       [NL80211_BSS_SELECT_ATTR_BAND_PREF] = { .type = NLA_U32 },
+       [NL80211_BSS_SELECT_ATTR_RSSI_ADJUST] = {
+               .len = sizeof(struct nl80211_bss_select_rssi_adjust)
+       },
+};
+
 static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
                                     struct netlink_callback *cb,
                                     struct cfg80211_registered_device **rdev,
@@ -524,7 +536,7 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
                *rdev = wiphy_to_rdev(wiphy);
                *wdev = NULL;
 
-               list_for_each_entry(tmp, &(*rdev)->wdev_list, list) {
+               list_for_each_entry(tmp, &(*rdev)->wiphy.wdev_list, list) {
                        if (tmp->identifier == cb->args[1]) {
                                *wdev = tmp;
                                break;
@@ -720,6 +732,7 @@ static int nl80211_parse_key_new(struct nlattr *key, struct key_parse *k)
 
        if (tb[NL80211_KEY_DEFAULT_TYPES]) {
                struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
+
                err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
                                       tb[NL80211_KEY_DEFAULT_TYPES],
                                       nl80211_key_default_policy);
@@ -1253,7 +1266,7 @@ nl80211_send_mgmt_stypes(struct sk_buff *msg,
 struct nl80211_dump_wiphy_state {
        s64 filter_wiphy;
        long start;
-       long split_start, band_start, chan_start;
+       long split_start, band_start, chan_start, capa_start;
        bool split;
 };
 
@@ -1266,7 +1279,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
        struct nlattr *nl_bands, *nl_band;
        struct nlattr *nl_freqs, *nl_freq;
        struct nlattr *nl_cmds;
-       enum ieee80211_band band;
+       enum nl80211_band band;
        struct ieee80211_channel *chan;
        int i;
        const struct ieee80211_txrx_stypes *mgmt_stypes =
@@ -1371,6 +1384,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                    rdev->ops->get_antenna) {
                        u32 tx_ant = 0, rx_ant = 0;
                        int res;
+
                        res = rdev_get_antenna(rdev, &tx_ant, &rx_ant);
                        if (!res) {
                                if (nla_put_u32(msg,
@@ -1399,7 +1413,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                        goto nla_put_failure;
 
                for (band = state->band_start;
-                    band < IEEE80211_NUM_BANDS; band++) {
+                    band < NUM_NL80211_BANDS; band++) {
                        struct ieee80211_supported_band *sband;
 
                        sband = rdev->wiphy.bands[band];
@@ -1461,7 +1475,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                }
                nla_nest_end(msg, nl_bands);
 
-               if (band < IEEE80211_NUM_BANDS)
+               if (band < NUM_NL80211_BANDS)
                        state->band_start = band + 1;
                else
                        state->band_start = 0;
@@ -1731,6 +1745,66 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                            rdev->wiphy.ext_features))
                        goto nla_put_failure;
 
+               if (rdev->wiphy.bss_select_support) {
+                       struct nlattr *nested;
+                       u32 bss_select_support = rdev->wiphy.bss_select_support;
+
+                       nested = nla_nest_start(msg, NL80211_ATTR_BSS_SELECT);
+                       if (!nested)
+                               goto nla_put_failure;
+
+                       i = 0;
+                       while (bss_select_support) {
+                               if ((bss_select_support & 1) &&
+                                   nla_put_flag(msg, i))
+                                       goto nla_put_failure;
+                               i++;
+                               bss_select_support >>= 1;
+                       }
+                       nla_nest_end(msg, nested);
+               }
+
+               state->split_start++;
+               break;
+       case 13:
+               if (rdev->wiphy.num_iftype_ext_capab &&
+                   rdev->wiphy.iftype_ext_capab) {
+                       struct nlattr *nested_ext_capab, *nested;
+
+                       nested = nla_nest_start(msg,
+                                               NL80211_ATTR_IFTYPE_EXT_CAPA);
+                       if (!nested)
+                               goto nla_put_failure;
+
+                       for (i = state->capa_start;
+                            i < rdev->wiphy.num_iftype_ext_capab; i++) {
+                               const struct wiphy_iftype_ext_capab *capab;
+
+                               capab = &rdev->wiphy.iftype_ext_capab[i];
+
+                               nested_ext_capab = nla_nest_start(msg, i);
+                               if (!nested_ext_capab ||
+                                   nla_put_u32(msg, NL80211_ATTR_IFTYPE,
+                                               capab->iftype) ||
+                                   nla_put(msg, NL80211_ATTR_EXT_CAPA,
+                                           capab->extended_capabilities_len,
+                                           capab->extended_capabilities) ||
+                                   nla_put(msg, NL80211_ATTR_EXT_CAPA_MASK,
+                                           capab->extended_capabilities_len,
+                                           capab->extended_capabilities_mask))
+                                       goto nla_put_failure;
+
+                               nla_nest_end(msg, nested_ext_capab);
+                               if (state->split)
+                                       break;
+                       }
+                       nla_nest_end(msg, nested);
+                       if (i < rdev->wiphy.num_iftype_ext_capab) {
+                               state->capa_start = i + 1;
+                               break;
+                       }
+               }
+
                /* done */
                state->split_start = 0;
                break;
@@ -2086,7 +2160,6 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, struct genl_info *info)
        return rdev_set_wds_peer(rdev, dev, bssid);
 }
 
-
 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 {
        struct cfg80211_registered_device *rdev;
@@ -2221,6 +2294,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
        if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
            info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
                u32 tx_ant, rx_ant;
+
                if ((!rdev->wiphy.available_antennas_tx &&
                     !rdev->wiphy.available_antennas_rx) ||
                    !rdev->ops->set_antenna)
@@ -2399,7 +2473,8 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
 
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD) ||
            nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, wdev_address(wdev)) ||
            nla_put_u32(msg, NL80211_ATTR_GENERATION,
                        rdev->devlist_generation ^
@@ -2459,7 +2534,7 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
                }
                if_idx = 0;
 
-               list_for_each_entry(wdev, &rdev->wdev_list, list) {
+               list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
                        if (if_idx < if_start) {
                                if_idx++;
                                continue;
@@ -2731,7 +2806,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
                spin_lock_init(&wdev->mgmt_registrations_lock);
 
                wdev->identifier = ++rdev->wdev_id;
-               list_add_rcu(&wdev->list, &rdev->wdev_list);
+               list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
                rdev->devlist_generation++;
                break;
        default:
@@ -2888,6 +2963,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
        pairwise = !!mac_addr;
        if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
                u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
+
                if (kt >= NUM_NL80211_KEYTYPES)
                        return -EINVAL;
                if (kt != NL80211_KEYTYPE_GROUP &&
@@ -3267,7 +3343,7 @@ static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev,
        struct wireless_dev *wdev;
        bool ret = false;
 
-       list_for_each_entry(wdev, &rdev->wdev_list, list) {
+       list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
                if (wdev->iftype != NL80211_IFTYPE_AP &&
                    wdev->iftype != NL80211_IFTYPE_P2P_GO)
                        continue;
@@ -3463,7 +3539,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
        }
 
        params.pbss = nla_get_flag(info->attrs[NL80211_ATTR_PBSS]);
-       if (params.pbss && !rdev->wiphy.bands[IEEE80211_BAND_60GHZ])
+       if (params.pbss && !rdev->wiphy.bands[NL80211_BAND_60GHZ])
                return -EOPNOTSUPP;
 
        wdev_lock(wdev);
@@ -3724,11 +3800,18 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                goto nla_put_failure;
 
 #define PUT_SINFO(attr, memb, type) do {                               \
-       if (sinfo->filled & BIT(NL80211_STA_INFO_ ## attr) &&           \
+       BUILD_BUG_ON(sizeof(type) == sizeof(u64));                      \
+       if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) &&      \
            nla_put_ ## type(msg, NL80211_STA_INFO_ ## attr,            \
                             sinfo->memb))                              \
                goto nla_put_failure;                                   \
        } while (0)
+#define PUT_SINFO_U64(attr, memb) do {                                 \
+       if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) &&      \
+           nla_put_u64_64bit(msg, NL80211_STA_INFO_ ## attr,           \
+                             sinfo->memb, NL80211_STA_INFO_PAD))       \
+               goto nla_put_failure;                                   \
+       } while (0)
 
        PUT_SINFO(CONNECTED_TIME, connected_time, u32);
        PUT_SINFO(INACTIVE_TIME, inactive_time, u32);
@@ -3745,11 +3828,12 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                        (u32)sinfo->tx_bytes))
                goto nla_put_failure;
 
-       PUT_SINFO(RX_BYTES64, rx_bytes, u64);
-       PUT_SINFO(TX_BYTES64, tx_bytes, u64);
+       PUT_SINFO_U64(RX_BYTES64, rx_bytes);
+       PUT_SINFO_U64(TX_BYTES64, tx_bytes);
        PUT_SINFO(LLID, llid, u16);
        PUT_SINFO(PLID, plid, u16);
        PUT_SINFO(PLINK_STATE, plink_state, u8);
+       PUT_SINFO_U64(RX_DURATION, rx_duration);
 
        switch (rdev->wiphy.signal_type) {
        case CFG80211_SIGNAL_TYPE_MBM:
@@ -3817,12 +3901,13 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                    &sinfo->sta_flags))
                goto nla_put_failure;
 
-       PUT_SINFO(T_OFFSET, t_offset, u64);
-       PUT_SINFO(RX_DROP_MISC, rx_dropped_misc, u64);
-       PUT_SINFO(BEACON_RX, rx_beacon, u64);
+       PUT_SINFO_U64(T_OFFSET, t_offset);
+       PUT_SINFO_U64(RX_DROP_MISC, rx_dropped_misc);
+       PUT_SINFO_U64(BEACON_RX, rx_beacon);
        PUT_SINFO(BEACON_SIGNAL_AVG, rx_beacon_signal_avg, u8);
 
 #undef PUT_SINFO
+#undef PUT_SINFO_U64
 
        if (sinfo->filled & BIT(NL80211_STA_INFO_TID_STATS)) {
                struct nlattr *tidsattr;
@@ -3845,19 +3930,19 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                        if (!tidattr)
                                goto nla_put_failure;
 
-#define PUT_TIDVAL(attr, memb, type) do {                              \
+#define PUT_TIDVAL_U64(attr, memb) do {                                        \
        if (tidstats->filled & BIT(NL80211_TID_STATS_ ## attr) &&       \
-           nla_put_ ## type(msg, NL80211_TID_STATS_ ## attr,           \
-                            tidstats->memb))                           \
+           nla_put_u64_64bit(msg, NL80211_TID_STATS_ ## attr,          \
+                             tidstats->memb, NL80211_TID_STATS_PAD))   \
                goto nla_put_failure;                                   \
        } while (0)
 
-                       PUT_TIDVAL(RX_MSDU, rx_msdu, u64);
-                       PUT_TIDVAL(TX_MSDU, tx_msdu, u64);
-                       PUT_TIDVAL(TX_MSDU_RETRIES, tx_msdu_retries, u64);
-                       PUT_TIDVAL(TX_MSDU_FAILED, tx_msdu_failed, u64);
+                       PUT_TIDVAL_U64(RX_MSDU, rx_msdu);
+                       PUT_TIDVAL_U64(TX_MSDU, tx_msdu);
+                       PUT_TIDVAL_U64(TX_MSDU_RETRIES, tx_msdu_retries);
+                       PUT_TIDVAL_U64(TX_MSDU_FAILED, tx_msdu_failed);
 
-#undef PUT_TIDVAL
+#undef PUT_TIDVAL_U64
                        nla_nest_end(msg, tidattr);
                }
 
@@ -3922,7 +4007,6 @@ static int nl80211_dump_station(struct sk_buff *skb,
                sta_idx++;
        }
 
-
  out:
        cb->args[2] = sta_idx;
        err = skb->len;
@@ -3977,6 +4061,10 @@ int cfg80211_check_station_change(struct wiphy *wiphy,
            statype != CFG80211_STA_AP_CLIENT_UNASSOC)
                return -EINVAL;
 
+       if (params->support_p2p_ps != -1 &&
+           statype != CFG80211_STA_AP_CLIENT_UNASSOC)
+               return -EINVAL;
+
        if (params->aid &&
            !(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) &&
            statype != CFG80211_STA_AP_CLIENT_UNASSOC)
@@ -4270,6 +4358,18 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
        else
                params.listen_interval = -1;
 
+       if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) {
+               u8 tmp;
+
+               tmp = nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);
+               if (tmp >= NUM_NL80211_P2P_PS_STATUS)
+                       return -EINVAL;
+
+               params.support_p2p_ps = tmp;
+       } else {
+               params.support_p2p_ps = -1;
+       }
+
        if (!info->attrs[NL80211_ATTR_MAC])
                return -EINVAL;
 
@@ -4393,6 +4493,23 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
        params.listen_interval =
                nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
 
+       if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) {
+               u8 tmp;
+
+               tmp = nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);
+               if (tmp >= NUM_NL80211_P2P_PS_STATUS)
+                       return -EINVAL;
+
+               params.support_p2p_ps = tmp;
+       } else {
+               /*
+                * if not specified, assume it's supported for P2P GO interface,
+                * and is NOT supported for AP interface
+                */
+               params.support_p2p_ps =
+                       dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO;
+       }
+
        if (info->attrs[NL80211_ATTR_PEER_AID])
                params.aid = nla_get_u16(info->attrs[NL80211_ATTR_PEER_AID]);
        else
@@ -4690,7 +4807,6 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
                path_idx++;
        }
 
-
  out:
        cb->args[2] = path_idx;
        err = skb->len;
@@ -4980,7 +5096,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
        enum nl80211_user_reg_hint_type user_reg_hint_type;
        u32 owner_nlportid;
 
-
        /*
         * You should only get this when cfg80211 hasn't yet initialized
         * completely when built-in to the kernel right between the time
@@ -5189,7 +5304,6 @@ do {                                                                          \
        }                                                                   \
 } while (0)
 
-
        if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
                return -EINVAL;
        if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
@@ -5336,7 +5450,6 @@ static int nl80211_parse_mesh_setup(struct genl_info *info,
                 IEEE80211_PATH_METRIC_VENDOR :
                 IEEE80211_PATH_METRIC_AIRTIME;
 
-
        if (tb[NL80211_MESH_SETUP_IE]) {
                struct nlattr *ieattr =
                        tb[NL80211_MESH_SETUP_IE];
@@ -5723,10 +5836,8 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
                }
        }
 
-       r = set_regdom(rd, REGD_SOURCE_CRDA);
-       /* set_regdom took ownership */
-       rd = NULL;
-
+       /* set_regdom takes ownership of rd */
+       return set_regdom(rd, REGD_SOURCE_CRDA);
  bad_reg:
        kfree(rd);
        return r;
@@ -5758,6 +5869,73 @@ static int validate_scan_freqs(struct nlattr *freqs)
        return n_channels;
 }
 
+static bool is_band_valid(struct wiphy *wiphy, enum nl80211_band b)
+{
+       return b < NUM_NL80211_BANDS && wiphy->bands[b];
+}
+
+static int parse_bss_select(struct nlattr *nla, struct wiphy *wiphy,
+                           struct cfg80211_bss_selection *bss_select)
+{
+       struct nlattr *attr[NL80211_BSS_SELECT_ATTR_MAX + 1];
+       struct nlattr *nest;
+       int err;
+       bool found = false;
+       int i;
+
+       /* only process one nested attribute */
+       nest = nla_data(nla);
+       if (!nla_ok(nest, nla_len(nest)))
+               return -EINVAL;
+
+       err = nla_parse(attr, NL80211_BSS_SELECT_ATTR_MAX, nla_data(nest),
+                       nla_len(nest), nl80211_bss_select_policy);
+       if (err)
+               return err;
+
+       /* only one attribute may be given */
+       for (i = 0; i <= NL80211_BSS_SELECT_ATTR_MAX; i++) {
+               if (attr[i]) {
+                       if (found)
+                               return -EINVAL;
+                       found = true;
+               }
+       }
+
+       bss_select->behaviour = __NL80211_BSS_SELECT_ATTR_INVALID;
+
+       if (attr[NL80211_BSS_SELECT_ATTR_RSSI])
+               bss_select->behaviour = NL80211_BSS_SELECT_ATTR_RSSI;
+
+       if (attr[NL80211_BSS_SELECT_ATTR_BAND_PREF]) {
+               bss_select->behaviour = NL80211_BSS_SELECT_ATTR_BAND_PREF;
+               bss_select->param.band_pref =
+                       nla_get_u32(attr[NL80211_BSS_SELECT_ATTR_BAND_PREF]);
+               if (!is_band_valid(wiphy, bss_select->param.band_pref))
+                       return -EINVAL;
+       }
+
+       if (attr[NL80211_BSS_SELECT_ATTR_RSSI_ADJUST]) {
+               struct nl80211_bss_select_rssi_adjust *adj_param;
+
+               adj_param = nla_data(attr[NL80211_BSS_SELECT_ATTR_RSSI_ADJUST]);
+               bss_select->behaviour = NL80211_BSS_SELECT_ATTR_RSSI_ADJUST;
+               bss_select->param.adjust.band = adj_param->band;
+               bss_select->param.adjust.delta = adj_param->delta;
+               if (!is_band_valid(wiphy, bss_select->param.adjust.band))
+                       return -EINVAL;
+       }
+
+       /* user-space did not provide behaviour attribute */
+       if (bss_select->behaviour == __NL80211_BSS_SELECT_ATTR_INVALID)
+               return -EINVAL;
+
+       if (!(wiphy->bss_select_support & BIT(bss_select->behaviour)))
+               return -EINVAL;
+
+       return 0;
+}
+
 static int nl80211_parse_random_mac(struct nlattr **attrs,
                                    u8 *mac_addr, u8 *mac_addr_mask)
 {
@@ -5888,11 +6066,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
                        i++;
                }
        } else {
-               enum ieee80211_band band;
+               enum nl80211_band band;
 
                /* all channels */
-               for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+               for (band = 0; band < NUM_NL80211_BANDS; band++) {
                        int j;
+
                        if (!wiphy->bands[band])
                                continue;
                        for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
@@ -5936,7 +6115,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
                       request->ie_len);
        }
 
-       for (i = 0; i < IEEE80211_NUM_BANDS; i++)
+       for (i = 0; i < NUM_NL80211_BANDS; i++)
                if (wiphy->bands[i])
                        request->rates[i] =
                                (1 << wiphy->bands[i]->n_bitrates) - 1;
@@ -5945,9 +6124,9 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
                nla_for_each_nested(attr,
                                    info->attrs[NL80211_ATTR_SCAN_SUPP_RATES],
                                    tmp) {
-                       enum ieee80211_band band = nla_type(attr);
+                       enum nl80211_band band = nla_type(attr);
 
-                       if (band < 0 || band >= IEEE80211_NUM_BANDS) {
+                       if (band < 0 || band >= NUM_NL80211_BANDS) {
                                err = -EINVAL;
                                goto out_free;
                        }
@@ -5996,6 +6175,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
        request->no_cck =
                nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
 
+       if (info->attrs[NL80211_ATTR_MAC])
+               memcpy(request->bssid, nla_data(info->attrs[NL80211_ATTR_MAC]),
+                      ETH_ALEN);
+       else
+               eth_broadcast_addr(request->bssid);
+
        request->wdev = wdev;
        request->wiphy = &rdev->wiphy;
        request->scan_start = jiffies;
@@ -6129,7 +6314,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
        struct cfg80211_sched_scan_request *request;
        struct nlattr *attr;
        int err, tmp, n_ssids = 0, n_match_sets = 0, n_channels, i, n_plans = 0;
-       enum ieee80211_band band;
+       enum nl80211_band band;
        size_t ie_len;
        struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
        s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
@@ -6294,8 +6479,9 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
                }
        } else {
                /* all channels */
-               for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+               for (band = 0; band < NUM_NL80211_BANDS; band++) {
                        int j;
+
                        if (!wiphy->bands[band])
                                continue;
                        for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
@@ -6365,7 +6551,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
                                       nla_data(ssid), nla_len(ssid));
                                request->match_sets[i].ssid.ssid_len =
                                        nla_len(ssid);
-                               /* special attribute - old implemenation w/a */
+                               /* special attribute - old implementation w/a */
                                request->match_sets[i].rssi_thold =
                                        default_match_rssi;
                                rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
@@ -6738,7 +6924,8 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
        if (wdev->netdev &&
            nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex))
                goto nla_put_failure;
-       if (nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+       if (nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD))
                goto nla_put_failure;
 
        bss = nla_nest_start(msg, NL80211_ATTR_BSS);
@@ -6759,7 +6946,8 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
         */
        ies = rcu_dereference(res->ies);
        if (ies) {
-               if (nla_put_u64(msg, NL80211_BSS_TSF, ies->tsf))
+               if (nla_put_u64_64bit(msg, NL80211_BSS_TSF, ies->tsf,
+                                     NL80211_BSS_PAD))
                        goto fail_unlock_rcu;
                if (ies->len && nla_put(msg, NL80211_BSS_INFORMATION_ELEMENTS,
                                        ies->len, ies->data))
@@ -6769,7 +6957,8 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
        /* and this pointer is always (unless driver didn't know) beacon data */
        ies = rcu_dereference(res->beacon_ies);
        if (ies && ies->from_beacon) {
-               if (nla_put_u64(msg, NL80211_BSS_BEACON_TSF, ies->tsf))
+               if (nla_put_u64_64bit(msg, NL80211_BSS_BEACON_TSF, ies->tsf,
+                                     NL80211_BSS_PAD))
                        goto fail_unlock_rcu;
                if (ies->len && nla_put(msg, NL80211_BSS_BEACON_IES,
                                        ies->len, ies->data))
@@ -6788,8 +6977,8 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
                goto nla_put_failure;
 
        if (intbss->ts_boottime &&
-           nla_put_u64(msg, NL80211_BSS_LAST_SEEN_BOOTTIME,
-                       intbss->ts_boottime))
+           nla_put_u64_64bit(msg, NL80211_BSS_LAST_SEEN_BOOTTIME,
+                             intbss->ts_boottime, NL80211_BSS_PAD))
                goto nla_put_failure;
 
        switch (rdev->wiphy.signal_type) {
@@ -6909,28 +7098,28 @@ static int nl80211_send_survey(struct sk_buff *msg, u32 portid, u32 seq,
            nla_put_flag(msg, NL80211_SURVEY_INFO_IN_USE))
                goto nla_put_failure;
        if ((survey->filled & SURVEY_INFO_TIME) &&
-           nla_put_u64(msg, NL80211_SURVEY_INFO_TIME,
-                       survey->time))
+           nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME,
+                       survey->time, NL80211_SURVEY_INFO_PAD))
                goto nla_put_failure;
        if ((survey->filled & SURVEY_INFO_TIME_BUSY) &&
-           nla_put_u64(msg, NL80211_SURVEY_INFO_TIME_BUSY,
-                       survey->time_busy))
+           nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_BUSY,
+                             survey->time_busy, NL80211_SURVEY_INFO_PAD))
                goto nla_put_failure;
        if ((survey->filled & SURVEY_INFO_TIME_EXT_BUSY) &&
-           nla_put_u64(msg, NL80211_SURVEY_INFO_TIME_EXT_BUSY,
-                       survey->time_ext_busy))
+           nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_EXT_BUSY,
+                             survey->time_ext_busy, NL80211_SURVEY_INFO_PAD))
                goto nla_put_failure;
        if ((survey->filled & SURVEY_INFO_TIME_RX) &&
-           nla_put_u64(msg, NL80211_SURVEY_INFO_TIME_RX,
-                       survey->time_rx))
+           nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_RX,
+                             survey->time_rx, NL80211_SURVEY_INFO_PAD))
                goto nla_put_failure;
        if ((survey->filled & SURVEY_INFO_TIME_TX) &&
-           nla_put_u64(msg, NL80211_SURVEY_INFO_TIME_TX,
-                       survey->time_tx))
+           nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_TX,
+                             survey->time_tx, NL80211_SURVEY_INFO_PAD))
                goto nla_put_failure;
        if ((survey->filled & SURVEY_INFO_TIME_SCAN) &&
-           nla_put_u64(msg, NL80211_SURVEY_INFO_TIME_SCAN,
-                       survey->time_scan))
+           nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_SCAN,
+                             survey->time_scan, NL80211_SURVEY_INFO_PAD))
                goto nla_put_failure;
 
        nla_nest_end(msg, infoattr);
@@ -7055,6 +7244,7 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
        if (key.idx >= 0) {
                int i;
                bool ok = false;
+
                for (i = 0; i < rdev->wiphy.n_cipher_suites; i++) {
                        if (key.p.cipher == rdev->wiphy.cipher_suites[i]) {
                                ok = true;
@@ -7133,6 +7323,7 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
 
        if (info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]) {
                u16 proto;
+
                proto = nla_get_u16(
                        info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]);
                settings->control_port_ethertype = cpu_to_be16(proto);
@@ -7402,14 +7593,14 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
 
 static bool
 nl80211_parse_mcast_rate(struct cfg80211_registered_device *rdev,
-                        int mcast_rate[IEEE80211_NUM_BANDS],
+                        int mcast_rate[NUM_NL80211_BANDS],
                         int rateval)
 {
        struct wiphy *wiphy = &rdev->wiphy;
        bool found = false;
        int band, i;
 
-       for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+       for (band = 0; band < NUM_NL80211_BANDS; band++) {
                struct ieee80211_supported_band *sband;
 
                sband = wiphy->bands[band];
@@ -7589,7 +7780,7 @@ static int nl80211_set_mcast_rate(struct sk_buff *skb, struct genl_info *info)
 {
        struct cfg80211_registered_device *rdev = info->user_ptr[0];
        struct net_device *dev = info->user_ptr[1];
-       int mcast_rate[IEEE80211_NUM_BANDS];
+       int mcast_rate[NUM_NL80211_BANDS];
        u32 nla_rate;
        int err;
 
@@ -7650,8 +7841,8 @@ __cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev,
        }
 
        if (wdev) {
-               if (nla_put_u64(skb, NL80211_ATTR_WDEV,
-                               wdev_id(wdev)))
+               if (nla_put_u64_64bit(skb, NL80211_ATTR_WDEV,
+                                     wdev_id(wdev), NL80211_ATTR_PAD))
                        goto nla_put_failure;
                if (wdev->netdev &&
                    nla_put_u32(skb, NL80211_ATTR_IFINDEX,
@@ -7922,6 +8113,10 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
                connect.mfp = NL80211_MFP_NO;
        }
 
+       if (info->attrs[NL80211_ATTR_PREV_BSSID])
+               connect.prev_bssid =
+                       nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]);
+
        if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
                connect.channel = nl80211_get_valid_chan(
                        wiphy, info->attrs[NL80211_ATTR_WIPHY_FREQ]);
@@ -7990,13 +8185,29 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
        }
 
        connect.pbss = nla_get_flag(info->attrs[NL80211_ATTR_PBSS]);
-       if (connect.pbss && !rdev->wiphy.bands[IEEE80211_BAND_60GHZ]) {
+       if (connect.pbss && !rdev->wiphy.bands[NL80211_BAND_60GHZ]) {
                kzfree(connkeys);
                return -EOPNOTSUPP;
        }
 
+       if (info->attrs[NL80211_ATTR_BSS_SELECT]) {
+               /* bss selection makes no sense if bssid is set */
+               if (connect.bssid) {
+                       kzfree(connkeys);
+                       return -EINVAL;
+               }
+
+               err = parse_bss_select(info->attrs[NL80211_ATTR_BSS_SELECT],
+                                      wiphy, &connect.bss_select);
+               if (err) {
+                       kzfree(connkeys);
+                       return err;
+               }
+       }
+
        wdev_lock(dev->ieee80211_ptr);
-       err = cfg80211_connect(rdev, dev, &connect, connkeys, NULL);
+       err = cfg80211_connect(rdev, dev, &connect, connkeys,
+                              connect.prev_bssid);
        wdev_unlock(dev->ieee80211_ptr);
        if (err)
                kzfree(connkeys);
@@ -8224,7 +8435,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
        if (err)
                goto free_msg;
 
-       if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
+       if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie,
+                             NL80211_ATTR_PAD))
                goto nla_put_failure;
 
        genlmsg_end(msg, hdr);
@@ -8265,6 +8477,7 @@ static u32 rateset_to_mask(struct ieee80211_supported_band *sband,
        for (i = 0; i < rates_len; i++) {
                int rate = (rates[i] & 0x7f) * 5;
                int ridx;
+
                for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
                        struct ieee80211_rate *srate =
                                &sband->bitrates[ridx];
@@ -8394,7 +8607,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
 
        memset(&mask, 0, sizeof(mask));
        /* Default to all rates enabled */
-       for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
+       for (i = 0; i < NUM_NL80211_BANDS; i++) {
                sband = rdev->wiphy.bands[i];
 
                if (!sband)
@@ -8418,14 +8631,14 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
 
        /*
         * The nested attribute uses enum nl80211_band as the index. This maps
-        * directly to the enum ieee80211_band values used in cfg80211.
+        * directly to the enum nl80211_band values used in cfg80211.
         */
        BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
        nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) {
-               enum ieee80211_band band = nla_type(tx_rates);
+               enum nl80211_band band = nla_type(tx_rates);
                int err;
 
-               if (band < 0 || band >= IEEE80211_NUM_BANDS)
+               if (band < 0 || band >= NUM_NL80211_BANDS)
                        return -EINVAL;
                sband = rdev->wiphy.bands[band];
                if (sband == NULL)
@@ -8573,7 +8786,6 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
                if (params.wait < NL80211_MIN_REMAIN_ON_CHANNEL_TIME ||
                    params.wait > rdev->wiphy.max_remain_on_channel_duration)
                        return -EINVAL;
-
        }
 
        params.offchan = info->attrs[NL80211_ATTR_OFFCHANNEL_TX_OK];
@@ -8636,7 +8848,8 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
                goto free_msg;
 
        if (msg) {
-               if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
+               if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie,
+                                     NL80211_ATTR_PAD))
                        goto nla_put_failure;
 
                genlmsg_end(msg, hdr);
@@ -9922,7 +10135,8 @@ static int nl80211_probe_client(struct sk_buff *skb,
        if (err)
                goto free_msg;
 
-       if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
+       if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie,
+                             NL80211_ATTR_PAD))
                goto nla_put_failure;
 
        genlmsg_end(msg, hdr);
@@ -10220,7 +10434,7 @@ static int nl80211_prepare_vendor_dump(struct sk_buff *skb,
                *wdev = NULL;
 
                if (cb->args[1]) {
-                       list_for_each_entry(tmp, &(*rdev)->wdev_list, list) {
+                       list_for_each_entry(tmp, &wiphy->wdev_list, list) {
                                if (tmp->identifier == cb->args[1] - 1) {
                                        *wdev = tmp;
                                        break;
@@ -10347,8 +10561,9 @@ static int nl80211_vendor_cmd_dump(struct sk_buff *skb,
                        break;
 
                if (nla_put_u32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
-                   (wdev && nla_put_u64(skb, NL80211_ATTR_WDEV,
-                                        wdev_id(wdev)))) {
+                   (wdev && nla_put_u64_64bit(skb, NL80211_ATTR_WDEV,
+                                              wdev_id(wdev),
+                                              NL80211_ATTR_PAD))) {
                        genlmsg_cancel(skb, hdr);
                        break;
                }
@@ -10417,7 +10632,6 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb)
 }
 EXPORT_SYMBOL_GPL(cfg80211_vendor_cmd_reply);
 
-
 static int nl80211_set_qos_map(struct sk_buff *skb,
                               struct genl_info *info)
 {
@@ -10590,7 +10804,7 @@ static int nl80211_tdls_channel_switch(struct sk_buff *skb,
         * section 10.22.6.2.1. Disallow 5/10Mhz channels as well for now, the
         * specification is not defined for them.
         */
-       if (chandef.chan->band == IEEE80211_BAND_2GHZ &&
+       if (chandef.chan->band == NL80211_BAND_2GHZ &&
            chandef.width != NL80211_CHAN_WIDTH_20_NOHT &&
            chandef.width != NL80211_CHAN_WIDTH_20)
                return -EINVAL;
@@ -10772,7 +10986,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_WIPHY,
                .doit = nl80211_set_wiphy,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_RTNL,
        },
        {
@@ -10788,7 +11002,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_INTERFACE,
                .doit = nl80211_set_interface,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10796,7 +11010,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_NEW_INTERFACE,
                .doit = nl80211_new_interface,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10804,7 +11018,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEL_INTERFACE,
                .doit = nl80211_del_interface,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10812,7 +11026,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_GET_KEY,
                .doit = nl80211_get_key,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10820,7 +11034,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_KEY,
                .doit = nl80211_set_key,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL |
                                  NL80211_FLAG_CLEAR_SKB,
@@ -10829,7 +11043,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_NEW_KEY,
                .doit = nl80211_new_key,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL |
                                  NL80211_FLAG_CLEAR_SKB,
@@ -10838,14 +11052,14 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEL_KEY,
                .doit = nl80211_del_key,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
        {
                .cmd = NL80211_CMD_SET_BEACON,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .doit = nl80211_set_beacon,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
@@ -10853,7 +11067,7 @@ static const struct genl_ops nl80211_ops[] = {
        {
                .cmd = NL80211_CMD_START_AP,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .doit = nl80211_start_ap,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
@@ -10861,7 +11075,7 @@ static const struct genl_ops nl80211_ops[] = {
        {
                .cmd = NL80211_CMD_STOP_AP,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .doit = nl80211_stop_ap,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
@@ -10878,7 +11092,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_STATION,
                .doit = nl80211_set_station,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10886,7 +11100,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_NEW_STATION,
                .doit = nl80211_new_station,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10894,7 +11108,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEL_STATION,
                .doit = nl80211_del_station,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10903,7 +11117,7 @@ static const struct genl_ops nl80211_ops[] = {
                .doit = nl80211_get_mpath,
                .dumpit = nl80211_dump_mpath,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10912,7 +11126,7 @@ static const struct genl_ops nl80211_ops[] = {
                .doit = nl80211_get_mpp,
                .dumpit = nl80211_dump_mpp,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10920,7 +11134,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_MPATH,
                .doit = nl80211_set_mpath,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10928,7 +11142,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_NEW_MPATH,
                .doit = nl80211_new_mpath,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10936,7 +11150,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEL_MPATH,
                .doit = nl80211_del_mpath,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10944,7 +11158,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_BSS,
                .doit = nl80211_set_bss,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10983,7 +11197,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_MESH_CONFIG,
                .doit = nl80211_update_mesh_config,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10991,7 +11205,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_TRIGGER_SCAN,
                .doit = nl80211_trigger_scan,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -10999,7 +11213,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_ABORT_SCAN,
                .doit = nl80211_abort_scan,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11012,7 +11226,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_START_SCHED_SCAN,
                .doit = nl80211_start_sched_scan,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11020,7 +11234,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_STOP_SCHED_SCAN,
                .doit = nl80211_stop_sched_scan,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11028,7 +11242,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_AUTHENTICATE,
                .doit = nl80211_authenticate,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL |
                                  NL80211_FLAG_CLEAR_SKB,
@@ -11037,7 +11251,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_ASSOCIATE,
                .doit = nl80211_associate,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11045,7 +11259,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEAUTHENTICATE,
                .doit = nl80211_deauthenticate,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11053,7 +11267,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DISASSOCIATE,
                .doit = nl80211_disassociate,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11061,7 +11275,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_JOIN_IBSS,
                .doit = nl80211_join_ibss,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11069,7 +11283,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_LEAVE_IBSS,
                .doit = nl80211_leave_ibss,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11079,7 +11293,7 @@ static const struct genl_ops nl80211_ops[] = {
                .doit = nl80211_testmode_do,
                .dumpit = nl80211_testmode_dump,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11088,7 +11302,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_CONNECT,
                .doit = nl80211_connect,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11096,7 +11310,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DISCONNECT,
                .doit = nl80211_disconnect,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11104,7 +11318,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_WIPHY_NETNS,
                .doit = nl80211_wiphy_netns,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11117,7 +11331,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_PMKSA,
                .doit = nl80211_setdel_pmksa,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11125,7 +11339,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEL_PMKSA,
                .doit = nl80211_setdel_pmksa,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11133,7 +11347,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_FLUSH_PMKSA,
                .doit = nl80211_flush_pmksa,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11141,7 +11355,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_REMAIN_ON_CHANNEL,
                .doit = nl80211_remain_on_channel,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11149,7 +11363,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
                .doit = nl80211_cancel_remain_on_channel,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11157,7 +11371,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_TX_BITRATE_MASK,
                .doit = nl80211_set_tx_bitrate_mask,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11165,7 +11379,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_REGISTER_FRAME,
                .doit = nl80211_register_mgmt,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11173,7 +11387,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_FRAME,
                .doit = nl80211_tx_mgmt,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11181,7 +11395,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_FRAME_WAIT_CANCEL,
                .doit = nl80211_tx_mgmt_cancel_wait,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11189,7 +11403,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_POWER_SAVE,
                .doit = nl80211_set_power_save,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11205,7 +11419,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_CQM,
                .doit = nl80211_set_cqm,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11213,7 +11427,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_CHANNEL,
                .doit = nl80211_set_channel,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11221,7 +11435,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_WDS_PEER,
                .doit = nl80211_set_wds_peer,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11229,7 +11443,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_JOIN_MESH,
                .doit = nl80211_join_mesh,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11237,7 +11451,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_LEAVE_MESH,
                .doit = nl80211_leave_mesh,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11245,7 +11459,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_JOIN_OCB,
                .doit = nl80211_join_ocb,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11253,7 +11467,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_LEAVE_OCB,
                .doit = nl80211_leave_ocb,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11270,7 +11484,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_WOWLAN,
                .doit = nl80211_set_wowlan,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11279,7 +11493,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_REKEY_OFFLOAD,
                .doit = nl80211_set_rekey_data,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL |
                                  NL80211_FLAG_CLEAR_SKB,
@@ -11288,7 +11502,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_TDLS_MGMT,
                .doit = nl80211_tdls_mgmt,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11296,7 +11510,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_TDLS_OPER,
                .doit = nl80211_tdls_oper,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11304,7 +11518,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_UNEXPECTED_FRAME,
                .doit = nl80211_register_unexpected_frame,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11312,7 +11526,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_PROBE_CLIENT,
                .doit = nl80211_probe_client,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11320,7 +11534,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_REGISTER_BEACONS,
                .doit = nl80211_register_beacons,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11328,7 +11542,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_NOACK_MAP,
                .doit = nl80211_set_noack_map,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11336,7 +11550,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_START_P2P_DEVICE,
                .doit = nl80211_start_p2p_device,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11344,7 +11558,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_STOP_P2P_DEVICE,
                .doit = nl80211_stop_p2p_device,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11352,7 +11566,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_MCAST_RATE,
                .doit = nl80211_set_mcast_rate,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11360,7 +11574,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_MAC_ACL,
                .doit = nl80211_set_mac_acl,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11368,7 +11582,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_RADAR_DETECT,
                .doit = nl80211_start_radar_detection,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11381,7 +11595,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_UPDATE_FT_IES,
                .doit = nl80211_update_ft_ies,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11389,7 +11603,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_CRIT_PROTOCOL_START,
                .doit = nl80211_crit_protocol_start,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11397,7 +11611,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_CRIT_PROTOCOL_STOP,
                .doit = nl80211_crit_protocol_stop,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11412,7 +11626,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_COALESCE,
                .doit = nl80211_set_coalesce,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11420,7 +11634,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_CHANNEL_SWITCH,
                .doit = nl80211_channel_switch,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11429,7 +11643,7 @@ static const struct genl_ops nl80211_ops[] = {
                .doit = nl80211_vendor_cmd,
                .dumpit = nl80211_vendor_cmd_dump,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_WIPHY |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11437,7 +11651,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_SET_QOS_MAP,
                .doit = nl80211_set_qos_map,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11445,7 +11659,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_ADD_TX_TS,
                .doit = nl80211_add_tx_ts,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11453,7 +11667,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_DEL_TX_TS,
                .doit = nl80211_del_tx_ts,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11461,7 +11675,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_TDLS_CHANNEL_SWITCH,
                .doit = nl80211_tdls_channel_switch,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11469,7 +11683,7 @@ static const struct genl_ops nl80211_ops[] = {
                .cmd = NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH,
                .doit = nl80211_tdls_cancel_channel_switch,
                .policy = nl80211_policy,
-               .flags = GENL_ADMIN_PERM,
+               .flags = GENL_UNS_ADMIN_PERM,
                .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
@@ -11555,7 +11769,8 @@ static int nl80211_send_scan_msg(struct sk_buff *msg,
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
                                         wdev->netdev->ifindex)) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD))
                goto nla_put_failure;
 
        /* ignore errors and send incomplete event anyway */
@@ -11918,7 +12133,7 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
                                 struct net_device *netdev, const u8 *bssid,
                                 const u8 *req_ie, size_t req_ie_len,
                                 const u8 *resp_ie, size_t resp_ie_len,
-                                u16 status, gfp_t gfp)
+                                int status, gfp_t gfp)
 {
        struct sk_buff *msg;
        void *hdr;
@@ -11936,7 +12151,10 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
            (bssid && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) ||
-           nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, status) ||
+           nla_put_u16(msg, NL80211_ATTR_STATUS_CODE,
+                       status < 0 ? WLAN_STATUS_UNSPECIFIED_FAILURE :
+                       status) ||
+           (status < 0 && nla_put_flag(msg, NL80211_ATTR_TIMED_OUT)) ||
            (req_ie &&
             nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) ||
            (resp_ie &&
@@ -11952,7 +12170,6 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
        nlmsg_free(msg);
-
 }
 
 void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
@@ -11991,7 +12208,6 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
        nlmsg_free(msg);
-
 }
 
 void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
@@ -12029,7 +12245,6 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
        nlmsg_free(msg);
-
 }
 
 void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev,
@@ -12222,11 +12437,13 @@ static void nl80211_send_remain_on_chan_event(
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
                                         wdev->netdev->ifindex)) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD) ||
            nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq) ||
            nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
                        NL80211_CHAN_NO_HT) ||
-           nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
+           nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie,
+                             NL80211_ATTR_PAD))
                goto nla_put_failure;
 
        if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL &&
@@ -12460,7 +12677,8 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            (netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
                                        netdev->ifindex)) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD) ||
            nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq) ||
            (sig_dbm &&
             nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) ||
@@ -12503,9 +12721,11 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            (netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
                                   netdev->ifindex)) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD) ||
            nla_put(msg, NL80211_ATTR_FRAME, len, buf) ||
-           nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) ||
+           nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie,
+                             NL80211_ATTR_PAD) ||
            (ack && nla_put_flag(msg, NL80211_ATTR_ACK)))
                goto nla_put_failure;
 
@@ -12885,7 +13105,8 @@ nl80211_radar_notify(struct cfg80211_registered_device *rdev,
                struct wireless_dev *wdev = netdev->ieee80211_ptr;
 
                if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
-                   nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+                   nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                                     NL80211_ATTR_PAD))
                        goto nla_put_failure;
        }
 
@@ -12930,7 +13151,8 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
            nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) ||
-           nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) ||
+           nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie,
+                             NL80211_ATTR_PAD) ||
            (acked && nla_put_flag(msg, NL80211_ATTR_ACK)))
                goto nla_put_failure;
 
@@ -13075,7 +13297,8 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
                goto free_msg;
 
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD))
                goto free_msg;
 
        if (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
@@ -13231,7 +13454,7 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
                    sched_scan_req->owner_nlportid == notify->portid)
                        schedule_scan_stop = true;
 
-               list_for_each_entry_rcu(wdev, &rdev->wdev_list, list) {
+               list_for_each_entry_rcu(wdev, &rdev->wiphy.wdev_list, list) {
                        cfg80211_mlme_unregister_socket(wdev, notify->portid);
 
                        if (wdev->owner_nlportid == notify->portid)
@@ -13350,7 +13573,8 @@ void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
                goto nla_put_failure;
 
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD))
                goto nla_put_failure;
 
        genlmsg_end(msg, hdr);
@@ -13362,7 +13586,6 @@ void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
        if (hdr)
                genlmsg_cancel(msg, hdr);
        nlmsg_free(msg);
-
 }
 EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
 
@@ -13383,7 +13606,8 @@ void nl80211_send_ap_stopped(struct wireless_dev *wdev)
 
        if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
            nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) ||
-           nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+           nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+                             NL80211_ATTR_PAD))
                goto out;
 
        genlmsg_end(msg, hdr);