[PATCH] mac80211: Remove unused initialization

2018-09-29 Thread Masashi Honma
The variable j will be initialized at trailing step.

Signed-off-by: Masashi Honma 
---
 net/mac80211/rc80211_minstrel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 07fb219..fc6134c 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -632,7 +632,7 @@ minstrel_init_cck_rates(struct minstrel_priv *mp)
if (!sband)
return;
 
-   for (i = 0, j = 0; i < sband->n_bitrates; i++) {
+   for (i = 0; i < sband->n_bitrates; i++) {
struct ieee80211_rate *rate = >bitrates[i];
 
if (rate->flags & IEEE80211_RATE_ERP_G)
-- 
2.7.4



Re: [PATCH 2/2] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds

2018-09-26 Thread Masashi Honma
On 2018/09/26 18:23, Johannes Berg wrote:> I applied the first patch in 
the seies, but I don't understand why this

patch should be necessary.

The value of i isn't controlled by the user, so it shouldn't need to be
sanitized?

The context was *just* missing, added by me:

 for (i = 0; i < n; i++)

if (last < wdev->cqm_config->rssi_thresholds[i])
break;


This loop determines i, and the user doesn't even control "last", but
even if they did, the possible values of i could only end up being in
the range 0..n-1, so no problems?


The variable i could be n after the loop when this condition is not 
satisfied for all rssi_thresholds[i].


>>if (last < wdev->cqm_config->rssi_thresholds[i])
>>break;

And user could control rssi_thresholds[i] by using 
NL80211_ATTR_CQM_RSSI_THOLD.


For example, I could set 4 rssi_thresholds -400, -300, -200, -100.
And then last is -34. I could get i = n = 4 after the loop.

Regards,
Masashi Honma.




[PATCH 2/2] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds

2018-09-24 Thread Masashi Honma
Use array_index_nospec() to sanitize i with respect to speculation.

Signed-off-by: Masashi Honma 
---
 net/wireless/nl80211.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3c469c1..4f47502 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10227,7 +10227,7 @@ static int cfg80211_cqm_rssi_update(struct 
cfg80211_registered_device *rdev,
struct wireless_dev *wdev = dev->ieee80211_ptr;
s32 last, low, high;
u32 hyst;
-   int i, n;
+   int i, n, low_index;
int err;
 
/* RSSI reporting disabled? */
@@ -10264,10 +10264,19 @@ static int cfg80211_cqm_rssi_update(struct 
cfg80211_registered_device *rdev,
if (last < wdev->cqm_config->rssi_thresholds[i])
break;
 
-   low = i > 0 ?
-   (wdev->cqm_config->rssi_thresholds[i - 1] - hyst) : S32_MIN;
-   high = i < n ?
-   (wdev->cqm_config->rssi_thresholds[i] + hyst - 1) : S32_MAX;
+   low_index = i - 1;
+   if (low_index >= 0) {
+   low_index = array_index_nospec(low_index, n);
+   low = wdev->cqm_config->rssi_thresholds[low_index] - hyst;
+   } else {
+   low = S32_MIN;
+   }
+   if (i < n) {
+   i = array_index_nospec(i, n);
+   high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1;
+   } else {
+   high = S32_MAX;
+   }
 
return rdev_set_cqm_rssi_range_config(rdev, dev, low, high);
 }
-- 
2.7.4



[PATCH 1/2] nl80211: Fix possible Spectre-v1 for NL80211_TXRATE_HT

2018-09-24 Thread Masashi Honma
Use array_index_nospec() to sanitize ridx with respect to speculation.

Signed-off-by: Masashi Honma 
---
 net/wireless/nl80211.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0827cbd..3c469c1 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3748,6 +3748,7 @@ static bool ht_rateset_to_mask(struct 
ieee80211_supported_band *sband,
return false;
 
/* check availability */
+   ridx = array_index_nospec(ridx, IEEE80211_HT_MCS_MASK_LEN);
if (sband->ht_cap.mcs.rx_mask[ridx] & rbit)
mcs[ridx] |= rbit;
else
-- 
2.7.4



Re: [PATCH] nl80211: relax ht operation checks for mesh

2018-06-25 Thread Masashi Honma
On 2018/06/25 10:10, Bob Copeland wrote:> The latter bit is actually 
reserved for mesh BSSes

according to Table 9-168 in 802.11-2016, so in fact it should not
be set.


Good catch !
Indeed the bit is reserved at non-AP case.

Reviewed-by: Masashi Honma 


Re: [PATCH] nl80211: relax ht operation checks for mesh

2018-06-24 Thread Masashi Honma

On 2018/06/25 10:10, Bob Copeland wrote:

The latter bit is actually reserved for mesh BSSes
according to Table 9-168 in 802.11-2016, so in fact it should not
be set.


Good catch !
Indeed the bit is reserved at non-AP case.

Reviewed-by: Masashi Honma 


Re: [PATCH v2] mac80211: Use rssi_threshold even though user_mpm=1

2017-03-26 Thread Masashi Honma

On 2017/03/17 14:59, Masashi Honma wrote:

Previously the meshcfg.rssi_threshold did not work with user_mpm=1.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>


Is there any comment ?

Masashi Honma.



Re: [PATCH 2/2] mac80211: Drop new node with weak power

2017-03-20 Thread Masashi Honma

On 2017/03/17 21:28, Johannes Berg wrote:

Hmm. If path selection isn't done by mac80211 in this case, wouldn't it
be more appropriate to put this logic into the (userspace) component
that does path selection?


Currently, userspace application(wpa_supplicant) does not have mesh
path selection functionality.


IOW, I'm not convinced that outright not adding the *peer* is a good
idea either way - it seems much better to me to not use the *path*.


We have already had the code to calculate mesh path metric with RSSI.

But we still needs this patch for a special case on SAE. Some hardware
can use hardware encryption for mesh SAE. Then the hardware has a
limitation of key registration. For example, some hardware could only
save keys for 8 stations. So we need to drop stations itself with weak
signal instead of the pathes to its.

Masashi Honma.


[PATCH v2] mac80211: Use rssi_threshold even though user_mpm=1

2017-03-17 Thread Masashi Honma
Previously the meshcfg.rssi_threshold did not work with user_mpm=1.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/mesh.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 6e7b6a0..281d834 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1100,8 +1100,14 @@ static void ieee80211_mesh_rx_bcn_presp(struct 
ieee80211_sub_if_data *sdata,
if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
return;
 
-   if (mesh_matches_local(sdata, ))
-   mesh_neighbour_update(sdata, mgmt->sa, );
+   if (mesh_matches_local(sdata, )) {
+   mpl_dbg(sdata, "rssi_threshold=%d,rx_status->signal=%d\n",
+   sdata->u.mesh.mshcfg.rssi_threshold, rx_status->signal);
+   if (!sdata->u.mesh.user_mpm ||
+   sdata->u.mesh.mshcfg.rssi_threshold == 0 ||
+   sdata->u.mesh.mshcfg.rssi_threshold < rx_status->signal)
+   mesh_neighbour_update(sdata, mgmt->sa, );
+   }
 
if (ifmsh->sync_ops)
ifmsh->sync_ops->rx_bcn_presp(sdata,
-- 
2.7.4



Re: [PATCH 2/2] mac80211: Drop new node with weak power

2017-03-16 Thread Masashi Honma

On 2017/03/16 19:03, Johannes Berg wrote:

I'm not really sure this is the right solution?

It seems to me that it should be a function of the path selection to
take this into account, not prohibiting the longer path entirely?


Right. To calculate metric with RSSI level is better solution than
this solution.


It seems that this is really what the meshcfg.rssi_threshold was
intended for, and the plink code *does* take it into account. Can you
explain where that's breaking down?


Indeed meshcfg.rssi_threshold is already referred by some codes. But
when booting mesh node with user_mpm=1, the codes is not called.
So we need to add another code.

I will update commit log because this patch just enables
meshcfg.rssi_threshold with user_mpm=1.

Masashi Honma.


[PATCH 1/2] nl80211: Use signed function for a signed variable

2017-03-15 Thread Masashi Honma
The rssi_threshold is defined as s32.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/wireless/nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b15903b..bd5959f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5714,7 +5714,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
   cur_params.dot11MeshGateAnnouncementProtocol) ||
nla_put_u8(msg, NL80211_MESHCONF_FORWARDING,
   cur_params.dot11MeshForwarding) ||
-   nla_put_u32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
+   nla_put_s32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
cur_params.rssi_threshold) ||
nla_put_u32(msg, NL80211_MESHCONF_HT_OPMODE,
cur_params.ht_opmode) ||
-- 
2.7.4



[PATCH 2/2] mac80211: Drop new node with weak power

2017-03-15 Thread Masashi Honma
On some practical cases, it is useful to drop new node in the distance.
Because mesh metric is calculated with hop count and without RSSI
information, a node far from local peer and near to destination node
could be used as best path.

For example, the nodes are located in linear. Distance of 0 - 1 and
1 - 2 and 2 - 3 is 20meters. 0 to 3 signal is very weak.

0 --- 1 --- 2 --- 3

Though most robust path from 0 to 3 is 0 -> 1 -> 2 -> 3,
unfortunately, node 0 could recognize node 3 as neighbor. Then node 3
could be next of node 0. This patch aims to avoid such a case.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/mesh.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 6e7b6a0..281d834 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1100,8 +1100,14 @@ static void ieee80211_mesh_rx_bcn_presp(struct 
ieee80211_sub_if_data *sdata,
if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
return;
 
-   if (mesh_matches_local(sdata, ))
-   mesh_neighbour_update(sdata, mgmt->sa, );
+   if (mesh_matches_local(sdata, )) {
+   mpl_dbg(sdata, "rssi_threshold=%d,rx_status->signal=%d\n",
+   sdata->u.mesh.mshcfg.rssi_threshold, rx_status->signal);
+   if (!sdata->u.mesh.user_mpm ||
+   sdata->u.mesh.mshcfg.rssi_threshold == 0 ||
+   sdata->u.mesh.mshcfg.rssi_threshold < rx_status->signal)
+   mesh_neighbour_update(sdata, mgmt->sa, );
+   }
 
if (ifmsh->sync_ops)
ifmsh->sync_ops->rx_bcn_presp(sdata,
-- 
2.7.4



[PATCH v2] iw: Fix bitrate output when no rate info found

2017-02-14 Thread Masashi Honma
Previously, bitrate showed uninitialized buffer when no rate info found.
This patch fixes the issue.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 station.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/station.c b/station.c
index f3e3da8..4885dc0 100644
--- a/station.c
+++ b/station.c
@@ -151,6 +151,8 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, 
int buflen)
if (rate > 0)
pos += snprintf(pos, buflen - (pos - buf),
"%d.%d MBit/s", rate / 10, rate % 10);
+   else
+   pos += snprintf(pos, buflen - (pos - buf), "(unknown)");
 
if (rinfo[NL80211_RATE_INFO_MCS])
pos += snprintf(pos, buflen - (pos - buf),
-- 
2.7.4



Re: [PATCH] iw: Fix bitrate output when no rate info found

2017-02-14 Thread Masashi Honma

On 2017-02-14 18:14, Johannes Berg wrote:

Yes, this is bad! But if you saw that, why did you ever get to the
below code that checked for the BITRATE(32) attributes?


So I used explaining message. We could see the message like this.

tx bitrate: No rate info found!
rx bitrate: 48.0 MBit/s


Yeah I was just thinking we could also see

tx bitrate: (unknown)

and then if there was MCS anyway you'd see

tx bitrate: (unknown) MCS 7

or something like that?


Yes, showing information as far as possible looks good.

I will modify this patch.

Masashi Honma.


Re: [PATCH] iw: Fix bitrate output when no rate info found

2017-02-14 Thread Masashi Honma

On 2017-02-14 17:35, Johannes Berg wrote:

On Tue, 2017-02-14 at 14:21 +0900, Masashi Honma wrote:

Previously, bitrate showed uninitialized buffer when no rate info
found.


When would this happen?


I could see in mesh STA connection with 11n and legacy mixed.
STA A has disable_ht=1.
STA B has disable_ht=0.

> I'm not really sure this is right - perhaps we don't have
> RATE_INFO_BITRATE(32), but still have the MCS data?

I recognized there was a issue on such a case. I will send a patch to 
wpa_supplicant. Anyway, showing string message is better than showing 
raw binary data.



How about we just add "(unknown)" or so and not return here?


Yes. First time, I supposed to use "unknown". But in the function 
parse_bitrate(), nla_parse_nested() returns message "failed to parse 
nested rate attributes!". This explains why the bitrate is unknown. So I 
used explaining message. We could see the message like this.


tx bitrate: No rate info found!
rx bitrate: 48.0 MBit/s

Masashi Honma.


Re: [PATCH] iw: Fix bitrate output when no rate info found

2017-02-13 Thread Masashi Honma

On 2017/02/14 14:21, Masashi Honma wrote:

Previously, bitrate showed uninitialized buffer when no rate info found.
This patch fixes the issue.


This is the screen shot.

Masashi Honma.


[PATCH] iw: Fix bitrate output when no rate info found

2017-02-13 Thread Masashi Honma
Previously, bitrate showed uninitialized buffer when no rate info found.
This patch fixes the issue.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 station.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/station.c b/station.c
index f3e3da8..9d3eb4d 100644
--- a/station.c
+++ b/station.c
@@ -151,6 +151,10 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, 
int buflen)
if (rate > 0)
pos += snprintf(pos, buflen - (pos - buf),
"%d.%d MBit/s", rate / 10, rate % 10);
+   else {
+   snprintf(buf, buflen, "No rate info found!");
+   return;
+   }
 
if (rinfo[NL80211_RATE_INFO_MCS])
pos += snprintf(pos, buflen - (pos - buf),
-- 
2.7.4



[PATCH] mac80211: Remove VHT Capabilities/Operation IEs from mesh beacon if VHT was disabled

2017-02-01 Thread Masashi Honma
When wpa_supplicant.conf includes disable_ht=1, the beacon of the mesh
node does not have HT Capabilities/Operation IEs. However, the beacon
of the mesh node has VHT Capabilities/Operation IEs even though
wpa_supplicant.conf includes disable_vht=1.

This patch removes VHT Capabilities/Operation IEs when the
wpa_supplicant.conf includes disable_vht=1. We recognize the local peer
as 11ac ready, when it has more than 80MHz band width. Because
net/mac80211/util.c#ieee80211_build_preq_ies_band() uses 80MHz threshold
for VHT Capabilities IE inclusion.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/mesh.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 9c23172..a30be19 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -469,9 +469,9 @@ int mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
 
sband = local->hw.wiphy->bands[band];
if (!sband->vht_cap.vht_supported ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
+   !(sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_80 ||
+   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_80P80 ||
+   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_160))
return 0;
 
if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_vht_cap))
@@ -506,9 +506,9 @@ int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data 
*sdata,
vht_cap = >vht_cap;
 
if (!vht_cap->vht_supported ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
+   !(sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_80 ||
+   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_80P80 ||
+   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_160))
return 0;
 
if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_vht_operation))
-- 
2.7.4



[PATCH] nl80211: Fix mesh HT operation check

2017-01-25 Thread Masashi Honma
commit 9757235f451c27deaa88925399f070ff6fcea832 ('nl80211: correct
checks for NL80211_MESHCONF_HT_OPMODE value') missed to mask a flag
when replacing FILL_IN_MESH_PARAM_IF_SET with checking codes. This
could drop the received HT operation value when called by
nl80211_update_mesh_config().

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/wireless/nl80211.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e6ed8dc..006c147 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5924,6 +5924,7 @@ do {  
\
break;
}
cfg->ht_opmode = ht_opmode;
+   mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
}
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
  1, 65535, mask,
-- 
2.7.4



Re: mac80211: Fix headroom allocation when forwarding mesh pkt

2017-01-11 Thread Masashi Honma

On 2017/01/11 23:39, Cedric Izoard wrote:

-   fwd_skb = skb_copy_expand(skb, local->tx_headroom, 0, GFP_ATOMIC);
+   fwd_skb = skb_copy_expand(skb, local->tx_headroom +
+ sdata->encrypt_headroom, 0, GFP_ATOMIC);
if (!fwd_skb) {
net_info_ratelimited("%s: failed to clone mesh frame\n",
sdata->name);



# I retransmit this because of server error.

Thanks ! It work for me.

Bisected-reported-and-tested-by: Masashi Honma <masashi.ho...@gmail.com>

Masashi Honma.


Re: [REGRESSION, bisect] mesh: SAE connection causes kernel crash

2017-01-11 Thread Masashi Honma

On 2017年01月11日 20:01, Johannes Berg wrote:

Sure, ssh won't - I was thinking of netconsole:
https://www.kernel.org/doc/Documentation/networking/netconsole.txt


Oh, I see. Thanks, I will try.

Masashi Honma.



Re: [REGRESSION, bisect] mesh: SAE connection causes kernel crash

2017-01-11 Thread Masashi Honma

On 2017年01月11日 19:00, Johannes Berg wrote:

Nevertheless, I don't have hardware to try to reproduce it, and I can't
see any such issues (even with real forwarding, I even just wrote a
wpa_s test for that) in hwsim.

Even a photo of the crash on the VT would help. Or maybe you can set up
netconsole on the wired interface?


Thanks but SSH console via wired interface and laptop display does not 
show any log...


Masashi Honma.


Re: [REGRESSION, bisect] mesh: SAE connection causes kernel crash

2017-01-11 Thread Masashi Honma

On 2017年01月11日 18:00, Johannes Berg wrote:

Ok, that's strange, but maybe there's a reason.

Can you extract *any* information whatsoever? Like maybe if you switch
to a VT console before running into the crash? I don't have any
hardware to run this on, and hwsim doesn't have any issues.


I will call the mesh peers "STA A" and "STA B".

Both STA has one physical wireless I/F and wired I/F.
I have connected to both with SSH via wired I/F and started
wpa_supplicant with this command for both.
	sudo ./hostap/wpa_supplicant/wpa_supplicant -i  -D nl80211 -c 
mesh_sae.conf


STA A's mesh_sae.conf is this.

--
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
user_mpm=1
update_config=0

network={
ssid="mesh0"
key_mgmt=SAE
mode=5
frequency=2412
psk="01234567"
}
--

STA B's mesh_sae.conf is this. The difference is "no_auto_peer=1".

--
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
user_mpm=1
update_config=0

network={
ssid="mesh0"
key_mgmt=SAE
mode=5
frequency=2412
psk="01234567"
no_auto_peer=1
}
--

Booting the wpa_supplicant finishes successfully.

After the successfull peering process, I could see
MESH-PEER-CONNECTED
message on both side.

Then STA A or STA B crashes, not both.

Masashi Honma.


Re: [REGRESSION, bisect] mesh: SAE connection causes kernel crash

2017-01-11 Thread Masashi Honma

On 2017年01月11日 17:02, Johannes Berg wrote:

I don't think this makes sense - if you only have two peers then you
shouldn't even run into forwarding code paths?

johannes


Though it looks odd, the code has run into forwarding code path even 
though peer to peer mesh connection.


fwd_skb = skb_copy(skb, GFP_ATOMIC);

I checked it with printk().

# I know printk() should not be used in the context, just for checking.

Masashi Honma.


[REGRESSION, bisect] mesh: SAE connection causes kernel crash

2017-01-10 Thread Masashi Honma
I have encountered kernel crash when I have used mesh SAE connection  
with ath9k_htc device (Sony UWA-BR100). I have tried to connect 2 peers  
to each other, then only one peer crashes.


By bisect, this commit looks causes this issue.

commit d8da0b5d64d58f7775a94bcf12dda50f13a76f22
Author: Cedric Izoard <cedric.izo...@ceva-dsp.com>
Date:   Wed Dec 7 09:59:00 2016 +

mac80211: Ensure enough headroom when forwarding mesh pkt

When a buffer is duplicated during MESH packet forwarding,
this patch ensures that the new buffer has enough headroom.

I do not have any crash log because the computer was fully uncontrollable.

Regards,
Masashi Honma.


Re: [PATCH] mac80211: Fix addition of mesh configuration element

2016-12-26 Thread Masashi Honma

On 2016年12月27日 01:17, Ilan Peer wrote:

The code was setting the capabilities byte to zero,
after it was already properly set previously. Fix it.

The bug was found while debugging hwsim mesh tests failures
that happened in commit 76f43b4 (mac80211: Remove invalid flag
operations in mesh TSF synchronization).


Thanks!

Reviewed-by: Masashi Honma <masashi.ho...@gmail.com>



Re: [PATCH] mac80211: Remove invalid flag operations in mesh TSF synchronization

2016-12-07 Thread Masashi Honma

On 2016年12月07日 18:24, Johannes Berg wrote:

And the flag is refered by 1) as you said.


The purpose of the flag is to prevent 1) while 2) is ongoing.

In other words, 1) has only read access authority to the flag.
However,
previous code updated the flag in 1). In addition, there is no code
for
2). So I just remove the invalid accessing codes.


I don't think 1) has read only access to that flag. A TSF adjust will
by definition move the TBTT as well.


It seems that the wording in the spec disagrees with that - it says
(twice) to set the bit only while the TBTT adjustment procedure is
ongoing, which isn't the case here?

Then again, what exactly *is* this code doing?




It's called mesh_sync_offset_adjust_tbtt() which matches more closely
"TBTT adjustment" than "neighbor offset synchronization"?


I think so. Because there is not any code creating "TBTT Adjustment 
Request frame" even though the frame is required by "TBTT adjustment".



The code
looks more like offset synchronization though. Perhaps there's some
confusing and it's kinda doing both?


In theory, updating the flag with 1) looks not correct because it is not 
clearly defined in spec.


In practice, I could consider extending the meaning of the flag over the 
spec to use it to avoid referring the updating TSF value by peer as 
Thomas said. I have took the statistics how many TSF drift 
(ifmsh->sync_offset_clockdrift_max) happens. The attached file shows the 
stats. The horizontal axis shows TSF drift time(usec) and vertical axis 
shows how many time the drift occurred. The graph shows almost drifts 
are under 20usec. In contrast, 2) could causes more than 1000usec drift. 
So 1) looks not so large enough to protect with the flag.


Masashi Honma.


Re: [PATCH] mac80211: Remove invalid flag operations in mesh TSF synchronization

2016-12-02 Thread Masashi Honma

On 2016/12/03 06:13, Bob Copeland wrote:

On Fri, Dec 02, 2016 at 12:07:18PM -0800, Thomas Pedersen wrote:


# Rejected by linux wireless ML. This is resubmission.

thomas and Bob, Thanks for comments.

> 802.11-2012 13.13.2.2.3:
> The mesh STA checks if the transmitter of the Beacon frame or Probe
> Response frame is in the
> process of the TBTT adjustment (see 13.13.4.4.3).

There are two functionalities.

1) 13.13.2.2 Neighbor offset synchronization method
2) 13.13.4.4 TBTT adjustment

The ifmsh->adjusting_tbtt flag implements "TBTT Adjusting field" in the
Mesh Configuration field.

The flag is updated by 2).
13.13.4.4.3 TBTT scanning and adjustment procedures:
The mesh STA shall set the TBTT Adjusting field in the Mesh
Configuration element to 1 in order to announce that the TBTT
adjustment procedure is ongoing.

And the flag is refered by 1) as you said.

The purpose of the flag is to prevent 1) while 2) is ongoing.

In other words, 1) has only read access authority to the flag. However,
previous code updated the flag in 1). In addition, there is no code for
2). So I just remove the invalid accessing codes.

Masashi Honma.


[PATCH] mac80211: Remove invalid flag operations in mesh TSF synchronization

2016-11-30 Thread Masashi Honma
mesh_sync_offset_adjust_tbtt() implements Extensible synchronization
framework ([1] 13.13.2 Extensible synchronization framework). It shall
not operate the flag "TBTT Adjusting subfield" ([1] 8.4.2.100.8 Mesh
Capability), since it is used only for MBCA ([1] 13.13.4 Mesh beacon
collision avoidance, see 13.13.4.4.3 TBTT scanning and adjustment
procedures for detail). So this patch remove the flag operations.

[1] IEEE Std 802.11 2012

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/mesh_sync.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c
index faca22c..836d791 100644
--- a/net/mac80211/mesh_sync.c
+++ b/net/mac80211/mesh_sync.c
@@ -172,11 +172,9 @@ static void mesh_sync_offset_adjust_tbtt(struct 
ieee80211_sub_if_data *sdata,
 struct beacon_data *beacon)
 {
struct ieee80211_if_mesh *ifmsh = >u.mesh;
-   u8 cap;
 
WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET);
WARN_ON(!rcu_read_lock_held());
-   cap = beacon->meshconf->meshconf_cap;
 
spin_lock_bh(>sync_offset_lock);
 
@@ -190,21 +188,13 @@ static void mesh_sync_offset_adjust_tbtt(struct 
ieee80211_sub_if_data *sdata,
  "TBTT : kicking off TBTT adjustment with 
clockdrift_max=%lld\n",
  ifmsh->sync_offset_clockdrift_max);
set_bit(MESH_WORK_DRIFT_ADJUST, >wrkq_flags);
-
-   ifmsh->adjusting_tbtt = true;
} else {
msync_dbg(sdata,
  "TBTT : max clockdrift=%lld; too small to adjust\n",
  (long long)ifmsh->sync_offset_clockdrift_max);
ifmsh->sync_offset_clockdrift_max = 0;
-
-   ifmsh->adjusting_tbtt = false;
}
spin_unlock_bh(>sync_offset_lock);
-
-   beacon->meshconf->meshconf_cap = ifmsh->adjusting_tbtt ?
-   IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING | cap :
-   ~IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING & cap;
 }
 
 static const struct sync_method sync_methods[] = {
-- 
2.7.4



[PATCH] mac80211: Suppress NEW_PEER_CANDIDATE event if no room

2016-11-29 Thread Masashi Honma
Previously, kernel sends NEW_PEER_CANDIDATE event to user land even if
the found peer does not have any room to accept other peer. This causes
continuous connection trials.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/mesh_plink.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 7fcdcf6..fcba70e5 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -505,12 +505,14 @@ mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, 
u8 *addr,
 
/* Userspace handles station allocation */
if (sdata->u.mesh.user_mpm ||
-   sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED)
-   cfg80211_notify_new_peer_candidate(sdata->dev, addr,
-  elems->ie_start,
-  elems->total_len,
-  GFP_KERNEL);
-   else
+   sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
+   if (mesh_peer_accepts_plinks(elems) &&
+   mesh_plink_availables(sdata))
+   cfg80211_notify_new_peer_candidate(sdata->dev, addr,
+  elems->ie_start,
+  elems->total_len,
+  GFP_KERNEL);
+   } else
sta = __mesh_sta_info_alloc(sdata, addr);
 
return sta;
-- 
2.7.4



Re: [PATCH v2] nl80211: Receive correct value for NL80211_MESHCONF_HT_OPMODE command

2016-08-03 Thread Masashi Honma

On 2016年08月03日 15:52, Johannes Berg wrote:

I'm actually half thinking that we could just remove all restrictions
on this and allow any u16 value of this field, and rely on
wpa_supplicant to do the right thing... Then we don't have to update
this if we ever want to do something new either.

What do you think? What does the validation actually help us with?


I think checking the bits here is better than allowing all values.

Because if we allow any values for ht_opmode, kernel developer needs to 
care about any bit combination working well. For example, kernel 
developer should test there is not any unexpected thing when non-GF and 
non-HT both flags are enabled. If we check invalid bit at the entrance,

we don't need to care anymore about invalid combination. In any case we
need to care about combination. Then, it is more easy to do it near the
entrance.

And I think checking only in wpa_supplicant is not good idea. Because 
other user application can access to the kernel API. If invalid flag

combination causes kernel panic, it could be kernel vulnerability.

