]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Filter channel list updated events after country code change
authorAbhishek Singh <absingh@qti.qualcomm.com>
Wed, 13 Nov 2013 12:00:27 +0000 (17:30 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 15 Nov 2013 00:59:55 +0000 (02:59 +0200)
We were not filtering the EVENT_CHANNEL_LIST_CHANGED events based on the
regulatory hint initiator. So wait for EVENT_CHANNEL_LIST_CHANGED event
after our own change was triggered even when regulatory hint initiator
was the driver. This could result in the wait for the channel list to be
updated to be terminated before the real change has occurred and as
such, old channel list remaining in use when configuring
hostapd/wpa_supplicant country parameter. Fix this by filtering the
hints according to the initiator and only regulatory hints initiated by
user will be used to stop the wait.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/ap/drv_callbacks.c
src/ap/hostapd.c
src/ap/hostapd.h
src/drivers/driver.h
src/drivers/driver_nl80211.c

index 0f4b12ec0a8a48009dec1428106c8ecf00e29315..aee29467cb25395404c1ae3686843a8b81612827 100644 (file)
@@ -1007,7 +1007,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                /* TODO: check this. hostapd_get_hw_features() initializes
                 * too much stuff. */
                /* hostapd_get_hw_features(hapd->iface); */
-               hostapd_channel_list_updated(hapd->iface);
+               hostapd_channel_list_updated(
+                       hapd->iface, data->channel_list_changed.initiator);
                break;
 #endif /* NEED_AP_MLME */
        default:
index 60224ccbfd2d16570b92f7c3691cf9dd04895040..a06ec9f3434cdc3d59be73a3d7e2278005a37ac6 100644 (file)
@@ -961,9 +961,9 @@ static void channel_list_update_timeout(void *eloop_ctx, void *timeout_ctx)
 }
 
 
-void hostapd_channel_list_updated(struct hostapd_iface *iface)
+void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator)
 {
-       if (!iface->wait_channel_update)
+       if (!iface->wait_channel_update || initiator != REGDOM_SET_BY_USER)
                return;
 
        wpa_printf(MSG_DEBUG, "Channel list updated - continue setup");
index 1887531f9364777844d4afe4387a657f9581b448..9a10626b40e566c2f8fb37d87a6e6f819bd6bcc1 100644 (file)
@@ -375,7 +375,7 @@ int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
 int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
 int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
 int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
-void hostapd_channel_list_updated(struct hostapd_iface *iface);
+void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
 void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
 const char * hostapd_state_text(enum hostapd_iface_state s);
 
index f233032ebbf3d426a615ef8a44874556a1b9b5c6..c56af83bce36e814fb6cd277cbc7f88bd500718c 100644 (file)
 #define HOSTAPD_CHAN_VHT_50_30 0x00002000
 #define HOSTAPD_CHAN_VHT_70_10 0x00004000
 
+enum reg_change_initiator {
+       REGDOM_SET_BY_CORE,
+       REGDOM_SET_BY_USER,
+       REGDOM_SET_BY_DRIVER,
+       REGDOM_SET_BY_COUNTRY_IE,
+};
+
 /**
  * struct hostapd_channel_data - Channel information
  */
@@ -3999,6 +4006,14 @@ union wpa_event_data {
                unsigned int freq_filter;
                struct dl_list survey_list; /* struct freq_survey */
        } survey_results;
+
+       /**
+        * channel_list_changed - Data for EVENT_CHANNEL_LIST_CHANGED
+        * @initiator: Initiator of the regulatory change
+        */
+       struct channel_list_changed {
+               enum reg_change_initiator initiator;
+       } channel_list_changed;
 };
 
 /**
index 90d04e48d71667615517554c3147279989b98d9a..48ac6a2105373a9e29767cd00c33636dd9461fdb 100644 (file)
@@ -2614,6 +2614,7 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
                                 struct nlattr **tb)
 {
        struct wpa_driver_nl80211_data *drv = bss->drv;
+       union wpa_event_data data;
 
        wpa_printf(MSG_DEBUG, "nl80211: Drv Event %d (%s) received for %s",
                   cmd, nl80211_command_to_string(cmd), bss->ifname);
@@ -2713,8 +2714,33 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
                break;
        case NL80211_CMD_REG_CHANGE:
                wpa_printf(MSG_DEBUG, "nl80211: Regulatory domain change");
+               if (tb[NL80211_ATTR_REG_INITIATOR] == NULL)
+                       break;
+               os_memset(&data, 0, sizeof(data));
+               switch (nla_get_u8(tb[NL80211_ATTR_REG_INITIATOR])) {
+               case NL80211_REGDOM_SET_BY_CORE:
+                       data.channel_list_changed.initiator =
+                               REGDOM_SET_BY_CORE;
+                       break;
+               case NL80211_REGDOM_SET_BY_USER:
+                       data.channel_list_changed.initiator =
+                               REGDOM_SET_BY_USER;
+                       break;
+               case NL80211_REGDOM_SET_BY_DRIVER:
+                       data.channel_list_changed.initiator =
+                               REGDOM_SET_BY_DRIVER;
+                       break;
+               case NL80211_REGDOM_SET_BY_COUNTRY_IE:
+                       data.channel_list_changed.initiator =
+                               REGDOM_SET_BY_COUNTRY_IE;
+                       break;
+               default:
+                       wpa_printf(MSG_DEBUG, "nl80211: Unknown reg change initiator %d received",
+                                  nla_get_u8(tb[NL80211_ATTR_REG_INITIATOR]));
+                       break;
+               }
                wpa_supplicant_event(drv->ctx, EVENT_CHANNEL_LIST_CHANGED,
-                                    NULL);
+                                    &data);
                break;
        case NL80211_CMD_REG_BEACON_HINT:
                wpa_printf(MSG_DEBUG, "nl80211: Regulatory beacon hint");