diff options
author | Bob Copeland <me@bobcopeland.com> | 2013-11-05 14:16:53 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-11-25 14:49:58 -0500 |
commit | 32cb05bfe81ed00676a21d914db5729abe3f326f (patch) | |
tree | 13637decaa066dc2ad3338ce8c67e06f8a2d93ca | |
parent | e76d67f035649f1cc40603ab06ebcc1d2eb49253 (diff) |
mac80211: mesh_plink: group basic fitness checks
The initial frame checks differ depending on whether this is
a new peer or not, but they were all intermixed with sta checks
as necessary. Group them together so the two cases are clearer.
Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | net/mac80211/mesh_plink.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 3bab76f4f3b6..5048658709d0 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -700,7 +700,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
700 | enum plink_event event; | 700 | enum plink_event event; |
701 | enum ieee80211_self_protected_actioncode ftype; | 701 | enum ieee80211_self_protected_actioncode ftype; |
702 | size_t baselen; | 702 | size_t baselen; |
703 | bool matches_local = true; | 703 | bool matches_local; |
704 | u8 ie_len; | 704 | u8 ie_len; |
705 | u8 *baseaddr; | 705 | u8 *baseaddr; |
706 | u32 changed = 0; | 706 | u32 changed = 0; |
@@ -771,11 +771,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
771 | rcu_read_lock(); | 771 | rcu_read_lock(); |
772 | 772 | ||
773 | sta = sta_info_get(sdata, mgmt->sa); | 773 | sta = sta_info_get(sdata, mgmt->sa); |
774 | if (!sta && ftype != WLAN_SP_MESH_PEERING_OPEN) { | 774 | |
775 | mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n"); | 775 | matches_local = ftype == WLAN_SP_MESH_PEERING_CLOSE || |
776 | rcu_read_unlock(); | 776 | mesh_matches_local(sdata, &elems); |
777 | return; | ||
778 | } | ||
779 | 777 | ||
780 | if (ftype == WLAN_SP_MESH_PEERING_OPEN && | 778 | if (ftype == WLAN_SP_MESH_PEERING_OPEN && |
781 | !rssi_threshold_check(sta, sdata)) { | 779 | !rssi_threshold_check(sta, sdata)) { |
@@ -785,22 +783,41 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
785 | return; | 783 | return; |
786 | } | 784 | } |
787 | 785 | ||
788 | if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) { | 786 | if (!sta) { |
789 | mpl_dbg(sdata, "Mesh plink: Action frame from non-authed peer\n"); | 787 | if (ftype != WLAN_SP_MESH_PEERING_OPEN) { |
790 | rcu_read_unlock(); | 788 | mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n"); |
791 | return; | 789 | rcu_read_unlock(); |
792 | } | 790 | return; |
793 | 791 | } | |
794 | if (sta && sta->plink_state == NL80211_PLINK_BLOCKED) { | 792 | /* ftype == WLAN_SP_MESH_PEERING_OPEN */ |
795 | rcu_read_unlock(); | 793 | if (!mesh_plink_free_count(sdata)) { |
796 | return; | 794 | mpl_dbg(sdata, "Mesh plink error: no more free plinks\n"); |
795 | rcu_read_unlock(); | ||
796 | return; | ||
797 | } | ||
798 | /* deny open request from non-matching peer */ | ||
799 | if (!matches_local) { | ||
800 | rcu_read_unlock(); | ||
801 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, | ||
802 | mgmt->sa, 0, plid, | ||
803 | cpu_to_le16(WLAN_REASON_MESH_CONFIG)); | ||
804 | return; | ||
805 | } | ||
806 | } else { | ||
807 | if (!test_sta_flag(sta, WLAN_STA_AUTH)) { | ||
808 | mpl_dbg(sdata, "Mesh plink: Action frame from non-authed peer\n"); | ||
809 | rcu_read_unlock(); | ||
810 | return; | ||
811 | } | ||
812 | if (sta->plink_state == NL80211_PLINK_BLOCKED) { | ||
813 | rcu_read_unlock(); | ||
814 | return; | ||
815 | } | ||
797 | } | 816 | } |
798 | 817 | ||
799 | /* Now we will figure out the appropriate event... */ | 818 | /* Now we will figure out the appropriate event... */ |
800 | event = PLINK_UNDEFINED; | 819 | event = PLINK_UNDEFINED; |
801 | if (ftype != WLAN_SP_MESH_PEERING_CLOSE && | 820 | if (!matches_local) { |
802 | !mesh_matches_local(sdata, &elems)) { | ||
803 | matches_local = false; | ||
804 | switch (ftype) { | 821 | switch (ftype) { |
805 | case WLAN_SP_MESH_PEERING_OPEN: | 822 | case WLAN_SP_MESH_PEERING_OPEN: |
806 | event = OPN_RJCT; | 823 | event = OPN_RJCT; |
@@ -813,22 +830,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
813 | } | 830 | } |
814 | } | 831 | } |
815 | 832 | ||
816 | if (!sta && !matches_local) { | 833 | if (!sta) |
817 | rcu_read_unlock(); | ||
818 | llid = 0; | ||
819 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, | ||
820 | mgmt->sa, llid, plid, | ||
821 | cpu_to_le16(WLAN_REASON_MESH_CONFIG)); | ||
822 | return; | ||
823 | } else if (!sta) { | ||
824 | /* ftype == WLAN_SP_MESH_PEERING_OPEN */ | ||
825 | if (!mesh_plink_free_count(sdata)) { | ||
826 | mpl_dbg(sdata, "Mesh plink error: no more free plinks\n"); | ||
827 | rcu_read_unlock(); | ||
828 | return; | ||
829 | } | ||
830 | event = OPN_ACPT; | 834 | event = OPN_ACPT; |
831 | } else if (matches_local) { | 835 | else if (matches_local) { |
832 | switch (ftype) { | 836 | switch (ftype) { |
833 | case WLAN_SP_MESH_PEERING_OPEN: | 837 | case WLAN_SP_MESH_PEERING_OPEN: |
834 | if (!mesh_plink_free_count(sdata) || | 838 | if (!mesh_plink_free_count(sdata) || |