* [PATCH 1/3] mac80211: comment allocation of mesh frames
@ 2011-10-20 0:23 Thomas Pedersen
2011-10-20 0:23 ` [PATCH 2/3] mac80211: find correct IE offset in mesh beacons Thomas Pedersen
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Thomas Pedersen @ 2011-10-20 0:23 UTC (permalink / raw)
To: linux-wireless; +Cc: Thomas Pedersen, johannes, linville
Remove most references to magic numbers, save a few bytes and hopefully
improve readability.
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
net/mac80211/mesh_hwmp.c | 36 ++++++++++++++++++------------------
net/mac80211/mesh_plink.c | 28 +++++++++++++++++-----------
net/mac80211/tx.c | 19 +++++++++++++------
3 files changed, 48 insertions(+), 35 deletions(-)
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 174040a..9a1f8bb 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -113,20 +113,20 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_local *local = sdata->local;
- struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
+ struct sk_buff *skb;
struct ieee80211_mgmt *mgmt;
- u8 *pos;
- int ie_len;
+ u8 *pos, ie_len;
+ int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) +
+ sizeof(mgmt->u.action.u.mesh_action);
+ skb = dev_alloc_skb(local->hw.extra_tx_headroom +
+ hdr_len +
+ 2 + 37); /* max HWMP IE */
if (!skb)
return -1;
skb_reserve(skb, local->hw.extra_tx_headroom);
- /* 25 is the size of the common mgmt part (24) plus the size of the
- * common action part (1)
- */
- mgmt = (struct ieee80211_mgmt *)
- skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action));
- memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action));
+ mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
+ memset(mgmt, 0, hdr_len);
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_ACTION);
@@ -240,20 +240,20 @@ int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn,
struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_local *local = sdata->local;
- struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
+ struct sk_buff *skb;
struct ieee80211_mgmt *mgmt;
- u8 *pos;
- int ie_len;
+ u8 *pos, ie_len;
+ int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) +
+ sizeof(mgmt->u.action.u.mesh_action);
+ skb = dev_alloc_skb(local->hw.extra_tx_headroom +
+ hdr_len +
+ 2 + 15 /* PERR IE */);
if (!skb)
return -1;
skb_reserve(skb, local->tx_headroom + local->hw.extra_tx_headroom);
- /* 25 is the size of the common mgmt part (24) plus the size of the
- * common action part (1)
- */
- mgmt = (struct ieee80211_mgmt *)
- skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action));
- memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action));
+ mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
+ memset(mgmt, 0, hdr_len);
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_ACTION);
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 7e57f5d..351e48c 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -153,23 +153,29 @@ 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) {
struct ieee80211_local *local = sdata->local;
- struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 +
- sdata->u.mesh.ie_len);
+ struct sk_buff *skb;
struct ieee80211_mgmt *mgmt;
bool include_plid = false;
- int ie_len = 4;
u16 peering_proto = 0;
- u8 *pos;
-
+ u8 *pos, ie_len = 4;
+ int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
+ sizeof(mgmt->u.action.u.self_prot);
+
+ skb = dev_alloc_skb(local->hw.extra_tx_headroom +
+ hdr_len +
+ 2 + /* capability info */
+ 2 + /* AID */
+ 2 + 8 + /* supported rates */
+ 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
+ 2 + sdata->u.mesh.mesh_id_len +
+ 2 + sizeof(struct ieee80211_meshconf_ie) +
+ 2 + 8 + /* peering IE */
+ sdata->u.mesh.ie_len);
if (!skb)
return -1;
skb_reserve(skb, local->hw.extra_tx_headroom);
- /* 25 is the size of the common mgmt part (24) plus the size of the
- * common action part (1)
- */
- mgmt = (struct ieee80211_mgmt *)
- skb_put(skb, 25 + sizeof(mgmt->u.action.u.self_prot));
- memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.self_prot));
+ mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
+ memset(mgmt, 0, hdr_len);
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_ACTION);
memcpy(mgmt->da, da, ETH_ALEN);
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 48bbb96..f4dd339 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2278,22 +2278,29 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
} else if (ieee80211_vif_is_mesh(&sdata->vif)) {
struct ieee80211_mgmt *mgmt;
u8 *pos;
+ int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) +
+ sizeof(mgmt->u.beacon);
#ifdef CONFIG_MAC80211_MESH
if (!sdata->u.mesh.mesh_id_len)
goto out;
#endif
- /* headroom, head length, tail length and maximum TIM length */
- skb = dev_alloc_skb(local->tx_headroom + 400 +
- sdata->u.mesh.ie_len);
+ skb = dev_alloc_skb(local->tx_headroom +
+ hdr_len +
+ 2 + /* NULL SSID */
+ 2 + 8 + /* supported rates */
+ 2 + 3 + /* DS params */
+ 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
+ 2 + sdata->u.mesh.mesh_id_len +
+ 2 + sizeof(struct ieee80211_meshconf_ie) +
+ sdata->u.mesh.ie_len);
if (!skb)
goto out;
skb_reserve(skb, local->hw.extra_tx_headroom);
- mgmt = (struct ieee80211_mgmt *)
- skb_put(skb, 24 + sizeof(mgmt->u.beacon));
- memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
+ mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
+ memset(mgmt, 0, hdr_len);
mgmt->frame_control =
cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
memset(mgmt->da, 0xff, ETH_ALEN);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/3] mac80211: find correct IE offset in mesh beacons
2011-10-20 0:23 [PATCH 1/3] mac80211: comment allocation of mesh frames Thomas Pedersen
@ 2011-10-20 0:23 ` Thomas Pedersen
2011-10-20 11:13 ` Johannes Berg
2011-10-20 0:23 ` [PATCH 3/3] mac80211: select queue for fwded mesh frames Thomas Pedersen
2011-10-20 7:26 ` [PATCH v2 " Thomas Pedersen
2 siblings, 1 reply; 8+ messages in thread
From: Thomas Pedersen @ 2011-10-20 0:23 UTC (permalink / raw)
To: linux-wireless; +Cc: Thomas Pedersen, johannes, linville
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
net/mac80211/mesh.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index a7078fd..19ec8bd 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -569,6 +569,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
u32 supp_rates = 0;
size_t baselen;
int freq;
+ u8 *ies;
enum ieee80211_band band = rx_status->band;
/* ignore ProbeResp to foreign address */
@@ -576,12 +577,22 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
compare_ether_addr(mgmt->da, sdata->vif.addr))
return;
- baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
+ switch (stype) {
+ case IEEE80211_STYPE_PROBE_RESP:
+ ies = (u8 *) mgmt->u.probe_resp.variable;
+ break;
+ case IEEE80211_STYPE_BEACON:
+ ies = (u8 *) mgmt->u.beacon.variable;
+ break;
+ default:
+ return;
+ }
+
+ baselen = ies - (u8 *) mgmt;
if (baselen > len)
return;
- ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
- &elems);
+ ieee802_11_parse_elems(ies, len - baselen, &elems);
/* ignore beacons from secure mesh peers if our security is off */
if (elems.rsn_len && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] mac80211: find correct IE offset in mesh beacons
2011-10-20 0:23 ` [PATCH 2/3] mac80211: find correct IE offset in mesh beacons Thomas Pedersen
@ 2011-10-20 11:13 ` Johannes Berg
2011-10-20 17:48 ` Thomas Pedersen
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2011-10-20 11:13 UTC (permalink / raw)
To: Thomas Pedersen; +Cc: linux-wireless, linville
> - baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
> + switch (stype) {
> + case IEEE80211_STYPE_PROBE_RESP:
> + ies = (u8 *) mgmt->u.probe_resp.variable;
> + break;
> + case IEEE80211_STYPE_BEACON:
> + ies = (u8 *) mgmt->u.beacon.variable;
> + break;
> + default:
> + return;
> + }
> +
Does that really make sense? the offset is the same anyway and we don't
get here with other frames.
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] mac80211: find correct IE offset in mesh beacons
2011-10-20 11:13 ` Johannes Berg
@ 2011-10-20 17:48 ` Thomas Pedersen
2011-10-20 17:51 ` Johannes Berg
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Pedersen @ 2011-10-20 17:48 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, linville
On Thu, Oct 20, 2011 at 4:13 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
>
>> - baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
>> + switch (stype) {
>> + case IEEE80211_STYPE_PROBE_RESP:
>> + ies = (u8 *) mgmt->u.probe_resp.variable;
>> + break;
>> + case IEEE80211_STYPE_BEACON:
>> + ies = (u8 *) mgmt->u.beacon.variable;
>> + break;
>> + default:
>> + return;
>> + }
>> +
>
> Does that really make sense? the offset is the same anyway and we don't
> get here with other frames.
I don't think so:
struct {
__le64 timestamp;
__le16 beacon_int;
__le16 capab_info;
/* followed by some of SSID, Supported rates,
* FH Params, DS Params, CF Params, IBSS Params, TIM */
u8 variable[0];
} __attribute__ ((packed)) beacon;
struct {
/* only variable items: SSID, Supported rates */
u8 variable[0];
} __attribute__ ((packed)) probe_req;
True, we don't currently get probe responses in a mesh, but the
function _is_ named "_rx_bcn_presp" so we should be ready to handle
these in the future. Previously we always getting the wrong offset.
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] mac80211: find correct IE offset in mesh beacons
2011-10-20 17:48 ` Thomas Pedersen
@ 2011-10-20 17:51 ` Johannes Berg
2011-10-20 17:53 ` Thomas Pedersen
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2011-10-20 17:51 UTC (permalink / raw)
To: Thomas Pedersen; +Cc: linux-wireless, linville
On Thu, 2011-10-20 at 10:48 -0700, Thomas Pedersen wrote:
> On Thu, Oct 20, 2011 at 4:13 AM, Johannes Berg
> <johannes@sipsolutions.net> wrote:
> >
> >> - baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
> >> + switch (stype) {
> >> + case IEEE80211_STYPE_PROBE_RESP:
> >> + ies = (u8 *) mgmt->u.probe_resp.variable;
> >> + break;
> >> + case IEEE80211_STYPE_BEACON:
> >> + ies = (u8 *) mgmt->u.beacon.variable;
> >> + break;
> >> + default:
> >> + return;
> >> + }
> >> +
> >
> > Does that really make sense? the offset is the same anyway and we don't
> > get here with other frames.
>
> I don't think so:
>
> struct {
> __le64 timestamp;
> __le16 beacon_int;
> __le16 capab_info;
> /* followed by some of SSID, Supported rates,
> * FH Params, DS Params, CF Params, IBSS Params, TIM */
> u8 variable[0];
> } __attribute__ ((packed)) beacon;
> struct {
> /* only variable items: SSID, Supported rates */
> u8 variable[0];
> } __attribute__ ((packed)) probe_req;
Err, probe_req != probe_resp.
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] mac80211: find correct IE offset in mesh beacons
2011-10-20 17:51 ` Johannes Berg
@ 2011-10-20 17:53 ` Thomas Pedersen
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Pedersen @ 2011-10-20 17:53 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, linville
On Thu, Oct 20, 2011 at 10:51 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Thu, 2011-10-20 at 10:48 -0700, Thomas Pedersen wrote:
>> On Thu, Oct 20, 2011 at 4:13 AM, Johannes Berg
>> <johannes@sipsolutions.net> wrote:
>> >
>> >> - baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
>> >> + switch (stype) {
>> >> + case IEEE80211_STYPE_PROBE_RESP:
>> >> + ies = (u8 *) mgmt->u.probe_resp.variable;
>> >> + break;
>> >> + case IEEE80211_STYPE_BEACON:
>> >> + ies = (u8 *) mgmt->u.beacon.variable;
>> >> + break;
>> >> + default:
>> >> + return;
>> >> + }
>> >> +
>> >
>> > Does that really make sense? the offset is the same anyway and we don't
>> > get here with other frames.
>>
>> I don't think so:
>>
>> struct {
>> __le64 timestamp;
>> __le16 beacon_int;
>> __le16 capab_info;
>> /* followed by some of SSID, Supported rates,
>> * FH Params, DS Params, CF Params, IBSS Params, TIM */
>> u8 variable[0];
>> } __attribute__ ((packed)) beacon;
>> struct {
>> /* only variable items: SSID, Supported rates */
>> u8 variable[0];
>> } __attribute__ ((packed)) probe_req;
>
> Err, probe_req != probe_resp.
Wow, I need glasses. In that case, I'll drop this patch and resubmit.
Thanks!
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] mac80211: select queue for fwded mesh frames
2011-10-20 0:23 [PATCH 1/3] mac80211: comment allocation of mesh frames Thomas Pedersen
2011-10-20 0:23 ` [PATCH 2/3] mac80211: find correct IE offset in mesh beacons Thomas Pedersen
@ 2011-10-20 0:23 ` Thomas Pedersen
2011-10-20 7:26 ` [PATCH v2 " Thomas Pedersen
2 siblings, 0 replies; 8+ messages in thread
From: Thomas Pedersen @ 2011-10-20 0:23 UTC (permalink / raw)
To: linux-wireless; +Cc: Thomas Pedersen, johannes, linville
Set proper queue mapping and timestamp for forwarded mesh frames.
Thanks to Luis Rodriguez for investigating and fixing this.
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
net/mac80211/rx.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index b867bd5..8c03d6e 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1952,6 +1952,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
info = IEEE80211_SKB_CB(fwd_skb);
memset(info, 0, sizeof(*info));
info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
+ info->control.jiffies = jiffies;
info->control.vif = &rx->sdata->vif;
if (is_multicast_ether_addr(fwd_hdr->addr1)) {
IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
@@ -1974,6 +1975,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
if (err)
return RX_DROP_MONITOR;
+ skb_set_queue_mapping(fwd_skb,
+ ieee80211_select_queue(sdata, fwd_skb));
+ ieee80211_set_qos_hdr(sdata, fwd_skb);
+
IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
fwded_unicast);
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 3/3] mac80211: select queue for fwded mesh frames
2011-10-20 0:23 [PATCH 1/3] mac80211: comment allocation of mesh frames Thomas Pedersen
2011-10-20 0:23 ` [PATCH 2/3] mac80211: find correct IE offset in mesh beacons Thomas Pedersen
2011-10-20 0:23 ` [PATCH 3/3] mac80211: select queue for fwded mesh frames Thomas Pedersen
@ 2011-10-20 7:26 ` Thomas Pedersen
2 siblings, 0 replies; 8+ messages in thread
From: Thomas Pedersen @ 2011-10-20 7:26 UTC (permalink / raw)
To: linux-wireless; +Cc: Thomas Pedersen, johannes, linville
Set proper queue mapping and timestamp for forwarded mesh frames.
Thanks to Luis Rodriguez for investigating and fixing this.
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
---
v2:
We were already doing this for mcast frames, so don't duplicate
the code.
net/mac80211/rx.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index b867bd5..1408472 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1952,13 +1952,15 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
info = IEEE80211_SKB_CB(fwd_skb);
memset(info, 0, sizeof(*info));
info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
+ info->control.jiffies = jiffies;
info->control.vif = &rx->sdata->vif;
+ skb_set_queue_mapping(fwd_skb,
+ ieee80211_select_queue(sdata, fwd_skb));
+ ieee80211_set_qos_hdr(sdata, fwd_skb);
+
if (is_multicast_ether_addr(fwd_hdr->addr1)) {
IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
fwded_mcast);
- skb_set_queue_mapping(fwd_skb,
- ieee80211_select_queue(sdata, fwd_skb));
- ieee80211_set_qos_hdr(sdata, fwd_skb);
} else {
int err;
/*
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-10-20 17:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-20 0:23 [PATCH 1/3] mac80211: comment allocation of mesh frames Thomas Pedersen
2011-10-20 0:23 ` [PATCH 2/3] mac80211: find correct IE offset in mesh beacons Thomas Pedersen
2011-10-20 11:13 ` Johannes Berg
2011-10-20 17:48 ` Thomas Pedersen
2011-10-20 17:51 ` Johannes Berg
2011-10-20 17:53 ` Thomas Pedersen
2011-10-20 0:23 ` [PATCH 3/3] mac80211: select queue for fwded mesh frames Thomas Pedersen
2011-10-20 7:26 ` [PATCH v2 " Thomas Pedersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox