diff options
author | Bob Copeland <me@bobcopeland.com> | 2013-11-05 14:16:51 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-11-25 14:49:52 -0500 |
commit | 0f5ffd24fb732fb4d653a8ee97faea767a0e7172 (patch) | |
tree | 39f27dec66a1f31ff55da27cf1880bd02ef92a5c /net/mac80211/mesh_plink.c | |
parent | 4efec45134d82fa73826cc24d41274beb5097d64 (diff) |
mac80211: hold sta->lock across plink switch statements
Rather than unlock at the end of each case, do it once after
all is said and done.
Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/mesh_plink.c')
-rw-r--r-- | net/mac80211/mesh_plink.c | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index d45826e347ed..c3a3faf9b311 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -575,7 +575,6 @@ static void mesh_plink_timer(unsigned long data) | |||
575 | rand % sta->plink_timeout; | 575 | rand % sta->plink_timeout; |
576 | ++sta->plink_retries; | 576 | ++sta->plink_retries; |
577 | mod_plink_timer(sta, sta->plink_timeout); | 577 | mod_plink_timer(sta, sta->plink_timeout); |
578 | spin_unlock_bh(&sta->lock); | ||
579 | action = WLAN_SP_MESH_PEERING_OPEN; | 578 | action = WLAN_SP_MESH_PEERING_OPEN; |
580 | break; | 579 | break; |
581 | } | 580 | } |
@@ -587,19 +586,17 @@ static void mesh_plink_timer(unsigned long data) | |||
587 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT); | 586 | reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT); |
588 | sta->plink_state = NL80211_PLINK_HOLDING; | 587 | sta->plink_state = NL80211_PLINK_HOLDING; |
589 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); | 588 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); |
590 | spin_unlock_bh(&sta->lock); | ||
591 | action = WLAN_SP_MESH_PEERING_CLOSE; | 589 | action = WLAN_SP_MESH_PEERING_CLOSE; |
592 | break; | 590 | break; |
593 | case NL80211_PLINK_HOLDING: | 591 | case NL80211_PLINK_HOLDING: |
594 | /* holding timer */ | 592 | /* holding timer */ |
595 | del_timer(&sta->plink_timer); | 593 | del_timer(&sta->plink_timer); |
596 | mesh_plink_fsm_restart(sta); | 594 | mesh_plink_fsm_restart(sta); |
597 | spin_unlock_bh(&sta->lock); | ||
598 | break; | 595 | break; |
599 | default: | 596 | default: |
600 | spin_unlock_bh(&sta->lock); | ||
601 | break; | 597 | break; |
602 | } | 598 | } |
599 | spin_unlock_bh(&sta->lock); | ||
603 | if (action) | 600 | if (action) |
604 | mesh_plink_frame_tx(sdata, action, sta->sta.addr, | 601 | mesh_plink_frame_tx(sdata, action, sta->sta.addr, |
605 | llid, plid, reason); | 602 | llid, plid, reason); |
@@ -856,12 +853,10 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
856 | reason = 0; | 853 | reason = 0; |
857 | spin_lock_bh(&sta->lock); | 854 | spin_lock_bh(&sta->lock); |
858 | switch (sta->plink_state) { | 855 | switch (sta->plink_state) { |
859 | /* spin_unlock as soon as state is updated at each case */ | ||
860 | case NL80211_PLINK_LISTEN: | 856 | case NL80211_PLINK_LISTEN: |
861 | switch (event) { | 857 | switch (event) { |
862 | case CLS_ACPT: | 858 | case CLS_ACPT: |
863 | mesh_plink_fsm_restart(sta); | 859 | mesh_plink_fsm_restart(sta); |
864 | spin_unlock_bh(&sta->lock); | ||
865 | break; | 860 | break; |
866 | case OPN_ACPT: | 861 | case OPN_ACPT: |
867 | sta->plink_state = NL80211_PLINK_OPN_RCVD; | 862 | sta->plink_state = NL80211_PLINK_OPN_RCVD; |
@@ -874,11 +869,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
874 | /* set the non-peer mode to active during peering */ | 869 | /* set the non-peer mode to active during peering */ |
875 | changed |= ieee80211_mps_local_status_update(sdata); | 870 | changed |= ieee80211_mps_local_status_update(sdata); |
876 | 871 | ||
877 | spin_unlock_bh(&sta->lock); | ||
878 | action = WLAN_SP_MESH_PEERING_OPEN; | 872 | action = WLAN_SP_MESH_PEERING_OPEN; |
879 | break; | 873 | break; |
880 | default: | 874 | default: |
881 | spin_unlock_bh(&sta->lock); | ||
882 | break; | 875 | break; |
883 | } | 876 | } |
884 | break; | 877 | break; |
@@ -897,14 +890,12 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
897 | mshcfg->dot11MeshHoldingTimeout)) | 890 | mshcfg->dot11MeshHoldingTimeout)) |
898 | sta->ignore_plink_timer = true; | 891 | sta->ignore_plink_timer = true; |
899 | 892 | ||
900 | spin_unlock_bh(&sta->lock); | ||
901 | action = WLAN_SP_MESH_PEERING_CLOSE; | 893 | action = WLAN_SP_MESH_PEERING_CLOSE; |
902 | break; | 894 | break; |
903 | case OPN_ACPT: | 895 | case OPN_ACPT: |
904 | /* retry timer is left untouched */ | 896 | /* retry timer is left untouched */ |
905 | sta->plink_state = NL80211_PLINK_OPN_RCVD; | 897 | sta->plink_state = NL80211_PLINK_OPN_RCVD; |
906 | sta->plid = plid; | 898 | sta->plid = plid; |
907 | spin_unlock_bh(&sta->lock); | ||
908 | action = WLAN_SP_MESH_PEERING_CONFIRM; | 899 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
909 | break; | 900 | break; |
910 | case CNF_ACPT: | 901 | case CNF_ACPT: |
@@ -913,10 +904,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
913 | mshcfg->dot11MeshConfirmTimeout)) | 904 | mshcfg->dot11MeshConfirmTimeout)) |
914 | sta->ignore_plink_timer = true; | 905 | sta->ignore_plink_timer = true; |
915 | 906 | ||
916 | spin_unlock_bh(&sta->lock); | ||
917 | break; | 907 | break; |
918 | default: | 908 | default: |
919 | spin_unlock_bh(&sta->lock); | ||
920 | break; | 909 | break; |
921 | } | 910 | } |
922 | break; | 911 | break; |
@@ -935,17 +924,14 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
935 | mshcfg->dot11MeshHoldingTimeout)) | 924 | mshcfg->dot11MeshHoldingTimeout)) |
936 | sta->ignore_plink_timer = true; | 925 | sta->ignore_plink_timer = true; |
937 | 926 | ||
938 | spin_unlock_bh(&sta->lock); | ||
939 | action = WLAN_SP_MESH_PEERING_CLOSE; | 927 | action = WLAN_SP_MESH_PEERING_CLOSE; |
940 | break; | 928 | break; |
941 | case OPN_ACPT: | 929 | case OPN_ACPT: |
942 | spin_unlock_bh(&sta->lock); | ||
943 | action = WLAN_SP_MESH_PEERING_CONFIRM; | 930 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
944 | break; | 931 | break; |
945 | case CNF_ACPT: | 932 | case CNF_ACPT: |
946 | del_timer(&sta->plink_timer); | 933 | del_timer(&sta->plink_timer); |
947 | sta->plink_state = NL80211_PLINK_ESTAB; | 934 | sta->plink_state = NL80211_PLINK_ESTAB; |
948 | spin_unlock_bh(&sta->lock); | ||
949 | changed |= mesh_plink_inc_estab_count(sdata); | 935 | changed |= mesh_plink_inc_estab_count(sdata); |
950 | changed |= mesh_set_ht_prot_mode(sdata); | 936 | changed |= mesh_set_ht_prot_mode(sdata); |
951 | changed |= mesh_set_short_slot_time(sdata); | 937 | changed |= mesh_set_short_slot_time(sdata); |
@@ -956,7 +942,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
956 | mshcfg->power_mode); | 942 | mshcfg->power_mode); |
957 | break; | 943 | break; |
958 | default: | 944 | default: |
959 | spin_unlock_bh(&sta->lock); | ||
960 | break; | 945 | break; |
961 | } | 946 | } |
962 | break; | 947 | break; |
@@ -975,13 +960,11 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
975 | mshcfg->dot11MeshHoldingTimeout)) | 960 | mshcfg->dot11MeshHoldingTimeout)) |
976 | sta->ignore_plink_timer = true; | 961 | sta->ignore_plink_timer = true; |
977 | 962 | ||
978 | spin_unlock_bh(&sta->lock); | ||
979 | action = WLAN_SP_MESH_PEERING_CLOSE; | 963 | action = WLAN_SP_MESH_PEERING_CLOSE; |
980 | break; | 964 | break; |
981 | case OPN_ACPT: | 965 | case OPN_ACPT: |
982 | del_timer(&sta->plink_timer); | 966 | del_timer(&sta->plink_timer); |
983 | sta->plink_state = NL80211_PLINK_ESTAB; | 967 | sta->plink_state = NL80211_PLINK_ESTAB; |
984 | spin_unlock_bh(&sta->lock); | ||
985 | changed |= mesh_plink_inc_estab_count(sdata); | 968 | changed |= mesh_plink_inc_estab_count(sdata); |
986 | changed |= mesh_set_ht_prot_mode(sdata); | 969 | changed |= mesh_set_ht_prot_mode(sdata); |
987 | changed |= mesh_set_short_slot_time(sdata); | 970 | changed |= mesh_set_short_slot_time(sdata); |
@@ -993,7 +976,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
993 | mshcfg->power_mode); | 976 | mshcfg->power_mode); |
994 | break; | 977 | break; |
995 | default: | 978 | default: |
996 | spin_unlock_bh(&sta->lock); | ||
997 | break; | 979 | break; |
998 | } | 980 | } |
999 | break; | 981 | break; |
@@ -1006,17 +988,14 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
1006 | changed |= __mesh_plink_deactivate(sta); | 988 | changed |= __mesh_plink_deactivate(sta); |
1007 | sta->plink_state = NL80211_PLINK_HOLDING; | 989 | sta->plink_state = NL80211_PLINK_HOLDING; |
1008 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); | 990 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); |
1009 | spin_unlock_bh(&sta->lock); | ||
1010 | changed |= mesh_set_ht_prot_mode(sdata); | 991 | changed |= mesh_set_ht_prot_mode(sdata); |
1011 | changed |= mesh_set_short_slot_time(sdata); | 992 | changed |= mesh_set_short_slot_time(sdata); |
1012 | action = WLAN_SP_MESH_PEERING_CLOSE; | 993 | action = WLAN_SP_MESH_PEERING_CLOSE; |
1013 | break; | 994 | break; |
1014 | case OPN_ACPT: | 995 | case OPN_ACPT: |
1015 | spin_unlock_bh(&sta->lock); | ||
1016 | action = WLAN_SP_MESH_PEERING_CONFIRM; | 996 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
1017 | break; | 997 | break; |
1018 | default: | 998 | default: |
1019 | spin_unlock_bh(&sta->lock); | ||
1020 | break; | 999 | break; |
1021 | } | 1000 | } |
1022 | break; | 1001 | break; |
@@ -1026,26 +1005,24 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
1026 | if (del_timer(&sta->plink_timer)) | 1005 | if (del_timer(&sta->plink_timer)) |
1027 | sta->ignore_plink_timer = 1; | 1006 | sta->ignore_plink_timer = 1; |
1028 | mesh_plink_fsm_restart(sta); | 1007 | mesh_plink_fsm_restart(sta); |
1029 | spin_unlock_bh(&sta->lock); | ||
1030 | break; | 1008 | break; |
1031 | case OPN_ACPT: | 1009 | case OPN_ACPT: |
1032 | case CNF_ACPT: | 1010 | case CNF_ACPT: |
1033 | case OPN_RJCT: | 1011 | case OPN_RJCT: |
1034 | case CNF_RJCT: | 1012 | case CNF_RJCT: |
1035 | spin_unlock_bh(&sta->lock); | ||
1036 | action = WLAN_SP_MESH_PEERING_CLOSE; | 1013 | action = WLAN_SP_MESH_PEERING_CLOSE; |
1037 | break; | 1014 | break; |
1038 | default: | 1015 | default: |
1039 | spin_unlock_bh(&sta->lock); | 1016 | break; |
1040 | } | 1017 | } |
1041 | break; | 1018 | break; |
1042 | default: | 1019 | default: |
1043 | /* should not get here, PLINK_BLOCKED is dealt with at the | 1020 | /* should not get here, PLINK_BLOCKED is dealt with at the |
1044 | * beginning of the function | 1021 | * beginning of the function |
1045 | */ | 1022 | */ |
1046 | spin_unlock_bh(&sta->lock); | ||
1047 | break; | 1023 | break; |
1048 | } | 1024 | } |
1025 | spin_unlock_bh(&sta->lock); | ||
1049 | if (action) { | 1026 | if (action) { |
1050 | mesh_plink_frame_tx(sdata, action, sta->sta.addr, | 1027 | mesh_plink_frame_tx(sdata, action, sta->sta.addr, |
1051 | sta->llid, sta->plid, sta->reason); | 1028 | sta->llid, sta->plid, sta->reason); |