Commit 32cb05bfe81ed00676a21d914db5729abe3f326f

Authored by Bob Copeland
Committed by Johannes Berg
1 parent e76d67f035

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>

Showing 1 changed file with 37 additions and 33 deletions Side-by-side Diff

net/mac80211/mesh_plink.c
... ... @@ -700,7 +700,7 @@
700 700 enum plink_event event;
701 701 enum ieee80211_self_protected_actioncode ftype;
702 702 size_t baselen;
703   - bool matches_local = true;
  703 + bool matches_local;
704 704 u8 ie_len;
705 705 u8 *baseaddr;
706 706 u32 changed = 0;
707 707  
... ... @@ -771,12 +771,10 @@
771 771 rcu_read_lock();
772 772  
773 773 sta = sta_info_get(sdata, mgmt->sa);
774   - if (!sta && ftype != WLAN_SP_MESH_PEERING_OPEN) {
775   - mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n");
776   - rcu_read_unlock();
777   - return;
778   - }
779 774  
  775 + matches_local = ftype == WLAN_SP_MESH_PEERING_CLOSE ||
  776 + mesh_matches_local(sdata, &elems);
  777 +
780 778 if (ftype == WLAN_SP_MESH_PEERING_OPEN &&
781 779 !rssi_threshold_check(sta, sdata)) {
782 780 mpl_dbg(sdata, "Mesh plink: %pM does not meet rssi threshold\n",
783 781  
784 782  
... ... @@ -785,22 +783,41 @@
785 783 return;
786 784 }
787 785  
788   - if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) {
789   - mpl_dbg(sdata, "Mesh plink: Action frame from non-authed peer\n");
790   - rcu_read_unlock();
791   - return;
  786 + if (!sta) {
  787 + if (ftype != WLAN_SP_MESH_PEERING_OPEN) {
  788 + mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n");
  789 + rcu_read_unlock();
  790 + return;
  791 + }
  792 + /* ftype == WLAN_SP_MESH_PEERING_OPEN */
  793 + if (!mesh_plink_free_count(sdata)) {
  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 + }
792 816 }
793 817  
794   - if (sta && sta->plink_state == NL80211_PLINK_BLOCKED) {
795   - rcu_read_unlock();
796   - return;
797   - }
798   -
799 818 /* Now we will figure out the appropriate event... */
800 819 event = PLINK_UNDEFINED;
801   - if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
802   - !mesh_matches_local(sdata, &elems)) {
803   - matches_local = false;
  820 + if (!matches_local) {
804 821 switch (ftype) {
805 822 case WLAN_SP_MESH_PEERING_OPEN:
806 823 event = OPN_RJCT;
807 824  
... ... @@ -813,22 +830,9 @@
813 830 }
814 831 }
815 832  
816   - if (!sta && !matches_local) {
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   - }
  833 + if (!sta)
830 834 event = OPN_ACPT;
831   - } else if (matches_local) {
  835 + else if (matches_local) {
832 836 switch (ftype) {
833 837 case WLAN_SP_MESH_PEERING_OPEN:
834 838 if (!mesh_plink_free_count(sdata) ||