Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cfg80211/nl80211: Notify connection request failure in AP mode

In AP mode, when a station requests connection to an AP and if the
request is failed for particular reason, userspace is notified about the
failure through NL80211_CMD_CONN_FAILED command. Reason for the failure
is sent through the attribute NL80211_ATTR_CONN_FAILED_REASON.

Signed-off-by: Pandiyarajan Pitchaimuthu <c_ppitch@qca.qualcomm.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Pandiyarajan Pitchaimuthu and committed by
Johannes Berg
ed44a951 30d08a46

+93
+24
include/linux/nl80211.h
··· 573 573 * @NL80211_CMD_STOP_P2P_DEVICE: Stop the given P2P Device, identified by 574 574 * its %NL80211_ATTR_WDEV identifier. 575 575 * 576 + * @NL80211_CMD_CONN_FAILED: connection request to an AP failed; used to 577 + * notify userspace that AP has rejected the connection request from a 578 + * station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON 579 + * is used for this. 580 + * 576 581 * @NL80211_CMD_MAX: highest used command number 577 582 * @__NL80211_CMD_AFTER_LAST: internal use 578 583 */ ··· 723 718 724 719 NL80211_CMD_START_P2P_DEVICE, 725 720 NL80211_CMD_STOP_P2P_DEVICE, 721 + 722 + NL80211_CMD_CONN_FAILED, 726 723 727 724 /* add new commands above here */ 728 725 ··· 1269 1262 * was used to provide the hint. For the different types of 1270 1263 * allowed user regulatory hints see nl80211_user_reg_hint_type. 1271 1264 * 1265 + * @NL80211_ATTR_CONN_FAILED_REASON: The reason for which AP has rejected 1266 + * the connection request from a station. nl80211_connect_failed_reason 1267 + * enum has different reasons of connection failure. 1268 + * 1272 1269 * @NL80211_ATTR_MAX: highest attribute number currently defined 1273 1270 * @__NL80211_ATTR_AFTER_LAST: internal use 1274 1271 */ ··· 1527 1516 NL80211_ATTR_WDEV, 1528 1517 1529 1518 NL80211_ATTR_USER_REG_HINT_TYPE, 1519 + 1520 + NL80211_ATTR_CONN_FAILED_REASON, 1530 1521 1531 1522 /* add attributes here, update the policy in nl80211.c */ 1532 1523 ··· 3056 3043 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1<<1, 3057 3044 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1<<2, 3058 3045 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3, 3046 + }; 3047 + 3048 + /** 3049 + * enum nl80211_connect_failed_reason - connection request failed reasons 3050 + * @NL80211_CONN_FAIL_MAX_CLIENTS: Maximum number of clients that can be 3051 + * handled by the AP is reached. 3052 + * @NL80211_CONN_FAIL_BLOCKED_CLIENT: Client's MAC is in the AP's blocklist. 3053 + */ 3054 + enum nl80211_connect_failed_reason { 3055 + NL80211_CONN_FAIL_MAX_CLIENTS, 3056 + NL80211_CONN_FAIL_BLOCKED_CLIENT, 3059 3057 }; 3060 3058 3061 3059 #endif /* __LINUX_NL80211_H */
+19
include/net/cfg80211.h
··· 3361 3361 void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); 3362 3362 3363 3363 /** 3364 + * cfg80211_conn_failed - connection request failed notification 3365 + * 3366 + * @dev: the netdev 3367 + * @mac_addr: the station's address 3368 + * @reason: the reason for connection failure 3369 + * @gfp: allocation flags 3370 + * 3371 + * Whenever a station tries to connect to an AP and if the station 3372 + * could not connect to the AP as the AP has rejected the connection 3373 + * for some reasons, this function is called. 3374 + * 3375 + * The reason for connection failure can be any of the value from 3376 + * nl80211_connect_failed_reason enum 3377 + */ 3378 + void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, 3379 + enum nl80211_connect_failed_reason reason, 3380 + gfp_t gfp); 3381 + 3382 + /** 3364 3383 * cfg80211_rx_mgmt - notification of received, unprocessed management frame 3365 3384 * @wdev: wireless device receiving the frame 3366 3385 * @freq: Frequency on which the frame was received in MHz
+11
net/wireless/mlme.c
··· 612 612 } 613 613 EXPORT_SYMBOL(cfg80211_del_sta); 614 614 615 + void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, 616 + enum nl80211_connect_failed_reason reason, 617 + gfp_t gfp) 618 + { 619 + struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 620 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 621 + 622 + nl80211_send_conn_failed_event(rdev, dev, mac_addr, reason, gfp); 623 + } 624 + EXPORT_SYMBOL(cfg80211_conn_failed); 625 + 615 626 struct cfg80211_mgmt_registration { 616 627 struct list_head list; 617 628
+34
net/wireless/nl80211.c
··· 8364 8364 nlmsg_free(msg); 8365 8365 } 8366 8366 8367 + void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, 8368 + struct net_device *dev, const u8 *mac_addr, 8369 + enum nl80211_connect_failed_reason reason, 8370 + gfp_t gfp) 8371 + { 8372 + struct sk_buff *msg; 8373 + void *hdr; 8374 + 8375 + msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8376 + if (!msg) 8377 + return; 8378 + 8379 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CONN_FAILED); 8380 + if (!hdr) { 8381 + nlmsg_free(msg); 8382 + return; 8383 + } 8384 + 8385 + if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 8386 + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) || 8387 + nla_put_u32(msg, NL80211_ATTR_CONN_FAILED_REASON, reason)) 8388 + goto nla_put_failure; 8389 + 8390 + genlmsg_end(msg, hdr); 8391 + 8392 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 8393 + nl80211_mlme_mcgrp.id, gfp); 8394 + return; 8395 + 8396 + nla_put_failure: 8397 + genlmsg_cancel(msg, hdr); 8398 + nlmsg_free(msg); 8399 + } 8400 + 8367 8401 static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd, 8368 8402 const u8 *addr, gfp_t gfp) 8369 8403 {
+5
net/wireless/nl80211.h
··· 91 91 struct net_device *dev, const u8 *mac_addr, 92 92 gfp_t gfp); 93 93 94 + void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, 95 + struct net_device *dev, const u8 *mac_addr, 96 + enum nl80211_connect_failed_reason reason, 97 + gfp_t gfp); 98 + 94 99 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, 95 100 struct wireless_dev *wdev, u32 nlpid, 96 101 int freq, int sig_dbm,