aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-01-08 12:06:26 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-01-12 14:02:06 -0500
commitd524215f6cad245249df8def19125ae6fd0bcc9b (patch)
tree4ddbf4b50005a41a8ac69e2d156a78edd47f457d
parent199afd9d89b18e8b530734ed73788518e19bed9b (diff)
mac80211: use nullfunc frames for 4-addr sta detection
To detect incoming 4-addr stations, hostapd needs to receive a 4-addr data frame from the remote station, so that it can create the AP VLAN for it. With this patch, the mlme code emits a 4-addr nullfunc frame immediately after assoc. On the AP side it also drops 4-addr nullfunc frames to the cooked monitor mode interface, if the interface hasn't been fully set up to receive 4-addr data frames yet. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/mlme.c39
-rw-r--r--net/mac80211/rx.c12
2 files changed, 51 insertions, 0 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 5484cf930a87..0336dbb45ac5 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -282,6 +282,38 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
282 ieee80211_tx_skb(sdata, skb); 282 ieee80211_tx_skb(sdata, skb);
283} 283}
284 284
285static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
286 struct ieee80211_sub_if_data *sdata)
287{
288 struct sk_buff *skb;
289 struct ieee80211_hdr *nullfunc;
290 __le16 fc;
291
292 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
293 return;
294
295 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30);
296 if (!skb) {
297 printk(KERN_DEBUG "%s: failed to allocate buffer for 4addr "
298 "nullfunc frame\n", sdata->name);
299 return;
300 }
301 skb_reserve(skb, local->hw.extra_tx_headroom);
302
303 nullfunc = (struct ieee80211_hdr *) skb_put(skb, 30);
304 memset(nullfunc, 0, 30);
305 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
306 IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
307 nullfunc->frame_control = fc;
308 memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN);
309 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
310 memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN);
311 memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN);
312
313 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
314 ieee80211_tx_skb(sdata, skb);
315}
316
285/* spectrum management related things */ 317/* spectrum management related things */
286static void ieee80211_chswitch_work(struct work_struct *work) 318static void ieee80211_chswitch_work(struct work_struct *work)
287{ 319{
@@ -1090,6 +1122,13 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
1090 ieee80211_set_associated(sdata, cbss, changed); 1122 ieee80211_set_associated(sdata, cbss, changed);
1091 1123
1092 /* 1124 /*
1125 * If we're using 4-addr mode, let the AP know that we're
1126 * doing so, so that it can create the STA VLAN on its side
1127 */
1128 if (ifmgd->use_4addr)
1129 ieee80211_send_4addr_nullfunc(local, sdata);
1130
1131 /*
1093 * Start timer to probe the connection to the AP now. 1132 * Start timer to probe the connection to the AP now.
1094 * Also start the timer that will detect beacon loss. 1133 * Also start the timer that will detect beacon loss.
1095 */ 1134 */
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index e12f39a96460..efa6d3689c5e 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1111,6 +1111,18 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1111 if (ieee80211_is_nullfunc(hdr->frame_control) || 1111 if (ieee80211_is_nullfunc(hdr->frame_control) ||
1112 ieee80211_is_qos_nullfunc(hdr->frame_control)) { 1112 ieee80211_is_qos_nullfunc(hdr->frame_control)) {
1113 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); 1113 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc);
1114
1115 /*
1116 * If we receive a 4-addr nullfunc frame from a STA
1117 * that was not moved to a 4-addr STA vlan yet, drop
1118 * the frame to the monitor interface, to make sure
1119 * that hostapd sees it
1120 */
1121 if (ieee80211_has_a4(hdr->frame_control) &&
1122 (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
1123 (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1124 !rx->sdata->u.vlan.sta)))
1125 return RX_DROP_MONITOR;
1114 /* 1126 /*
1115 * Update counter and free packet here to avoid 1127 * Update counter and free packet here to avoid
1116 * counting this as a dropped packed. 1128 * counting this as a dropped packed.