From patchwork Wed Nov 13 07:43:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yeow Yeoh X-Patchwork-Id: 3177341 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 498AEC045B for ; Wed, 13 Nov 2013 07:46:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0B4B200E8 for ; Wed, 13 Nov 2013 07:46:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B336C200FF for ; Wed, 13 Nov 2013 07:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758650Ab3KMHq1 (ORCPT ); Wed, 13 Nov 2013 02:46:27 -0500 Received: from mail-pb0-f42.google.com ([209.85.160.42]:43211 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758410Ab3KMHq0 (ORCPT ); Wed, 13 Nov 2013 02:46:26 -0500 Received: by mail-pb0-f42.google.com with SMTP id uo5so40684pbc.15 for ; Tue, 12 Nov 2013 23:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zIykSW8X1w69QMWS5kVy2TM30+ey7TdaXVf/npzW1NA=; b=gopHl+Rdkof1+CnFHAkfwIVMVC/l++w3VvBIjb62CHSqL3zcKXhUoXFzOWK/r6OhSp GJ5yturocZend/Mnvp37Y5+i14mCDPVt5Us2fcMIqluH1EXzKB7lLnLBP/6F05cIk8Rm rMGJ1WAS3PEo5elXcjj2X5gA+10A5owI50d06C4k/eD+f3tn/OJJY+LupOkg4sZzHmNX YWg8fpOQ/YWsYHVOdWw1QBoWcP//kJWtHN1xPzV46QSB4ro/wAmFGv3qTopTSyYz9AEa OFM4SnT1bdM+kpecWEUnsyA7HxROcc1DjMdmtNlXfsVPzUpocic2ruwmxhQC9vlxFuRV 06bg== X-Received: by 10.66.13.70 with SMTP id f6mr579320pac.180.1384328785992; Tue, 12 Nov 2013 23:46:25 -0800 (PST) Received: from localhost.localdomain ([203.106.67.32]) by mx.google.com with ESMTPSA id n10sm42441401pbg.28.2013.11.12.23.45.53 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Nov 2013 23:46:25 -0800 (PST) From: Chun-Yeow Yeoh To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, linville@tuxdriver.com, devel@lists.open80211s.org, distro11s@cozybit.com, Chun-Yeow Yeoh Subject: [PATCH] mac80211: use put_unaligned_le16 in mesh_plink_frame_tx Date: Wed, 13 Nov 2013 15:43:03 +0800 Message-Id: <1384328583-24639-1-git-send-email-yeohchunyeow@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use put_unaligned_le16 in mesh_plink_frame_tx. Signed-off-by: Chun-Yeow Yeoh --- net/mac80211/cfg.c | 4 ++-- net/mac80211/mesh_plink.c | 54 ++++++++++++++++++++++----------------------- net/mac80211/mesh_ps.c | 2 +- net/mac80211/sta_info.c | 2 +- net/mac80211/sta_info.h | 6 ++--- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 30cbeaf..e50857b 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -532,8 +532,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) STATION_INFO_PEER_PM | STATION_INFO_NONPEER_PM; - sinfo->llid = le16_to_cpu(sta->llid); - sinfo->plid = le16_to_cpu(sta->plid); + sinfo->llid = sta->llid; + sinfo->plid = sta->plid; sinfo->plink_state = sta->plink_state; if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { sinfo->filled |= STATION_INFO_T_OFFSET; diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index fadc3e1..cf83217 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -55,7 +55,7 @@ static const char * const mplevents[] = { static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, enum ieee80211_self_protected_actioncode action, - u8 *da, __le16 llid, __le16 plid, __le16 reason); + u8 *da, u16 llid, u16 plid, u16 reason); /* 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) spin_lock_bh(&sta->lock); changed = __mesh_plink_deactivate(sta); - sta->reason = cpu_to_le16(WLAN_REASON_MESH_PEER_CANCELED); + sta->reason = WLAN_REASON_MESH_PEER_CANCELED; mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, sta->sta.addr, sta->llid, sta->plid, sta->reason); @@ -257,7 +257,7 @@ u32 mesh_plink_deactivate(struct sta_info *sta) static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, enum ieee80211_self_protected_actioncode action, - u8 *da, __le16 llid, __le16 plid, __le16 reason) + u8 *da, u16 llid, u16 plid, u16 reason) { struct ieee80211_local *local = sdata->local; struct sk_buff *skb; @@ -305,7 +305,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, if (action == WLAN_SP_MESH_PEERING_CONFIRM) { /* AID */ pos = skb_put(skb, 2); - memcpy(pos + 2, &plid, 2); + put_unaligned_le16(plid, pos + 2); } if (ieee80211_add_srates_ie(sdata, skb, true, band) || 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, *pos++ = ie_len; memcpy(pos, &peering_proto, 2); pos += 2; - memcpy(pos, &llid, 2); + put_unaligned_le16(llid, pos); pos += 2; if (include_plid) { - memcpy(pos, &plid, 2); + put_unaligned_le16(plid, pos); pos += 2; } if (action == WLAN_SP_MESH_PEERING_CLOSE) { - memcpy(pos, &reason, 2); + put_unaligned_le16(reason, pos); pos += 2; } @@ -534,7 +534,7 @@ out: static void mesh_plink_timer(unsigned long data) { struct sta_info *sta; - __le16 llid, plid, reason; + u16 reason = 0; struct ieee80211_sub_if_data *sdata; struct mesh_config *mshcfg; enum ieee80211_self_protected_actioncode action = 0; @@ -558,9 +558,6 @@ static void mesh_plink_timer(unsigned long data) mpl_dbg(sta->sdata, "Mesh plink timer for %pM fired on state %s\n", sta->sta.addr, mplstates[sta->plink_state]); - reason = 0; - llid = sta->llid; - plid = sta->plid; sdata = sta->sdata; mshcfg = &sdata->u.mesh.mshcfg; @@ -582,12 +579,12 @@ static void mesh_plink_timer(unsigned long data) action = WLAN_SP_MESH_PEERING_OPEN; break; } - reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES); + reason = WLAN_REASON_MESH_MAX_RETRIES; /* fall through on else */ case NL80211_PLINK_CNF_RCVD: /* confirm timer */ if (!reason) - reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT); + reason = WLAN_REASON_MESH_CONFIRM_TIMEOUT; sta->plink_state = NL80211_PLINK_HOLDING; mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); action = WLAN_SP_MESH_PEERING_CLOSE; @@ -603,7 +600,7 @@ static void mesh_plink_timer(unsigned long data) spin_unlock_bh(&sta->lock); if (action) mesh_plink_frame_tx(sdata, action, sta->sta.addr, - llid, plid, reason); + sta->llid, sta->plid, reason); } static 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) } static bool llid_in_use(struct ieee80211_sub_if_data *sdata, - __le16 llid) + u16 llid) { struct ieee80211_local *local = sdata->local; bool in_use = false; @@ -634,7 +631,7 @@ static bool llid_in_use(struct ieee80211_sub_if_data *sdata, return in_use; } -static __le16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata) +static u16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata) { u16 llid; @@ -642,9 +639,9 @@ static __le16 mesh_get_new_llid(struct ieee80211_sub_if_data *sdata) get_random_bytes(&llid, sizeof(llid)); /* for mesh PS we still only have the AID range for TIM bits */ llid = (llid % IEEE80211_MAX_AID) + 1; - } while (llid_in_use(sdata, cpu_to_le16(llid))); + } while (llid_in_use(sdata, llid)); - return cpu_to_le16(llid); + return llid; } u32 mesh_plink_open(struct sta_info *sta) @@ -695,9 +692,8 @@ static void mesh_plink_close(struct ieee80211_sub_if_data *sdata, { struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; - __le16 reason = (event == CLS_ACPT) ? - cpu_to_le16(WLAN_REASON_MESH_CLOSE) : - cpu_to_le16(WLAN_REASON_MESH_CONFIG); + u16 reason = (event == CLS_ACPT) ? + WLAN_REASON_MESH_CLOSE : WLAN_REASON_MESH_CONFIG; sta->reason = reason; sta->plink_state = NL80211_PLINK_HOLDING; @@ -892,7 +888,7 @@ mesh_plink_get_event(struct ieee80211_sub_if_data *sdata, struct sta_info *sta, struct ieee802_11_elems *elems, enum ieee80211_self_protected_actioncode ftype, - __le16 llid, __le16 plid) + u16 llid, u16 plid) { enum plink_event event = PLINK_UNDEFINED; u8 ie_len = elems->peering_len; @@ -990,7 +986,8 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata, enum ieee80211_self_protected_actioncode ftype; u32 changed = 0; u8 ie_len = elems->peering_len; - __le16 plid, llid = 0; + __le16 _plid, _llid; + u16 plid, llid = 0; if (!elems->peering) { mpl_dbg(sdata, @@ -1024,10 +1021,13 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata, /* Note the lines below are correct, the llid in the frame is the plid * from the point of view of this host. */ - memcpy(&plid, PLINK_GET_LLID(elems->peering), 2); + memcpy(&_plid, PLINK_GET_LLID(elems->peering), sizeof(__le16)); + plid = le16_to_cpu(_plid); if (ftype == WLAN_SP_MESH_PEERING_CONFIRM || - (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8)) - memcpy(&llid, PLINK_GET_PLID(elems->peering), 2); + (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8)) { + memcpy(&_llid, PLINK_GET_PLID(elems->peering), sizeof(__le16)); + llid = le16_to_cpu(_llid); + } /* WARNING: Only for sta pointer, is dropped & re-acquired */ rcu_read_lock(); @@ -1056,7 +1056,7 @@ mesh_process_plink_frame(struct ieee80211_sub_if_data *sdata, } else if (!sta && event == OPN_RJCT) { mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, mgmt->sa, 0, plid, - cpu_to_le16(WLAN_REASON_MESH_CONFIG)); + WLAN_REASON_MESH_CONFIG); goto unlock_rcu; } else if (!sta || event == PLINK_UNDEFINED) { /* something went wrong */ diff --git a/net/mac80211/mesh_ps.c b/net/mac80211/mesh_ps.c index 9493868..2802f9d 100644 --- a/net/mac80211/mesh_ps.c +++ b/net/mac80211/mesh_ps.c @@ -578,7 +578,7 @@ void ieee80211_mps_frame_release(struct sta_info *sta, if (sta->plink_state == NL80211_PLINK_ESTAB) has_buffered = ieee80211_check_tim(elems->tim, elems->tim_len, - le16_to_cpu(sta->llid)); + sta->llid); if (has_buffered) mps_dbg(sta->sdata, "%pM indicates buffered frames\n", diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 7a91515..45b5f61 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -631,7 +631,7 @@ void sta_info_recalc_tim(struct sta_info *sta) } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { ps = &sta->sdata->u.mesh.ps; /* TIM map only for 1 <= PLID <= IEEE80211_MAX_AID */ - id = le16_to_cpu(sta->plid) % (IEEE80211_MAX_AID + 1); + id = sta->plid % (IEEE80211_MAX_AID + 1); #endif } else { return; diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 6b0d6c2..a2c9a4c 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -390,9 +390,9 @@ struct sta_info { * Mesh peer link attributes * TODO: move to a sub-structure that is referenced with pointer? */ - __le16 llid; - __le16 plid; - __le16 reason; + u16 llid; + u16 plid; + u16 reason; u8 plink_retries; bool ignore_plink_timer; enum nl80211_plink_state plink_state;