mac80211: restrict delayed tailroom needed decrement
PATCH 1/1 mac80211: restrict delayed tailroom needed decrement
As explained in ieee80211_delayed_tailroom_dec(), during roam, keys of the old AP will be destroyed and new keys will be installed. Deletion of the old key causes crypto_tx_tailroom_needed_cnt to go from 1 to 0 and the new key installation causes a transition from 0 to 1.
Whenever crypto_tx_tailroom_needed_cnt transitions from 0 to 1, we invoke synchronize_net(); the reason for doing this is to avoid a race in the TX path as explained in increment_tailroom_need_count(). This synchronize_net() operation can be slow and can affect the station roam time. To avoid this, decrementing the crypto_tx_tailroom_needed_cnt is delayed for a while so that upon installation of new key the transition would be from 1 to 2 instead of 0 to 1 and thereby improving the roam time.
This is all correct for a STA iftype, but deferring the tailroom_needed decrement for other iftypes may be incorrect.
For example, let's consider the case of a 4-addr client connecting to an AP for which AP_VLAN interface is also created, let the initial value for tailroom_needed on the AP be 1.
* 4-addr client connects to the AP (AP: tailroom_needed = 1)
* AP will clear old keys, delay decrement of tailroom_needed count
* AP_VLAN is created, it takes the tailroom count from master (AP_VLAN: tailroom_needed = 1, AP: tailroom_needed = 1)
* Install new key for the station, assume key is plumbed in the HW, there won't be any change in tailroom_needed count on AP iface
* Delayed decrement of tailroom_needed count on AP
(AP: tailroom_needed = 0, AP_VLAN: tailroom_needed = 1)
Because of the delayed decrement on AP iface, tailroom_needed count goes out of sync between AP(master iface) and AP_VLAN(slave iface) and there would be unnecessary tailroom created for the packets going through AP_VLAN iface.
Restricting delayed decrement to station interface alone fixes the problem and it makes sense to do so because delayed decrement is done to improve roam time which is applicable only for client devices.
--- net/mac80211/key.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/key.c +2 -1
@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,ieee80211_debugfs_key_remove (key); -if (delay_tailroom) { +if (delay_tailroom && + sdata->vif.type ==NL80211_IFTYPE_STATION ) {/* see ieee80211_delayed_tailroom_dec */ sdata->crypto_tx_tailroom_pending_dec++; schedule_delayed_work(&sdata->dec_tailroom_needed_wk,
Signature · 1 line
2.7.4
Johannes Berg
maintainerQuoted 6 lines · Manikanta Pubbisetty
As explained in
ieee80211_delayed_tailroom_dec(), during roam, keys of the old AP will be destroyed and new keys will be installed. Deletion of the old key causescrypto_tx_tailroom_needed_cntto go from 1 to 0 and the new key installation causes a transition from 0 to 1.
Quoted 8 lines
Whenever
crypto_tx_tailroom_needed_cnttransitions from 0 to 1, we invokesynchronize_net(); the reason for doing this is to avoid a race in the TX path as explained inincrement_tailroom_need_count(). Thissynchronize_net()operation can be slow and can affect the station roam time. To avoid this, decrementing thecrypto_tx_tailroom_needed_cntis delayed for a while so that upon installation of new key the transition would be from 1 to 2 instead of 0 to 1 and thereby improving the roam time.
Right.
Quoted 2 lines
This is all correct for a STA iftype, but deferring the
tailroom_neededdecrement for other iftypes may be incorrect.
I don't understand this. What do you mean by "incorrect"?
Quoted 13 lines
For example, let's consider the case of a 4-addr client connecting to an AP for which
AP_VLANinterface is also created, let the initial value fortailroom_neededon the AP be 1.* 4-addr client connects to the AP (AP:
tailroom_needed= 1)
* AP will clear old keys, delay decrement oftailroom_neededcount
*AP_VLANis created, it takes the tailroom count from master (AP_VLAN:tailroom_needed= 1, AP:tailroom_needed= 1)
* Install new key for the station, assume key is plumbed in the HW, there won't be any change intailroom_neededcount on AP iface
* Delayed decrement oftailroom_neededcount on AP
(AP:tailroom_needed= 0,AP_VLAN:tailroom_needed= 1)
Quoted 4 lines
Because of the delayed decrement on AP iface,
tailroom_neededcount goes out of sync between AP(master iface) andAP_VLAN(slave iface)and there would be unnecessary tailroom created for the packets going throughAP_VLANiface.
This describes a scenario where there's *unnecessary* work done, but not really one where we have something that's *incorrect*?
Are you saying that you found a problem with this? Did this show up in some sort of measurements?
net/mac80211/key.c static void __ieee80211_key_destroy(struct ieee80211_key *key, · line 590
Quoted 11 lines
+++
b/net/mac80211/key.cnet/mac80211/key.c +2
-1@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,ieee80211_debugfs_key_remove (key); -if (delay_tailroom) { +if (delay_tailroom && + sdata->vif.type ==NL80211_IFTYPE_STATION ) {/* see ieee80211_delayed_tailroom_dec */ sdata->crypto_tx_tailroom_pending_dec++; schedule_delayed_work(&sdata->dec_tailroom_needed_wk,
I think you'd better change the caller, i.e. ieee80211_del_key(), and a add a comment there that explains what's going on.
But I'm not yet really sure what you're trying to do :-)
johannes
Quoted 14 lines
Quoted 14 lines
For example, let's consider the case of a 4-addr client connecting to an AP for which
AP_VLANinterface is also created, let the initial value fortailroom_neededon the AP be 1.* 4-addr client connects to the AP (AP:
tailroom_needed= 1)
* AP will clear old keys, delay decrement oftailroom_neededcount
*AP_VLANis created, it takes the tailroom count from master (AP_VLAN:tailroom_needed= 1, AP:tailroom_needed= 1)
* Install new key for the station, assume key is plumbed in the HW, there won't be any change intailroom_neededcount on AP iface
* Delayed decrement oftailroom_neededcount on AP
(AP:tailroom_needed= 0,AP_VLAN:tailroom_needed= 1)
Quoted 7 lines
Quoted 4 lines
Because of the delayed decrement on AP iface,
tailroom_neededcount goes out of sync between AP(master iface) andAP_VLAN(slave iface)and there would be unnecessary tailroom created for the packets going throughAP_VLANiface.This describes a scenario where there's *unnecessary* work done, but not really one where we have something that's *incorrect*?
To me at least doing unnecessary things is incorrect :-D, may be we can change the statement.
Quoted 2 lines
Are you saying that you found a problem with this? Did this show up in some sort of measurements?
Not really, I have observed in my testing that there were warnings whenever a AP_VLAN was brought down; this is done in ieee80211_free_keys.
Warnings show up every time we bring down the AP_VLAN interface(using ifconfig); warnings apart but I thought there would be unnecessary overhead in the tailroom expansion though the overhead may be trivial.
Quoted 5 lines
Quoted 5 lines
+++
b/net/mac80211/key.cnet/mac80211/key.c +0
-0@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,ieee80211_debugfs_key_remove (key);
Quoted 8 lines
net/mac80211/key.c static void __ieee80211_key_destroy(struct ieee80211_key *key, · line 590
Quoted 6 lines
net/mac80211/key.c +2
-1-if (delay_tailroom) { +if (delay_tailroom && + sdata->vif.type ==NL80211_IFTYPE_STATION ) {/* see ieee80211_delayed_tailroom_dec */ sdata->crypto_tx_tailroom_pending_dec++; schedule_delayed_work(&sdata->dec_tailroom_needed_wk,I think you'd better change the caller, i.e.
ieee80211_del_key(), and a add a comment there that explains what's going on.
Not really sure what you were trying to tell here.
Manikanta
Johannes Berg
maintainerQuoted 6 lines · Manikanta Pubbisetty
Quoted 3 lines
This describes a scenario where there's *unnecessary* work done, but not really one where we have something that's *incorrect*?
To me at least doing unnecessary things is incorrect :-D, may be we can change the statement.
Well, I guess it's a question of semantics, but this doesn't really result in any observable incorrect behaviour.
Quoted 8 lines
Quoted 2 lines
Are you saying that you found a problem with this? Did this show up in some sort of measurements?
Not really, I have observed in my testing that there were warnings whenever a
AP_VLANwas brought down; this is done inieee80211_free_keys. Warnings show up every time we bring down theAP_VLANinterface(using ifconfig); warnings apart but I thought there would be unnecessary overhead in the tailroom expansion though the overhead may be trivial.
Except for that maybe :-)
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
+++
b/net/mac80211/key.cnet/mac80211/key.c +0
-0@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,ieee80211_debugfs_key_remove (key);Quoted 9 lines
net/mac80211/key.c static void __ieee80211_key_destroy(struct ieee80211_key *key, · line 590
Quoted 6 lines
net/mac80211/key.c +2
-1-if (delay_tailroom) { +if (delay_tailroom && + sdata->vif.type ==NL80211_IFTYPE_STATION ) {/* see ieee80211_delayed_tailroom_dec */ sdata->crypto_tx_tailroom_pending_dec++; schedule_delayed_work(&sdata->dec_tailroom_needed_wk,I think you'd better change the caller, i.e.
ieee80211_del_key(), and a add a comment there that explains what's going on.
Quoted 1 line
Not really sure what you were trying to tell here.
I think you should do
ieee80211_key_destroy(..., type == STATION);
in the caller, instead of hard-coding the thing here.
There may be more places that want the delay, perhaps for other reasons?
johannes
Quoted 9 lines · Johannes Berg
Quoted 5 lines · Manikanta Pubbisetty
Quoted 3 lines
This describes a scenario where there's *unnecessary* work done, but not really one where we have something that's *incorrect*?
To me at least doing unnecessary things is incorrect :-D, may be we can change the statement.
Well, I guess it's a question of semantics, but this doesn't really result in any observable incorrect behaviour.
Okay.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Are you saying that you found a problem with this? Did this show up in some sort of measurements?
Not really, I have observed in my testing that there were warnings whenever a
AP_VLANwas brought down; this is done inieee80211_free_keys. Warnings show up every time we bring down theAP_VLANinterface(using ifconfig); warnings apart but I thought there would be unnecessary overhead in the tailroom expansion though the overhead may be trivial.Except for that maybe :-)
:-)
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
net/mac80211/key.c static void __ieee80211_key_destroy(struct ieee80211_key *key, · line 590
Quoted 11 lines
+++
b/net/mac80211/key.cnet/mac80211/key.c +2
-1@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,ieee80211_debugfs_key_remove (key); -if (delay_tailroom) { +if (delay_tailroom && + sdata->vif.type ==NL80211_IFTYPE_STATION ) {/* see ieee80211_delayed_tailroom_dec */ sdata->crypto_tx_tailroom_pending_dec++; schedule_delayed_work(&sdata->dec_tailroom_needed_wk,I think you'd better change the caller, i.e.
ieee80211_del_key(), and a add a comment there that explains what's going on.
Quoted 4 lines
Quoted 1 line
Not really sure what you were trying to tell here.
I think you should do
ieee80211_key_destroy(..., type == STATION);
Even this would boil down to the same behavior, no?
Quoted 4 lines
in the caller, instead of hard-coding the thing here.
There may be more places that want the delay, perhaps for other reasons?
I was going through the source to figure out that; but all that I could understand is this was mainly done to improve roam time.
Johannes Berg
maintainerQuoted 5 lines · Manikanta Pubbisetty
Quoted 3 lines
I think you should do
ieee80211_key_destroy(..., type == STATION);Even this would boil down to the same behavior, no?
Yes, but I think it's easier to understand than thinking "ok this will delay" when you pass the parameter as true, but then it won't unless extra conditions are met.
Quoted 2 lines
I was going through the source to figure out that; but all that I could understand is this was mainly done to improve roam time.
Ok, so perhaps more callers should be updated - still I think it'd be easier to understand.
johannes