001-Fix-race-condition-between-AssocResp-callback-and-4a.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From: Jouni Malinen <jouni@qca.qualcomm.com>
  2. Date: Tue, 20 Dec 2016 01:30:09 +0200
  3. Subject: [PATCH] Fix race condition between AssocResp callback and 4addr event
  4. It is apparently possible for the NL80211_CMD_UNEXPECTED_4ADDR_FRAME
  5. event to be delivered to hostapd before the NL80211_CMD_FRAME_TX_STATUS
  6. event for (Re)Association Response frame. This resulted in the 4-address
  7. WDS mode not getting enabled for a STA. This could occur in particular
  8. when operating under heavy load and the STA is reconnecting to the same
  9. AP in a sequence where Deauthentication frame is followed immediately by
  10. Authentication frame and the driver event processing gets delayed due to
  11. removal of the previous netdev taking time in the middle of this
  12. sequence.
  13. Fix this by recording a pending item for 4-address WDS enabling if the
  14. NL80211_CMD_UNEXPECTED_4ADDR_FRAME event would have been dropped due to
  15. incompleted association and then process this pending item if the TX
  16. status for the (Re)Association Response frame is received and it shows
  17. that the frame was acknowledged.
  18. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
  19. ---
  20. --- a/src/ap/ieee802_11.c
  21. +++ b/src/ap/ieee802_11.c
  22. @@ -2634,6 +2634,8 @@ static void handle_assoc(struct hostapd_
  23. taxonomy_sta_info_assoc_req(hapd, sta, pos, left);
  24. #endif /* CONFIG_TAXONOMY */
  25. + sta->pending_wds_enable = 0;
  26. +
  27. fail:
  28. /*
  29. * In case of a successful response, add the station to the driver.
  30. @@ -3248,6 +3250,14 @@ static void handle_assoc_cb(struct hosta
  31. hostapd_set_sta_flags(hapd, sta);
  32. + if (!(sta->flags & WLAN_STA_WDS) && sta->pending_wds_enable) {
  33. + wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for STA "
  34. + MACSTR " based on pending request",
  35. + MAC2STR(sta->addr));
  36. + sta->pending_wds_enable = 0;
  37. + sta->flags |= WLAN_STA_WDS;
  38. + }
  39. +
  40. if (sta->flags & WLAN_STA_WDS) {
  41. int ret;
  42. char ifname_wds[IFNAMSIZ + 1];
  43. @@ -3512,10 +3522,22 @@ void ieee802_11_rx_from_unknown(struct h
  44. struct sta_info *sta;
  45. sta = ap_get_sta(hapd, src);
  46. - if (sta && (sta->flags & WLAN_STA_ASSOC)) {
  47. + if (sta &&
  48. + ((sta->flags & WLAN_STA_ASSOC) ||
  49. + ((sta->flags & WLAN_STA_ASSOC_REQ_OK) && wds))) {
  50. if (!hapd->conf->wds_sta)
  51. return;
  52. + if ((sta->flags & (WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK)) ==
  53. + WLAN_STA_ASSOC_REQ_OK) {
  54. + wpa_printf(MSG_DEBUG,
  55. + "Postpone 4-address WDS mode enabling for STA "
  56. + MACSTR " since TX status for AssocResp is not yet known",
  57. + MAC2STR(sta->addr));
  58. + sta->pending_wds_enable = 1;
  59. + return;
  60. + }
  61. +
  62. if (wds && !(sta->flags & WLAN_STA_WDS)) {
  63. int ret;
  64. char ifname_wds[IFNAMSIZ + 1];
  65. --- a/src/ap/sta_info.h
  66. +++ b/src/ap/sta_info.h
  67. @@ -115,6 +115,7 @@ struct sta_info {
  68. unsigned int radius_das_match:1;
  69. unsigned int ecsa_supported:1;
  70. unsigned int added_unassoc:1;
  71. + unsigned int pending_wds_enable:1;
  72. u16 auth_alg;