aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mesh_plink.c
diff options
context:
space:
mode:
authorChun-Yeow Yeoh <yeohchunyeow@gmail.com>2013-11-13 02:43:03 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-11-25 14:51:53 -0500
commit6f101ef04b77bcad71049e07007d34d14cab7b2f (patch)
tree3d26379af6043c49451ff19fbfda16e431fd1f06 /net/mac80211/mesh_plink.c
parent2a901468c221e778af52603e006a53d286e81f90 (diff)
mac80211: use put_unaligned_le16 in mesh_plink_frame_tx
Use put_unaligned_le16 in mesh_plink_frame_tx. Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/mesh_plink.c')
-rw-r--r--net/mac80211/mesh_plink.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index fadc3e189131..cf83217103f9 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -55,7 +55,7 @@ static const char * const mplevents[] = {
55 55
56static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, 56static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
57 enum ieee80211_self_protected_actioncode action, 57 enum ieee80211_self_protected_actioncode action,
58 u8 *da, __le16 llid, __le16 plid, __le16 reason); 58 u8 *da, u16 llid, u16 plid, u16 reason);
59 59
60 60
61/* We only need a valid sta if user configured a minimum rssi_threshold. */ 61/* We only need a valid sta if user configured a minimum rssi_threshold. */
@@ -246,7 +246,7 @@ u32 mesh_plink_deactivate(struct sta_info *sta)
246 246
247 spin_lock_bh(&sta->lock); 247 spin_lock_bh(&sta->lock);
248 changed = __mesh_plink_deactivate(sta); 248 changed = __mesh_plink_deactivate(sta);
249 sta->reason = cpu_to_le16(WLAN_REASON_MESH_PEER_CANCELED); 249 sta->reason = WLAN_REASON_MESH_PEER_CANCELED;
250 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, 250 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
251 sta->sta.addr, sta->llid, sta->plid, 251 sta->sta.addr, sta->llid, sta->plid,
252 sta->reason); 252 sta->reason);
@@ -257,7 +257,7 @@ u32 mesh_plink_deactivate(struct sta_info *sta)
257 257
258static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, 258static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
259 enum ieee80211_self_protected_actioncode action, 259 enum ieee80211_self_protected_actioncode action,
260 u8 *da, __le16 llid, __le16 plid, __le16 reason) 260 u8 *da, u16 llid, u16 plid, u16 reason)
261{ 261{
262 struct ieee80211_local *local = sdata->local; 262 struct ieee80211_local *local = sdata->local;
263 struct sk_buff *skb; 263 struct sk_buff *skb;
@@ -305,7 +305,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
305 if (action == WLAN_SP_MESH_PEERING_CONFIRM) { 305 if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
306 /* AID */ 306 /* AID */
307 pos = skb_put(skb, 2); 307 pos = skb_put(skb, 2);
308 memcpy(pos + 2, &plid, 2); 308 put_unaligned_le16(plid, pos + 2);
309 } 309 }
310 if (ieee80211_add_srates_ie(sdata, skb, true, band) || 310 if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
311 ieee80211_add_ext_srates_ie(sdata, skb, true, band) || 311 ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
@@ -347,14 +347,14 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
347 *pos++ = ie_len; 347 *pos++ = ie_len;
348 memcpy(pos, &peering_proto, 2); 348 memcpy(pos, &peering_proto, 2);
349 pos += 2; 349 pos += 2;
350 memcpy(pos, &llid, 2); 350 put_unaligned_le16(llid, pos);
351 pos += 2; 351 pos += 2;
352 if (include_plid) { 352 if (include_plid) {
353 memcpy(pos, &plid, 2); 353 put_unaligned_le16(plid, pos);
354 pos += 2; 354 pos += 2;
355 } 355 }
356 if (action == WLAN_SP_MESH_PEERING_CLOSE) { 356 if (action == WLAN_SP_MESH_PEERING_CLOSE) {
357 memcpy(pos, &reason, 2); 357 put_unaligned_le16(reason, pos);
358 pos += 2; 358 pos += 2;
359 } 359 }
360 360
@@ -534,7 +534,7 @@ out:
534static void mesh_plink_timer(unsigned long data) 534static void mesh_plink_timer(unsigned long data)
535{ 535{
536 struct sta_info *sta; 536 struct sta_info *sta;
537 __le16 llid, plid, reason; 537 u16 reason = 0;
538 struct ieee80211_sub_if_data *sdata; 538 struct ieee80211_sub_if_data *sdata;
539 struct mesh_config *mshcfg; 539 struct mesh_config *mshcfg;
540 enum ieee80211_self_protected_actioncode action = 0; 540 enum ieee80211_self_protected_actioncode action = 0;
@@ -558,9 +558,6 @@ static void mesh_plink_timer(unsigned long data)
558 mpl_dbg(sta->sdata, 558 mpl_dbg(sta->sdata,
559 "Mesh plink timer for %pM fired on state %s\n", 559 "Mesh plink timer for %pM fired on state %s\n",
560 sta->sta.addr, mplstates[sta->plink_state]); 560 sta->sta.addr, mplstates[sta->plink_state]);
561 reason = 0;
562 llid = sta->llid;
563 plid = sta->plid;
564 sdata = sta->sdata; 561 sdata = sta->sdata;
565 mshcfg = &sdata->u.mesh.mshcfg; 562 mshcfg = &sdata->u.mesh.mshcfg;
566 563
@@ -582,12 +579,12 @@ static void mesh_plink_timer(unsigned long data)
582 action = WLAN_SP_MESH_PEERING_OPEN; 579 action = WLAN_SP_MESH_PEERING_OPEN;
583 break; 580 break;
584 } 581 }
585 reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES); 582 reason = WLAN_REASON_MESH_MAX_RETRIES;
586 /* fall through on else */ 583 /* fall through on else */
587 case NL80211_PLINK_CNF_RCVD: 584 case NL80211_PLINK_CNF_RCVD:
588 /* confirm timer */ 585 /* confirm timer */
589 if (!reason) 586 if (!reason)
590 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT); 587 reason = WLAN_REASON_MESH_CONFIRM_TIMEOUT;
591 sta->plink_state = NL80211_PLINK_HOLDING; 588 sta->plink_state = NL80211_PLINK_HOLDING;
592 mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); 589 mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout);
593 action = WLAN_SP_MESH_PEERING_CLOSE; 590 action = WLAN_SP_MESH_PEERING_CLOSE;
@@ -603,7 +600,7 @@ static void mesh_plink_timer(unsigned long data)
603 spin_unlock_bh(&sta->lock); 600 spin_unlock_bh(&sta->lock);
604 if (action) 601 if (action)
605 mesh_plink_frame_tx(sdata, action, sta->sta.addr, 602 mesh_plink_frame_tx(sdata, action, sta->sta.addr,
606 llid, plid, reason); 603 sta->llid, sta->plid, reason);
607} 604}
608 605
609static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout) 606static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
@@ -616,7 +613,7 @@ static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
616} 613}
617 614
618static bool llid_in_use(struct ieee80211_sub_if_data *sdata, 615static bool llid_in_use(struct ieee80211_sub_if_data *sdata,
619 __le16 llid) 616 u16 llid)
620{ 617{
621 struct ieee80211_local *local = sdata->local; 618 struct ieee80211_local *local = sdata->local;
622 bool in_use = false; 619 bool in_use = false;
@@ -634,7 +631,7 @@ static bool llid_in_use(struct ieee80211_sub_if_data *sdata,
634 return in_use; 631 return in_use;
635} 632}
636 633
637static __le16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata) 634static u16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata)
638{ 635{
639 u16 llid; 636 u16 llid;
640 637
@@ -642,9 +639,9 @@ static __le16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata)
642 get_random_bytes(&llid, sizeof(llid)); 639 get_random_bytes(&llid, sizeof(llid));
643 /* for mesh PS we still only have the AID range for TIM bits */ 640 /* for mesh PS we still only have the AID range for TIM bits */
644 llid = (llid % IEEE80211_MAX_AID) + 1; 641 llid = (llid % IEEE80211_MAX_AID) + 1;
645 } while (llid_in_use(sdata, cpu_to_le16(llid))); 642 } while (llid_in_use(sdata, llid));
646 643
647 return cpu_to_le16(llid); 644 return llid;
648} 645}
649 646
650u32 mesh_plink_open(struct sta_info *sta) 647u32 mesh_plink_open(struct sta_info *sta)
@@ -695,9 +692,8 @@ static void mesh_plink_close(struct ieee80211_sub_if_data *sdata,
695{ 692{
696 struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; 693 struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg;
697 694
698 __le16 reason = (event == CLS_ACPT) ? 695 u16 reason = (event == CLS_ACPT) ?
699 cpu_to_le16(WLAN_REASON_MESH_CLOSE) : 696 WLAN_REASON_MESH_CLOSE : WLAN_REASON_MESH_CONFIG;
700 cpu_to_le16(WLAN_REASON_MESH_CONFIG);
701 697
702 sta->reason = reason; 698 sta->reason = reason;
703 sta->plink_state = NL80211_PLINK_HOLDING; 699 sta->plink_state = NL80211_PLINK_HOLDING;
@@ -892,7 +888,7 @@ mesh_plink_get_event(struct ieee80211_sub_if_data *sdata,
892 struct sta_info *sta, 888 struct sta_info *sta,
893 struct ieee802_11_elems *elems, 889 struct ieee802_11_elems *elems,
894 enum ieee80211_self_protected_actioncode ftype, 890 enum ieee80211_self_protected_actioncode ftype,
895 __le16 llid, __le16 plid) 891 u16 llid, u16 plid)
896{ 892{
897 enum plink_event event = PLINK_UNDEFINED; 893 enum plink_event event = PLINK_UNDEFINED;
898 u8 ie_len = elems->peering_len; 894 u8 ie_len = elems->peering_len;
@@ -990,7 +986,8 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
990 enum ieee80211_self_protected_actioncode ftype; 986 enum ieee80211_self_protected_actioncode ftype;
991 u32 changed = 0; 987 u32 changed = 0;
992 u8 ie_len = elems->peering_len; 988 u8 ie_len = elems->peering_len;
993 __le16 plid, llid = 0; 989 __le16 _plid, _llid;
990 u16 plid, llid = 0;
994 991
995 if (!elems->peering) { 992 if (!elems->peering) {
996 mpl_dbg(sdata, 993 mpl_dbg(sdata,
@@ -1024,10 +1021,13 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
1024 /* Note the lines below are correct, the llid in the frame is the plid 1021 /* Note the lines below are correct, the llid in the frame is the plid
1025 * from the point of view of this host. 1022 * from the point of view of this host.
1026 */ 1023 */
1027 memcpy(&plid, PLINK_GET_LLID(elems->peering), 2); 1024 memcpy(&_plid, PLINK_GET_LLID(elems->peering), sizeof(__le16));
1025 plid = le16_to_cpu(_plid);
1028 if (ftype == WLAN_SP_MESH_PEERING_CONFIRM || 1026 if (ftype == WLAN_SP_MESH_PEERING_CONFIRM ||
1029 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8)) 1027 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8)) {
1030 memcpy(&llid, PLINK_GET_PLID(elems->peering), 2); 1028 memcpy(&_llid, PLINK_GET_PLID(elems->peering), sizeof(__le16));
1029 llid = le16_to_cpu(_llid);
1030 }
1031 1031
1032 /* WARNING: Only for sta pointer, is dropped & re-acquired */ 1032 /* WARNING: Only for sta pointer, is dropped & re-acquired */
1033 rcu_read_lock(); 1033 rcu_read_lock();
@@ -1056,7 +1056,7 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata,
1056 } else if (!sta && event == OPN_RJCT) { 1056 } else if (!sta && event == OPN_RJCT) {
1057 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, 1057 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
1058 mgmt->sa, 0, plid, 1058 mgmt->sa, 0, plid,
1059 cpu_to_le16(WLAN_REASON_MESH_CONFIG)); 1059 WLAN_REASON_MESH_CONFIG);
1060 goto unlock_rcu; 1060 goto unlock_rcu;
1061 } else if (!sta || event == PLINK_UNDEFINED) { 1061 } else if (!sta || event == PLINK_UNDEFINED) {
1062 /* something went wrong */ 1062 /* something went wrong */