]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cfg80211: support configuring vif mac addr on create
authorBen Greear <greearb@candelatech.com>
Wed, 22 Oct 2014 19:23:05 +0000 (12:23 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 27 Oct 2014 07:48:33 +0000 (08:48 +0100)
This is useful when creating virtual interfaces.
Keeps udev from mucking with things it shouldn't, since
the default MAC is never seen by udev when specified on
the cmd-line during creation.

Signed-off-by: Ben Greear <greearb@candelatech.com>
[check for feature flag in nl80211 to force drivers to set it]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/uapi/linux/nl80211.h
net/wireless/nl80211.c

index 39d7996b060901b0c23ad0743a756556d96c158d..f67948e18600b313a18fcb18194a6dab496093d0 100644 (file)
@@ -319,9 +319,12 @@ struct ieee80211_supported_band {
 /**
  * struct vif_params - describes virtual interface parameters
  * @use_4addr: use 4-address frames
- * @macaddr: address to use for this virtual interface. This will only
- *     be used for non-netdevice interfaces. If this parameter is set
- *     to zero address the driver may determine the address as needed.
+ * @macaddr: address to use for this virtual interface.
+ *     If this parameter is set to zero address the driver may
+ *     determine the address as needed.
+ *     This feature is only fully supported by drivers that enable the
+ *     %NL80211_FEATURE_MAC_ON_CREATE flag.  Others may support creating
+ **    only p2p devices with specified MAC.
  */
 struct vif_params {
        int use_4addr;
index be1d5def304de345841bc83674e88dc89ab453f9..f7daae59248e3d63ff330f8b3c495f460a423b05 100644 (file)
@@ -4056,6 +4056,9 @@ enum nl80211_ap_sme_features {
  *     TSPEC sessions (TID aka TSID 0-7) with the %NL80211_CMD_ADD_TX_TS
  *     command. Standard IEEE 802.11 TSPEC setup is not yet supported, it
  *     needs to be able to handle Block-Ack agreements and other things.
+ * @NL80211_FEATURE_MAC_ON_CREATE: Device supports configuring
+ *     the vif's MAC address upon creation.
+ *     See 'macaddr' field in the vif_params (cfg80211.h).
  */
 enum nl80211_feature_flags {
        NL80211_FEATURE_SK_TX_STATUS                    = 1 << 0,
@@ -4085,6 +4088,7 @@ enum nl80211_feature_flags {
        NL80211_FEATURE_STATIC_SMPS                     = 1 << 24,
        NL80211_FEATURE_DYNAMIC_SMPS                    = 1 << 25,
        NL80211_FEATURE_SUPPORTS_WMM_ADMISSION          = 1 << 26,
+       NL80211_FEATURE_MAC_ON_CREATE                   = 1 << 27,
 };
 
 /**
index d98d4ea278199c260d8751d094e0dc894aa3f7b5..12736a7cd506959be8e6a42040161b8292cbc5d4 100644 (file)
@@ -2605,7 +2605,9 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
            !(rdev->wiphy.interface_modes & (1 << type)))
                return -EOPNOTSUPP;
 
-       if (type == NL80211_IFTYPE_P2P_DEVICE && info->attrs[NL80211_ATTR_MAC]) {
+       if ((type == NL80211_IFTYPE_P2P_DEVICE ||
+            rdev->wiphy.features & NL80211_FEATURE_MAC_ON_CREATE) &&
+           info->attrs[NL80211_ATTR_MAC]) {
                nla_memcpy(params.macaddr, info->attrs[NL80211_ATTR_MAC],
                           ETH_ALEN);
                if (!is_valid_ether_addr(params.macaddr))