Skip to content

Commit 3f718fd

Browse files
chunyeowjmberg-intel
authored andcommitted
mac80211: fix the mesh channel switch support
Mesh STA receiving the mesh CSA action frame is not able to trigger the mesh channel switch due to the incorrect handling and comparison of mesh channel switch parameters element (MCSP)'s TTL. Make sure the MCSP's TTL is updated accordingly before calling the ieee80211_mesh_process_chnswitch. Also, we update the beacon before forwarding the CSA action frame, so MCSP's precedence value and initiator flag need to be updated prior to this. Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 051a41f commit 3f718fd

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎net/mac80211/cfg.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3119,9 +3119,17 @@ static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
31193119
params->chandef.chan->band)
31203120
return -EINVAL;
31213121

3122+
ifmsh->chsw_init = true;
3123+
if (!ifmsh->pre_value)
3124+
ifmsh->pre_value = 1;
3125+
else
3126+
ifmsh->pre_value++;
3127+
31223128
err = ieee80211_mesh_csa_beacon(sdata, params, true);
3123-
if (err < 0)
3129+
if (err < 0) {
3130+
ifmsh->chsw_init = false;
31243131
return err;
3132+
}
31253133
break;
31263134
#endif
31273135
default:

‎net/mac80211/ieee80211_i.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ struct ieee80211_csa_ie {
12281228
u8 mode;
12291229
u8 count;
12301230
u8 ttl;
1231+
u16 pre_value;
12311232
};
12321233

12331234
/* Parsed Information Elements */

‎net/mac80211/mesh.c‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,14 +943,19 @@ ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata,
943943
params.chandef.chan->center_freq);
944944

945945
params.block_tx = csa_ie.mode & WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT;
946-
if (beacon)
946+
if (beacon) {
947947
ifmsh->chsw_ttl = csa_ie.ttl - 1;
948-
else
949-
ifmsh->chsw_ttl = 0;
948+
if (ifmsh->pre_value >= csa_ie.pre_value)
949+
return false;
950+
ifmsh->pre_value = csa_ie.pre_value;
951+
}
950952

951-
if (ifmsh->chsw_ttl > 0)
953+
if (ifmsh->chsw_ttl < ifmsh->mshcfg.dot11MeshTTL) {
952954
if (ieee80211_mesh_csa_beacon(sdata, &params, false) < 0)
953955
return false;
956+
} else {
957+
return false;
958+
}
954959

955960
sdata->csa_radar_required = params.radar_required;
956961

@@ -1163,7 +1168,6 @@ static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata,
11631168
offset_ttl = (len < 42) ? 7 : 10;
11641169
*(pos + offset_ttl) -= 1;
11651170
*(pos + offset_ttl + 1) &= ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR;
1166-
sdata->u.mesh.chsw_ttl = *(pos + offset_ttl);
11671171

11681172
memcpy(mgmt_fwd, mgmt, len);
11691173
eth_broadcast_addr(mgmt_fwd->da);
@@ -1182,7 +1186,7 @@ static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata,
11821186
u16 pre_value;
11831187
bool fwd_csa = true;
11841188
size_t baselen;
1185-
u8 *pos, ttl;
1189+
u8 *pos;
11861190

11871191
if (mgmt->u.action.u.measurement.action_code !=
11881192
WLAN_ACTION_SPCT_CHL_SWITCH)
@@ -1193,8 +1197,8 @@ static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata,
11931197
u.action.u.chan_switch.variable);
11941198
ieee802_11_parse_elems(pos, len - baselen, false, &elems);
11951199

1196-
ttl = elems.mesh_chansw_params_ie->mesh_ttl;
1197-
if (!--ttl)
1200+
ifmsh->chsw_ttl = elems.mesh_chansw_params_ie->mesh_ttl;
1201+
if (!--ifmsh->chsw_ttl)
11981202
fwd_csa = false;
11991203

12001204
pre_value = le16_to_cpu(elems.mesh_chansw_params_ie->mesh_pre_value);

‎net/mac80211/spectmgmt.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
7878
if (elems->mesh_chansw_params_ie) {
7979
csa_ie->ttl = elems->mesh_chansw_params_ie->mesh_ttl;
8080
csa_ie->mode = elems->mesh_chansw_params_ie->mesh_flags;
81+
csa_ie->pre_value = le16_to_cpu(
82+
elems->mesh_chansw_params_ie->mesh_pre_value);
8183
}
8284

8385
new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);

‎net/mac80211/util.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,14 +2457,9 @@ int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
24572457
WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT : 0x00;
24582458
put_unaligned_le16(WLAN_REASON_MESH_CHAN, pos); /* Reason Cd */
24592459
pos += 2;
2460-
if (!ifmsh->pre_value)
2461-
ifmsh->pre_value = 1;
2462-
else
2463-
ifmsh->pre_value++;
24642460
pre_value = cpu_to_le16(ifmsh->pre_value);
24652461
memcpy(pos, &pre_value, 2); /* Precedence Value */
24662462
pos += 2;
2467-
ifmsh->chsw_init = true;
24682463
}
24692464

24702465
ieee80211_tx_skb(sdata, skb);

0 commit comments

Comments
 (0)