[PATCH v3 00/15] mesh: enable DFS channels in mesh mode

Masashi Honma masashi.honma at gmail.com
Fri May 4 18:21:00 PDT 2018


On 2018/04/18 13:54, peter.oh at bowerswilkins.com wrote:
> From: Peter Oh <peter.oh at bowerswilkins.com>
> 
> This patchset enables DFS channels in mesh mode along with
> CAC and channel switch.
> It's been verified that works for non-dfs channels, dfs channels,
> w/wo encryption (none and SAE), radar detection, channel switch,
> and mesh re-association after channel switch.
> Only left area to cover is in the case when multiple mesh points
> detect radar at the same time, but they select different channels.
> To cover the case I think we need a private patch for it,
> because current 802.11s standard does not address it how to handle.
> 
> * v2: corrected wrong sender's email
> * v3: rebased on top of "mesh: Properly handle sae_password"
>        fix compiler warnings on unused variables and parentheses

It looks need to be added notifications like this.

diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index 5a0d781..ba9d7d7 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -637,6 +637,17 @@ static unsigned int dfs_get_cac_time(struct 
hostapd_iface *iface,
  }


+static void *get_message_ctx(struct hostapd_iface *iface)
+{
+#ifdef CONFIG_MESH
+       if (iface->mconf)
+               return iface->owner;
+#endif /* CONFIG_MESH */
+
+       return iface->bss[0]->msg_ctx;
+}
+
+
  /*
   * Main DFS handler
   * 1 - continue channel/ap setup
@@ -719,7 +730,7 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
         /* Finally start CAC */
         hostapd_set_state(iface, HAPD_IFACE_DFS);
         wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz", iface->freq);
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_CAC_START
                 "freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, 
seg1=%d, cac_time=%ds",
                 iface->freq,
                 iface->conf->channel, iface->conf->secondary_channel,
@@ -768,7 +779,7 @@ int hostapd_dfs_complete_cac(struct hostapd_iface 
*iface, int success, int freq,
                              int ht_enabled, int chan_offset, int 
chan_width,
                              int cf1, int cf2)
  {
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_COMPLETED
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_CAC_COMPLETED
                 "success=%d freq=%d ht_enabled=%d chan_offset=%d 
chan_width=%d cf1=%d cf2=%d",
                 success, freq, ht_enabled, chan_offset, chan_width, 
cf1, cf2);

@@ -810,7 +821,7 @@ int hostapd_dfs_pre_cac_expired(struct hostapd_iface 
*iface, int freq,
                                 int ht_enabled, int chan_offset, int 
chan_width,
                                 int cf1, int cf2)
  {
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_PRE_CAC_EXPIRED
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_PRE_CAC_EXPIRED
                 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d 
cf1=%d cf2=%d",
                 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);

@@ -848,7 +859,7 @@ static int 
hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface)

         wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d",
                    channel->chan);
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_NEW_CHANNEL
                 "freq=%d chan=%d sec_chan=%d", channel->freq,
                 channel->chan, secondary_channel);

@@ -935,7 +946,7 @@ static int hostapd_dfs_start_channel_switch(struct 
hostapd_iface *iface)

         wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d",
                    channel->chan);
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_NEW_CHANNEL
                 "freq=%d chan=%d sec_chan=%d", channel->freq,
                 channel->chan, secondary_channel);

@@ -997,7 +1008,7 @@ int hostapd_dfs_radar_detected(struct hostapd_iface 
*iface, int freq,
  {
         int res;

-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_RADAR_DETECTED
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_RADAR_DETECTED
                 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d 
cf1=%d cf2=%d",
                 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);

@@ -1028,7 +1039,7 @@ int hostapd_dfs_nop_finished(struct hostapd_iface 
*iface, int freq,
                              int ht_enabled, int chan_offset, int 
chan_width,
                              int cf1, int cf2)
  {
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NOP_FINISHED
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_NOP_FINISHED
                 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d 
cf1=%d cf2=%d",
                 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);

@@ -1078,7 +1089,7 @@ int hostapd_dfs_start_cac(struct hostapd_iface 
*iface, int freq,
                           int ht_enabled, int chan_offset, int chan_width,
                           int cf1, int cf2)
  {
-       wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
+       wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_CAC_START
                 "freq=%d chan=%d chan_offset=%d width=%d seg0=%d "
                 "seg1=%d cac_time=%ds",
                 freq, (freq - 5000) / 5, chan_offset, chan_width, cf1, 
cf2, 60);


diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 6524a53..edf1c89 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3818,7 +3818,7 @@ static void wpas_event_dfs_cac_finished(struct 
wpa_supplicant *wpa_s,
                                         struct dfs_event *radar)
  {
  #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
-       if (wpa_s->ap_iface) {
+       if (wpa_s->ap_iface || wpa_s->ifmsh) {
                 wpas_ap_event_dfs_cac_finished(wpa_s, radar);
         } else
  #endif /* NEED_AP_MLME && CONFIG_AP */


And a memory leak should be fixed like this.


diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 67519fe..ca62b1a 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -439,6 +439,7 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant 
*wpa_s,

         if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency 
|| !params) {
                 ret = -ENOENT;
+               os_free(params);
                 goto out;
         }


After these fixes, I could pass this test case.

def test_wpas_mesh_open_dfs(dev, apdev):
     """wpa_supplicant open MESH network with DFS"""
     try:
         _test_wpas_mesh_open_dfs(dev, apdev)
     finally:
         set_country("00")

def _test_wpas_mesh_open_dfs(dev, apdev):
     set_country("US")
     dev[0].request("SET country US")
     check_mesh_support(dev[0])
     add_open_mesh_network(dev[0], freq="5260", basic_rates="60 120 240",
                           disable_ht40=True)

     ev = dev[0].wait_event(["DFS-CAC-START"], timeout=5)
     if ev is None:
         raise Exception("CAC did not start")

     check_mesh_group_added(dev[0])

     ev = dev[0].wait_event(["DFS-CAC-COMPLETED"], timeout=70)
     if ev is None:
         raise Exception("CAC did not complete")
     if "success=1" not in ev:
         raise Exception("CAC failed")
     if "freq=5260" not in ev:
         raise Exception("Unexpected DFS freq result")

     dev[0].mesh_group_remove()
     check_mesh_group_removed(dev[0])
     dev[0].dump_monitor()



Regards,
Masashi Honma.



More information about the Hostap mailing list