Masashi Honma.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: Include HT Capabilities element if capable

2016-08-02 Thread Masashi Honma
Previously, "HT Capabilities element" was not included in beacon and
Mesh Peering Open/Close frames when wpa_supplicant config file includes
disable_ht=1 even though HT is capable. But "HT Capabilities element"
should not be modified because it is defined by hardware and software
spec of the node.

We do not change "HT Operation element" code, because it is defined by
surrounding environment and configuration of the node. So it could be
vanished by disable_ht=1.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/mesh.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index c66411d..ebd4159 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -409,10 +409,7 @@ int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
u8 *pos;
 
sband = local->hw.wiphy->bands[band];
-   if (!sband->ht_cap.ht_supported ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_5 ||
-   sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_10)
+   if (!sband->ht_cap.ht_supported)
return 0;
 
if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap))
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-08-02 Thread Masashi Honma

On 2016年08月02日 16:27, Johannes Berg wrote:

This explicitly configures *HT capability* though - that's even the
name of the parameter. If you enable HT40 in the capability, the
resulting BSS might still not actually *use* 40 MHz bandwidth, as
required by overlapping BSS detection.


OK, I see.

HT Capabilities element = Defined by hardware and software spec of the 
node. So it does not be modified after boot.


HT Operation element = Defined by surrounding environment and 
configuration of the node. So it could be modified after boot.


So, if the node supports HT40, HT Capabilities shows HT40 is capable.
Now, I understand why you rejected this patch.

But now, when disable_ht=1, no HT Capabilities element in beacon even 
though the node supports HT.


My trailing patch could solve the issue.

Masashi Honma.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] nl80211: Receive correct value for NL80211_MESHCONF_HT_OPMODE command

2016-08-02 Thread Masashi Honma

On 2016年08月02日 20:41, Masashi Honma wrote:

-   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
+   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0,
+ IEEE80211_HT_OP_MODE_PROTECTION |
+ IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
+ IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT,
  mask, NL80211_MESHCONF_HT_OPMODE,
  nl80211_check_u16);


This patch could over write cfg->ht_opmode even though EINVAL.
I will modify this.

Masashi Honma.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] nl80211: Receive correct value for NL80211_MESHCONF_HT_OPMODE command

2016-08-02 Thread Masashi Honma
Previously, NL80211_MESHCONF_HT_OPMODE rejected correct flag
combination, ex) IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED |
IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT.

This was caused by simple comparison with value 16. This causes setting
non-existent flag (like 0x08) and invalid flag combinations. So this
commit implements some checks based on IEEE 802.11 2012 8.4.2.59 HT
Operation element.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/wireless/nl80211.c | 42 +++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 46417f9..7b7530d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5380,6 +5380,7 @@ static int nl80211_parse_mesh_config(struct genl_info 
*info,
 {
struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1];
u32 mask = 0;
+   u16 ht_opmode;
 
 #define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, min, max, mask, attr, fn) \
 do {   \
@@ -5471,9 +5472,44 @@ do { 
\
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
  mask, NL80211_MESHCONF_RSSI_THRESHOLD,
  nl80211_check_s32);
-   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
- mask, NL80211_MESHCONF_HT_OPMODE,
- nl80211_check_u16);
+   /*
+* Check HT operation mode based on
+* IEEE 802.11 2012 8.4.2.59 HT Operation element.
+*/
+   if (tb[NL80211_MESHCONF_HT_OPMODE]) {
+   ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
+
+   if (ht_opmode & (~(IEEE80211_HT_OP_MODE_PROTECTION |
+   IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)))
+   return -EINVAL;
+
+   if ((ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
+   (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
+   return -EINVAL;
+
+   switch (ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) {
+   case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
+   if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
+   return -EINVAL;
+   break;
+   case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
+   if (!(ht_opmode &
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
+   return -EINVAL;
+   break;
+   case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
+   if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
+   return -EINVAL;
+   break;
+   case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
+   if (!(ht_opmode &
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
+   return -EINVAL;
+   break;
+   }
+   cfg->ht_opmode = ht_opmode;
+   }
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
  1, 65535, mask,
  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] nl80211: Expand max value of NL80211_MESHCONF_HT_OPMODE command

2016-08-02 Thread Masashi Honma

On 2016年08月02日 16:43, Johannes Berg wrote:

You're now changing it to 23, which makes some sense, but is kinda
strange. It allows setting the unused bit 0x8 by itself or in
combination with any protection and/or the NON_GF bit, but not in
combination with the NON_HT bit.


Thanks. This is reasonable. I will implement bitwise checks.

Masashi Honma.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] nl80211: Receive correct value for NL80211_MESHCONF_HT_OPMODE command

2016-08-02 Thread Masashi Honma
Previously, NL80211_MESHCONF_HT_OPMODE rejected correct flag
combination, ex) IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED |
IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT.

This was caused by simple comparison with value 16. This causes setting
non-existent flag (like 0x08) and invalid flag combinations. So this
commit implements some checks based on IEEE 802.11 2012 8.4.2.59 HT
Operation element.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/wireless/nl80211.c | 42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 46417f9..b2af600 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5471,9 +5471,49 @@ do { 
\
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
  mask, NL80211_MESHCONF_RSSI_THRESHOLD,
  nl80211_check_s32);
-   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
+   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0,
+ IEEE80211_HT_OP_MODE_PROTECTION |
+ IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
+ IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT,
  mask, NL80211_MESHCONF_HT_OPMODE,
  nl80211_check_u16);
+   if (tb[NL80211_MESHCONF_HT_OPMODE]) {
+   /*
+* Check HT operation mode based on IEEE 802.11 2012 8.4.2.59
+* HT Operation element.
+*/
+   if (cfg->ht_opmode & (~(IEEE80211_HT_OP_MODE_PROTECTION |
+   IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)))
+   return -EINVAL;
+
+   if ((cfg->ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
+   (cfg->ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
+   return -EINVAL;
+
+   switch (cfg->ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) {
+   case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
+   if (cfg->ht_opmode &
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
+   return -EINVAL;
+   break;
+   case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
+   if (!(cfg->ht_opmode &
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
+   return -EINVAL;
+   break;
+   case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
+   if (cfg->ht_opmode &
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
+   return -EINVAL;
+   break;
+   case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
+   if (!(cfg->ht_opmode &
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
+   return -EINVAL;
+   break;
+   }
+   }
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
  1, 65535, mask,
  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] mac80211: End the MPSP even if EOSP frame was not acked

2016-08-02 Thread Masashi Honma
If QoS frame with EOSP (end of service period) subfield=1 sent by local
peer was not acked by remote peer, local peer did not end the MPSP. This
prevents local peer from going to DOZE state. And if the remote peer
goes away without closing connection, local peer continues AWAKE state
and wastes battery.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/status.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index c6d5c72..a2a6826 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -771,6 +771,13 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct 
sk_buff *skb)
clear_sta_flag(sta, WLAN_STA_SP);
 
acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
+
+   /* mesh Peer Service Period support */
+   if (ieee80211_vif_is_mesh(>sdata->vif) &&
+   ieee80211_is_data_qos(fc))
+   ieee80211_mpsp_trigger_process(
+   ieee80211_get_qos_ctl(hdr), sta, true, acked);
+
if (!acked && test_sta_flag(sta, WLAN_STA_PS_STA)) {
/*
 * The STA is in power save mode, so assume
@@ -781,13 +788,6 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct 
sk_buff *skb)
return;
}
 
-   /* mesh Peer Service Period support */
-   if (ieee80211_vif_is_mesh(>sdata->vif) &&
-   ieee80211_is_data_qos(fc))
-   ieee80211_mpsp_trigger_process(
-   ieee80211_get_qos_ctl(hdr),
-   sta, true, acked);
-
if (ieee80211_hw_check(>hw, HAS_RATE_CONTROL) &&
(ieee80211_is_data(hdr->frame_control)) &&
(rates_idx != -1))
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: End the MPSP even if EOSP frame was not received

2016-08-02 Thread Masashi Honma

On 2016年08月02日 16:47, Johannes Berg wrote:

Can you elaborate why? Does it fix anything? Please resend the patch
with that (and perhaps the "subfield" typo fixed above).


I see.

Masashi Honma.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-08-01 Thread Masashi Honma

On 2016年08月01日 19:03, Johannes Berg wrote:


But why is that behaviour *correct*? We still support 40 MHz bandwidth
things, we just don't use them if we disable HT40.


Or do you mean difference between "hardware capability" and "software 
capability" ?
Do you think IEEE80211_HT_CAP_SUP_WIDTH_20_40 bit should be 1 if the 
hardware capable of HT40 even though HT40 is disabled by 
wpa_supplicant/hostapd ?


I have tested with hostapd. I compared these 2 configfiles.

hostapd0.conf
ht_capab=[HT40-]
hostapd1.conf
#ht_capab=[HT40-]

The IEEE80211_HT_CAP_SUP_WIDTH_20_40 bit in beacon was below.

hostapd0.conf
IEEE80211_HT_CAP_SUP_WIDTH_20_40 = 1
hostapd1.conf
IEEE80211_HT_CAP_SUP_WIDTH_20_40 = 0

So I think the bit should be zero if disabled also for mesh peer.

Masashi Honma.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-08-01 Thread Masashi Honma

On 2016年08月01日 19:03, Johannes Berg wrote:


But why is that behaviour *correct*? We still support 40 MHz bandwidth
things, we just don't use them if we disable HT40.


I could not fully understand your concern...

Do you mean we have 2 bugs about disabling HT40 ?

1) bits in HT capabilities IE
2) HT40 still enabled even if it was disabled by wpa_supplicant or 
hostapd with disable_ht40


And do you mean 1) and 2) should be fixed at one time ?
Indeed, currently on the view point of opposite peer, HT40 was enabled 
even though it was disabled because both 1) and 2) are wrong.

But if only 1) was fixed, this causes unmatch.

Now I do not recognize bug 2).
Do you have any information about 2) ?
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-07-25 Thread Masashi Honma

On 2016年07月22日 14:26, Masashi Honma wrote:
> On 2016年07月14日 05:07, Yaniv Machani wrote:
>> +
>> +/* if channel width is 20MHz - configure HT capab accordingly*/
>> +if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20) {
>> +cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
>> +cap &= ~IEEE80211_HT_CAP_DSSSCCK40;
>> +}
>
> I have tested this part of your patch and this works for me.
>
> Previouly, "Supported Channel Width Set bit" in HT Capabilities element
> was 1 even though disable_ht40=1 existed in wpa_supplicant.conf.
> After appllication of patch, the bit was 0.
>
>

# I retransmit this because of mail delivery errors.

I forgot to mention I have used this patch to test.
http://lists.infradead.org/pipermail/hostap/2016-July/036029.html
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-07-21 Thread Masashi Honma

On 2016年07月14日 05:07, Yaniv Machani wrote:

+
+   /* if channel width is 20MHz - configure HT capab accordingly*/
+   if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20) {
+   cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
+   cap &= ~IEEE80211_HT_CAP_DSSSCCK40;
+   }


I have tested this part of your patch and this works for me.

Previouly, "Supported Channel Width Set bit" in HT Capabilities element
was 1 even though disable_ht40=1 existed in wpa_supplicant.conf.
After appllication of patch, the bit was 0.


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: End the MPSP even if EOSP frame was not received

2016-07-20 Thread Masashi Honma

On 2016年07月19日 19:40, Bob Copeland wrote:


OK, do we need to also clear WLAN_STA_PS_STA flag for the peer in
ieee80211_mps_sta_status_update(), or does the node completely repeer?

ISTR running into a problem where rebooted peer (previously in power-save)
would send popen but we would buffer the response due to stale PS sta
flag.


Thanks. I have tried your scenario.

I have disconnected remote peer by accidental shutdown.
(This means local peer does not recognize remote peer left.)

Then remote peer restarted and started to send Mesh Peering Open frames.

Local peer receives these frames but does not respond to these
because peer_lid mismatch.

After 3 times retrial, remote peer sent Mesh Peering Close frame
with reason code = 56(MESH-MAX-RETRIES).

And then, struct sta_info is freed and allocated.

So looks no problem.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nl80211: Expand max value of NL80211_MESHCONF_HT_OPMODE command

2016-07-19 Thread Masashi Honma
Previously, the max value of NL80211_MESHCONF_HT_OPMODE was 16.
But it causes EINVAL when IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
and IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT bit is enabled.
So this patch expands the max value.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/wireless/nl80211.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 46417f9..8a00e50 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5471,7 +5471,10 @@ do { 
\
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
  mask, NL80211_MESHCONF_RSSI_THRESHOLD,
  nl80211_check_s32);
-   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
+   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0,
+ IEEE80211_HT_OP_MODE_PROTECTION |
+ IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
+ IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT,
  mask, NL80211_MESHCONF_HT_OPMODE,
  nl80211_check_u16);
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: End the MPSP even if EOSP frame was not received

2016-07-18 Thread Masashi Honma

On 2016年07月13日 22:50, Bob Copeland wrote:


Hmm, my recollection on this stuff is a little fuzzy.  So we only get
here if the peer sta is in doze state, but it shouldn't do that if we
are in an MPSP.

Yes. In the MPSP, local peer only transmits frame when opposite peer is in
AWAKE. This patch expects we lost opposite peer accidentally
(AC adapter unplugged).


   So, is the real problem that we don't wait for an ack
from the peer before marking ourselves in a MPSP?


This patch does not fix starting MPSP, this patch fixes ending of MPSP.
Without this patch, local peer continues MPSP even if we lost opposite peer
accidentally.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: End the MPSP even if EOSP frame was not received

2016-07-13 Thread Masashi Honma
The mesh STA sends QoS frame with EOSP (end of service period)
subfiled=1 to end the MPSP(mesh peer service period). Previously, if
the frame was not acked by peer, the mesh STA did not end the MPSP.
This patch ends the MPSP even if the QoS frame was no acked.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/status.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index c6d5c72..a2a6826 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -771,6 +771,13 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct 
sk_buff *skb)
clear_sta_flag(sta, WLAN_STA_SP);
 
acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
+
+   /* mesh Peer Service Period support */
+   if (ieee80211_vif_is_mesh(>sdata->vif) &&
+   ieee80211_is_data_qos(fc))
+   ieee80211_mpsp_trigger_process(
+   ieee80211_get_qos_ctl(hdr), sta, true, acked);
+
if (!acked && test_sta_flag(sta, WLAN_STA_PS_STA)) {
/*
 * The STA is in power save mode, so assume
@@ -781,13 +788,6 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct 
sk_buff *skb)
return;
}
 
-   /* mesh Peer Service Period support */
-   if (ieee80211_vif_is_mesh(>sdata->vif) &&
-   ieee80211_is_data_qos(fc))
-   ieee80211_mpsp_trigger_process(
-   ieee80211_get_qos_ctl(hdr),
-   sta, true, acked);
-
if (ieee80211_hw_check(>hw, HAS_RATE_CONTROL) &&
(ieee80211_is_data(hdr->frame_control)) &&
(rates_idx != -1))
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()

2016-07-08 Thread Masashi Honma
On 2016年07月06日 09:28, Masashi Honma wrote:
> Though netlink_broadcast() ...

Thanks for reply of David Miller, Eric Dumazet, David Teigrand.

On the basis of their comment, only rtnl_unicast() looks need to add gfp
flag
argument. So I will drop almost of patches except 0005.

I will send patch v2 to more limited destination.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()

2016-07-08 Thread Masashi Honma

On 2016年07月09日 01:08, David Teigland wrote:

On Thu, Jul 07, 2016 at 09:35:45AM +0900, Masashi Honma wrote:

At the fs/dlm/netlink.c#dlm_timeout_warn(),
prepare_data allocates buffer with GFP_NOFS
and send_data() sends the buffer.

But send_data() uses GFP_KERNEL or GFP_ATOMIC inside it.
Should it be replaced by GFP_NOFS ?

That's old code that's never been used so it doesn't really matter.


I see. Thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 5/7] net: Add allocation flag to rtnl_unicast()

2016-07-07 Thread Masashi Honma

On 2016年07月08日 11:56, Eric Dumazet wrote:


Managing to mix GFP_ATOMIC and GFP_KERNEL almost randomly as you did in
this patch is definitely not good.

Further more, RTNL is a mutex, held in control path, designed to allow
schedules and waiting for memory under pressure.

We do not want to encourage GFP_ATOMIC usage in control path.

Your patch series gives the wrong signal to developers.





Thanks for comment.

I have selected GFP flags based on existing code.

I have selected GFP_ATOMIC in inet6_netconf_get_devconf() because
skb was allocated with GFP_ATOMIC.

I have used GFP_KERNEL in inet6_rtm_getaddr() by same reason.

> I will send a patch against net/ipv4/devinet.c so that we remove
> GFP_ATOMIC usage there.

Thanks. I will modify my patch based on your new code.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()

2016-07-06 Thread Masashi Honma
At the fs/dlm/netlink.c#dlm_timeout_warn(),
prepare_data allocates buffer with GFP_NOFS
and send_data() sends the buffer.

But send_data() uses GFP_KERNEL or GFP_ATOMIC inside it.
Should it be replaced by GFP_NOFS ?

Masashi Honma

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 5/7] net: Add allocation flag to rtnl_unicast()

2016-07-05 Thread Masashi Honma
Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/linux/rtnetlink.h |  3 ++-
 net/core/net_namespace.c  |  2 +-
 net/core/rtnetlink.c  | 10 ++
 net/dcb/dcbnl.c   |  2 +-
 net/decnet/dn_route.c |  3 ++-
 net/ipv4/devinet.c|  2 +-
 net/ipv4/ipmr.c   |  6 --
 net/ipv4/route.c  |  2 +-
 net/ipv6/addrconf.c   |  4 ++--
 net/ipv6/addrlabel.c  |  2 +-
 net/ipv6/ip6mr.c  |  6 --
 net/ipv6/route.c  |  2 +-
 net/sched/act_api.c   |  2 +-
 13 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 2daece8..132730f 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -8,7 +8,8 @@
 #include 
 
 extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 
group, int echo);
-extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
+extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid,
+   gfp_t flags);
 extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
u32 group, struct nlmsghdr *nlh, gfp_t flags);
 extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 2c2eb1b..28eed58 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -646,7 +646,7 @@ static int rtnl_net_getid(struct sk_buff *skb, struct 
nlmsghdr *nlh)
if (err < 0)
goto err_out;
 
-   err = rtnl_unicast(msg, net, NETLINK_CB(skb).portid);
+   err = rtnl_unicast(msg, net, NETLINK_CB(skb).portid, GFP_KERNEL);
goto out;
 
 err_out:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 7f7927f..89fd826 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -653,11 +653,11 @@ int rtnetlink_send(struct sk_buff *skb, struct net *net, 
u32 pid, unsigned int g
return err;
 }
 
-int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)
+int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid, gfp_t flags)
 {
struct sock *rtnl = net->rtnl;
 
-   return nlmsg_unicast(rtnl, skb, pid, gfp_any());
+   return nlmsg_unicast(rtnl, skb, pid, flags);
 }
 EXPORT_SYMBOL(rtnl_unicast);
 
@@ -2565,7 +2565,8 @@ static int rtnl_getlink(struct sk_buff *skb, struct 
nlmsghdr* nlh)
WARN_ON(err == -EMSGSIZE);
kfree_skb(nskb);
} else
-   err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid);
+   err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid,
+  GFP_KERNEL);
 
return err;
 }
@@ -3601,7 +3602,8 @@ static int rtnl_stats_get(struct sk_buff *skb, struct 
nlmsghdr *nlh)
WARN_ON(err == -EMSGSIZE);
kfree_skb(nskb);
} else {
-   err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid);
+   err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid,
+  GFP_KERNEL);
}
 
return err;
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 4f6c186..e4de9fe 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1749,7 +1749,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr 
*nlh)
 
nlmsg_end(reply_skb, reply_nlh);
 
-   ret = rtnl_unicast(reply_skb, net, portid);
+   ret = rtnl_unicast(reply_skb, net, portid, GFP_KERNEL);
 out:
return ret;
 }
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index b1dc096..6fe02bb 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1714,7 +1714,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, 
struct nlmsghdr *nlh)
goto out_free;
}
 
-   return rtnl_unicast(skb, _net, NETLINK_CB(in_skb).portid);
+   return rtnl_unicast(skb, _net, NETLINK_CB(in_skb).portid,
+   GFP_KERNEL);
 
 out_free:
kfree_skb(skb);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e333bc8..5e969e5 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1917,7 +1917,7 @@ static int inet_netconf_get_devconf(struct sk_buff 
*in_skb,
kfree_skb(skb);
goto errout;
}
-   err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+   err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_ATOMIC);
 errout:
return err;
 }
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 5ad48ec..c704a2a 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -654,7 +654,8 @@ static void ipmr_destroy_unres(struct mr_table *mrt, struct 
mfc_cache *c)
e->error = -ETIMEDOUT;
memset(>msg, 0, sizeof(e->msg));
 
-   rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+   rtnl_unicast(skb, net, N

[RFC 4/7] infiniband: Add allocation flag to ibnl_unicast()

2016-07-05 Thread Masashi Honma
Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 drivers/infiniband/core/iwpm_msg.c  | 6 +++---
 drivers/infiniband/core/iwpm_util.c | 5 +++--
 drivers/infiniband/core/iwpm_util.h | 1 +
 drivers/infiniband/core/netlink.c   | 4 ++--
 include/rdma/rdma_netlink.h | 3 ++-
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/core/iwpm_msg.c 
b/drivers/infiniband/core/iwpm_msg.c
index 1c41b95..4307eab 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -174,7 +174,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 
nl_client)
goto add_mapping_error;
nlmsg_request->req_buffer = pm_msg;
 
-   ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+   ret = ibnl_unicast(skb, nlh, iwpm_user_pid, GFP_ATOMIC);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
iwpm_user_pid = IWPM_PID_UNDEFINED;
@@ -251,7 +251,7 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, 
u8 nl_client)
goto query_mapping_error;
nlmsg_request->req_buffer = pm_msg;
 
-   ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+   ret = ibnl_unicast(skb, nlh, iwpm_user_pid, GFP_ATOMIC);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
err_str = "Unable to send a nlmsg";
@@ -312,7 +312,7 @@ int iwpm_remove_mapping(struct sockaddr_storage 
*local_addr, u8 nl_client)
if (ret)
goto remove_mapping_error;
 
-   ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+   ret = ibnl_unicast(skb, nlh, iwpm_user_pid, GFP_ATOMIC);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
iwpm_user_pid = IWPM_PID_UNDEFINED;
diff --git a/drivers/infiniband/core/iwpm_util.c 
b/drivers/infiniband/core/iwpm_util.c
index b65e06c..6dcbb2d 100644
--- a/drivers/infiniband/core/iwpm_util.c
+++ b/drivers/infiniband/core/iwpm_util.c
@@ -609,7 +609,7 @@ static int send_mapinfo_num(u32 mapping_num, u8 nl_client, 
int iwpm_pid)
_num, IWPM_NLA_MAPINFO_SEND_NUM);
if (ret)
goto mapinfo_num_error;
-   ret = ibnl_unicast(skb, nlh, iwpm_pid);
+   ret = ibnl_unicast(skb, nlh, iwpm_pid, GFP_ATOMIC);
if (ret) {
skb = NULL;
err_str = "Unable to send a nlmsg";
@@ -638,7 +638,8 @@ static int send_nlmsg_done(struct sk_buff *skb, u8 
nl_client, int iwpm_pid)
return -ENOMEM;
}
nlh->nlmsg_type = NLMSG_DONE;
-   ret = ibnl_unicast(skb, (struct nlmsghdr *)skb->data, iwpm_pid);
+   ret = ibnl_unicast(skb, (struct nlmsghdr *)skb->data, iwpm_pid,
+  GFP_ATOMIC);
if (ret)
pr_warn("%s Unable to send a nlmsg\n", __func__);
return ret;
diff --git a/drivers/infiniband/core/iwpm_util.h 
b/drivers/infiniband/core/iwpm_util.h
index af1fc14..0ced7f4 100644
--- a/drivers/infiniband/core/iwpm_util.h
+++ b/drivers/infiniband/core/iwpm_util.h
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 09037a9..1451238 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -227,9 +227,9 @@ static void ibnl_rcv(struct sk_buff *skb)
 }
 
 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-   __u32 pid)
+   __u32 pid, gfp_t flags)
 {
-   return nlmsg_unicast(nls, skb, pid, gfp_any());
+   return nlmsg_unicast(nls, skb, pid, flags);
 }
 EXPORT_SYMBOL(ibnl_unicast);
 
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 5852661..0bb3010 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -61,10 +61,11 @@ int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
  * @skb: The netlink skb
  * @nlh: Header of the netlink message to send
  * @pid: Userspace netlink process ID
+ * @flags: allocation flags
  * Returns 0 on success or a negative error code.
  */
 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-   __u32 pid);
+   __u32 pid, gfp_t flags);
 
 /**
  * Send the supplied skb to a netlink group.
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 2/7] netfilter: Add allocation flag to nfnetlink_unicast()

2016-07-05 Thread Masashi Honma
Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/linux/netfilter/nfnetlink.h | 2 +-
 net/netfilter/nfnetlink.c   | 4 ++--
 net/netfilter/nfnetlink_log.c   | 4 ++--
 net/netfilter/nfnetlink_queue.c | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/linux/netfilter/nfnetlink.h 
b/include/linux/netfilter/nfnetlink.h
index 1d82dd5..a1c7808 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -38,7 +38,7 @@ int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 
portid,
   unsigned int group, int echo, gfp_t flags);
 int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error);
 int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
- int flags);
+ int flags, gfp_t allocation);
 
 void nfnl_lock(__u8 subsys_id);
 void nfnl_unlock(__u8 subsys_id);
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index f6193e7..b0910c7 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -141,9 +141,9 @@ int nfnetlink_set_err(struct net *net, u32 portid, u32 
group, int error)
 EXPORT_SYMBOL_GPL(nfnetlink_set_err);
 
 int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
- int flags)
+ int flags, gfp_t allocation)
 {
-   return netlink_unicast(net->nfnl, skb, portid, flags, 0);
+   return netlink_unicast(net->nfnl, skb, portid, flags, allocation);
 }
 EXPORT_SYMBOL_GPL(nfnetlink_unicast);
 
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 11f81c8..c834306 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -357,8 +357,8 @@ __nfulnl_send(struct nfulnl_instance *inst)
goto out;
}
}
-   nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
- MSG_DONTWAIT);
+   nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid, MSG_DONTWAIT,
+ gfp_any());
 out:
inst->qlen = 0;
inst->skb = NULL;
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 5d36a09..8d7b6ff 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -638,7 +638,8 @@ __nfqnl_enqueue_packet(struct net *net, struct 
nfqnl_instance *queue,
*packet_id_ptr = htonl(entry->id);
 
/* nfnetlink_unicast will either free the nskb or add it to a socket */
-   err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT);
+   err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT,
+   GFP_ATOMIC);
if (err < 0) {
if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
failopen = 1;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 6/7] genetlink: Add allocation flag to genlmsg_unicast()

2016-07-05 Thread Masashi Honma
Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 drivers/net/gtp.c | 3 ++-
 drivers/net/team/team.c   | 5 +++--
 drivers/net/wireless/mac80211_hwsim.c | 2 +-
 fs/dlm/netlink.c  | 2 +-
 include/net/genetlink.h   | 8 +---
 kernel/taskstats.c| 2 +-
 net/hsr/hsr_netlink.c | 6 --
 net/l2tp/l2tp_netlink.c   | 8 +---
 net/openvswitch/datapath.c| 3 ++-
 net/tipc/netlink_compat.c | 2 +-
 net/wireless/nl80211.c| 9 +
 11 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 97e0cbc..0156abb 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -1210,7 +1210,8 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct 
