wifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient
authorVinayak Yadawad <vinayak.yadawad@broadcom.com>
Tue, 26 Sep 2023 10:32:22 +0000 (16:02 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 23 Oct 2023 10:50:44 +0000 (12:50 +0200)
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>
Link: https://lore.kernel.org/r/dee3b0a2b4f617e932c90bff4504a89389273632.1695721435.git.vinayak.yadawad@broadcom.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/core.h
net/wireless/nl80211.c
net/wireless/nl80211.h
net/wireless/sme.c
net/wireless/util.c

index 0e7abb083a777fa671410410fe854ee45c345203..b137a33a1b6892190dfa4e9067cf1045b82cf4b4 100644 (file)
@@ -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);
 
 /**
index 79b1c6d17847701fd748fb58036f54d1606df4b7..4c692c7faf30d408ab2cb3101b5344786bb690ab 100644 (file)
@@ -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);
index d468e015d828d5958dae272e0bccf4428ca1cb2d..56fd7cf2563b4a89ee01cff225495a7ceeb99d29 100644 (file)
@@ -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)
index 3edd53c389122d66538d49cb66dfabdb3bd01a0f..aad40240d9cb298cd05de9b2cb80d5535c88413b 100644 (file)
@@ -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,
index 50fcb27e6dabbf35cd1799d4059aacc234b4a5f4..acfe66da7109b7655589acacd21d497050a4f320 100644 (file)
@@ -1281,24 +1281,29 @@ out:
 }
 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 (WARN_ON(!wdev->connected) ||
-           WARN_ON(!ether_addr_equal(wdev->u.client.connected_addr, bssid)))
-               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, 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);
index 0893b7f57832ba5668774f72da358265a61cbfa7..626b858b4b35c5a93e343b9a2ee1a19649a9672f 100644 (file)
@@ -1062,7 +1062,7 @@ void cfg80211_process_wdev_events(struct wireless_dev *wdev)
                        cfg80211_leave(wiphy_to_rdev(wdev->wiphy), wdev);
                        break;
                case EVENT_PORT_AUTHORIZED:
-                       __cfg80211_port_authorized(wdev, ev->pa.bssid,
+                       __cfg80211_port_authorized(wdev, ev->pa.peer_addr,
                                                   ev->pa.td_bitmap,
                                                   ev->pa.td_bitmap_len);
                        break;