From 34d26283de8c63ec5ecc912e0404e1449331d474 Mon Sep 17 00:00:00 2001
From: Chung-Hsien Hsu <stanley.hsu@cypress.com>
Date: Thu, 14 Feb 2019 16:33:53 +0800
Subject: [PATCH] nl80211: add authorized flag back to ROAM event

Commit 503c1fb98ba3 ("cfg80211/nl80211: add a port authorized event")
added the NL80211_CMD_PORT_AUTHORIZED event to indicate that a
connection is authorized. It replaced the PORT_AUTHORIZED attribute and
the authorized flag added in commit f45cbe6e691f
("nl80211: add authorized flag to ROAM event").

However, for offload FT, using PORT_AUTHORIZED event mechanism induces
wpa_supplicant to start a full EAP exchange after a successful roaming.
This patch adds the flag mechanism back to the ROAM event for drivers
to fix the offload FT roaming issue.

Signed-off-by: Chung-Hsien Hsu <stanley.hsu@cypress.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
---
 include/net/cfg80211.h       | 5 ++++-
 include/uapi/linux/nl80211.h | 5 ++++-
 net/wireless/nl80211.c       | 4 +++-
 net/wireless/sme.c           | 1 +
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 941dc62f3..bf1dc5d30 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -8291,6 +8291,9 @@ cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
  * @links.bss: For MLO roaming, entry of new bss to which STA link got
  *	roamed. For non-MLO roaming, links[0].bss points to entry of bss to
  *	which STA got roamed (may be %NULL if %links.bssid is set)
+ * @authorized: true if the 802.1X authentication was done by the driver or is
+ *	not needed (e.g., when Fast Transition protocol was used), false
+ *	otherwise. Ignored for networks that don't use 802.1X authentication.
  */
 struct cfg80211_roam_info {
 	const u8 *req_ie;
@@ -8298,7 +8301,6 @@ struct cfg80211_roam_info {
 	const u8 *resp_ie;
 	size_t resp_ie_len;
 	struct cfg80211_fils_resp_params fils;
-
 	const u8 *ap_mld_addr;
 	u16 valid_links;
 	struct {
@@ -8307,6 +8309,7 @@ struct cfg80211_roam_info {
 		struct ieee80211_channel *channel;
 		struct cfg80211_bss *bss;
 	} links[IEEE80211_MLD_MAX_NUM_LINKS];
+	bool authorized;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index f97f5adc8..1bdff5f49 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2583,7 +2583,10 @@ enum nl80211_commands {
  *	in %NL80211_CMD_CONNECT to indicate that for 802.1X authentication it
  *	wants to use the supported offload of the 4-way handshake.
  * @NL80211_ATTR_PMKR0_NAME: PMK-R0 Name for offloaded FT.
- * @NL80211_ATTR_PORT_AUTHORIZED: (reserved)
+ * @NL80211_ATTR_PORT_AUTHORIZED: flag attribute used in %NL80211_CMD_ROAMED
+ *	notification indicating that that 802.1X authentication was done by
+ *	the driver or is not needed (because roaming used the Fast Transition
+ *	protocol).
  *
  * @NL80211_ATTR_EXTERNAL_AUTH_ACTION: Identify the requested external
  *     authentication operation (u32 attribute with an
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 1e78f575f..765a7ead6 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -18375,7 +18375,9 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
 	    (info->fils.pmk &&
 	     nla_put(msg, NL80211_ATTR_PMK, info->fils.pmk_len, info->fils.pmk)) ||
 	    (info->fils.pmkid &&
-	     nla_put(msg, NL80211_ATTR_PMKID, WLAN_PMKID_LEN, info->fils.pmkid)))
+	     nla_put(msg, NL80211_ATTR_PMKID, WLAN_PMKID_LEN, info->fils.pmkid)) ||
+	    (info->authorized &&
+	     nla_put_flag(msg, NL80211_ATTR_PORT_AUTHORIZED)))
 		goto nla_put_failure;
 
 	if (info->valid_links) {
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 268171600..8c2c2b064 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -1271,6 +1271,7 @@ void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
 			next += ETH_ALEN;
 		}
 	}
+	ev->rm.authorized = info->authorized;
 
 	spin_lock_irqsave(&wdev->event_lock, flags);
 	list_add_tail(&ev->list, &wdev->event_list);
-- 
2.39.5 (Apple Git-154)