genl_info *info)
goto err_unlock_free;
 
rcu_read_unlock();
-   return genlmsg_unicast(genl_info_net(info), skb2, info->snd_portid);
+   return genlmsg_unicast(genl_info_net(info), skb2, info->snd_portid,
+  GFP_ATOMIC);
 
 err_unlock_free:
kfree_skb(skb2);
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index f9eebea..3d40b55 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2194,7 +2194,8 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct 
genl_info *info)
 
genlmsg_end(msg, hdr);
 
-   return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid);
+   return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid,
+  GFP_KERNEL);
 
 err_msg_put:
nlmsg_free(msg);
@@ -2240,7 +2241,7 @@ typedef int team_nl_send_func_t(struct sk_buff *skb,
 
 static int team_nl_send_unicast(struct sk_buff *skb, struct team *team, u32 
portid)
 {
-   return genlmsg_unicast(dev_net(team->dev), skb, portid);
+   return genlmsg_unicast(dev_net(team->dev), skb, portid, gfp_any());
 }
 
 static int team_nl_fill_one_option_get(struct sk_buff *skb, struct team *team,
diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 382109bb..5c7bf77 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1008,7 +1008,7 @@ static int hwsim_unicast_netgroup(struct 
mac80211_hwsim_data *data,
rcu_read_lock();
for_each_net_rcu(net) {
if (data->netgroup == hwsim_net_get_netgroup(net)) {
-   res = genlmsg_unicast(net, skb, portid);
+   res = genlmsg_unicast(net, skb, portid, GFP_ATOMIC);
found = true;
break;
}
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index 1e6e227..c498616 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -59,7 +59,7 @@ static int send_data(struct sk_buff *skb)
 
genlmsg_end(skb, data);
 
-   return genlmsg_unicast(_net, skb, listener_nlportid);
+   return genlmsg_unicast(_net, skb, listener_nlportid, GFP_NOFS);
 }
 
 static int user_cmd(struct sk_buff *skb, struct genl_info *info)
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index b107a35..5f0f2ff 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -331,10 +331,12 @@ int genlmsg_multicast_allns(struct genl_family *family,
  * genlmsg_unicast - unicast a netlink message
  * @skb: netlink message as socket buffer
  * @portid: netlink portid of the destination socket
+ * @flags: allocation flags
  */
-static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 
portid)
+static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb,
+ u32 portid, gfp_t flags)
 {
-   return nlmsg_unicast(net->genl_sock, skb, portid, 0);
+   return nlmsg_unicast(net->genl_sock, skb, portid, flags);
 }
 
 /**
@@ -344,7 +346,7 @@ static inline int genlmsg_unicast(struct net *net, struct 
sk_buff *skb, u32 port
  */
 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
 {
-   return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid);
+   return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid, 0);
 }
 
 /**
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index b3f05ee..ecfcaff 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -140,7 +140,7 @@ static void send_cpu_listeners(struct sk_buff *skb,
if (!skb_next)
break;
}
-   rc = genlmsg_unicast(_net, skb_cur, s->pid);
+   rc = genlmsg_unicast(_net, skb_cur, s->pid, GFP_KERNEL);
if (rc == -ECONNREFUSED) {
s->valid = 0;
delcount++;
diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
index d4d1617..dcc674f 100644
--- a/n

[RFC 7/7] genetlink: Add allocation flag to genlmsg_reply()

2016-07-05 Thread Masashi Honma
Add allocation flag to genlmsg_reply() and remove netlink_unicast()
temporal functionality for stepwise modification.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 drivers/block/drbd/drbd_nl.c  |  2 +-
 drivers/net/wireless/mac80211_hwsim.c |  2 +-
 include/net/genetlink.h   |  7 +--
 kernel/taskstats.c|  2 +-
 net/core/devlink.c| 12 ++--
 net/ieee802154/ieee802154.h   |  3 ++-
 net/ieee802154/netlink.c  |  5 +++--
 net/ieee802154/nl-mac.c   |  4 ++--
 net/ieee802154/nl-phy.c   |  6 +++---
 net/ieee802154/nl802154.c |  4 ++--
 net/ipv4/fou.c|  2 +-
 net/ipv4/tcp_metrics.c|  2 +-
 net/ipv6/ila/ila_xlat.c   |  2 +-
 net/irda/irnetlink.c  |  2 +-
 net/netfilter/ipvs/ip_vs_ctl.c|  2 +-
 net/netlabel/netlabel_cipso_v4.c  |  2 +-
 net/netlabel/netlabel_mgmt.c  |  4 ++--
 net/netlabel/netlabel_unlabeled.c |  2 +-
 net/netlink/af_netlink.c  |  2 +-
 net/netlink/genetlink.c   |  2 +-
 net/nfc/netlink.c |  6 +++---
 net/openvswitch/datapath.c|  6 +++---
 net/tipc/bearer.c |  4 ++--
 net/tipc/node.c   |  2 +-
 net/wireless/nl80211.c| 34 +-
 25 files changed, 63 insertions(+), 58 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 0bac9c8..3162608 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -100,7 +100,7 @@ static char *drbd_m_holder = "Hands off! this is DRBD's 
meta data device.";
 static void drbd_adm_send_reply(struct sk_buff *skb, struct genl_info *info)
 {
genlmsg_end(skb, genlmsg_data(nlmsg_data(nlmsg_hdr(skb;
-   if (genlmsg_reply(skb, info))
+   if (genlmsg_reply(skb, info, GFP_KERNEL))
pr_err("error sending genl reply\n");
 }
 
diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 5c7bf77..5319cd1 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3160,7 +3160,7 @@ static int hwsim_get_radio_nl(struct sk_buff *msg, struct 
genl_info *info)
goto out_err;
}
 
-   genlmsg_reply(skb, info);
+   genlmsg_reply(skb, info, GFP_KERNEL);
break;
}
 
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 5f0f2ff..99c9c39 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -343,10 +343,13 @@ static inline int genlmsg_unicast(struct net *net, struct 
sk_buff *skb,
  * genlmsg_reply - reply to a request
  * @skb: netlink message to be sent back
  * @info: receiver information
+ * @flags: allocation flags
  */
-static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
+static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info,
+   gfp_t flags)
 {
-   return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid, 0);
+   return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid,
+  flags);
 }
 
 /**
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index ecfcaff..894d0da 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -114,7 +114,7 @@ static int send_reply(struct sk_buff *skb, struct genl_info 
*info)
 
genlmsg_end(skb, reply);
 
-   return genlmsg_reply(skb, info);
+   return genlmsg_reply(skb, info, GFP_KERNEL);
 }
 
 /*
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 933e8d4..61a1c8a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -501,7 +501,7 @@ static int devlink_nl_cmd_get_doit(struct sk_buff *skb, 
struct genl_info *info)
return err;
}
 
-   return genlmsg_reply(msg, info);
+   return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg,
@@ -554,7 +554,7 @@ static int devlink_nl_cmd_port_get_doit(struct sk_buff *skb,
return err;
}
 
-   return genlmsg_reply(msg, info);
+   return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
@@ -736,7 +736,7 @@ static int devlink_nl_cmd_sb_get_doit(struct sk_buff *skb,
return err;
}
 
-   return genlmsg_reply(msg, info);
+   return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg,
@@ -843,7 +843,7 @@ static int devlink_nl_cmd_sb_pool_get_doit(struct sk_buff 
*skb,
return err;
}
 
-   return genlmsg_reply(msg, info);
+   return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int __sb_pool_get_dumpit(str

[RFC 3/7] netlink: Add allocation flag to nlmsg_unicast()

2016-07-05 Thread Masashi Honma
Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 crypto/crypto_user.c  |  3 ++-
 drivers/infiniband/core/netlink.c |  2 +-
 include/net/genetlink.h   |  2 +-
 include/net/netlink.h |  6 --
 net/core/rtnetlink.c  |  2 +-
 net/netfilter/nf_tables_api.c | 10 +-
 net/netlink/af_netlink.c  |  2 +-
 net/xfrm/xfrm_user.c  | 15 +--
 8 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 7097a33..f379b74 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -249,7 +249,8 @@ drop_alg:
if (err)
return err;
 
-   return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid);
+   return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid,
+GFP_ATOMIC);
 }
 
 static int crypto_dump_report(struct sk_buff *skb, struct netlink_callback *cb)
diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 9b8c20c..09037a9 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -229,7 +229,7 @@ static void ibnl_rcv(struct sk_buff *skb)
 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
__u32 pid)
 {
-   return nlmsg_unicast(nls, skb, pid);
+   return nlmsg_unicast(nls, skb, pid, gfp_any());
 }
 EXPORT_SYMBOL(ibnl_unicast);
 
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 8d4608c..b107a35 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -334,7 +334,7 @@ int genlmsg_multicast_allns(struct genl_family *family,
  */
 static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 
portid)
 {
-   return nlmsg_unicast(net->genl_sock, skb, portid);
+   return nlmsg_unicast(net->genl_sock, skb, portid, 0);
 }
 
 /**
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 898e449..df5b533 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -585,12 +585,14 @@ static inline int nlmsg_multicast(struct sock *sk, struct 
sk_buff *skb,
  * @sk: netlink socket to spread message to
  * @skb: netlink message as socket buffer
  * @portid: netlink portid of the destination socket
+ * @flags: allocation flags
  */
-static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 
portid)
+static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb,
+   u32 portid, gfp_t flags)
 {
int err;
 
-   err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT, 0);
+   err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT, flags);
if (err > 0)
err = 0;
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3433633f..7f7927f 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -657,7 +657,7 @@ int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 
pid)
 {
struct sock *rtnl = net->rtnl;
 
-   return nlmsg_unicast(rtnl, skb, pid);
+   return nlmsg_unicast(rtnl, skb, pid, gfp_any());
 }
 EXPORT_SYMBOL(rtnl_unicast);
 
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 2c88187..4afb751 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -581,7 +581,7 @@ static int nf_tables_gettable(struct net *net, struct sock 
*nlsk,
if (err < 0)
goto err;
 
-   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
kfree_skb(skb2);
@@ -1144,7 +1144,7 @@ static int nf_tables_getchain(struct net *net, struct 
sock *nlsk,
if (err < 0)
goto err;
 
-   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
kfree_skb(skb2);
@@ -1976,7 +1976,7 @@ static int nf_tables_getrule(struct net *net, struct sock 
*nlsk,
if (err < 0)
goto err;
 
-   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
kfree_skb(skb2);
@@ -2664,7 +2664,7 @@ static int nf_tables_getset(struct net *net, struct sock 
*nlsk,
if (err < 0)
goto err;
 
-   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
kfree_skb(skb2);
@@ -3798,7 +3798,7 @@ static int nf_tables_getgen(struct net *net, struct sock 
*nlsk,
if (err < 0)
goto err;
 
-   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+   return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 err:
kfree_skb(skb2);
return err;
diff --git a/net/netlink/af_netlink.c

[RFC 1/7] netlink: Add allocation flag to netlink_unicast()

2016-07-05 Thread Masashi Honma
Though netlink_broadcast() has allocation flag which can specify
memory allocation type (ex. GFP_KERNEL/GFP_ATOMIC), netlink_unicast()
does not have it. This can cause "BUG: sleeping function called from
invalid context at" with CONFIG_DEBUG_ATOMIC_SLEEP enabled kernel when
calling netlink_unicast() inside RCU read-side section and not in IRQ.

This patch adds an allocation flag to netlink_unicast().

At this moment, the allocation flag could be zero to imply gfp_any().
This is a temporal functionality for stepwise modification and
removed at the end of the series of patches.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 drivers/connector/connector.c|  2 +-
 include/linux/netlink.h  |  3 ++-
 include/net/netlink.h|  2 +-
 kernel/audit.c   |  9 +
 net/core/rtnetlink.c |  2 +-
 net/ipv4/fib_frontend.c  |  2 +-
 net/ipv4/inet_diag.c |  2 +-
 net/ipv4/udp_diag.c  |  2 +-
 net/netfilter/ipset/ip_set_core.c| 11 +++
 net/netfilter/nf_conntrack_netlink.c |  9 ++---
 net/netfilter/nfnetlink.c|  2 +-
 net/netfilter/nfnetlink_acct.c   |  2 +-
 net/netfilter/nfnetlink_cthelper.c   |  2 +-
 net/netfilter/nfnetlink_cttimeout.c  |  5 +++--
 net/netfilter/nft_compat.c   |  4 ++--
 net/netlink/af_netlink.c | 12 +++-
 net/sctp/sctp_diag.c |  2 +-
 net/unix/diag.c  |  2 +-
 samples/connector/cn_test.c  |  2 +-
 19 files changed, 44 insertions(+), 33 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 25693b0..44470e6 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -125,7 +125,7 @@ int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 
portid, u32 __group,
return netlink_broadcast(dev->nls, skb, portid, group,
 gfp_mask);
return netlink_unicast(dev->nls, skb, portid,
-   !gfpflags_allow_blocking(gfp_mask));
+  !gfpflags_allow_blocking(gfp_mask), gfp_mask);
 }
 EXPORT_SYMBOL_GPL(cn_netlink_send_mult);
 
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index da14ab6..f90d24a 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -69,7 +69,8 @@ extern void __netlink_clear_multicast_users(struct sock *sk, 
unsigned int group)
 extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
 extern int netlink_has_listeners(struct sock *sk, unsigned int group);
 
-extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 
portid, int nonblock);
+extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
+  int nonblock, gfp_t allocation);
 extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 
portid,
 __u32 group, gfp_t allocation);
 extern int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 254a0fc..898e449 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -590,7 +590,7 @@ static inline int nlmsg_unicast(struct sock *sk, struct 
sk_buff *skb, u32 portid
 {
int err;
 
-   err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT);
+   err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT, 0);
if (err > 0)
err = 0;
 
diff --git a/kernel/audit.c b/kernel/audit.c
index 8d528f9..131577d 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -411,7 +411,7 @@ static void kauditd_send_skb(struct sk_buff *skb)
 restart:
