Commit a58fbe1a authored by Johannes Berg's avatar Johannes Berg

mac80211: clean up/rename prepare_for_handlers()

The function really shouldn't be called prepare_for_handlers(),
all it does is check if the frame should be dropped. Rename it
to ieee80211_accept_frame() and clean it up a bit.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 5c90067c
...@@ -3223,11 +3223,11 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid) ...@@ -3223,11 +3223,11 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
/* main receive path */ /* main receive path */
static bool prepare_for_handlers(struct ieee80211_rx_data *rx, static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
struct ieee80211_hdr *hdr)
{ {
struct ieee80211_sub_if_data *sdata = rx->sdata; struct ieee80211_sub_if_data *sdata = rx->sdata;
struct sk_buff *skb = rx->skb; struct sk_buff *skb = rx->skb;
struct ieee80211_hdr *hdr = (void *)skb->data;
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type);
int multicast = is_multicast_ether_addr(hdr->addr1); int multicast = is_multicast_ether_addr(hdr->addr1);
...@@ -3236,24 +3236,23 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx, ...@@ -3236,24 +3236,23 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx,
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
if (!bssid && !sdata->u.mgd.use_4addr) if (!bssid && !sdata->u.mgd.use_4addr)
return false; return false;
if (!multicast && if (multicast)
!ether_addr_equal(sdata->vif.addr, hdr->addr1)) return true;
return false; return ether_addr_equal(sdata->vif.addr, hdr->addr1);
break;
case NL80211_IFTYPE_ADHOC: case NL80211_IFTYPE_ADHOC:
if (!bssid) if (!bssid)
return false; return false;
if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2)) ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
return false; return false;
if (ieee80211_is_beacon(hdr->frame_control)) { if (ieee80211_is_beacon(hdr->frame_control))
return true; return true;
} else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid))
return false; return false;
} else if (!multicast && if (!multicast &&
!ether_addr_equal(sdata->vif.addr, hdr->addr1)) { !ether_addr_equal(sdata->vif.addr, hdr->addr1))
return false; return false;
} else if (!rx->sta) { if (!rx->sta) {
int rate_idx; int rate_idx;
if (status->flag & (RX_FLAG_HT | RX_FLAG_VHT)) if (status->flag & (RX_FLAG_HT | RX_FLAG_VHT))
rate_idx = 0; /* TODO: HT/VHT rates */ rate_idx = 0; /* TODO: HT/VHT rates */
...@@ -3262,20 +3261,18 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx, ...@@ -3262,20 +3261,18 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx,
ieee80211_ibss_rx_no_sta(sdata, bssid, hdr->addr2, ieee80211_ibss_rx_no_sta(sdata, bssid, hdr->addr2,
BIT(rate_idx)); BIT(rate_idx));
} }
break; return true;
case NL80211_IFTYPE_OCB: case NL80211_IFTYPE_OCB:
if (!bssid) if (!bssid)
return false; return false;
if (ieee80211_is_beacon(hdr->frame_control)) { if (ieee80211_is_beacon(hdr->frame_control))
return false; return false;
} else if (!is_broadcast_ether_addr(bssid)) { if (!is_broadcast_ether_addr(bssid))
ocb_dbg(sdata, "BSSID mismatch in OCB mode!\n");
return false; return false;
} else if (!multicast && if (!multicast &&
!ether_addr_equal(sdata->dev->dev_addr, !ether_addr_equal(sdata->dev->dev_addr, hdr->addr1))
hdr->addr1)) {
return false; return false;
} else if (!rx->sta) { if (!rx->sta) {
int rate_idx; int rate_idx;
if (status->flag & RX_FLAG_HT) if (status->flag & RX_FLAG_HT)
rate_idx = 0; /* TODO: HT rates */ rate_idx = 0; /* TODO: HT rates */
...@@ -3284,18 +3281,17 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx, ...@@ -3284,18 +3281,17 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx,
ieee80211_ocb_rx_no_sta(sdata, bssid, hdr->addr2, ieee80211_ocb_rx_no_sta(sdata, bssid, hdr->addr2,
BIT(rate_idx)); BIT(rate_idx));
} }
break; return true;
case NL80211_IFTYPE_MESH_POINT: case NL80211_IFTYPE_MESH_POINT:
if (!multicast && if (multicast)
!ether_addr_equal(sdata->vif.addr, hdr->addr1)) return true;
return false; return ether_addr_equal(sdata->vif.addr, hdr->addr1);
break;
case NL80211_IFTYPE_AP_VLAN: case NL80211_IFTYPE_AP_VLAN:
case NL80211_IFTYPE_AP: case NL80211_IFTYPE_AP:
if (!bssid) { if (!bssid)
if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) return ether_addr_equal(sdata->vif.addr, hdr->addr1);
return false;
} else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) { if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) {
/* /*
* Accept public action frames even when the * Accept public action frames even when the
* BSSID doesn't match, this is used for P2P * BSSID doesn't match, this is used for P2P
...@@ -3308,7 +3304,9 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx, ...@@ -3308,7 +3304,9 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx,
if (ieee80211_is_public_action(hdr, skb->len)) if (ieee80211_is_public_action(hdr, skb->len))
return true; return true;
return ieee80211_is_beacon(hdr->frame_control); return ieee80211_is_beacon(hdr->frame_control);
} else if (!ieee80211_has_tods(hdr->frame_control)) { }
if (!ieee80211_has_tods(hdr->frame_control)) {
/* ignore data frames to TDLS-peers */ /* ignore data frames to TDLS-peers */
if (ieee80211_is_data(hdr->frame_control)) if (ieee80211_is_data(hdr->frame_control))
return false; return false;
...@@ -3317,27 +3315,22 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx, ...@@ -3317,27 +3315,22 @@ static bool prepare_for_handlers(struct ieee80211_rx_data *rx,
!ether_addr_equal(bssid, hdr->addr1)) !ether_addr_equal(bssid, hdr->addr1))
return false; return false;
} }
break; return true;
case NL80211_IFTYPE_WDS: case NL80211_IFTYPE_WDS:
if (bssid || !ieee80211_is_data(hdr->frame_control)) if (bssid || !ieee80211_is_data(hdr->frame_control))
return false; return false;
if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2)) return ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2);
return false;
break;
case NL80211_IFTYPE_P2P_DEVICE: case NL80211_IFTYPE_P2P_DEVICE:
if (!ieee80211_is_public_action(hdr, skb->len) && return ieee80211_is_public_action(hdr, skb->len) ||
!ieee80211_is_probe_req(hdr->frame_control) && ieee80211_is_probe_req(hdr->frame_control) ||
!ieee80211_is_probe_resp(hdr->frame_control) && ieee80211_is_probe_resp(hdr->frame_control) ||
!ieee80211_is_beacon(hdr->frame_control)) ieee80211_is_beacon(hdr->frame_control);
return false;
break;
default: default:
/* should never get here */
WARN_ON_ONCE(1);
break; break;
} }
return true; WARN_ON_ONCE(1);
return false;
} }
/* /*
...@@ -3351,11 +3344,10 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx, ...@@ -3351,11 +3344,10 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
{ {
struct ieee80211_local *local = rx->local; struct ieee80211_local *local = rx->local;
struct ieee80211_sub_if_data *sdata = rx->sdata; struct ieee80211_sub_if_data *sdata = rx->sdata;
struct ieee80211_hdr *hdr = (void *)skb->data;
rx->skb = skb; rx->skb = skb;
if (!prepare_for_handlers(rx, hdr)) if (!ieee80211_accept_frame(rx))
return false; return false;
if (!consume) { if (!consume) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment