diff mbox series

[RFC,4/4] {nl,cfg}nl80211: Support mac change for mlme_authenticate

Message ID 20190904191155.28056-5-prestwoj@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series Allow live MAC address change | expand

Commit Message

James Prestwood Sept. 4, 2019, 7:11 p.m. UTC
---
 net/wireless/core.h    | 3 ++-
 net/wireless/mlme.c    | 9 ++++++++-
 net/wireless/nl80211.c | 7 ++++++-
 net/wireless/sme.c     | 2 +-
 4 files changed, 17 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/wireless/core.h b/net/wireless/core.h
index 29e6ab2cf343..869ab983692d 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -366,7 +366,8 @@  int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
 		       const u8 *ssid, int ssid_len,
 		       const u8 *ie, int ie_len,
 		       const u8 *key, int key_len, int key_idx,
-		       const u8 *auth_data, int auth_data_len);
+		       const u8 *auth_data, int auth_data_len,
+		       const u8 *mac_to_use);
 int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
 			struct net_device *dev,
 			struct ieee80211_channel *chan,
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index f9462010575f..adf411905e64 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -226,7 +226,8 @@  int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
 		       const u8 *ssid, int ssid_len,
 		       const u8 *ie, int ie_len,
 		       const u8 *key, int key_len, int key_idx,
-		       const u8 *auth_data, int auth_data_len)
+		       const u8 *auth_data, int auth_data_len,
+		       const u8 *mac_to_use)
 {
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
 	struct cfg80211_auth_request req = {
@@ -257,6 +258,12 @@  int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
 	if (!req.bss)
 		return -ENOENT;
 
+	if (mac_to_use) {
+		err = cfg80211_set_mac_to_use(dev, mac_to_use);
+		if (err)
+			return err;
+	}
+
 	err = rdev_auth(rdev, dev, &req);
 
 	cfg80211_put_bss(&rdev->wiphy, req.bss);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0202a762b5c8..db32eaaaa50e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8898,6 +8898,7 @@  static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
 	enum nl80211_auth_type auth_type;
 	struct key_parse key;
 	bool local_state_change;
+	const u8 *mac_to_change = NULL;
 
 	if (!info->attrs[NL80211_ATTR_MAC])
 		return -EINVAL;
@@ -8993,6 +8994,10 @@  static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
 
 	local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
 
+	if (info->attrs[NL80211_ATTR_MAC_TO_USE])
+		mac_to_change = nla_data(
+				info->attrs[NL80211_ATTR_MAC_TO_USE]);
+
 	/*
 	 * Since we no longer track auth state, ignore
 	 * requests to only change local state.
@@ -9004,7 +9009,7 @@  static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
 	err = cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
 				 ssid, ssid_len, ie, ie_len,
 				 key.p.key, key.p.key_len, key.idx,
-				 auth_data, auth_data_len);
+				 auth_data, auth_data_len, mac_to_change);
 	wdev_unlock(dev->ieee80211_ptr);
 	return err;
 }
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index f164af33655f..f66ea48b73df 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -174,7 +174,7 @@  static int cfg80211_conn_do_work(struct wireless_dev *wdev,
 					  params->ssid, params->ssid_len,
 					  NULL, 0,
 					  params->key, params->key_len,
-					  params->key_idx, NULL, 0);
+					  params->key_idx, NULL, 0, NULL);
 	case CFG80211_CONN_AUTH_FAILED_TIMEOUT:
 		*treason = NL80211_TIMEOUT_AUTH;
 		return -ENOTCONN;