/* take a reference in case we can't send it and we want to hold it */
skb_get(skb);
-   err = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0);
+   err = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0, gfp_any());
if (err < 0) {
pr_err("netlink_unicast sending to audit_pid=%d returned error: 
%d\n",
   audit_pid, err);
@@ -547,7 +547,7 @@ int audit_send_list(void *_dest)
mutex_unlock(_cmd_mutex);
 
while ((skb = __skb_dequeue(>q)) != NULL)
-   netlink_unicast(aunet->nlsk, skb, dest->portid, 0);
+   netlink_unicast(aunet->nlsk, skb, dest->portid, 0, gfp_any());
 
put_net(net);
kfree(dest);
@@ -591,7 +591,7 @@ static int audit_send_reply_thread(void *arg)
 
/* Ignore failure. It'll only happen if the sender goes away,
   because our timeout is set to infinite. */
-   netlink_unicast(aunet->nlsk , reply->skb, reply->portid, 0);
+   netlink_unicast(aunet->nlsk , reply->skb, reply->portid, 0, gfp_any());
put_net(net);
kfree(reply);
return 0;
@@ -814,7 +814,8 @@ static 

[RFC 0/7] netlink: Add allocation flag to netlink_unicast()

2016-07-05 Thread Masashi Honma
Though netlink_broadcast() has allocation flag which can specify
memory allocation type (ex. GFP_KERNEL/GFP_ATOMIC), netlink_unicast()
does not have it. This can cause "BUG: sleeping function called from
invalid context at" with CONFIG_DEBUG_ATOMIC_SLEEP enabled kernel when
calling netlink_unicast() inside RCU read-side section and not in IRQ.

Though currently such a use case was not found, to solve potential
issue we will add an allocation flag to netlink_unicast(). Previously
netlink_unicast() have used gfp_any() as a flag. We replaced it to
GFP_KERNEL or GFP_ATOMIC or etc by guessing based on context. If we
could not determine the value, we remain it gfp_any(). We welcome
comments like "this gfp_any() should be GFP_KERNEL". Of course other
comments are welcome as well.

This series of patches are not tested.
This is a RFC because this does not fix existing issue.

Masashi Honma (7):
  netlink: Add allocation flag to netlink_unicast()
  netfilter: Add allocation flag to nfnetlink_unicast()
  netlink: Add allocation flag to nlmsg_unicast()
  infiniband: Add allocation flag to ibnl_unicast()
  net: Add allocation flag to rtnl_unicast()
  genetlink: Add allocation flag to genlmsg_unicast()
  genetlink: Add allocation flag to genlmsg_reply()

 crypto/crypto_user.c  |  3 ++-
 drivers/block/drbd/drbd_nl.c  |  2 +-
 drivers/connector/connector.c |  2 +-
 drivers/infiniband/core/iwpm_msg.c|  6 ++---
 drivers/infiniband/core/iwpm_util.c   |  5 ++--
 drivers/infiniband/core/iwpm_util.h   |  1 +
 drivers/infiniband/core/netlink.c |  4 ++--
 drivers/net/gtp.c |  3 ++-
 drivers/net/team/team.c   |  5 ++--
 drivers/net/wireless/mac80211_hwsim.c |  4 ++--
 fs/dlm/netlink.c  |  2 +-
 include/linux/netfilter/nfnetlink.h   |  2 +-
 include/linux/netlink.h   |  3 ++-
 include/linux/rtnetlink.h |  3 ++-
 include/net/genetlink.h   | 13 +++
 include/net/netlink.h |  6 +++--
 include/rdma/rdma_netlink.h   |  3 ++-
 kernel/audit.c|  9 
 kernel/taskstats.c|  4 ++--
 net/core/devlink.c| 12 +-
 net/core/net_namespace.c  |  2 +-
 net/core/rtnetlink.c  | 12 ++
 net/dcb/dcbnl.c   |  2 +-
 net/decnet/dn_route.c |  3 ++-
 net/hsr/hsr_netlink.c |  6 +++--
 net/ieee802154/ieee802154.h   |  3 ++-
 net/ieee802154/netlink.c  |  5 ++--
 net/ieee802154/nl-mac.c   |  4 ++--
 net/ieee802154/nl-phy.c   |  6 ++---
 net/ieee802154/nl802154.c |  4 ++--
 net/ipv4/devinet.c|  2 +-
 net/ipv4/fib_frontend.c   |  2 +-
 net/ipv4/fou.c|  2 +-
 net/ipv4/inet_diag.c  |  2 +-
 net/ipv4/ipmr.c   |  6 +++--
 net/ipv4/route.c  |  2 +-
 net/ipv4/tcp_metrics.c|  2 +-
 net/ipv4/udp_diag.c   |  2 +-
 net/ipv6/addrconf.c   |  4 ++--
 net/ipv6/addrlabel.c  |  2 +-
 net/ipv6/ila/ila_xlat.c   |  2 +-
 net/ipv6/ip6mr.c  |  6 +++--
 net/ipv6/route.c  |  2 +-
 net/irda/irnetlink.c  |  2 +-
 net/l2tp/l2tp_netlink.c   |  8 ---
 net/netfilter/ipset/ip_set_core.c | 11 +
 net/netfilter/ipvs/ip_vs_ctl.c|  2 +-
 net/netfilter/nf_conntrack_netlink.c  |  9 +---
 net/netfilter/nf_tables_api.c | 10 
 net/netfilter/nfnetlink.c |  4 ++--
 net/netfilter/nfnetlink_acct.c|  2 +-
 net/netfilter/nfnetlink_cthelper.c|  2 +-
 net/netfilter/nfnetlink_cttimeout.c   |  5 ++--
 net/netfilter/nfnetlink_log.c |  4 ++--
 net/netfilter/nfnetlink_queue.c   |  3 ++-
 net/netfilter/nft_compat.c|  4 ++--
 net/netlabel/netlabel_cipso_v4.c  |  2 +-
 net/netlabel/netlabel_mgmt.c  |  4 ++--
 net/netlabel/netlabel_unlabeled.c |  2 +-
 net/netlink/af_netlink.c  | 14 +++-
 net/netlink/genetlink.c   |  2 +-
 net/nfc/netlink.c |  6 ++---
 net/openvswitch/datapath.c|  9 
 net/sched/act_api.c   |  2 +-
 net/sctp/sctp_diag.c  |  2 +-
 net/tipc/bearer.c |  4 ++--
 net/tipc/netlink_compat.c |  2 +-
 net/tipc/node.c   |  2 +-
 net/unix/diag.c   |  2 +-
 net/wireless/nl80211.c| 43 ++-
 net/xfrm/xfrm_user.c  | 15 +++-
 samples/connector/cn_test.c   |  2 +-
 72 files changed, 199 insertions(+), 155 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
t

[PATCH v2] cfg80211: Add mesh peer AID setting API

2016-06-30 Thread Masashi Honma
Previously, mesh power management functionality works only with kernel
MPM. Because user space MPM did not report mesh peer AID to kernel,
the kernel could not identify the bit in TIM element. So this patch
adds mesh peer AID setting API.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/net/cfg80211.h   | 2 ++
 include/uapi/linux/nl80211.h | 5 +
 net/mac80211/cfg.c   | 1 +
 net/wireless/nl80211.c   | 7 +++
 4 files changed, 15 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7bbb00d..23e34ca 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -774,6 +774,7 @@ enum station_parameters_apply_mask {
  * (bitmask of BIT(NL80211_STA_FLAG_...))
  * @listen_interval: listen interval or -1 for no change
  * @aid: AID or zero for no change
+ * @peer_aid: mesh peer AID or zero for no change
  * @plink_action: plink action to take
  * @plink_state: set the peer link state for a station
  * @ht_capa: HT capabilities of station
@@ -805,6 +806,7 @@ struct station_parameters {
u32 sta_modify_mask;
int listen_interval;
u16 aid;
+   u16 peer_aid;
u8 supported_rates_len;
u8 plink_action;
u8 plink_state;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 53c8278..f8c454e 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1829,6 +1829,9 @@ enum nl80211_commands {
  * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per
  * interface type.
  *
+ * @NL80211_ATTR_MESH_PEER_AID: Association ID for the mesh peer (u16). This is
+ * used to pull the stored data for mesh peer in power save state.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2213,6 +2216,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_IFTYPE_EXT_CAPA,
 
+   NL80211_ATTR_MESH_PEER_AID,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0c12e40..47e99ab8 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -997,6 +997,7 @@ static void sta_apply_mesh_params(struct ieee80211_local 
*local,
if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
changed = mesh_plink_inc_estab_count(sdata);
sta->mesh->plink_state = params->plink_state;
+   sta->mesh->aid = params->peer_aid;
 
ieee80211_mps_sta_status_update(sta);
changed |= ieee80211_mps_set_sta_local_pm(sta,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 244d552..8337349 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4410,6 +4410,13 @@ static int nl80211_set_station(struct sk_buff *skb, 
struct genl_info *info)
nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]);
if (params.plink_state >= NUM_NL80211_PLINK_STATES)
return -EINVAL;
+   if (info->attrs[NL80211_ATTR_MESH_PEER_AID]) {
+   if (nla_get_u16(info->attrs[NL80211_ATTR_MESH_PEER_AID])
+   > IEEE80211_MAX_AID)
+   return -EINVAL;
+   params.peer_aid = nla_get_u16(
+   info->attrs[NL80211_ATTR_MESH_PEER_AID]);
+   }
params.sta_modify_mask |= STATION_PARAM_APPLY_PLINK_STATE;
}
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cfg80211: Add mesh peer AID setting API

2016-06-30 Thread Masashi Honma

On 2016年06月30日 20:11, Bob Copeland wrote:

Let's call it peer_aid or mesh_peer_aid or something like that, per my
email on hostapd list.  Also you probably saw kbuild robot pointed out
missing documentation for the field.

Yes. I will modify this also.


We need a check against IEEE80211_MAX_AID somewhere.

Sure. I will add a check.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cfg80211: Add mesh peer AID setting API

2016-06-30 Thread Masashi Honma
Previously, mesh peer AID is not reported to kernel when local mesh
STA is created without iw command. The mesh peer AID is needed by
mesh peer power management functionality to identify a AID in a TIM
element.

This patch creates mesh peer AID setting API.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/net/cfg80211.h   | 1 +
 include/uapi/linux/nl80211.h | 5 +
 net/mac80211/cfg.c   | 1 +
 net/wireless/nl80211.c   | 3 +++
 4 files changed, 10 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7bbb00d..2fa5896 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -805,6 +805,7 @@ struct station_parameters {
u32 sta_modify_mask;
int listen_interval;
u16 aid;
+   u16 mesh_aid;
u8 supported_rates_len;
u8 plink_action;
u8 plink_state;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 53c8278..f8c454e 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1829,6 +1829,9 @@ enum nl80211_commands {
  * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per
  * interface type.
  *
+ * @NL80211_ATTR_MESH_PEER_AID: Association ID for the mesh peer (u16). This is
+ * used to pull the stored data for mesh peer in power save state.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2213,6 +2216,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_IFTYPE_EXT_CAPA,
 
+   NL80211_ATTR_MESH_PEER_AID,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0c12e40..08802f7 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -997,6 +997,7 @@ static void sta_apply_mesh_params(struct ieee80211_local 
*local,
if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
changed = mesh_plink_inc_estab_count(sdata);
sta->mesh->plink_state = params->plink_state;
+   sta->mesh->aid = params->mesh_aid;
 
ieee80211_mps_sta_status_update(sta);
changed |= ieee80211_mps_set_sta_local_pm(sta,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c503e96..f41fb61 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4410,6 +4410,9 @@ static int nl80211_set_station(struct sk_buff *skb, 
struct genl_info *info)
nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]);
if (params.plink_state >= NUM_NL80211_PLINK_STATES)
return -EINVAL;
+   if (info->attrs[NL80211_ATTR_MESH_PEER_AID])
+   params.mesh_aid = nla_get_u16(
+   info->attrs[NL80211_ATTR_MESH_PEER_AID]);
params.sta_modify_mask |= STATION_PARAM_APPLY_PLINK_STATE;
}
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-29 Thread Masashi Honma

On 2016年06月30日 01:25, Johannes Berg wrote:

[please don't quote everything to add a single line]
I applied it today, but forgot to say so. 


Thanks, and sorry for wrong quotation.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-29 Thread Masashi Honma
On 2016年06月22日 19:55, Masashi Honma wrote:
> Previously, the action frames to group address was not encrypted. But
> [1] "Table 8-38 Category values" indicates "Mesh" and "Multihop" category
> action frames should be encrypted (Group addressed privacy == yes). And the
> encyption key should be MGTK ([1] 10.13 Group addressed robust management 
> frame
> procedures). So this patch modifies the code to make it suitable for spec.
>
> [1] IEEE Std 802.11-2012
>
> Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
> ---
>  include/linux/ieee80211.h | 32 
>  net/mac80211/rx.c |  7 ++-
>  net/mac80211/tx.c |  6 +-
>  3 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
> index b118744..7c0771a 100644
> --- a/include/linux/ieee80211.h
> +++ b/include/linux/ieee80211.h
> @@ -19,6 +19,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -2487,6 +2488,37 @@ static inline bool ieee80211_is_public_action(struct 
> ieee80211_hdr *hdr,
>  }
>  
>  /**
> + * _ieee80211_is_group_privacy_action - check if frame is a group addressed
> + * privacy action frame
> + * @hdr: the frame
> + */
> +static inline bool _ieee80211_is_group_privacy_action(struct ieee80211_hdr 
> *hdr)
> +{
> + struct ieee80211_mgmt *mgmt;
> +
> + if (!ieee80211_is_action(hdr->frame_control) ||
> + !is_multicast_ether_addr(hdr->addr1))
> + return false;
> +
> + mgmt = (struct ieee80211_mgmt *)hdr;
> +
> + return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION ||
> + mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION;
> +}
> +
> +/**
> + * ieee80211_is_group_privacy_action - check if frame is a group addressed
> + * privacy action frame
> + * @skb: the skb containing the frame, length will be checked
> + */
> +static inline bool ieee80211_is_group_privacy_action(struct sk_buff *skb)
> +{
> + if (skb->len < IEEE80211_MIN_ACTION_SIZE)
> + return false;
> + return _ieee80211_is_group_privacy_action((void *)skb->data);
> +}
> +
> +/**
>   * ieee80211_tu_to_usec - convert time units (TU) to microseconds
>   * @tu: the TUs
>   */
> diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> index 5e65e83..2300c0f 100644
> --- a/net/mac80211/rx.c
> +++ b/net/mac80211/rx.c
> @@ -1624,8 +1624,13 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
>   if (mmie_keyidx < NUM_DEFAULT_KEYS ||
>   mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
>   return RX_DROP_MONITOR; /* unexpected BIP keyidx */
> - if (rx->sta)
> + if (rx->sta) {
> + if (ieee80211_is_group_privacy_action(skb) &&
> + test_sta_flag(rx->sta, WLAN_STA_MFP))
> + return RX_DROP_MONITOR;
> +
>   rx->key = rcu_dereference(rx->sta->gtk[mmie_keyidx]);
> + }
>   if (!rx->key)
>   rx->key = rcu_dereference(rx->sdata->keys[mmie_keyidx]);
>   } else if (!ieee80211_has_protected(fc)) {
> diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> index 2030443..e194df6 100644
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -590,6 +590,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
>   else if (tx->sta &&
>(key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx])))
>   tx->key = key;
> + else if (ieee80211_is_group_privacy_action(tx->skb) &&
> + (key = rcu_dereference(tx->sdata->default_multicast_key)))
> + tx->key = key;
>   else if (ieee80211_is_mgmt(hdr->frame_control) &&
>is_multicast_ether_addr(hdr->addr1) &&
>ieee80211_is_robust_mgmt_frame(tx->skb) &&
> @@ -622,7 +625,8 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
>   case WLAN_CIPHER_SUITE_GCMP_256:
>   if (!ieee80211_is_data_present(hdr->frame_control) &&
>   !ieee80211_use_mfp(hdr->frame_control, tx->sta,
> -tx->skb))
> +tx->skb) &&
> + !ieee80211_is_group_privacy_action(tx->skb))
>   tx->key = NULL;
>   else
>   skip_hw = (tx->key->conf.flags &

Is there any comment about this ?


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: Use macro instead of number

2016-06-22 Thread Masashi Honma
Use IEEE80211_MIN_ACTION_SIZE macro for robust management frame check.

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/linux/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 7c0771a..8326a91 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -2465,7 +2465,7 @@ static inline bool _ieee80211_is_robust_mgmt_frame(struct 
ieee80211_hdr *hdr)
  */
 static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
 {
-   if (skb->len < 25)
+   if (skb->len < IEEE80211_MIN_ACTION_SIZE)
return false;
return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-22 Thread Masashi Honma
Previously, the action frames to group address was not encrypted. But
[1] "Table 8-38 Category values" indicates "Mesh" and "Multihop" category
action frames should be encrypted (Group addressed privacy == yes). And the
encyption key should be MGTK ([1] 10.13 Group addressed robust management frame
procedures). So this patch modifies the code to make it suitable for spec.

[1] IEEE Std 802.11-2012

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/linux/ieee80211.h | 32 
 net/mac80211/rx.c |  7 ++-
 net/mac80211/tx.c |  6 +-
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index b118744..7c0771a 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -2487,6 +2488,37 @@ static inline bool ieee80211_is_public_action(struct 
ieee80211_hdr *hdr,
 }
 
 /**
+ * _ieee80211_is_group_privacy_action - check if frame is a group addressed
+ * privacy action frame
+ * @hdr: the frame
+ */
+static inline bool _ieee80211_is_group_privacy_action(struct ieee80211_hdr 
*hdr)
+{
+   struct ieee80211_mgmt *mgmt;
+
+   if (!ieee80211_is_action(hdr->frame_control) ||
+   !is_multicast_ether_addr(hdr->addr1))
+   return false;
+
+   mgmt = (struct ieee80211_mgmt *)hdr;
+
+   return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION ||
+   mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION;
+}
+
+/**
+ * ieee80211_is_group_privacy_action - check if frame is a group addressed
+ * privacy action frame
+ * @skb: the skb containing the frame, length will be checked
+ */
+static inline bool ieee80211_is_group_privacy_action(struct sk_buff *skb)
+{
+   if (skb->len < IEEE80211_MIN_ACTION_SIZE)
+   return false;
+   return _ieee80211_is_group_privacy_action((void *)skb->data);
+}
+
+/**
  * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  * @tu: the TUs
  */
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 5e65e83..2300c0f 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1624,8 +1624,13 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
if (mmie_keyidx < NUM_DEFAULT_KEYS ||
mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
return RX_DROP_MONITOR; /* unexpected BIP keyidx */
-   if (rx->sta)
+   if (rx->sta) {
+   if (ieee80211_is_group_privacy_action(skb) &&
+   test_sta_flag(rx->sta, WLAN_STA_MFP))
+   return RX_DROP_MONITOR;
+
rx->key = rcu_dereference(rx->sta->gtk[mmie_keyidx]);
+   }
if (!rx->key)
rx->key = rcu_dereference(rx->sdata->keys[mmie_keyidx]);
} else if (!ieee80211_has_protected(fc)) {
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 2030443..e194df6 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -590,6 +590,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
else if (tx->sta &&
 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx])))
tx->key = key;
+   else if (ieee80211_is_group_privacy_action(tx->skb) &&
+   (key = rcu_dereference(tx->sdata->default_multicast_key)))
+   tx->key = key;
else if (ieee80211_is_mgmt(hdr->frame_control) &&
 is_multicast_ether_addr(hdr->addr1) &&
 ieee80211_is_robust_mgmt_frame(tx->skb) &&
@@ -622,7 +625,8 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
case WLAN_CIPHER_SUITE_GCMP_256:
if (!ieee80211_is_data_present(hdr->frame_control) &&
!ieee80211_use_mfp(hdr->frame_control, tx->sta,
-  tx->skb))
+  tx->skb) &&
+   !ieee80211_is_group_privacy_action(tx->skb))
tx->key = NULL;
else
skip_hw = (tx->key->conf.flags &
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-22 Thread Masashi Honma


On 2016年06月22日 02:01, Jouni Malinen wrote:

Please keep in mind that "working" here means two things:
(1) being able decrypt the frame,
(2) being able to reject the frame if it was not properly protected. It
is that (2) that is unlikely to be covered here..

We actually cover (2) for some cases by "accident" since
ieee80211_rx_h_decrypt() assigns rx->key to rx->sta->gtk[i] if one is
available. I'm not completely sure this is correct since it applies to
management frame as well, but that's the way commit
897bed8b4320774e56f282cdc1cceb4d77442797 ('mac80211: clean up RX key
checks') implemented it (Johannes: Could you please take a look whether
that gtk[] case was really supposed to apply for non-Data frames?).
Interestingly, even on the TX side, we had code that picked tx->key for
these group addressed Action frames, but that got then cleared later..

That said, if rx->sta->gtk[i] is not set for any value of i, we would
not enforce encryption of "group addressed privacy" Action frames as far
as I can tell. This may be a pretty small window since RX MGTK is
supposed to get set immediately for each peer. However, I would not be
surprised if there were indeed a window between adding the STA entry and
marking it authorized and configuring the RX MGTK. And even if this is
not possible, this should really be commented somewhere so that there is
less of a change of accidentally optimizing or cleaning up something
that is needed for this to be protected..

And when operating with PMF enabled, this is clearly broken, i.e., the
RX path accepts BIP protected version of the broadcast Mesh Action frame
while that frame needs to be rejected since it was not encrypted with
CCMP/GCMP.

To cover all these RX cases properly, I'd expect there to be RX path
changes that use ieee80211_is_group_privacy_action() and reject some
cases.. This should like be there in the !ieee80211_has_protected(fc)
case in ieee80211_rx_h_decrypt() before selecting the key and if
ieee80211_is_group_privacy_action() returns true, return RX_DROP_MONITOR
would be needed.


Thank you Jouni and Johannes.

Indeed, received unencrypted Group Addressed Privacy action frame is 
dropped at

below if condition in ieee80211_drop_unencrypted_mgmt().
/* BIP does not use Protected field, so need to check MMIE */
if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx->skb) &&
 ieee80211_get_mmie_keyidx(rx->skb) < 0)) {
if (ieee80211_is_deauth(fc) ||
ieee80211_is_disassoc(fc))
cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
 rx->skb->data,
 rx->skb->len);
return -EACCES;
}
Because the frame was not encrypted and does not have MMIE.

And there could be one more case. Group Addressed Privacy action frame 
could have

robustness by MMIC because of previous wrong implementation. The frame could
not be cought by ieee80211_drop_unencrypted_mgmt(). Because the frame 
has MMIE.

So I have added new condition to ieee80211_rx_h_decrypt() by follwing patch.


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-22 Thread Masashi Honma

On 2016年06月22日 01:42, Jouni Malinen wrote:


This is somewhat problematic since no indication of the frame length is
passed in here and we are reading beyond the frame header below.. Maybe
this should use the same style as ieee80211_is_robust_mgmt_frame()
instead, i.e., use skb as the argument and define
_ieee80211_is_group_privacy_action() to take in struct ieee80211_hdr *.

Thank you. I will modify it.




These read the buffer at offset 24, i.e., just after the header. This
should do same as ieee80211_is_robust_mgmt_frame(), i.e., return false
if skb->len < 25.

Thank you. I will modify it also.



This looks completely separate item and I don't see why we would even
delete that empty line.. In any case, it should probably not be in this
patch.
   


Sorry. This is just a miss of removal of printk().

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-21 Thread Masashi Honma
Previously, the action frames to group address was not encrypted. But
[1] "Table 8-38 Category values" indicates "Mesh" and "Multihop" category
action frames should be encrypted (Group addressed privacy == yes). And the
encyption key should be MGTK ([1] 10.13 Group addressed robust management frame
procedures). So this patch modifies the code to make it suitable for spec.

[1] IEEE Std 802.11-2012

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 include/linux/ieee80211.h | 20 
 net/mac80211/tx.c |  7 +--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index b118744..3ff7d3f 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -2487,6 +2488,25 @@ static inline bool ieee80211_is_public_action(struct 
ieee80211_hdr *hdr,
 }
 
 /**
+ * ieee80211_is_group_privacy_action - check if frame is a group addressed
+ * privacy action frame
+ * @hdr: the frame
+ */
+static inline bool ieee80211_is_group_privacy_action(struct ieee80211_hdr *hdr)
+{
+   struct ieee80211_mgmt *mgmt;
+
+   if (!ieee80211_is_action(hdr->frame_control) ||
+   !is_multicast_ether_addr(hdr->addr1))
+   return false;
+
+   mgmt = (struct ieee80211_mgmt *)hdr;
+
+   return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION ||
+   mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION;
+}
+
+/**
  * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  * @tu: the TUs
  */
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 2030443..5ad205e 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -590,6 +590,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
else if (tx->sta &&
 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx])))
tx->key = key;
+   else if (ieee80211_is_group_privacy_action(hdr) &&
+(key = rcu_dereference(tx->sdata->default_multicast_key)))
+   tx->key = key;
else if (ieee80211_is_mgmt(hdr->frame_control) &&
 is_multicast_ether_addr(hdr->addr1) &&
 ieee80211_is_robust_mgmt_frame(tx->skb) &&
@@ -608,7 +611,6 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
bool skip_hw = false;
 
/* TODO: add threshold stuff again */
-
switch (tx->key->conf.cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
@@ -622,7 +624,8 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
case WLAN_CIPHER_SUITE_GCMP_256:
if (!ieee80211_is_data_present(hdr->frame_control) &&
!ieee80211_use_mfp(hdr->frame_control, tx->sta,
-  tx->skb))
+  tx->skb) &&
+   !ieee80211_is_group_privacy_action(hdr))
tx->key = NULL;
else
skip_hw = (tx->key->conf.flags &
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-21 Thread Masashi Honma

On 2016年06月21日 06:25, Jouni Malinen wrote:

Do we really want that?


Sorry, I mis-understood your previous massage.
I have thought you required backward compatibility.
Ok, I will remove backward compatibility code.


> What about RX side?

Previously, MGTK and IGTK was identical key.
Now new wpa_supplicant can provide correct IGTK.
(Because of your great works !)
I have tested with new IGTK, RX side can work without
modification.

I will send new patch.
The patch move ieee80211_is_group_privacy_action()
to appropriate file and fix a bug of skip_hw flag.


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-19 Thread Masashi Honma

On 2016年06月18日 18:11, Jouni Malinen wrote:

What about RX side? Shouldn't there be a matching change there to
enforce use of group addressed privacy for the specific Action
categories?


Thank you. Yes, RX side modification is needed.
I was not aware of it because ping test was OK.
Now I recognize it is because MGTK and IGTK is same as you say.


This will make devices using fixed implementation not
interoperate with devices using older version, I'd assume, but it looks
like the current use of mesh with RSN is pretty hopelessly broken as far
as no PMF case is concerned at least when using the wpa_supplicant
implementation (sets IGTK incorrectly and ends up using BIP even when
PMF was not enabled), so there does not seem to be any convenient way of
addressing this apart from requiring all devices in the MBSS to get
updated to the fixed versions.

Yes. This patch breaks backward compatibility.
I do not have smart idea to avoid also.
I will create new define like this.
CONFIG_MAC80211_MESH_GROUP_ADDRESSED_PRIVACY


And this helper should likely be in some more generic location so that 
it could be shared for TX and RX.. 


Sure.


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: Encrypt "Group addressed privacy" action frames

2016-06-14 Thread Masashi Honma
Previously, the action frames to group address was not encrypted. But
[1] "Table 8-38 Category values" indicates "Mesh" and "Multihop" category
action frames should be encrypted (Group addressed privacy == yes). And the
encyption key should be MGTK ([1] 10.13 Group addressed robust management frame
procedures). So this patch modifies the code to make it suitable for spec.

[1] IEEE Std 802.11-2012

Signed-off-by: Masashi Honma <masashi.ho...@gmail.com>
---
 net/mac80211/tx.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 2030443..80afc47 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -578,6 +578,21 @@ ieee80211_tx_h_check_control_port_protocol(struct 
ieee80211_tx_data *tx)
return TX_CONTINUE;
 }
 
+static bool debug_noinline
+ieee80211_is_group_privacy_action(struct ieee80211_hdr *hdr)
+{
+   struct ieee80211_mgmt *mgmt;
+
+   if (!ieee80211_is_action(hdr->frame_control) ||
+   !is_multicast_ether_addr(hdr->addr1))
+   return false;
+
+   mgmt = (struct ieee80211_mgmt *)hdr;
+
+   return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION ||
+   mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION;
+}
+
 static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
 {
@@ -590,6 +605,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
else if (tx->sta &&
 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx])))
tx->key = key;
+   else if (ieee80211_is_group_privacy_action(hdr) &&
+(key = rcu_dereference(tx->sdata->default_multicast_key)))
+   tx->key = key;
else if (ieee80211_is_mgmt(hdr->frame_control) &&
 is_multicast_ether_addr(hdr->addr1) &&
 ieee80211_is_robust_mgmt_frame(tx->skb) &&
@@ -620,6 +638,8 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
case WLAN_CIPHER_SUITE_CCMP_256:
case WLAN_CIPHER_SUITE_GCMP:
case WLAN_CIPHER_SUITE_GCMP_256:
+   if (ieee80211_is_group_privacy_action(hdr))
+   break;
if (!ieee80211_is_data_present(hdr->frame_control) &&
!ieee80211_use_mfp(hdr->frame_control, tx->sta,
   tx->skb))
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fwd: [PATCH v4] mac80211: Allow 0 for NL80211_MESHCONF_PLINK_TIMEOUT to disable STA expiration

2015-02-24 Thread Masashi Honma
I will re-send this message to ML because of delivery error.

-- Forwarded message --
From: Masashi Honma masashi.ho...@gmail.com
Date: 2015-02-24 19:00 GMT+09:00
Subject: Re: [PATCH v4] mac80211: Allow 0 for
NL80211_MESHCONF_PLINK_TIMEOUT to disable STA expiration
To: Johannes Berg johan...@sipsolutions.net
Cc: linux-wireless@vger.kernel.org linux-wireless@vger.kernel.org,
Bob Copeland m...@bobcopeland.com


2015-02-24 18:46 GMT+09:00 Johannes Berg johan...@sipsolutions.net:

 Hi,

 Sorry about the late reply! I'm getting back to merging now and taking a
 closer look at this issue.



Thank you for your review.



  +++ b/net/wireless/nl80211.c
  @@ -5261,7 +5261,7 @@ do {  
\
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration,
  0, 65535, mask,
  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
  - FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 1, 0x,
  + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 0, 0x,
  mask, NL80211_MESHCONF_PLINK_TIMEOUT,

 I think you should document this new behaviour also in nl80211.h.


Yes. I will modify and re-send this patch.



 Additionally - what's the plan on how to discover this? Should userspace
 just try to set with 0 value and then drop back to some big number if it
 gets an error?


I already modified wpa_supplicant by commit
0cb5f8d94536e097af7a11273f79239001a602d6.
The way is same as you. It tries to set with 0, if failed it re-try
with 60sec future of wpa_supplicant timeout value.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5] mac80211: Allow 0 for NL80211_MESHCONF_PLINK_TIMEOUT to disable STA expiration

2015-02-24 Thread Masashi Honma
Both wpa_supplicant and mac80211 has inactivity timer. By default
wpa_supplicant will be timed out in 5 minutes and mac80211's it is 30 minutes.
If wpa_supplicant uses more long timer than mac80211, wpa_supplicant will get
unexpected disconnection by mac80211. This patch adds functionality of disabling
mac80211 inactivity timer to avoid to prevent wpa_supplicant inactivity timer.

I have thought setting 0x to NL80211_MESHCONF_PLINK_TIMEOUT will solve
this problem without this patch. But the approach does not work on 32 bit
system. To explain the reason, I will show STA expiration rule in kernel. This
is the expression.

(current jiffies)  (frame Rx jiffies + NL80211_MESHCONF_PLINK_TIMEOUT * 250)

On 32bit system, right side could be over flow and be unexpected small value if
NL80211_MESHCONF_PLINK_TIMEOUT is sufficiently large. STA expiration occurs by
this reason. So I made this patch.

Signed-off-by: Masashi Honma masashi.ho...@gmail.com
---
 include/uapi/linux/nl80211.h | 3 ++-
 net/mac80211/mesh.c  | 3 ++-
 net/wireless/nl80211.c   | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 1cbc3aa..0c71180 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -3092,7 +3092,8 @@ enum nl80211_mesh_power_mode {
  *
  * @NL80211_MESHCONF_PLINK_TIMEOUT: If no tx activity is seen from a STA we've
  * established peering with for longer than this time (in seconds), then
- * remove it from the STA's list of peers.  Default is 30 minutes.
+ * remove it from the STA's list of peers. You may set this to 0 to disable
+ * the removal of the STA. Default is 30 minutes.
  *
  * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
  */
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 0c8b2a7..acf441f 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,8 @@ static void ieee80211_mesh_housekeeping(struct 
ieee80211_sub_if_data *sdata)
struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
u32 changed;
 
-   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout * HZ);
+   if (ifmsh-mshcfg.plink_timeout  0)
+   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout * HZ);
mesh_path_expire(sdata);
 
changed = mesh_accept_plinks_update(sdata);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e9ad9d9..bef52af 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5261,7 +5261,7 @@ do {  
\
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration,
  0, 65535, mask,
  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
-   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 1, 0x,
+   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 0, 0x,
  mask, NL80211_MESHCONF_PLINK_TIMEOUT,
  nla_get_u32);
if (mask_out)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5] mac80211: Allow 0 for NL80211_MESHCONF_PLINK_TIMEOUT to disable STA expiration

2015-02-24 Thread Masashi Honma
2015-02-25 5:08 GMT+09:00 Johannes Berg johan...@sipsolutions.net:
 Applied, I've reworded and rewrapped the commit log - in the future
 please send commit logs with at most 72 characters per line.

Thanks. I will remember 72 characters rule.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] mac80211: Allow 0 for NL80211_MESHCONF_PLINK_TIMEOUT to disable STA expiration

2015-02-03 Thread Masashi Honma
Both wpa_supplicant and mac80211 has inactivity timer. By default
wpa_supplicant will be timed out in 5 minutes and mac80211's it is 30 minutes.
If wpa_supplicant uses more long timer than mac80211, wpa_supplicant will get
unexpected disconnection by mac80211. This patch adds functionality of disabling
mac80211 inactivity timer to avoid to prevent wpa_supplicant inactivity timer.

I have thought setting 0x to NL80211_MESHCONF_PLINK_TIMEOUT will solve
this problem without this patch. But the approach does not work on 32 bit
system. To explain the reason, I will show STA expiration rule in kernel. This
is the expression.

(current jiffies)  (frame Rx jiffies + NL80211_MESHCONF_PLINK_TIMEOUT * 250)

On 32bit system, right side could be over flow and be unexpected small value if
NL80211_MESHCONF_PLINK_TIMEOUT is sufficiently large. STA expiration occurs by
this reason. So I made this patch.

Signed-off-by: Masashi Honma masashi.ho...@gmail.com
---
 net/mac80211/mesh.c| 3 ++-
 net/wireless/nl80211.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 0c8b2a7..acf441f 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,8 @@ static void ieee80211_mesh_housekeeping(struct 
ieee80211_sub_if_data *sdata)
struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
u32 changed;
 
-   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout * HZ);
+   if (ifmsh-mshcfg.plink_timeout  0)
+   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout * HZ);
mesh_path_expire(sdata);
 
changed = mesh_accept_plinks_update(sdata);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e9ad9d9..bef52af 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5261,7 +5261,7 @@ do {  
\
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration,
  0, 65535, mask,
  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
-   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 1, 0x,
+   FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 0, 0x,
  mask, NL80211_MESHCONF_PLINK_TIMEOUT,
  nla_get_u32);
if (mask_out)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] mac80211: Avoid STA expiration timer truncation to u32

2015-01-23 Thread Masashi Honma
2015-01-23 18:42 GMT+09:00 Johannes Berg johan...@sipsolutions.net:
 Ok - but that doesn't really disable the timer? Perhaps we should have a
 new userspace API to explicitly disable it? OTOH, worst case I guess
 that means it's like 100 years in the future, so I guess it doesn't
 matter. However, though, you can hardly rely on this fix being present
 in the kernel, so you can't really set such a large value
 unconditionally anyway, no? Otherwise a newer wpa_supplicant running on
 an older kernel would suddenly behave incorrectly. That doesn't seem
 right.

 Having an explicit feature to disable plink timeout would perhaps be
 better?

Thank you for your review.

On my environment, HZ macro is 250. So jiffies counts up 250 per seconds.
So jiffies overflows in 199 days.
It is a large value still. But on my arm64 environment, jiffies could over the
u32 max value. Because it looks starts with about 0x.
So I need this patch. On the i386 environment, it does not occur.

 I'm not convinced this is right. For one, I believe on 32-bit machines
 you'll need to write 0x1ULL instead of the plain constant.
 Perhaps preferably, you'd use use = MAX_UINT.

I have written such a code 0x1ULL few years ago. But now,
0x1 works. I re-tested on 64bit.
Anyway I think using MAX_UINT is better.

 However, the argument to ieee80211_sta_expire() is an unsigned long (as
 is jiffies), so on 64-bit machines you could even still use the value
 and the conditional isn't needed.

Yes, this is a code for 32bit machine.

 Given these complications, I would prefer having a feature attribute to
 treat e.g. 0 as disabling the timer entirely, and if this feature isn't
 present then have wpa_supplicant instead use a safe value that doesn't
 trigger the kernel bug - e.g. 0x/1000 [which is the max possible
 HZ].

Looks fine. I will modify this patch.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] mac80211: Avoid STA expiration timer truncation to u32

2015-01-19 Thread Masashi Honma
2015-01-16 22:31 GMT+09:00 Bob Copeland m...@bobcopeland.com:
 Nice catch!
 There's a remaining problem on 32-bit platforms: there, unsigned long
 is 32 bits so 0x * HZ will still truncate to 32 bits.

 For normal values of HZ though, result will still be 'a rather large
 number,' so maybe it's not worth caring about that.

Thank you for your review.

I modified my patch.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mesh: Skip STA expiration on user_mpm mode

2015-01-18 Thread Masashi Honma
2015-01-16 21:59 GMT+09:00 Bob Copeland m...@bobcopeland.com:
 No, it relies on mac80211's inactivity timer.  So, yeah, I think this
 patch would break authsae, in the sense that stations would never
 get removed.

I see. I will drop this patch.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mesh: Avoid STA expiration timer truncation to u32

2015-01-15 Thread Masashi Honma
On some combination of plink_timeout and HZ, the STA expiration timer will be
unexpectedly truncated to u32. Maybe there is a question Who sets such a large
number to plink_timeout ?. At least wpa_supplicant will set 0x to
plink_timeout to disable this timer because wpa_supplicant has it's own
expiration mechanism.

Signed-off-by: Masashi Honma masashi.ho...@gmail.com
---
 net/mac80211/mesh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 0c8b2a7..bb721a0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,8 @@ static void ieee80211_mesh_housekeeping(struct 
ieee80211_sub_if_data *sdata)
struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
u32 changed;
 
-   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout * HZ);
+   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout *
+(unsigned long)HZ);
mesh_path_expire(sdata);
 
changed = mesh_accept_plinks_update(sdata);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mesh: Avoid STA expiration timer truncation to u32

2015-01-15 Thread Masashi Honma
2015-01-16 14:49 GMT+09:00 Kalle Valo kv...@codeaurora.org:
 For mac80211 patches please use prefix mac80211: .

Thanks. I will fix it.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] mac80211: Avoid STA expiration timer truncation to u32

2015-01-15 Thread Masashi Honma
On some combination of plink_timeout and HZ, the STA expiration timer will be
unexpectedly truncated to u32. Maybe there is a question Who sets such a large
number to plink_timeout ?. At least wpa_supplicant will set 0x to
plink_timeout to disable this timer because wpa_supplicant has it's own
expiration mechanism.

Signed-off-by: Masashi Honma masashi.ho...@gmail.com
---
 net/mac80211/mesh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 0c8b2a7..bb721a0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,8 @@ static void ieee80211_mesh_housekeeping(struct 
ieee80211_sub_if_data *sdata)
struct ieee80211_if_mesh *ifmsh = sdata-u.mesh;
u32 changed;
 
-   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout * HZ);
+   ieee80211_sta_expire(sdata, ifmsh-mshcfg.plink_timeout *
+(unsigned long)HZ);
mesh_path_expire(sdata);
 
changed = mesh_accept_plinks_update(sdata);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mesh: Skip STA expiration on user_mpm mode

2015-01-15 Thread Masashi Honma
2015-01-15 12:14 GMT+09:00 Bob Copeland m...@bobcopeland.com:
 I took a look at what authsae is doing, and it looks like it's just
 prepared to handle the NL80211_CMD_DEL_STATION events generated from
 cfg80211_del_sta() -- is there a reason that couldn't work for wpa_s
 too?  Then you'd only need the patch to configure that timeout on the
 client, and you can simplify it by not caring about user_mpm.

Thank you for your review.

Indeed wpa_supplicant do nothing even if it receivced NL80211_CMD_DEL_STATION.
But the mismatch (wpa_supplicant recognizes STA is alive, mac80211
recognizes STA leaved) is not so good.

Anyway I have not considered authsae user land application.
Does authsae have it's own inactivity timer ?
If not, I will drop this patch.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


test

2014-11-17 Thread Masashi Honma
Just a test. Ignore this email.
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html