aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-05-15 18:55:00 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-06-04 07:03:10 -0400
commit6ff57cf88807dd81300b5b9c623dc5eb6422b9f6 (patch)
tree8819fea1f493077ff311208986ebfe27bd327623
parent51217cee3a94d5409d6ee2ac090ae96bc9a06757 (diff)
cfg80211/mac80211: clean up cfg80211 SME APIs
Do some cleanups in the cfg80211 SME APIs, which are only used by mac80211. Most of these functions get a frame passed, and there isn't really any reason to export multiple functions as cfg80211 can check the frame type instead, do that. Additionally, the API functions have confusing names like cfg80211_send_...() which was meant to indicate that it sends an event to userspace, but gets a bit confusing when there's both TX and RX and they're not all clearly labeled. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--include/net/cfg80211.h91
-rw-r--r--net/mac80211/mlme.c44
-rw-r--r--net/mac80211/rx.c26
-rw-r--r--net/wireless/mlme.c86
-rw-r--r--net/wireless/nl80211.c30
-rw-r--r--net/wireless/trace.h46
6 files changed, 170 insertions, 153 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 6169fca216b4..195330d4ef34 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3432,59 +3432,66 @@ void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
3432void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss); 3432void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
3433 3433
3434/** 3434/**
3435 * cfg80211_send_rx_auth - notification of processed authentication 3435 * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
3436 * @dev: network device 3436 * @dev: network device
3437 * @buf: authentication frame (header + body) 3437 * @buf: authentication frame (header + body)
3438 * @len: length of the frame data 3438 * @len: length of the frame data
3439 * 3439 *
3440 * This function is called whenever an authentication has been processed in 3440 * This function is called whenever an authentication, disassociation or
3441 * station mode. The driver is required to call either this function or 3441 * deauthentication frame has been received and processed in station mode.
3442 * cfg80211_send_auth_timeout() to indicate the result of cfg80211_ops::auth() 3442 * After being asked to authenticate via cfg80211_ops::auth() the driver must
3443 * call. This function may sleep. The caller must hold the corresponding wdev's 3443 * call either this function or cfg80211_auth_timeout().
3444 * mutex. 3444 * After being asked to associate via cfg80211_ops::assoc() the driver must
3445 * call either this function or cfg80211_auth_timeout().
3446 * While connected, the driver must calls this for received and processed
3447 * disassociation and deauthentication frames. If the frame couldn't be used
3448 * because it was unprotected, the driver must call the function
3449 * cfg80211_rx_unprot_mlme_mgmt() instead.
3450 *
3451 * This function may sleep. The caller must hold the corresponding wdev's mutex.
3445 */ 3452 */
3446void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len); 3453void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
3447 3454
3448/** 3455/**
3449 * cfg80211_send_auth_timeout - notification of timed out authentication 3456 * cfg80211_auth_timeout - notification of timed out authentication
3450 * @dev: network device 3457 * @dev: network device
3451 * @addr: The MAC address of the device with which the authentication timed out 3458 * @addr: The MAC address of the device with which the authentication timed out
3452 * 3459 *
3453 * This function may sleep. The caller must hold the corresponding wdev's 3460 * This function may sleep. The caller must hold the corresponding wdev's
3454 * mutex. 3461 * mutex.
3455 */ 3462 */
3456void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr); 3463void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
3457 3464
3458/** 3465/**
3459 * cfg80211_send_rx_assoc - notification of processed association 3466 * cfg80211_rx_assoc_resp - notification of processed association response
3460 * @dev: network device 3467 * @dev: network device
3461 * @bss: the BSS struct association was requested for, the struct reference 3468 * @bss: the BSS that association was requested with, ownership of the pointer
3462 * is owned by cfg80211 after this call 3469 * moves to cfg80211 in this call
3463 * @buf: (re)association response frame (header + body) 3470 * @buf: authentication frame (header + body)
3464 * @len: length of the frame data 3471 * @len: length of the frame data
3465 * 3472 *
3466 * This function is called whenever a (re)association response has been 3473 * After being asked to associate via cfg80211_ops::assoc() the driver must
3467 * processed in station mode. The driver is required to call either this 3474 * call either this function or cfg80211_auth_timeout().
3468 * function or cfg80211_send_assoc_timeout() to indicate the result of 3475 *
3469 * cfg80211_ops::assoc() call. This function may sleep. The caller must hold 3476 * This function may sleep. The caller must hold the corresponding wdev's mutex.
3470 * the corresponding wdev's mutex.
3471 */ 3477 */
3472void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, 3478void cfg80211_rx_assoc_resp(struct net_device *dev,
3479 struct cfg80211_bss *bss,
3473 const u8 *buf, size_t len); 3480 const u8 *buf, size_t len);
3474 3481
3475/** 3482/**
3476 * cfg80211_send_assoc_timeout - notification of timed out association 3483 * cfg80211_assoc_timeout - notification of timed out association
3477 * @dev: network device 3484 * @dev: network device
3478 * @addr: The MAC address of the device with which the association timed out 3485 * @addr: The MAC address of the device with which the association timed out
3479 * 3486 *
3480 * This function may sleep. The caller must hold the corresponding wdev's mutex. 3487 * This function may sleep. The caller must hold the corresponding wdev's mutex.
3481 */ 3488 */
3482void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr); 3489void cfg80211_assoc_timeout(struct net_device *dev, const u8 *addr);
3483 3490
3484/** 3491/**
3485 * cfg80211_send_deauth - notification of processed deauthentication 3492 * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
3486 * @dev: network device 3493 * @dev: network device
3487 * @buf: deauthentication frame (header + body) 3494 * @buf: 802.11 frame (header + body)
3488 * @len: length of the frame data 3495 * @len: length of the frame data
3489 * 3496 *
3490 * This function is called whenever deauthentication has been processed in 3497 * This function is called whenever deauthentication has been processed in
@@ -3492,46 +3499,20 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr);
3492 * locally generated ones. This function may sleep. The caller must hold the 3499 * locally generated ones. This function may sleep. The caller must hold the
3493 * corresponding wdev's mutex. 3500 * corresponding wdev's mutex.
3494 */ 3501 */
3495void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len); 3502void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
3496 3503
3497/** 3504/**
3498 * cfg80211_send_disassoc - notification of processed disassociation 3505 * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
3499 * @dev: network device
3500 * @buf: disassociation response frame (header + body)
3501 * @len: length of the frame data
3502 *
3503 * This function is called whenever disassociation has been processed in
3504 * station mode. This includes both received disassociation frames and locally
3505 * generated ones. This function may sleep. The caller must hold the
3506 * corresponding wdev's mutex.
3507 */
3508void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len);
3509
3510/**
3511 * cfg80211_send_unprot_deauth - notification of unprotected deauthentication
3512 * @dev: network device 3506 * @dev: network device
3513 * @buf: deauthentication frame (header + body) 3507 * @buf: deauthentication frame (header + body)
3514 * @len: length of the frame data 3508 * @len: length of the frame data
3515 * 3509 *
3516 * This function is called whenever a received Deauthentication frame has been 3510 * This function is called whenever a received deauthentication or dissassoc
3517 * dropped in station mode because of MFP being used but the Deauthentication 3511 * frame has been dropped in station mode because of MFP being used but the
3518 * frame was not protected. This function may sleep.
3519 */
3520void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf,
3521 size_t len);
3522
3523/**
3524 * cfg80211_send_unprot_disassoc - notification of unprotected disassociation
3525 * @dev: network device
3526 * @buf: disassociation frame (header + body)
3527 * @len: length of the frame data
3528 *
3529 * This function is called whenever a received Disassociation frame has been
3530 * dropped in station mode because of MFP being used but the Disassociation
3531 * frame was not protected. This function may sleep. 3512 * frame was not protected. This function may sleep.
3532 */ 3513 */
3533void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, 3514void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
3534 size_t len); 3515 const u8 *buf, size_t len);
3535 3516
3536/** 3517/**
3537 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP) 3518 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 9950e13f641b..df8170a80a56 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2155,7 +2155,8 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
2155 IEEE80211_MAX_QUEUE_MAP, 2155 IEEE80211_MAX_QUEUE_MAP,
2156 IEEE80211_QUEUE_STOP_REASON_CSA); 2156 IEEE80211_QUEUE_STOP_REASON_CSA);
2157 2157
2158 cfg80211_send_deauth(sdata->dev, frame_buf, IEEE80211_DEAUTH_FRAME_LEN); 2158 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
2159 IEEE80211_DEAUTH_FRAME_LEN);
2159 sdata_unlock(sdata); 2160 sdata_unlock(sdata);
2160} 2161}
2161 2162
@@ -2302,7 +2303,7 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
2302 sdata_info(sdata, "%pM denied authentication (status %d)\n", 2303 sdata_info(sdata, "%pM denied authentication (status %d)\n",
2303 mgmt->sa, status_code); 2304 mgmt->sa, status_code);
2304 ieee80211_destroy_auth_data(sdata, false); 2305 ieee80211_destroy_auth_data(sdata, false);
2305 cfg80211_send_rx_auth(sdata->dev, (u8 *)mgmt, len); 2306 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
2306 return; 2307 return;
2307 } 2308 }
2308 2309
@@ -2337,7 +2338,7 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
2337 * Report auth frame to user space for processing since another 2338 * Report auth frame to user space for processing since another
2338 * round of Authentication frames is still needed. 2339 * round of Authentication frames is still needed.
2339 */ 2340 */
2340 cfg80211_send_rx_auth(sdata->dev, (u8 *)mgmt, len); 2341 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
2341 return; 2342 return;
2342 } 2343 }
2343 2344
@@ -2354,7 +2355,7 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
2354 } 2355 }
2355 mutex_unlock(&sdata->local->sta_mtx); 2356 mutex_unlock(&sdata->local->sta_mtx);
2356 2357
2357 cfg80211_send_rx_auth(sdata->dev, (u8 *)mgmt, len); 2358 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
2358 return; 2359 return;
2359 out_err: 2360 out_err:
2360 mutex_unlock(&sdata->local->sta_mtx); 2361 mutex_unlock(&sdata->local->sta_mtx);
@@ -2387,7 +2388,7 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
2387 2388
2388 ieee80211_set_disassoc(sdata, 0, 0, false, NULL); 2389 ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
2389 2390
2390 cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, len); 2391 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
2391} 2392}
2392 2393
2393 2394
@@ -2413,7 +2414,7 @@ static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
2413 2414
2414 ieee80211_set_disassoc(sdata, 0, 0, false, NULL); 2415 ieee80211_set_disassoc(sdata, 0, 0, false, NULL);
2415 2416
2416 cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, len); 2417 cfg80211_rx_mlme_mgmt(sdata->dev, (u8 *)mgmt, len);
2417} 2418}
2418 2419
2419static void ieee80211_get_rates(struct ieee80211_supported_band *sband, 2420static void ieee80211_get_rates(struct ieee80211_supported_band *sband,
@@ -2711,7 +2712,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
2711 /* oops -- internal error -- send timeout for now */ 2712 /* oops -- internal error -- send timeout for now */
2712 ieee80211_destroy_assoc_data(sdata, false); 2713 ieee80211_destroy_assoc_data(sdata, false);
2713 cfg80211_put_bss(sdata->local->hw.wiphy, bss); 2714 cfg80211_put_bss(sdata->local->hw.wiphy, bss);
2714 cfg80211_send_assoc_timeout(sdata->dev, mgmt->bssid); 2715 cfg80211_assoc_timeout(sdata->dev, mgmt->bssid);
2715 return; 2716 return;
2716 } 2717 }
2717 sdata_info(sdata, "associated\n"); 2718 sdata_info(sdata, "associated\n");
@@ -2724,7 +2725,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
2724 ieee80211_destroy_assoc_data(sdata, true); 2725 ieee80211_destroy_assoc_data(sdata, true);
2725 } 2726 }
2726 2727
2727 cfg80211_send_rx_assoc(sdata->dev, bss, (u8 *)mgmt, len); 2728 cfg80211_rx_assoc_resp(sdata->dev, bss, (u8 *)mgmt, len);
2728} 2729}
2729 2730
2730static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, 2731static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
@@ -3117,8 +3118,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
3117 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, 3118 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
3118 WLAN_REASON_DEAUTH_LEAVING, 3119 WLAN_REASON_DEAUTH_LEAVING,
3119 true, deauth_buf); 3120 true, deauth_buf);
3120 cfg80211_send_deauth(sdata->dev, deauth_buf, 3121 cfg80211_tx_mlme_mgmt(sdata->dev, deauth_buf,
3121 sizeof(deauth_buf)); 3122 sizeof(deauth_buf));
3122 return; 3123 return;
3123 } 3124 }
3124 3125
@@ -3236,7 +3237,8 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata,
3236 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason, 3237 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason,
3237 tx, frame_buf); 3238 tx, frame_buf);
3238 3239
3239 cfg80211_send_deauth(sdata->dev, frame_buf, IEEE80211_DEAUTH_FRAME_LEN); 3240 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
3241 IEEE80211_DEAUTH_FRAME_LEN);
3240} 3242}
3241 3243
3242static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) 3244static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata)
@@ -3427,7 +3429,7 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
3427 3429
3428 ieee80211_destroy_auth_data(sdata, false); 3430 ieee80211_destroy_auth_data(sdata, false);
3429 3431
3430 cfg80211_send_auth_timeout(sdata->dev, bssid); 3432 cfg80211_auth_timeout(sdata->dev, bssid);
3431 } 3433 }
3432 } else if (ifmgd->auth_data && ifmgd->auth_data->timeout_started) 3434 } else if (ifmgd->auth_data && ifmgd->auth_data->timeout_started)
3433 run_again(sdata, ifmgd->auth_data->timeout); 3435 run_again(sdata, ifmgd->auth_data->timeout);
@@ -3443,7 +3445,7 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
3443 3445
3444 ieee80211_destroy_assoc_data(sdata, false); 3446 ieee80211_destroy_assoc_data(sdata, false);
3445 3447
3446 cfg80211_send_assoc_timeout(sdata->dev, bssid); 3448 cfg80211_assoc_timeout(sdata->dev, bssid);
3447 } 3449 }
3448 } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started) 3450 } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started)
3449 run_again(sdata, ifmgd->assoc_data->timeout); 3451 run_again(sdata, ifmgd->assoc_data->timeout);
@@ -3992,8 +3994,8 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
3992 WLAN_REASON_UNSPECIFIED, 3994 WLAN_REASON_UNSPECIFIED,
3993 false, frame_buf); 3995 false, frame_buf);
3994 3996
3995 cfg80211_send_deauth(sdata->dev, frame_buf, 3997 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
3996 sizeof(frame_buf)); 3998 sizeof(frame_buf));
3997 } 3999 }
3998 4000
3999 sdata_info(sdata, "authenticate with %pM\n", req->bss->bssid); 4001 sdata_info(sdata, "authenticate with %pM\n", req->bss->bssid);
@@ -4055,8 +4057,8 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
4055 WLAN_REASON_UNSPECIFIED, 4057 WLAN_REASON_UNSPECIFIED,
4056 false, frame_buf); 4058 false, frame_buf);
4057 4059
4058 cfg80211_send_deauth(sdata->dev, frame_buf, 4060 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
4059 sizeof(frame_buf)); 4061 sizeof(frame_buf));
4060 } 4062 }
4061 4063
4062 if (ifmgd->auth_data && !ifmgd->auth_data->done) { 4064 if (ifmgd->auth_data && !ifmgd->auth_data->done) {
@@ -4309,8 +4311,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
4309 4311
4310 out: 4312 out:
4311 if (report_frame) 4313 if (report_frame)
4312 cfg80211_send_deauth(sdata->dev, frame_buf, 4314 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
4313 IEEE80211_DEAUTH_FRAME_LEN); 4315 IEEE80211_DEAUTH_FRAME_LEN);
4314 4316
4315 return 0; 4317 return 0;
4316} 4318}
@@ -4340,8 +4342,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
4340 req->reason_code, !req->local_state_change, 4342 req->reason_code, !req->local_state_change,
4341 frame_buf); 4343 frame_buf);
4342 4344
4343 cfg80211_send_disassoc(sdata->dev, frame_buf, 4345 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
4344 IEEE80211_DEAUTH_FRAME_LEN); 4346 IEEE80211_DEAUTH_FRAME_LEN);
4345 4347
4346 return 0; 4348 return 0;
4347} 4349}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index bdd7b4a719e9..23dbcfc69b3b 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1747,27 +1747,21 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
1747 if (unlikely(!ieee80211_has_protected(fc) && 1747 if (unlikely(!ieee80211_has_protected(fc) &&
1748 ieee80211_is_unicast_robust_mgmt_frame(rx->skb) && 1748 ieee80211_is_unicast_robust_mgmt_frame(rx->skb) &&
1749 rx->key)) { 1749 rx->key)) {
1750 if (ieee80211_is_deauth(fc)) 1750 if (ieee80211_is_deauth(fc) ||
1751 cfg80211_send_unprot_deauth(rx->sdata->dev, 1751 ieee80211_is_disassoc(fc))
1752 rx->skb->data, 1752 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
1753 rx->skb->len); 1753 rx->skb->data,
1754 else if (ieee80211_is_disassoc(fc)) 1754 rx->skb->len);
1755 cfg80211_send_unprot_disassoc(rx->sdata->dev,
1756 rx->skb->data,
1757 rx->skb->len);
1758 return -EACCES; 1755 return -EACCES;
1759 } 1756 }
1760 /* BIP does not use Protected field, so need to check MMIE */ 1757 /* BIP does not use Protected field, so need to check MMIE */
1761 if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx->skb) && 1758 if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx->skb) &&
1762 ieee80211_get_mmie_keyidx(rx->skb) < 0)) { 1759 ieee80211_get_mmie_keyidx(rx->skb) < 0)) {
1763 if (ieee80211_is_deauth(fc)) 1760 if (ieee80211_is_deauth(fc) ||
1764 cfg80211_send_unprot_deauth(rx->sdata->dev, 1761 ieee80211_is_disassoc(fc))
1765 rx->skb->data, 1762 cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
1766 rx->skb->len); 1763 rx->skb->data,
1767 else if (ieee80211_is_disassoc(fc)) 1764 rx->skb->len);
1768 cfg80211_send_unprot_disassoc(rx->sdata->dev,
1769 rx->skb->data,
1770 rx->skb->len);
1771 return -EACCES; 1765 return -EACCES;
1772 } 1766 }
1773 /* 1767 /*
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 7bde5d9c0003..4b9c2be0d56d 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -18,20 +18,7 @@
18#include "rdev-ops.h" 18#include "rdev-ops.h"
19 19
20 20
21void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) 21void cfg80211_rx_assoc_resp(struct net_device *dev, struct cfg80211_bss *bss,
22{
23 struct wireless_dev *wdev = dev->ieee80211_ptr;
24 struct wiphy *wiphy = wdev->wiphy;
25 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
26
27 trace_cfg80211_send_rx_auth(dev);
28
29 nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL);
30 cfg80211_sme_rx_auth(dev, buf, len);
31}
32EXPORT_SYMBOL(cfg80211_send_rx_auth);
33
34void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss,
35 const u8 *buf, size_t len) 22 const u8 *buf, size_t len)
36{ 23{
37 u16 status_code; 24 u16 status_code;
@@ -84,10 +71,10 @@ void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss,
84 status_code, 71 status_code,
85 status_code == WLAN_STATUS_SUCCESS, bss); 72 status_code == WLAN_STATUS_SUCCESS, bss);
86} 73}
87EXPORT_SYMBOL(cfg80211_send_rx_assoc); 74EXPORT_SYMBOL(cfg80211_rx_assoc_resp);
88 75
89void cfg80211_send_deauth(struct net_device *dev, 76static void cfg80211_process_deauth(struct net_device *dev,
90 const u8 *buf, size_t len) 77 const u8 *buf, size_t len)
91{ 78{
92 struct wireless_dev *wdev = dev->ieee80211_ptr; 79 struct wireless_dev *wdev = dev->ieee80211_ptr;
93 struct wiphy *wiphy = wdev->wiphy; 80 struct wiphy *wiphy = wdev->wiphy;
@@ -96,9 +83,6 @@ void cfg80211_send_deauth(struct net_device *dev,
96 const u8 *bssid = mgmt->bssid; 83 const u8 *bssid = mgmt->bssid;
97 bool was_current = false; 84 bool was_current = false;
98 85
99 trace_cfg80211_send_deauth(dev);
100 ASSERT_WDEV_LOCK(wdev);
101
102 if (wdev->current_bss && 86 if (wdev->current_bss &&
103 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) { 87 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
104 cfg80211_unhold_bss(wdev->current_bss); 88 cfg80211_unhold_bss(wdev->current_bss);
@@ -123,10 +107,9 @@ void cfg80211_send_deauth(struct net_device *dev,
123 false, NULL); 107 false, NULL);
124 } 108 }
125} 109}
126EXPORT_SYMBOL(cfg80211_send_deauth);
127 110
128void cfg80211_send_disassoc(struct net_device *dev, 111static void cfg80211_process_disassoc(struct net_device *dev,
129 const u8 *buf, size_t len) 112 const u8 *buf, size_t len)
130{ 113{
131 struct wireless_dev *wdev = dev->ieee80211_ptr; 114 struct wireless_dev *wdev = dev->ieee80211_ptr;
132 struct wiphy *wiphy = wdev->wiphy; 115 struct wiphy *wiphy = wdev->wiphy;
@@ -136,9 +119,6 @@ void cfg80211_send_disassoc(struct net_device *dev,
136 u16 reason_code; 119 u16 reason_code;
137 bool from_ap; 120 bool from_ap;
138 121
139 trace_cfg80211_send_disassoc(dev);
140 ASSERT_WDEV_LOCK(wdev);
141
142 nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL); 122 nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL);
143 123
144 if (wdev->sme_state != CFG80211_SME_CONNECTED) 124 if (wdev->sme_state != CFG80211_SME_CONNECTED)
@@ -153,15 +133,38 @@ void cfg80211_send_disassoc(struct net_device *dev,
153 } else 133 } else
154 WARN_ON(1); 134 WARN_ON(1);
155 135
156
157 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 136 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
158 137
159 from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr); 138 from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr);
160 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); 139 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
161} 140}
162EXPORT_SYMBOL(cfg80211_send_disassoc);
163 141
164void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) 142void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len)
143{
144 struct wireless_dev *wdev = dev->ieee80211_ptr;
145 struct wiphy *wiphy = wdev->wiphy;
146 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
147 struct ieee80211_mgmt *mgmt = (void *)buf;
148
149 ASSERT_WDEV_LOCK(wdev);
150
151 trace_cfg80211_rx_mlme_mgmt(dev, buf, len);
152
153 if (WARN_ON(len < 2))
154 return;
155
156 if (ieee80211_is_auth(mgmt->frame_control)) {
157 nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL);
158 cfg80211_sme_rx_auth(dev, buf, len);
159 } else if (ieee80211_is_deauth(mgmt->frame_control)) {
160 cfg80211_process_deauth(dev, buf, len);
161 } else if (ieee80211_is_disassoc(mgmt->frame_control)) {
162 cfg80211_process_disassoc(dev, buf, len);
163 }
164}
165EXPORT_SYMBOL(cfg80211_rx_mlme_mgmt);
166
167void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr)
165{ 168{
166 struct wireless_dev *wdev = dev->ieee80211_ptr; 169 struct wireless_dev *wdev = dev->ieee80211_ptr;
167 struct wiphy *wiphy = wdev->wiphy; 170 struct wiphy *wiphy = wdev->wiphy;
@@ -175,9 +178,9 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
175 WLAN_STATUS_UNSPECIFIED_FAILURE, 178 WLAN_STATUS_UNSPECIFIED_FAILURE,
176 false, NULL); 179 false, NULL);
177} 180}
178EXPORT_SYMBOL(cfg80211_send_auth_timeout); 181EXPORT_SYMBOL(cfg80211_auth_timeout);
179 182
180void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr) 183void cfg80211_assoc_timeout(struct net_device *dev, const u8 *addr)
181{ 184{
182 struct wireless_dev *wdev = dev->ieee80211_ptr; 185 struct wireless_dev *wdev = dev->ieee80211_ptr;
183 struct wiphy *wiphy = wdev->wiphy; 186 struct wiphy *wiphy = wdev->wiphy;
@@ -191,7 +194,26 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr)
191 WLAN_STATUS_UNSPECIFIED_FAILURE, 194 WLAN_STATUS_UNSPECIFIED_FAILURE,
192 false, NULL); 195 false, NULL);
193} 196}
194EXPORT_SYMBOL(cfg80211_send_assoc_timeout); 197EXPORT_SYMBOL(cfg80211_assoc_timeout);
198
199void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len)
200{
201 struct wireless_dev *wdev = dev->ieee80211_ptr;
202 struct ieee80211_mgmt *mgmt = (void *)buf;
203
204 ASSERT_WDEV_LOCK(wdev);
205
206 trace_cfg80211_tx_mlme_mgmt(dev, buf, len);
207
208 if (WARN_ON(len < 2))
209 return;
210
211 if (ieee80211_is_deauth(mgmt->frame_control))
212 cfg80211_process_deauth(dev, buf, len);
213 else
214 cfg80211_process_disassoc(dev, buf, len);
215}
216EXPORT_SYMBOL(cfg80211_tx_mlme_mgmt);
195 217
196void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, 218void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
197 enum nl80211_key_type key_type, int key_id, 219 enum nl80211_key_type key_type, int key_id,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ce949e38178c..444f5effb77f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9313,31 +9313,27 @@ void nl80211_send_disassoc(struct cfg80211_registered_device *rdev,
9313 NL80211_CMD_DISASSOCIATE, gfp); 9313 NL80211_CMD_DISASSOCIATE, gfp);
9314} 9314}
9315 9315
9316void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, 9316void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev, const u8 *buf,
9317 size_t len) 9317 size_t len)
9318{ 9318{
9319 struct wireless_dev *wdev = dev->ieee80211_ptr; 9319 struct wireless_dev *wdev = dev->ieee80211_ptr;
9320 struct wiphy *wiphy = wdev->wiphy; 9320 struct wiphy *wiphy = wdev->wiphy;
9321 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9321 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
9322 const struct ieee80211_mgmt *mgmt = (void *)buf;
9323 u32 cmd;
9322 9324
9323 trace_cfg80211_send_unprot_deauth(dev); 9325 if (WARN_ON(len < 2))
9324 nl80211_send_mlme_event(rdev, dev, buf, len, 9326 return;
9325 NL80211_CMD_UNPROT_DEAUTHENTICATE, GFP_ATOMIC);
9326}
9327EXPORT_SYMBOL(cfg80211_send_unprot_deauth);
9328 9327
9329void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, 9328 if (ieee80211_is_deauth(mgmt->frame_control))
9330 size_t len) 9329 cmd = NL80211_CMD_UNPROT_DEAUTHENTICATE;
9331{ 9330 else
9332 struct wireless_dev *wdev = dev->ieee80211_ptr; 9331 cmd = NL80211_CMD_UNPROT_DISASSOCIATE;
9333 struct wiphy *wiphy = wdev->wiphy;
9334 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
9335 9332
9336 trace_cfg80211_send_unprot_disassoc(dev); 9333 trace_cfg80211_rx_unprot_mlme_mgmt(dev, buf, len);
9337 nl80211_send_mlme_event(rdev, dev, buf, len, 9334 nl80211_send_mlme_event(rdev, dev, buf, len, cmd, GFP_ATOMIC);
9338 NL80211_CMD_UNPROT_DISASSOCIATE, GFP_ATOMIC);
9339} 9335}
9340EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); 9336EXPORT_SYMBOL(cfg80211_rx_unprot_mlme_mgmt);
9341 9337
9342static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev, 9338static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev,
9343 struct net_device *netdev, int cmd, 9339 struct net_device *netdev, int cmd,
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 23fafeae8a10..e1534baf2ebb 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -1911,24 +1911,46 @@ TRACE_EVENT(cfg80211_send_rx_assoc,
1911 NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG) 1911 NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG)
1912); 1912);
1913 1913
1914DEFINE_EVENT(netdev_evt_only, cfg80211_send_deauth, 1914DECLARE_EVENT_CLASS(netdev_frame_event,
1915 TP_PROTO(struct net_device *netdev), 1915 TP_PROTO(struct net_device *netdev, const u8 *buf, int len),
1916 TP_ARGS(netdev) 1916 TP_ARGS(netdev, buf, len),
1917 TP_STRUCT__entry(
1918 NETDEV_ENTRY
1919 __dynamic_array(u8, frame, len)
1920 ),
1921 TP_fast_assign(
1922 NETDEV_ASSIGN;
1923 memcpy(__get_dynamic_array(frame), buf, len);
1924 ),
1925 TP_printk(NETDEV_PR_FMT ", ftype:0x%.2x",
1926 NETDEV_PR_ARG,
1927 le16_to_cpup((__le16 *)__get_dynamic_array(frame)))
1917); 1928);
1918 1929
1919DEFINE_EVENT(netdev_evt_only, cfg80211_send_disassoc, 1930DEFINE_EVENT(netdev_frame_event, cfg80211_rx_unprot_mlme_mgmt,
1920 TP_PROTO(struct net_device *netdev), 1931 TP_PROTO(struct net_device *netdev, const u8 *buf, int len),
1921 TP_ARGS(netdev) 1932 TP_ARGS(netdev, buf, len)
1922); 1933);
1923 1934
1924DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_deauth, 1935DEFINE_EVENT(netdev_frame_event, cfg80211_rx_mlme_mgmt,
1925 TP_PROTO(struct net_device *netdev), 1936 TP_PROTO(struct net_device *netdev, const u8 *buf, int len),
1926 TP_ARGS(netdev) 1937 TP_ARGS(netdev, buf, len)
1927); 1938);
1928 1939
1929DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_disassoc, 1940TRACE_EVENT(cfg80211_tx_mlme_mgmt,
1930 TP_PROTO(struct net_device *netdev), 1941 TP_PROTO(struct net_device *netdev, const u8 *buf, int len),
1931 TP_ARGS(netdev) 1942 TP_ARGS(netdev, buf, len),
1943 TP_STRUCT__entry(
1944 NETDEV_ENTRY
1945 __dynamic_array(u8, frame, len)
1946 ),
1947 TP_fast_assign(
1948 NETDEV_ASSIGN;
1949 memcpy(__get_dynamic_array(frame), buf, len);
1950 ),
1951 TP_printk(NETDEV_PR_FMT ", ftype:0x%.2x",
1952 NETDEV_PR_ARG,
1953 le16_to_cpup((__le16 *)__get_dynamic_array(frame)))
1932); 1954);
1933 1955
1934DECLARE_EVENT_CLASS(netdev_mac_evt, 1956DECLARE_EVENT_CLASS(netdev_mac_evt,