Commit f63f8421 authored by Chun-Yeow Yeoh's avatar Chun-Yeow Yeoh Committed by Johannes Berg

mac80211: use put_unaligned_le in mesh when necessary

Use put_unaligned_le16 and put_unaligned_le32 for
mesh_path_error_tx and mesh_path_sel_frame_tx.
Signed-off-by: default avatarChun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 6f101ef0
...@@ -301,8 +301,8 @@ void mesh_mpath_table_grow(void); ...@@ -301,8 +301,8 @@ void mesh_mpath_table_grow(void);
void mesh_mpp_table_grow(void); void mesh_mpp_table_grow(void);
/* Mesh paths */ /* Mesh paths */
int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
u8 ttl, const u8 *target, __le32 target_sn, u8 ttl, const u8 *target, u32 target_sn,
__le16 target_rcode, const u8 *ra); u16 target_rcode, const u8 *ra);
void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta); void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
void mesh_path_flush_pending(struct mesh_path *mpath); void mesh_path_flush_pending(struct mesh_path *mpath);
void mesh_path_tx_pending(struct mesh_path *mpath); void mesh_path_tx_pending(struct mesh_path *mpath);
......
...@@ -102,12 +102,11 @@ enum mpath_frame_type { ...@@ -102,12 +102,11 @@ enum mpath_frame_type {
static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
const u8 *orig_addr, __le32 orig_sn, const u8 *orig_addr, u32 orig_sn,
u8 target_flags, const u8 *target, u8 target_flags, const u8 *target,
__le32 target_sn, const u8 *da, u32 target_sn, const u8 *da,
u8 hop_count, u8 ttl, u8 hop_count, u8 ttl,
__le32 lifetime, __le32 metric, u32 lifetime, u32 metric, u32 preq_id,
__le32 preq_id,
struct ieee80211_sub_if_data *sdata) struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
...@@ -167,33 +166,33 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, ...@@ -167,33 +166,33 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
if (action == MPATH_PREP) { if (action == MPATH_PREP) {
memcpy(pos, target, ETH_ALEN); memcpy(pos, target, ETH_ALEN);
pos += ETH_ALEN; pos += ETH_ALEN;
memcpy(pos, &target_sn, 4); put_unaligned_le32(target_sn, pos);
pos += 4; pos += 4;
} else { } else {
if (action == MPATH_PREQ) { if (action == MPATH_PREQ) {
memcpy(pos, &preq_id, 4); put_unaligned_le32(preq_id, pos);
pos += 4; pos += 4;
} }
memcpy(pos, orig_addr, ETH_ALEN); memcpy(pos, orig_addr, ETH_ALEN);
pos += ETH_ALEN; pos += ETH_ALEN;
memcpy(pos, &orig_sn, 4); put_unaligned_le32(orig_sn, pos);
pos += 4; pos += 4;
} }
memcpy(pos, &lifetime, 4); /* interval for RANN */ put_unaligned_le32(lifetime, pos); /* interval for RANN */
pos += 4; pos += 4;
memcpy(pos, &metric, 4); put_unaligned_le32(metric, pos);
pos += 4; pos += 4;
if (action == MPATH_PREQ) { if (action == MPATH_PREQ) {
*pos++ = 1; /* destination count */ *pos++ = 1; /* destination count */
*pos++ = target_flags; *pos++ = target_flags;
memcpy(pos, target, ETH_ALEN); memcpy(pos, target, ETH_ALEN);
pos += ETH_ALEN; pos += ETH_ALEN;
memcpy(pos, &target_sn, 4); put_unaligned_le32(target_sn, pos);
pos += 4; pos += 4;
} else if (action == MPATH_PREP) { } else if (action == MPATH_PREP) {
memcpy(pos, orig_addr, ETH_ALEN); memcpy(pos, orig_addr, ETH_ALEN);
pos += ETH_ALEN; pos += ETH_ALEN;
memcpy(pos, &orig_sn, 4); put_unaligned_le32(orig_sn, pos);
pos += 4; pos += 4;
} }
...@@ -239,8 +238,8 @@ static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata, ...@@ -239,8 +238,8 @@ static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata,
* frame directly but add it to the pending queue instead. * frame directly but add it to the pending queue instead.
*/ */
int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
u8 ttl, const u8 *target, __le32 target_sn, u8 ttl, const u8 *target, u32 target_sn,
__le16 target_rcode, const u8 *ra) u16 target_rcode, const u8 *ra)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -293,9 +292,9 @@ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, ...@@ -293,9 +292,9 @@ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
pos++; pos++;
memcpy(pos, target, ETH_ALEN); memcpy(pos, target, ETH_ALEN);
pos += ETH_ALEN; pos += ETH_ALEN;
memcpy(pos, &target_sn, 4); put_unaligned_le32(target_sn, pos);
pos += 4; pos += 4;
memcpy(pos, &target_rcode, 2); put_unaligned_le16(target_rcode, pos);
/* see note in function header */ /* see note in function header */
prepare_frame_for_deferred_tx(sdata, skb); prepare_frame_for_deferred_tx(sdata, skb);
...@@ -592,10 +591,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -592,10 +591,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
if (ttl != 0) { if (ttl != 0) {
mhwmp_dbg(sdata, "replying to the PREQ\n"); mhwmp_dbg(sdata, "replying to the PREQ\n");
mesh_path_sel_frame_tx(MPATH_PREP, 0, orig_addr, mesh_path_sel_frame_tx(MPATH_PREP, 0, orig_addr,
cpu_to_le32(orig_sn), 0, target_addr, orig_sn, 0, target_addr,
cpu_to_le32(target_sn), mgmt->sa, 0, ttl, target_sn, mgmt->sa, 0, ttl,
cpu_to_le32(lifetime), cpu_to_le32(metric), lifetime, metric, 0, sdata);
0, sdata);
} else { } else {
ifmsh->mshstats.dropped_frames_ttl++; ifmsh->mshstats.dropped_frames_ttl++;
} }
...@@ -625,11 +623,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -625,11 +623,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
} }
mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr,
cpu_to_le32(orig_sn), target_flags, target_addr, orig_sn, target_flags, target_addr,
cpu_to_le32(target_sn), da, target_sn, da, hopcount, ttl, lifetime,
hopcount, ttl, cpu_to_le32(lifetime), metric, preq_id, sdata);
cpu_to_le32(metric), cpu_to_le32(preq_id),
sdata);
if (!is_multicast_ether_addr(da)) if (!is_multicast_ether_addr(da))
ifmsh->mshstats.fwded_unicast++; ifmsh->mshstats.fwded_unicast++;
else else
...@@ -695,11 +691,9 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -695,11 +691,9 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
target_sn = PREP_IE_TARGET_SN(prep_elem); target_sn = PREP_IE_TARGET_SN(prep_elem);
orig_sn = PREP_IE_ORIG_SN(prep_elem); orig_sn = PREP_IE_ORIG_SN(prep_elem);
mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr, orig_sn, 0,
cpu_to_le32(orig_sn), 0, target_addr, target_addr, target_sn, next_hop, hopcount,
cpu_to_le32(target_sn), next_hop, hopcount, ttl, lifetime, metric, 0, sdata);
ttl, cpu_to_le32(lifetime), cpu_to_le32(metric),
0, sdata);
rcu_read_unlock(); rcu_read_unlock();
sdata->u.mesh.mshstats.fwded_unicast++; sdata->u.mesh.mshstats.fwded_unicast++;
...@@ -750,8 +744,7 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -750,8 +744,7 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
if (!ifmsh->mshcfg.dot11MeshForwarding) if (!ifmsh->mshcfg.dot11MeshForwarding)
goto endperr; goto endperr;
mesh_path_error_tx(sdata, ttl, target_addr, mesh_path_error_tx(sdata, ttl, target_addr,
cpu_to_le32(target_sn), target_sn, target_rcode,
cpu_to_le16(target_rcode),
broadcast_addr); broadcast_addr);
} else } else
spin_unlock_bh(&mpath->state_lock); spin_unlock_bh(&mpath->state_lock);
...@@ -847,11 +840,9 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -847,11 +840,9 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
if (ifmsh->mshcfg.dot11MeshForwarding) { if (ifmsh->mshcfg.dot11MeshForwarding) {
mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr,
cpu_to_le32(orig_sn), orig_sn, 0, NULL, 0, broadcast_addr,
0, NULL, 0, broadcast_addr, hopcount, ttl, interval,
hopcount, ttl, cpu_to_le32(interval), metric + metric_txsta, 0, sdata);
cpu_to_le32(metric + metric_txsta),
0, sdata);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -1049,11 +1040,9 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) ...@@ -1049,11 +1040,9 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
spin_unlock_bh(&mpath->state_lock); spin_unlock_bh(&mpath->state_lock);
da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr;
mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, ifmsh->sn,
cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, target_flags, mpath->dst, mpath->sn, da, 0,
cpu_to_le32(mpath->sn), da, 0, ttl, lifetime, 0, ifmsh->preq_id++, sdata);
ttl, cpu_to_le32(lifetime), 0,
cpu_to_le32(ifmsh->preq_id++), sdata);
mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout);
enddiscovery: enddiscovery:
...@@ -1212,10 +1201,9 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) ...@@ -1212,10 +1201,9 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
switch (ifmsh->mshcfg.dot11MeshHWMPRootMode) { switch (ifmsh->mshcfg.dot11MeshHWMPRootMode) {
case IEEE80211_PROACTIVE_RANN: case IEEE80211_PROACTIVE_RANN:
mesh_path_sel_frame_tx(MPATH_RANN, flags, sdata->vif.addr, mesh_path_sel_frame_tx(MPATH_RANN, flags, sdata->vif.addr,
cpu_to_le32(++ifmsh->sn), ++ifmsh->sn, 0, NULL, 0, broadcast_addr,
0, NULL, 0, broadcast_addr,
0, ifmsh->mshcfg.element_ttl, 0, ifmsh->mshcfg.element_ttl,
cpu_to_le32(interval), 0, 0, sdata); interval, 0, 0, sdata);
break; break;
case IEEE80211_PROACTIVE_PREQ_WITH_PREP: case IEEE80211_PROACTIVE_PREQ_WITH_PREP:
flags |= IEEE80211_PREQ_PROACTIVE_PREP_FLAG; flags |= IEEE80211_PREQ_PROACTIVE_PREP_FLAG;
...@@ -1224,11 +1212,10 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) ...@@ -1224,11 +1212,10 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
target_flags |= IEEE80211_PREQ_TO_FLAG | target_flags |= IEEE80211_PREQ_TO_FLAG |
IEEE80211_PREQ_USN_FLAG; IEEE80211_PREQ_USN_FLAG;
mesh_path_sel_frame_tx(MPATH_PREQ, flags, sdata->vif.addr, mesh_path_sel_frame_tx(MPATH_PREQ, flags, sdata->vif.addr,
cpu_to_le32(++ifmsh->sn), target_flags, ++ifmsh->sn, target_flags,
(u8 *) broadcast_addr, 0, broadcast_addr, (u8 *) broadcast_addr, 0, broadcast_addr,
0, ifmsh->mshcfg.element_ttl, 0, ifmsh->mshcfg.element_ttl, interval,
cpu_to_le32(interval), 0, ifmsh->preq_id++, sdata);
0, cpu_to_le32(ifmsh->preq_id++), sdata);
break; break;
default: default:
mhwmp_dbg(sdata, "Proactive mechanism not supported\n"); mhwmp_dbg(sdata, "Proactive mechanism not supported\n");
......
...@@ -722,7 +722,6 @@ void mesh_plink_broken(struct sta_info *sta) ...@@ -722,7 +722,6 @@ void mesh_plink_broken(struct sta_info *sta)
struct mpath_node *node; struct mpath_node *node;
struct ieee80211_sub_if_data *sdata = sta->sdata; struct ieee80211_sub_if_data *sdata = sta->sdata;
int i; int i;
__le16 reason = cpu_to_le16(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE);
rcu_read_lock(); rcu_read_lock();
tbl = rcu_dereference(mesh_paths); tbl = rcu_dereference(mesh_paths);
...@@ -737,8 +736,8 @@ void mesh_plink_broken(struct sta_info *sta) ...@@ -737,8 +736,8 @@ void mesh_plink_broken(struct sta_info *sta)
spin_unlock_bh(&mpath->state_lock); spin_unlock_bh(&mpath->state_lock);
mesh_path_error_tx(sdata, mesh_path_error_tx(sdata,
sdata->u.mesh.mshcfg.element_ttl, sdata->u.mesh.mshcfg.element_ttl,
mpath->dst, cpu_to_le32(mpath->sn), mpath->dst, mpath->sn,
reason, bcast); WLAN_REASON_MESH_PATH_DEST_UNREACHABLE, bcast);
} }
} }
rcu_read_unlock(); rcu_read_unlock();
......
...@@ -2081,7 +2081,6 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) ...@@ -2081,7 +2081,6 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
struct ieee80211_sub_if_data *sdata = rx->sdata; struct ieee80211_sub_if_data *sdata = rx->sdata;
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
__le16 reason = cpu_to_le16(WLAN_REASON_MESH_PATH_NOFORWARD);
u16 q, hdrlen; u16 q, hdrlen;
hdr = (struct ieee80211_hdr *) skb->data; hdr = (struct ieee80211_hdr *) skb->data;
...@@ -2189,7 +2188,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) ...@@ -2189,7 +2188,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
} else { } else {
/* unable to resolve next hop */ /* unable to resolve next hop */
mesh_path_error_tx(sdata, ifmsh->mshcfg.element_ttl, mesh_path_error_tx(sdata, ifmsh->mshcfg.element_ttl,
fwd_hdr->addr3, 0, reason, fwd_hdr->addr2); fwd_hdr->addr3, 0,
WLAN_REASON_MESH_PATH_NOFORWARD,
fwd_hdr->addr2);
IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_no_route); IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_no_route);
kfree_skb(fwd_skb); kfree_skb(fwd_skb);
return RX_DROP_MONITOR; return RX_DROP_MONITOR;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment