diff mbox series

[1/1] cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient

Message ID 85614ee38fd3f68ade1810c2be0863c45c22fef1.1694499025.git.vinayak.yadawad@broadcom.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series [1/1] cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient | expand

Commit Message

Vinayak Yadawad Sept. 12, 2023, 6:54 a.m. UTC
In 4way handshake offload, cfg80211_port_authorized
enables driver to indicate successful 4way handshake to cfg80211 layer.
Currently this path of port authorization is restricted to
interface type NL80211_IFTYPE_STATION and NL80211_IFTYPE_P2P_CLIENT.
This patch extends the support for NL80211_IFTYPE_AP and
NL80211_IFTYPE_P2P_GO interfaces to authorize peer STA/P2P_CLIENT,
whenever authentication is offloaded on the AP/P2P_GO interface.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
---
 include/net/cfg80211.h |  8 ++++++--
 net/wireless/sme.c     | 18 +++++++++++-------
 2 files changed, 17 insertions(+), 9 deletions(-)

Comments

Johannes Berg Sept. 13, 2023, 9:31 a.m. UTC | #1
On Tue, 2023-09-12 at 12:24 +0530, Vinayak Yadawad wrote:
> In 4way handshake offload, cfg80211_port_authorized
> enables driver to indicate successful 4way handshake to cfg80211 layer.
> Currently this path of port authorization is restricted to
> interface type NL80211_IFTYPE_STATION and NL80211_IFTYPE_P2P_CLIENT.
> This patch extends the support for NL80211_IFTYPE_AP and
> NL80211_IFTYPE_P2P_GO interfaces to authorize peer STA/P2P_CLIENT,
> whenever authentication is offloaded on the AP/P2P_GO interface.

It seems that this should at least also come with documentation updates
in nl80211.h?

And proper code indentation :-)

> - * @bssid: the BSSID of the AP
> + * @peer_mac: BSSID of the AP/P2P GO in case of STA/GC or STA/GC macaddress in
> + * case of AP/P2P GO

And "peer_addr" is probably better? Technically, after all, it's the
"MAC address" (which you also spelled wrong), but the "MAC" itself :)

johannes
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 3a4b684f89bf..0ce46d0fd5ac 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -7967,7 +7967,8 @@  void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
  * cfg80211_port_authorized - notify cfg80211 of successful security association
  *
  * @dev: network device
- * @bssid: the BSSID of the AP
+ * @peer_mac: BSSID of the AP/P2P GO in case of STA/GC or STA/GC macaddress in
+ * case of AP/P2P GO
  * @td_bitmap: transition disable policy
  * @td_bitmap_len: Length of transition disable policy
  * @gfp: allocation flags
@@ -7978,8 +7979,11 @@  void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
  * should be preceded with a call to cfg80211_connect_result(),
  * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
  * indicate the 802.11 association.
+ * This function can also be called by AP/P2P GO driver that supports
+ * authentication offload. In this case the peer_mac passed is that of
+ * associated STA/GC.
  */
-void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
+void cfg80211_port_authorized(struct net_device *dev, const u8 *peer_mac,
 			      const u8* td_bitmap, u8 td_bitmap_len, gfp_t gfp);
 
 /**
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 9bba233b5a6e..f4384e0cce7d 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -1294,24 +1294,28 @@  void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
 }
 EXPORT_SYMBOL(cfg80211_roamed);
 
-void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *bssid,
+void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *peer_mac,
 					const u8 *td_bitmap, u8 td_bitmap_len)
 {
 	ASSERT_WDEV_LOCK(wdev);
 
 	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
-		    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT))
+		    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT &&
+		    wdev->iftype != NL80211_IFTYPE_AP &&
+		    wdev->iftype != NL80211_IFTYPE_P2P_GO))
 		return;
 
 	if (WARN_ON(!wdev->connected) ||
-	    WARN_ON(!ether_addr_equal(wdev->u.client.connected_addr, bssid)))
+	    WARN_ON((!ether_addr_equal(wdev->u.client.connected_addr, peer_mac) &&
+	    (wdev->iftype == NL80211_IFTYPE_STATION ||
+	    wdev->iftype == NL80211_IFTYPE_P2P_CLIENT))))
 		return;
 
 	nl80211_send_port_authorized(wiphy_to_rdev(wdev->wiphy), wdev->netdev,
-				     bssid, td_bitmap, td_bitmap_len);
+				     peer_mac, td_bitmap, td_bitmap_len);
 }
 
-void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
+void cfg80211_port_authorized(struct net_device *dev, const u8 *peer_mac,
 			      const u8 *td_bitmap, u8 td_bitmap_len, gfp_t gfp)
 {
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
@@ -1319,7 +1323,7 @@  void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
 	struct cfg80211_event *ev;
 	unsigned long flags;
 
-	if (WARN_ON(!bssid))
+	if (WARN_ON(!peer_mac))
 		return;
 
 	ev = kzalloc(sizeof(*ev) + td_bitmap_len, gfp);
@@ -1327,7 +1331,7 @@  void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
 		return;
 
 	ev->type = EVENT_PORT_AUTHORIZED;
-	memcpy(ev->pa.bssid, bssid, ETH_ALEN);
+	memcpy(ev->pa.bssid, peer_mac, ETH_ALEN);
 	ev->pa.td_bitmap = ((u8 *)ev) + sizeof(*ev);
 	ev->pa.td_bitmap_len = td_bitmap_len;
 	memcpy((void *)ev->pa.td_bitmap, td_bitmap, td_bitmap_len);