Commit e4e7e3af authored by Vinayak Yadawad's avatar Vinayak Yadawad Committed by Johannes Berg
Browse files

wifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient



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: default avatarVinayak Yadawad <vinayak.yadawad@broadcom.com>
Link: https://lore.kernel.org/r/dee3b0a2b4f617e932c90bff4504a89389273632.1695721435.git.vinayak.yadawad@broadcom.com


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent cf912ca1
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -8028,7 +8028,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_addr: BSSID of the AP/P2P GO in case of STA/GC or STA/GC MAC address
 *	in case of AP/P2P GO
 * @td_bitmap: transition disable policy
 * @td_bitmap_len: Length of transition disable policy
 * @gfp: allocation flags
@@ -8039,8 +8040,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_addr,
			      const u8* td_bitmap, u8 td_bitmap_len, gfp_t gfp);

/**
+2 −2
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ struct cfg80211_event {
			struct ieee80211_channel *channel;
		} ij;
		struct {
			u8 bssid[ETH_ALEN];
			u8 peer_addr[ETH_ALEN];
			const u8 *td_bitmap;
			u8 td_bitmap_len;
		} pa;
@@ -404,7 +404,7 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
			bool wextev);
void __cfg80211_roamed(struct wireless_dev *wdev,
		       struct cfg80211_roam_info *info);
void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *bssid,
void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *peer_addr,
				const u8 *td_bitmap, u8 td_bitmap_len);
int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
			      struct wireless_dev *wdev);
+2 −2
Original line number Diff line number Diff line
@@ -18124,7 +18124,7 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
}
void nl80211_send_port_authorized(struct cfg80211_registered_device *rdev,
				  struct net_device *netdev, const u8 *bssid,
				  struct net_device *netdev, const u8 *peer_addr,
				  const u8 *td_bitmap, u8 td_bitmap_len)
{
	struct sk_buff *msg;
@@ -18142,7 +18142,7 @@ void nl80211_send_port_authorized(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) ||
	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid))
	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer_addr))
		goto nla_put_failure;
	if ((td_bitmap_len > 0) && td_bitmap)
+4 −1
Original line number Diff line number Diff line
@@ -82,8 +82,11 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
			 struct net_device *netdev,
			 struct cfg80211_roam_info *info, gfp_t gfp);
/* For STA/GC, indicate port authorized with AP/GO bssid.
 * For GO/AP, use peer GC/STA mac_addr.
 */
void nl80211_send_port_authorized(struct cfg80211_registered_device *rdev,
				  struct net_device *netdev, const u8 *bssid,
				  struct net_device *netdev, const u8 *peer_addr,
				  const u8 *td_bitmap, u8 td_bitmap_len);
void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
			       struct net_device *netdev, u16 reason,
+14 −9
Original line number Diff line number Diff line
@@ -1281,24 +1281,29 @@ 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_addr,
					const u8 *td_bitmap, u8 td_bitmap_len)
{
	lockdep_assert_wiphy(wdev->wiphy);

	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 (wdev->iftype == NL80211_IFTYPE_STATION ||
		wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) {
		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_addr)))
			return;
	}

	nl80211_send_port_authorized(wiphy_to_rdev(wdev->wiphy), wdev->netdev,
				     bssid, td_bitmap, td_bitmap_len);
				     peer_addr, 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_addr,
			      const u8 *td_bitmap, u8 td_bitmap_len, gfp_t gfp)
{
	struct wireless_dev *wdev = dev->ieee80211_ptr;
@@ -1306,7 +1311,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_addr))
		return;

	ev = kzalloc(sizeof(*ev) + td_bitmap_len, gfp);
@@ -1314,7 +1319,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.peer_addr, peer_addr, 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);
Loading